List of usage examples for javax.servlet.http HttpServletResponse SC_CREATED
int SC_CREATED
To view the source code for javax.servlet.http HttpServletResponse SC_CREATED.
Click Source Link
From source file:org.eclipse.ecr.core.storage.sql.net.BinaryManagerServlet.java
/** * Creates a new binary./* w w w. j a v a2 s . com*/ */ @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { try { String digest = getDigest(req); Binary binary = binaryManager.getBinary(req.getInputStream()); if (!binary.getDigest().equals(digest)) { resp.sendError(HttpServletResponse.SC_CONFLICT, "Digest mismatch: '" + digest + "' vs '" + binary.getDigest() + "'"); } else { resp.setStatus(HttpServletResponse.SC_CREATED); } } catch (IOException e) { log.error(e, e); resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString()); } }
From source file:org.wso2.carbon.identity.oauth.dcr.factory.HttpRegistrationResponseFactory.java
@Override public void create(HttpIdentityResponse.HttpIdentityResponseBuilder httpIdentityResponseBuilder, IdentityResponse identityResponse) { RegistrationResponse registrationResponse = null; if (identityResponse instanceof RegistrationResponse) { registrationResponse = (RegistrationResponse) identityResponse; httpIdentityResponseBuilder.setBody(generateSuccessfulResponse(registrationResponse).toJSONString()); httpIdentityResponseBuilder.setStatusCode(HttpServletResponse.SC_CREATED); httpIdentityResponseBuilder.addHeader(OAuthConstants.HTTP_RESP_HEADER_CACHE_CONTROL, OAuthConstants.HTTP_RESP_HEADER_VAL_CACHE_CONTROL_NO_STORE); httpIdentityResponseBuilder.addHeader(OAuthConstants.HTTP_RESP_HEADER_PRAGMA, OAuthConstants.HTTP_RESP_HEADER_VAL_PRAGMA_NO_CACHE); httpIdentityResponseBuilder.addHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); } else {//from w w w. j a v a 2s .c om // This else part will not be reached from application logic. log.error("Can't create httpIdentityResponseBuilder. identityResponse is not an instance of " + "RegistrationResponse"); } }
From source file:org.ednovo.gooru.controllers.v2.api.TemplateRestV2Controller.java
@AuthorizeOperations(operations = { GooruOperationConstants.OPERATION_TEMPLATE_ADD }) @RequestMapping(method = { RequestMethod.POST }, value = "") public ModelAndView createTemplate(@RequestBody String data, HttpServletRequest request, HttpServletResponse response) throws Exception { User user = (User) request.getAttribute(Constants.USER); Template template = getTemplateService().createTemplate(this.buildTemplateFromInputParameters(data), user); response.setStatus(HttpServletResponse.SC_CREATED); String includes[] = (String[]) ArrayUtils.addAll(TEMPLATES_INCLUDES, ERROR_INCLUDE); return toModelAndViewWithIoFilter(template, RESPONSE_FORMAT_JSON, EXCLUDE_ALL, true, includes); }
From source file:org.syncope.core.rest.controller.ConfigurationController.java
@PreAuthorize("hasRole('CONFIGURATION_CREATE')") @RequestMapping(method = RequestMethod.POST, value = "/create") public ConfigurationTO create(final HttpServletResponse response, @RequestBody final ConfigurationTO configurationTO) { LOG.debug("Configuration create called with parameters {}", configurationTO); SyncopeConf conf = configurationDataBinder.createSyncopeConfiguration(configurationTO); conf = confDAO.save(conf);/*from w w w . j a va 2 s. c o m*/ response.setStatus(HttpServletResponse.SC_CREATED); return configurationDataBinder.getConfigurationTO(conf); }
From source file:com.homesnap.webserver.ControllerRestAPITest.java
@Test public void test02CreateControllerFromLabel() { // Test controller add in a label postRequestJSONObject(urn_labels + "/ch1", createJsonLabel("Chambre 1", "ch1"), HttpServletResponse.SC_CREATED); JSONObject jo = postRequestJSONObject(urn_labels + "/ch1/controller?id=11", createJsonController11(), HttpServletResponse.SC_CREATED); testController11(jo);/* w w w . j a v a2 s. c o m*/ jo = postRequestJSONObject(urn_labels + "/ch1/controller?id=17", createJsonController17(), HttpServletResponse.SC_CREATED); testController17(jo); jo = postRequestJSONObject(urn_labels + "/ch1/controller?id=12", createJsonController12(), HttpServletResponse.SC_CREATED); testController12(jo); // impossible to add again the same controller postRequestJSONObject(urn_labels + "/ch1/61", createJsonController61(), HttpServletResponse.SC_NOT_ACCEPTABLE); // Test impossible to create a new controller not existing in a Group postRequestJSONObject(urn_labels + "/ch1/61", createJsonController61(), HttpServletResponse.SC_NOT_ACCEPTABLE); postRequestJSONObject(urn_labels + "/ch1/controller?id=61", createJsonController61(), HttpServletResponse.SC_NOT_ACCEPTABLE); }
From source file:org.syncope.core.rest.controller.NotificationController.java
@PreAuthorize("hasRole('NOTIFICATION_CREATE')") @RequestMapping(method = RequestMethod.POST, value = "/create") public NotificationTO create(final HttpServletResponse response, @RequestBody final NotificationTO notificationTO) throws NotFoundException { LOG.debug("Notification create called with parameter {}", notificationTO); Notification notification = binder.createNotification(notificationTO); notification = notificationDAO.save(notification); response.setStatus(HttpServletResponse.SC_CREATED); return binder.getNotificationTO(notification); }
From source file:org.ednovo.gooru.controllers.v1.api.SubjectRestController.java
@AuthorizeOperations(operations = { GooruOperationConstants.OPERATION_SUBJECT_ADD }) @RequestMapping(method = RequestMethod.POST) public ModelAndView createSubject(HttpServletRequest request, HttpServletResponse response, @RequestBody String data) { User user = (User) request.getAttribute(Constants.USER); final ActionResponseDTO<Subject> responseDTO = this.getSubjectService() .createSubject(buildSubjectFromInputParameters(data), user); if (responseDTO.getErrors().getErrorCount() > 0) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); } else {/*from ww w.jav a 2 s . c o m*/ response.setStatus(HttpServletResponse.SC_CREATED); responseDTO.getModel().setUri(RequestMappingUri.SUBJECT + RequestMappingUri.SEPARATOR + responseDTO.getModel().getSubjectId()); } String includes[] = (String[]) ArrayUtils.addAll(CREATE_INCLUDES, ERROR_INCLUDE); return toModelAndViewWithIoFilter(responseDTO.getModelData(), FORMAT_JSON, EXCLUDE_ALL, true, includes); }
From source file:org.openo.drivermgr.service.impl.DriverMgrServiceImpl.java
/** * Register the driver info to the db./*from w w w. ja v a 2s. c o m*/ * <br/> * * @param request : HttpServletRequest Object * @param response : HttpServletResponse Object * @since */ public void register(HttpServletRequest request, HttpServletResponse response) { LOGGER.info("Going to Register Driver"); DriverProperties driverProp = CommonUtil.getInstance().getDriverInfo(request); CheckDriverParameter.getInstance().checkParameter(driverProp.getDriverInfo()); String instanceId = driverProp.getDriverInfo().getInstanceID(); if (driverManager.getDriverByInstanceId(instanceId) != null) { throw new DriverManagerException(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE, ErrorCode.DUPLICATE_ID); } if (driverManager.registerDriver(driverProp)) { response.setStatus(HttpServletResponse.SC_CREATED); } else { throw new DriverManagerException(HttpServletResponse.SC_FORBIDDEN, ErrorCode.FAILURE_INFORMATION); } }
From source file:org.ednovo.gooru.controllers.v1.api.SubdomainRestController.java
@AuthorizeOperations(operations = { GooruOperationConstants.OPERATION_SUBDOMAIN_ADD }) @RequestMapping(method = RequestMethod.POST) public ModelAndView createSubdomain(HttpServletRequest request, HttpServletResponse response, @RequestBody String data) { User user = (User) request.getAttribute(Constants.USER); final ActionResponseDTO<Subdomain> responseDTO = this.getSubdomainService() .createSubdomain(buildSubdomainFromInputParameters(data), user); if (responseDTO.getErrors().getErrorCount() > 0) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); } else {/*from w w w . j a va 2 s . co m*/ response.setStatus(HttpServletResponse.SC_CREATED); responseDTO.getModel().setUri(RequestMappingUri.SUBDOMAIN + RequestMappingUri.SEPARATOR + responseDTO.getModel().getSubdomainId()); } String includes[] = (String[]) ArrayUtils.addAll(CREATE_INCLUDES, ERROR_INCLUDE); return toModelAndViewWithIoFilter(responseDTO.getModelData(), FORMAT_JSON, EXCLUDE_ALL, true, includes); }
From source file:org.ednovo.gooru.controllers.v1.api.DomainRestController.java
@AuthorizeOperations(operations = { GooruOperationConstants.OPERATION_DOMAIN_ADD }) @RequestMapping(method = RequestMethod.POST) public ModelAndView createDomain(@RequestBody String data, HttpServletRequest request, HttpServletResponse response) {/*from w ww.jav a 2 s . c om*/ final User user = (User) request.getAttribute(Constants.USER); ActionResponseDTO<Domain> responseDTO = getDomainService() .createDomain(buildDomainFromInputParameters(data), user); if (responseDTO.getErrors().getErrorCount() > 0) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); } else { response.setStatus(HttpServletResponse.SC_CREATED); responseDTO.getModel().setUri( RequestMappingUri.DOMAIN + RequestMappingUri.SEPARATOR + responseDTO.getModel().getDomainId()); } String includes[] = (String[]) ArrayUtils.addAll(CREATE_INCLUDES, ERROR_INCLUDE); return toModelAndViewWithIoFilter(responseDTO.getModelData(), RESPONSE_FORMAT_JSON, EXCLUDE_ALL, true, includes); }