@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String requestFactorJson = request.getParameter("factor"); FactorClientData clientData = (FactorClientData) mRequestConverter.convert(requestFactorJson, FactorClientData.class); ResponsePayload responsePayload = new ResponsePayload(); mFactorController.storeFactor( clientData, responsePayload, ServletSecurityUtils.getLoggedUser(request)); if (responsePayload.getErrors().size() > 0) { ServletUtils.setResponseClientError(response); } else { ServletUtils.setResponseCreated(response); } ServletUtils.setResponseBody(response, mResponseFormatter.toJson(responsePayload)); }
@Override protected void doPut(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { String factorHousingJson = ServletUtils.getRequestBody(request); FactorClientData clientData = (FactorClientData) mRequestConverter.convert(factorHousingJson, FactorClientData.class); ResponsePayload responsePayload = new ResponsePayload(); Long factorId = ServletUtils.getNumberResourceId(request); if (!ValidatorUtils.isResourceValid(factorId, HttpMethod.PUT)) { ServletUtils.setResponseResourceNotFound(response); return; } mFactorController.updateFactor( factorId, clientData, responsePayload, ServletSecurityUtils.getLoggedUser(request)); if (responsePayload.getErrors().size() > 0) { ServletUtils.setResponseClientError(response); } else { ServletUtils.setResponseOk(response); } ServletUtils.setResponseBody(response, mResponseFormatter.toJson(responsePayload)); }
public AssessmentClientData createClientData() { return (AssessmentClientData) mRequestConverter.convert( TestConstants.DUMMY_ASSESSMENT_RAW_DATA, AssessmentClientData.class); }