private boolean validateEntry(LogLocationEntry lle) { if (lle != null) { if ((lle.getUserId() != null && !lle.getUserId().isEmpty()) && (lle.getLongitude() != 0.0) && (lle.getLatitude() != 0.0)) { return true; } } return false; }
private StatusResponse doLogLocationEntry(LogLocationEntry lle) { StatusResponse ret = new StatusResponse(StatusResponse.OK); if (validateEntry(lle)) { try { logLocationEntry(lle); } catch (Exception ee) { log.error("Error in logLocation", ee); } } else { log.error( "Error in request: %s, %s, %s", lle.getUserId(), lle.getLatitude(), lle.getLongitude()); ret.setResponse(StatusResponse.MALFORMED); } return ret; }
@RequestMapping(Routes.USER_LOCATION) public StatusResponse logLocation( @PathVariable(value = User.ID) final String userId, @RequestBody LogLocationEntry lle) { StatusResponse sr = doLogLocationEntry(lle); if (lle.getUserId() != null) { // Also check is we're in the middle of an EVENT, because stagnancy is then REALTIME. sr.setActiveEvents(mEMS.getActiveEvents(userId, new Date())); if (sr.getActiveEvents().size() > 0) { sr.setRequestedStagnancy(Stagnancy.REALTIME); } } return sr; }
private void logLocationEntry(LogLocationEntry lle) throws JsonProcessingException { MDC.put(LOGFILENAME, lle.getUserId()); userLogger.info(om.writeValueAsString(lle)); MDC.remove(LOGFILENAME); }