PageRenderTime 2937ms CodeModel.GetById 32ms RepoModel.GetById 1ms app.codeStats 0ms

/src/traveldashboard/server/data/UserCommentGetterUtils.java

https://bitbucket.org/ambientic/traveldashboard-server
Java | 34 lines | 21 code | 13 blank | 0 comment | 2 complexity | 5071ec7f2b8d0e727c9ccfacf6e01219 MD5 | raw file
  1. package traveldashboard.server.data;
  2. import org.ibicoop.sdp.config.NetworkMessage;
  3. import com.google.gson.Gson;
  4. public class UserCommentGetterUtils extends ResponseUtils {
  5. private static final String TAG = "UserCommentGetterUtils";
  6. public static NetworkMessage getUserCommentMessage(NetworkMessage req) {
  7. String methodTag = "getUserCommentMessage";
  8. if (DataConstants.DEBUG) TdServerLogger.print(TAG, methodTag, "Start getting user comment message");
  9. NetworkMessage resp = prepareMsgReturn(req);
  10. String city = req.getPayload(DataConstants.PARAM_KEY_CITY_TYPE);
  11. String userName = req.getPayload(DataConstants.PARAM_KEY_USER_NAME);
  12. String stopId = req.getPayload(DataConstants.PARAM_KEY_STOP_ID);
  13. String routeId = req.getPayload(DataConstants.PARAM_KEY_ROUTE_ID);
  14. int maxComments = Integer.parseInt(req.getPayload(DataConstants.PARAM_KEY_MAX_VALUES));
  15. Gson gson = new Gson();
  16. String json = gson.toJson(MongoDbManager.getMetroCommentsCollectionForUser(city, userName, stopId, routeId, maxComments));
  17. resp.addPayload(DataConstants.USER_COMMENT_MESSAGE, json);
  18. if (DataConstants.DEBUG) TdServerLogger.print(TAG, methodTag, "End get user comment message" + new String(resp.encode()));
  19. return resp;
  20. }
  21. }