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:de.codecentric.boot.admin.services.ApplicationRegistratorTest.java
@SuppressWarnings("rawtypes") @Test/*from w w w . j a v a 2 s . c o m*/ public void register_retry() { when(restTemplate.postForEntity(isA(String.class), isA(HttpEntity.class), eq(Application.class))) .thenThrow(new RestClientException("Error")); when(restTemplate.postForEntity(isA(String.class), isA(HttpEntity.class), eq(Map.class))) .thenReturn(new ResponseEntity<Map>(Collections.singletonMap("id", "-id-"), HttpStatus.CREATED)); assertTrue(registrator.register()); }
From source file:org.avidj.zuul.client.ZuulRestClient.java
@Override public boolean lock(String sessionId, List<String> path, LockType type, LockScope scope) { RestTemplate restTemplate = new RestTemplate(); HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); HttpEntity<String> entity = new HttpEntity<String>("parameters", headers); Map<String, String> parameters = new HashMap<>(); parameters.put("id", sessionId); // set the session id UriComponentsBuilder uriBuilder = UriComponentsBuilder.fromHttpUrl(serviceUrl + lockPath(path)) .queryParam("t", type(type)).queryParam("s", scope(scope)); ResponseEntity<String> result = restTemplate.exchange(uriBuilder.build().encode().toUri(), HttpMethod.PUT, entity, String.class); LOG.info(result.toString());// w w w .j ava2 s . c o m HttpStatus code = result.getStatusCode(); return code.equals(HttpStatus.CREATED); }
From source file:org.openbaton.autoscaling.api.RestElasticityManagementInterface.java
/** * Stops autoscaling for the passed NSR// w ww .ja v a 2s . com * * @param msg : NSR in payload to add for autoscaling */ @RequestMapping(value = "ERROR", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.CREATED) public void stop(@RequestBody String msg) throws NotFoundException { log.trace("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.trace("ACTION=" + action); // try { // NetworkServiceRecord nsr = mapper.fromJson(json.get("payload"), NetworkServiceRecord.class); // log.debug("NSR=" + nsr); // elasticityManagement.deactivate(nsr); // } catch (NullPointerException e) { // VirtualNetworkFunctionRecord vnfr = mapper.fromJson(json.get("payload"), VirtualNetworkFunctionRecord.class); // log.debug("vnfr=" + vnfr); // elasticityManagement.deactivate(vnfr); // } }
From source file:minium.cucumber.rest.CucumberRestController.java
@RequestMapping(value = BACKEND_PREFIX + WORLDS_URI, method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) public WorldDTO createWorld(@PathVariable String backendId) { return backendContext(backendId).createWorld(); }
From source file:nz.skytv.example.SwaggerApplication.java
@ApiOperation(value = "Create a book", notes = "Create a book.", response = Book.class, tags = { "book", "updates" }) @ApiResponses({ @ApiResponse(code = HttpURLConnection.HTTP_CREATED, message = "Book created successfully"), @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Something really bad happened") }) @RequestMapping(value = { "/rest/book" }, method = RequestMethod.POST, consumes = "application/json") ResponseEntity<Void> createBook( @ApiParam(value = "Book entity", required = true) @RequestBody @Valid final Book book) { LOG.debug("create {}", book); return new ResponseEntity<>(HttpStatus.CREATED); }
From source file:org.openbaton.nfvo.api.RestNetworkServiceRecord.java
/** * This operation allows submitting and validating a Network Service Descriptor (NSD), including * any related VNFFGD and VLD./*from w w w. j av a2 s.com*/ * * @param networkServiceDescriptor : the Network Service Descriptor to be created * @return NetworkServiceRecord: the Network Service Descriptor filled with id and values from * core */ @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.CREATED) public NetworkServiceRecord create(@RequestBody @Valid NetworkServiceDescriptor networkServiceDescriptor, @RequestHeader(value = "project-id") String projectId, @RequestBody String bodyJson) throws InterruptedException, ExecutionException, VimException, NotFoundException, BadFormatException, VimDriverException, QuotaExceededException, PluginException { JsonObject jsonObject = gson.fromJson(bodyJson, JsonObject.class); return networkServiceRecordManagement.onboard(networkServiceDescriptor, projectId, gson.fromJson(jsonObject.getAsJsonArray("keys"), List.class), gson.fromJson(jsonObject.getAsJsonObject("vduVimInstances"), Map.class)); }
From source file:com.boundlessgeo.geoserver.api.controllers.WorkspaceController.java
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.CREATED) public @ResponseBody JSONObj create(@RequestBody JSONObj obj) { Catalog cat = geoServer.getCatalog(); String wsName = obj.str("name"); if (wsName == null) { throw new BadRequestException("Workspace must have a name"); }//from ww w.j a va2s. co m String nsUri = obj.str("uri"); if (nsUri == null) { nsUri = "http://" + wsName; } boolean isDefault = obj.has("default") ? obj.bool("default") : false; WorkspaceInfo ws = cat.getFactory().createWorkspace(); ws.setName(wsName); NamespaceInfo ns = cat.getFactory().createNamespace(); ns.setPrefix(wsName); ns.setURI(nsUri); Metadata.created(ws, new Date()); cat.add(ws); cat.add(ns); recent.add(WorkspaceInfo.class, ws); if (isDefault) { cat.setDefaultWorkspace(ws); cat.setDefaultNamespace(ns); } return workspace(new JSONObj(), ws, ns, isDefault); }
From source file:org.nekorp.workflow.backend.controller.imp.AutoControllerImp.java
@Override @RequestMapping(method = RequestMethod.POST) public void crearAuto(@Valid @RequestBody Auto auto, HttpServletResponse response) { preprocesaAuto(auto);/*from w w w . j a v a 2 s . co m*/ //Auto respuesta = this.autoDAO.consultar(auto.getNumeroSerie()); //if (respuesta != null) { //el auto ya existe //response.setStatus(HttpStatus.BAD_REQUEST.value()); //return; //} this.autoDAO.guardar(auto); response.setStatus(HttpStatus.CREATED.value()); response.setHeader("Location", "/autos/" + auto.getNumeroSerie()); }
From source file:org.bozzo.ipplan.web.AddressPlanController.java
@RequestMapping(method = RequestMethod.POST) public HttpEntity<AddressPlanResource> addAddressPlan(@PathVariable @NotNull Integer infraId, @RequestBody @NotNull AddressPlan plan) { Preconditions.checkArgument(infraId.equals(plan.getInfraId())); logger.info("add new address plan: {}", plan); AddressPlan ap = this.repository.save(plan); return new ResponseEntity<>(assembler.toResource(ap), HttpStatus.CREATED); }
From source file:gateway.controller.DeploymentController.java
/** * Processes a request to create a GIS Server deployment for Piazza data. * /*from w w w . j a va 2s. c o m*/ * @see http ://pz-swagger.stage.geointservices.io/#!/Deployment/post_deployment * * @param job * The job, defining details on the deployment * @param user * The user executing the request * @return Job Id for the deployment; appropriate ErrorResponse if that call fails. */ @RequestMapping(value = "/deployment", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.CREATED) @ApiOperation(value = "Obtain a GIS Server Deployment for a Data Resource object", notes = "Data that has been loaded into Piazza can be deployed to the GIS Server. This will copy the data to the GIS Server data directory (if needed), or point to the Piazza PostGIS; and then create a WMS/WCS/WFS layer (as available) for the service. Only data that has been internally hosted within Piazza can be deployed.", tags = { "Deployment", "Data" }) @ApiResponses(value = { @ApiResponse(code = 201, message = "The Job Id for the specified Deployment. This could be a long-running process to copy the data over to the GIS Server, so a new Job is spawned.", response = JobResponse.class), @ApiResponse(code = 400, message = "Bad Request", response = ErrorResponse.class), @ApiResponse(code = 401, message = "Unauthorized", response = ErrorResponse.class), @ApiResponse(code = 500, message = "Internal Error", response = ErrorResponse.class) }) public ResponseEntity<PiazzaResponse> createDeployment( @ApiParam(value = "The Data Id and deployment information for creating the Deployment", name = "data", required = true) @Valid @RequestBody AccessJob job, Principal user) { try { // Log the request logger.log( String.format("User %s requested Deployment of type %s for Data %s", gatewayUtil.getPrincipalName(user), job.getDeploymentType(), job.getDataId()), PiazzaLogger.INFO); PiazzaJobRequest jobRequest = new PiazzaJobRequest(); jobRequest.createdBy = gatewayUtil.getPrincipalName(user); jobRequest.jobType = job; String jobId = gatewayUtil.sendJobRequest(jobRequest, null); // Send the response back to the user return new ResponseEntity<PiazzaResponse>(new JobResponse(jobId), HttpStatus.CREATED); } catch (Exception exception) { String error = String.format("Error Loading Data for user %s for Id %s of type %s: %s", gatewayUtil.getPrincipalName(user), job.getDataId(), job.getDeploymentType(), exception.getMessage()); LOGGER.error(error, exception); logger.log(error, PiazzaLogger.ERROR); return new ResponseEntity<PiazzaResponse>(new ErrorResponse(error, "Gateway"), HttpStatus.INTERNAL_SERVER_ERROR); } }