@GET @Path(GET_USER_CHARACTERS) @Produces(MediaType.APPLICATION_JSON) @Override public ServiceResponse<List<PlayerCharacter>> getUserCharacters( @QueryParam("user") String username) { long requestReceived = System.currentTimeMillis(); ServiceResponse<List<PlayerCharacter>> response = new ServiceResponse<List<PlayerCharacter>>(); CharacterFetchingProcessor proc = (CharacterFetchingProcessor) SpringContextAware.getSpringBeanFromContext(CharacterFetchingProcessor.class); LOGGER.info(GET_USER_CHARACTERS + " request for " + username); try { response.setResponse(proc.processUserCharacterFetchRequest(username)); response.setStatus(RESULT_SUCCESS); } catch (Exception e) { response.setMessage(e.getMessage()); response.setStatus(RESULT_FAIL); } finally { response.setVersion(VERSION); response.setResponseTime(System.currentTimeMillis() - requestReceived); response.setReferenceNumber(username + "-" + requestReceived); LOGGER.info(response.toString()); } return response; }
@POST @Path(ADD_ATTACK_MODE) @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Override public ServiceNullResponse addAttackMode(ServiceRequest<AttackMode> request) { long requestReceived = System.currentTimeMillis(); ServiceNullResponse response = new ServiceNullResponse(); CharacterProcessor proc = (CharacterProcessor) SpringContextAware.getSpringBeanFromContext(CharacterProcessor.class); LOGGER.info(request.toString()); try { if (proc.processAddAttackModeRequest(request.getRequest())) response.setStatus(RESULT_SUCCESS); else response.setStatus(RESULT_FAIL); } catch (Exception e) { response.setMessage(e.getMessage()); response.setStatus(RESULT_FAIL); } finally { response.setVersion(VERSION); response.setResponseTime(System.currentTimeMillis() - requestReceived); response.setReferenceNumber(request.getReferenceNumber()); LOGGER.info(response.toString()); } return response; }
@GET @Path(GET_CHARACTER_ATTACK_MODES) @Produces(MediaType.APPLICATION_JSON) @Override public ServiceResponse<List<AttackMode>> getCharacterAttackModes( @QueryParam("id") long characterId) { long requestReceived = System.currentTimeMillis(); ServiceResponse<List<AttackMode>> response = new ServiceResponse<List<AttackMode>>(); CharacterFetchingProcessor proc = (CharacterFetchingProcessor) SpringContextAware.getSpringBeanFromContext(CharacterFetchingProcessor.class); LOGGER.info( GET_CHARACTER_ATTACK_MODES + " request received for " + characterId + " - " + requestReceived); try { response.setResponse(proc.processGetCharacterAttackModesRequest(characterId)); response.setStatus(RESULT_SUCCESS); } catch (Exception e) { response.setMessage(e.getMessage()); response.setStatus(RESULT_FAIL); } finally { response.setVersion(VERSION); response.setResponseTime(System.currentTimeMillis() - requestReceived); response.setReferenceNumber(Long.toString(requestReceived)); LOGGER.info(response.toString()); } return response; }
@GET @Path(GET_FEATS) @Produces(MediaType.APPLICATION_JSON) @Override public ServiceResponse<List<Feat>> getAllFeats() { long requestReceived = System.currentTimeMillis(); ServiceResponse<List<Feat>> response = new ServiceResponse<List<Feat>>(); CharacterFetchingProcessor proc = (CharacterFetchingProcessor) SpringContextAware.getSpringBeanFromContext(CharacterFetchingProcessor.class); LOGGER.info(GET_FEATS + " request received - " + requestReceived); try { response.setResponse(proc.processGetAllFeatsRequest()); response.setStatus(RESULT_SUCCESS); } catch (Exception e) { response.setMessage(e.getMessage()); response.setStatus(RESULT_FAIL); } finally { response.setVersion(VERSION); response.setResponseTime(System.currentTimeMillis() - requestReceived); response.setReferenceNumber(Long.toString(requestReceived)); LOGGER.info(response.toString()); } return response; }
@GET @Path("/db/sanity") @Produces(MediaType.TEXT_PLAIN) public String databaseSanityCheck() { CharacterTemplate dao = (CharacterTemplate) SpringContextAware.getSpringBeanFromContext(CharacterTemplate.class); String message = ""; try { dao.sanityCheck(); message = "Great success!"; } catch (Exception e) { message = e.getMessage(); } return message; }