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:org.osiam.resources.controller.GroupController.java
@RequestMapping(method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) @ResponseBody/*from ww w. ja v a 2 s . c o m*/ public Group create(HttpServletRequest request, HttpServletResponse response) throws IOException { Group group = jsonInputValidator.validateJsonGroup(request); Group createdGroup = scimGroupProvisioning.create(group); setLocationUriWithNewId(request, response, createdGroup.getId()); return createdGroup; }
From source file:org.ala.spatial.web.services.LayerDistancesWSController.java
@RequestMapping(value = "/layers/analysis/inter_layer_association.csv", method = RequestMethod.GET) public ResponseEntity<String> CSV(HttpServletRequest req) { String csv = makeCSV("displayname"); HttpHeaders responseHeaders = new HttpHeaders(); responseHeaders.setContentType(MediaType.parseMediaType("text/csv")); return new ResponseEntity<String>(csv, responseHeaders, HttpStatus.CREATED); }
From source file:com.mentat.rest.web.GamesController.java
@RequestMapping(method = RequestMethod.POST, value = "") ResponseEntity<Void> createGame() { Game game = this.gameRepository.create(); HttpHeaders headers = new HttpHeaders(); headers.setLocation(linkTo(GamesController.class).slash(game.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); }
From source file:fr.esiea.windmeal.controller.crud.CrudUserCtrl.java
@RequestMapping(method = RequestMethod.POST, consumes = "application/json;charset=UTF-8") @ResponseStatus(HttpStatus.CREATED) public void create(@RequestBody User user) throws ServiceException, DaoException { LOGGER.info("[Controller] Querying to create new user : " + user.toString() + "\""); crudService.insert(user);// w w w . j av a 2s. co m }
From source file:org.dineth.shooter.app.view.ImageController.java
@RequestMapping(value = "/get/{name}.{ext}") public ResponseEntity<byte[]> getImage(@PathVariable("name") String name, @PathVariable("ext") String ext) { Resource resource = context.getResource("file:/home/dewmal/files/" + name + "." + ext); System.out.println(resource.getFilename()); final HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.IMAGE_PNG); try {/*from w w w. j av a 2s. c om*/ return new ResponseEntity<>(IOUtils.toByteArray(resource.getInputStream()), headers, HttpStatus.CREATED); } catch (IOException ex) { Logger.getLogger(ImageController.class.getName()).log(Level.SEVERE, null, ex); } return null; }
From source file:com.orange.cloud.servicebroker.filter.core.ServiceInstanceBindingFilterBrokerIntegrationTest.java
@Test public void should_proxy_create_service_instance_binding_request_to_filtered_broker() throws Exception { CreateServiceInstanceBindingRequest request = new CreateServiceInstanceBindingRequest() .withServiceInstanceId("instance_id").withBindingId("binding_id"); ResponseEntity<CreateServiceInstanceAppBindingResponse> response = new ResponseEntity<CreateServiceInstanceAppBindingResponse>( new CreateServiceInstanceAppBindingResponse(), HttpStatus.CREATED); given(this.serviceInstanceBindingServiceClient.createServiceInstanceBinding("instance_id", "binding_id", request)).willReturn(response); final ResponseEntity<CreateServiceInstanceAppBindingResponse> forEntity = this.restTemplate.getForEntity( "/v2/service_instances/{instance_id}/service_bindings/{binding_id}", CreateServiceInstanceAppBindingResponse.class, "instance_id", "binding_id"); Assert.assertEquals(response.getBody(), forEntity); }
From source file:org.openbaton.autoscaling.api.RestExecutionInterface.java
/** * Deactivates autoscaling for the passed NSR * * @param msg : NSR in payload to add for autoscaling *//*from ww w .j a v a 2s . com*/ @RequestMapping(value = "RELEASE_RESOURCES_FINISH", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.CREATED) public void deactivate(@RequestBody String msg) throws NotFoundException { log.debug("========================"); log.debug("msg=" + msg); JsonParser jsonParser = new JsonParser(); JsonObject json = jsonParser.parse(msg).getAsJsonObject(); Gson mapper = new GsonBuilder().create(); Action action = mapper.fromJson(json.get("action"), Action.class); log.debug("ACTION=" + action); NetworkServiceRecord nsr = mapper.fromJson(json.get("payload"), NetworkServiceRecord.class); log.debug("NSR=" + nsr); // detectionEngine.deactivate(nsr); }
From source file:plbtw.klmpk.barang.hilang.controller.LogController.java
@RequestMapping(method = RequestMethod.DELETE, produces = "application/json") public CustomResponseMessage deleteLog(@RequestBody LogRequest logRequest) { try {//ww w . ja va 2 s .c o m logService.deleteLog(logRequest.getIdLog()); return new CustomResponseMessage(HttpStatus.CREATED, "Delete log successfull"); } catch (Exception ex) { return new CustomResponseMessage(HttpStatus.BAD_REQUEST, ex.toString()); } }
From source file:com.envision.envservice.rest.AssessmentResource.java
@POST @Path("/addAssessment") @Consumes(MediaType.APPLICATION_JSON)// w ww . j a v a 2 s. c o m @Produces(MediaType.APPLICATION_JSON) public Response addAssessment(AssessmentBo assessmentBo) throws Exception { HttpStatus status = HttpStatus.CREATED; String response = StringUtils.EMPTY; if (!checkParam(assessmentBo)) { status = HttpStatus.BAD_REQUEST; response = FailResult.toJson(Code.PARAM_ERROR, "?"); } else { response = assessmentService.addAssessment(assessmentBo).toJSONString(); } return Response.status(status.value()).entity(response).build(); }
From source file:com.artivisi.belajar.restful.ui.controller.RoleController.java
@RequestMapping(value = "/role", method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) public void create(@RequestBody @Valid Role x, HttpServletRequest request, HttpServletResponse response) { belajarRestfulService.save(x);/* w ww .j av a 2 s . c o m*/ String requestUrl = request.getRequestURL().toString(); URI uri = new UriTemplate("{requestUrl}/{id}").expand(requestUrl, x.getId()); response.setHeader("Location", uri.toASCIIString()); }