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.apache.sling.launchpad.webapp.integrationtest.issues.SLING2082Test.java
public void testPOST() throws Exception { final String path = "/" + getClass().getSimpleName() + "/" + Math.random() + ".html/%22%3e%3cscript%3ealert(29679)%3c/script%3e"; final PostMethod post = new PostMethod(HTTP_BASE_URL + path); runTest(post, HttpServletResponse.SC_CREATED); }
From source file:sample.jaxrs.exmap.UserResource.java
@POST @Consumes(MediaType.APPLICATION_JSON)/*from w w w . ja v a 2s.c o m*/ @Path("/users") public void create(User user, @Context final HttpServletResponse response) throws UserDAOException { users.create(user); response.setStatus(HttpServletResponse.SC_CREATED); response.addHeader("Location", ""); }
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9.ClobDatatypeStorageController.java
@RequestMapping(method = RequestMethod.POST) @ResponseBody//from w w w .j a va2 s .c o m public String create(@RequestParam MultipartFile file, HttpServletRequest request, HttpServletResponse response) throws IOException { ClobDatatypeStorage clobData = new ClobDatatypeStorage(); String encoding = request.getHeader("Content-Encoding"); clobData.setValue(IOUtils.toString(file.getInputStream(), encoding)); clobData = datatypeService.saveClobDatatypeStorage(clobData); response.setStatus(HttpServletResponse.SC_CREATED); return clobData.getUuid(); }
From source file:com.thinkberg.moxo.dav.MkColHandler.java
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException { if (request.getReader().readLine() != null) { response.sendError(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE); return;// w w w . jav a2 s.c o m } FileObject object = getResourceManager().getFileObject(request.getPathInfo()); try { LockManager.getInstance().checkCondition(object, getIf(request)); } catch (LockException e) { if (e.getLocks() != null) { response.sendError(SC_LOCKED); } else { response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED); } return; } if (object.exists()) { response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED); return; } if (!object.getParent().exists() || !FileType.FOLDER.equals(object.getParent().getType())) { response.sendError(HttpServletResponse.SC_CONFLICT); return; } try { object.createFolder(); response.setStatus(HttpServletResponse.SC_CREATED); } catch (FileSystemException e) { response.sendError(HttpServletResponse.SC_FORBIDDEN); } }
From source file:org.pixmob.freemobile.netstat.gae.web.v1.DeviceService.java
@Put public Reply<?> register(Request req, @Named("id") String deviceId) { final DeviceReg devReg = req.read(DeviceReg.class).as(Json.class); devReg.brand = StringUtils.trimToNull(devReg.brand); devReg.model = StringUtils.trimToNull(devReg.model); logger.fine("Trying to register device: " + devReg); try {// ww w. j av a 2 s . c o m dr.create(deviceId, devReg.brand, devReg.model); } catch (DeviceException e) { logger.log(Level.WARNING, "Failed to register device " + deviceId, e); return Reply.with(e.getMessage()).status(HttpServletResponse.SC_CONFLICT); } logger.info("Device registered"); return Reply.saying().status(HttpServletResponse.SC_CREATED); }
From source file:org.syncope.core.rest.controller.SchemaController.java
@PreAuthorize("hasRole('SCHEMA_CREATE')") @RequestMapping(method = RequestMethod.POST, value = "/{kind}/create") public SchemaTO create(final HttpServletResponse response, @RequestBody final SchemaTO schemaTO, @PathVariable("kind") final String kind) { AbstractSchema schema = getAttributableUtil(kind).newSchema(); schemaDataBinder.create(schemaTO, schema); schema = schemaDAO.save(schema);/* w w w. j a v a2 s . com*/ response.setStatus(HttpServletResponse.SC_CREATED); return schemaDataBinder.getSchemaTO(schema, getAttributableUtil(kind)); }
From source file:com.homesnap.webserver.LabelRestAPITest.java
@Test public void test3CreateLabel() { // Test new label creation JSONObject label = postRequestJSONObject(urn_labels + "/ch6", createJsonLabelCh6(), HttpServletResponse.SC_CREATED); testLabelCh6(label);/*from w w w. j a va 2s . com*/ label = postRequestJSONObject(urn_labels + "/label?id=ch7", createJsonLabelCh7(), HttpServletResponse.SC_CREATED); testLabelCh7(label); }
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9.ClobDatatypeStorageControllerTest.java
@Test public void shouldAcceptAndStoreClobDataViaPost() throws Exception { long before = getAllCount(); byte[] fileData = IOUtils.toByteArray( getClass().getClassLoader().getResourceAsStream(RestTestConstants1_9.TEST_RESOURCE_FILE)); MockMultipartFile toUpload = new MockMultipartFile("file", "formresource.txt", "text/plain", fileData); MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest(); request.setRequestURI(getBaseRestURI() + getURI()); request.setMethod(RequestMethod.POST.name()); request.addHeader("Content-Type", "multipart/form-data"); request.addFile(toUpload);/* w w w . j a va 2s . c om*/ MockHttpServletResponse response = handle(request); Assert.assertEquals(HttpServletResponse.SC_CREATED, response.getStatus()); Assert.assertEquals(before + 1, getAllCount()); }
From source file:org.wso2.carbon.identity.oidc.dcr.factory.HttpOIDCRegistrationResponseFactory.java
@Override public void create(HttpIdentityResponse.HttpIdentityResponseBuilder httpIdentityResponseBuilder, IdentityResponse identityResponse) { RegistrationResponse registrationResponse = null; if (identityResponse instanceof RegistrationResponse) { registrationResponse = (RegistrationResponse) identityResponse; 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); httpIdentityResponseBuilder.setBody(generateSuccessfulResponse(registrationResponse).toJSONString()); } else {/*w w w . jav a 2 s . 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:com.thinkberg.webdav.MkColHandler.java
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException { BufferedReader bufferedReader = request.getReader(); String line = bufferedReader.readLine(); if (line != null) { response.sendError(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE); return;//from w ww . jav a2s. c om } FileObject object = VFSBackend.resolveFile(request.getPathInfo()); try { if (!LockManager.getInstance().evaluateCondition(object, getIf(request)).result) { response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED); return; } } catch (LockException e) { response.sendError(SC_LOCKED); return; } catch (ParseException e) { response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED); return; } if (object.exists()) { response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED); return; } if (!object.getParent().exists() || !FileType.FOLDER.equals(object.getParent().getType())) { response.sendError(HttpServletResponse.SC_CONFLICT); return; } try { object.createFolder(); response.setStatus(HttpServletResponse.SC_CREATED); } catch (FileSystemException e) { response.sendError(HttpServletResponse.SC_FORBIDDEN); } }