PageRenderTime 197ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/src/traveldashboard/server/data/TubeCommentGetterUtils.java

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