List of usage examples for org.springframework.http HttpStatus CREATED
HttpStatus CREATED
To view the source code for org.springframework.http HttpStatus CREATED.
Click Source Link
From source file:com.envision.envservice.rest.LeaveWordResource.java
@POST @Consumes(MediaType.APPLICATION_JSON)//from w w w .ja v a2s. c om @Produces(MediaType.APPLICATION_JSON) public Response addNew(@Context HttpServletRequest request, LeaveWordBo leaveWord) throws Exception { HttpStatus status = HttpStatus.CREATED; String response = StringUtils.EMPTY; if (!checkParam(leaveWord)) { status = HttpStatus.BAD_REQUEST; response = FailResult.toJson(Code.PARAM_ERROR, "?"); } else if (!checkContentLength(leaveWord)) { status = HttpStatus.BAD_REQUEST; response = FailResult.toJson(Code.CONTENT_TOO_LONG, ""); } else { DBLogger logger = operationLog(request, leaveWord.getUserIdTarget()); String leaveWordId = leaveWordService.addLeaveWord(leaveWord); loggerService.setSuccess(logger.getId(), true, leaveWordId); } return Response.status(status.value()).entity(response).build(); }
From source file:minium.cucumber.rest.CucumberRestController.java
@RequestMapping(value = BACKEND_PREFIX + GLUES_URI, method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) public GlueDTO createGlue(@PathVariable String backendId, @RequestParam("path") String... paths) { return backendContext(backendId).createGlue(paths); }
From source file:com.trenako.web.images.WebImageServiceImpl.java
@Override public ResponseEntity<byte[]> renderImage(String imageSlug) { GridFSDBFile img = repo.findFileBySlug(imageSlug); if (img == null) { throw new NotFoundException(); }/*w ww . j a v a2 s . c o m*/ InputStream in = img.getInputStream(); MediaType mediaType = parse(img.getContentType()); HttpHeaders headers = new HttpHeaders(); headers.setContentType(mediaType); try { return new ResponseEntity<byte[]>(IOUtils.toByteArray(in), headers, HttpStatus.CREATED); } catch (IOException ioEx) { throw new UploadRenderingException("Error occurred rendering the file.", ioEx); } }
From source file:rest.TorneoRestController.java
@RequestMapping(value = "/{id}/jugador", method = RequestMethod.POST) public ResponseEntity<?> guardarJugadorEnTorneo(@PathVariable int id, @RequestBody InfoJugador ij) { logicaTorneo.registrarJugadorEnTorneo(ij, id); return new ResponseEntity<>(HttpStatus.CREATED); }
From source file:com.ns.retailmgr.controller.ShopControllerTest.java
@Test public void test_addShop_Success() throws Exception { mockShopDetails.setStatus("New"); when(shopService.addShop(any(ShopDetails.class))).thenReturn(mockShopDetails); RequestBuilder requestBuilder = MockMvcRequestBuilders.post("/shop").accept(MediaType.APPLICATION_JSON) .content(objectMapper.writeValueAsBytes(jsonAddress)).contentType(MediaType.APPLICATION_JSON); MvcResult result = mockMvc.perform(requestBuilder).andReturn(); MockHttpServletResponse response = result.getResponse(); assertEquals(HttpStatus.CREATED.value(), response.getStatus()); }
From source file:org.trustedanalytics.uploader.rest.UploadController.java
@ApiOperation(value = "Uploads file as multipart content together with metadata.", notes = "Privilege level: Consumer of this endpoint must be a member of specified organization.") @ApiResponses(value = {/*from w w w . jav a 2 s .com*/ @ApiResponse(code = 201, message = "The request has succeeded", response = Transfer.class), @ApiResponse(code = 400, message = "The request could not be understood by the server due to malformed syntax"), @ApiResponse(code = 403, message = "User is not permitted to perform the requested operation"), @ApiResponse(code = 500, message = "Service encountered an unexpected condition which prevented it from fulfilling the request") }) @RequestMapping(value = "/rest/upload/{orgGuid}", method = RequestMethod.POST) @ResponseBody @ResponseStatus(HttpStatus.CREATED) public Transfer uploadFile(HttpServletRequest request, @PathVariable("orgGuid") UUID orgGuid) throws IOException, FileUploadException { final ServletFileUpload upload = new ServletFileUpload(); final UploadRequest uploadRequest = toUploadRequest(request, orgGuid, upload); return uploadService.processUpload(upload.getItemIterator(request), uploadRequest, false).get(0); }
From source file:org.bonitasoft.web.designer.controller.AssetResource.java
@RequestMapping(value = "/{artifactId}/assets/{type}", method = RequestMethod.POST, produces = MediaType.TEXT_PLAIN_VALUE) public ResponseEntity<Asset> saveOrUpdate(@RequestParam("file") MultipartFile file, @PathVariable("artifactId") String id, @PathVariable("type") String type) { checkArtifactId(id);//from ww w . j av a 2 s . c o m Asset asset = assetService.upload(file, repository.get(id), type); return new ResponseEntity<>(asset, HttpStatus.CREATED); }
From source file:curly.artifact.ArtifactResourceController.java
@RequestMapping(method = { POST, PUT }) public Callable<HttpEntity<?>> saveResource(@RequestBody Artifact artifact, @GitHubAuthentication OctoUser octoUser) { log.debug("Performing save operations based on user {}", octoUser.getId()); artifactService.save(artifact, octoUser); return () -> new ResponseEntity<>(HttpStatus.CREATED); }
From source file:io.curly.tagger.TagControllerTests.java
@Test public void testSave() throws Exception { Set<Tag> tagSet = new HashSet<>(1); tagSet.add(new Tag(null, "something")); mockMvc.perform(asyncDispatch(mockMvc .perform(post("/tags").content(json(tagSet, new MappingJackson2HttpMessageConverter())) .contentType(MediaType.APPLICATION_JSON)) .andExpect(request().asyncStarted()) .andExpect(request().asyncResult(new ResponseEntity<>(HttpStatus.CREATED))).andReturn())); }
From source file:com.envision.envservice.rest.PictureUploadResource.java
/** * ?Token/*from w w w . j a v a 2 s . c o m*/ */ @GET @Path("/get_token") @Produces(MediaType.APPLICATION_JSON) public Response getToken() { HttpStatus status = HttpStatus.CREATED; String response = StringUtils.EMPTY; //?ACCESS_KEYSECRET_KEY String ACCESS_KEY = mapConfigService.getValue("ACCESS_KEY"); String SECRET_KEY = mapConfigService.getValue("SECRET_KEY"); //? String bucketname = "challenger"; //? Auth auth = Auth.create(ACCESS_KEY, SECRET_KEY); Map map = new HashMap(); map.put("token", auth.uploadToken(bucketname).toString()); response = JSONObject.toJSONString(map, JSONFilter.UNDERLINEFILTER); return Response.status(status.value()).entity(response).build(); }