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.boundlessgeo.geoserver.api.controllers.MapController.java
@RequestMapping(value = "/{wsName}", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.CREATED) public @ResponseBody JSONObj create(@PathVariable String wsName, @RequestBody JSONObj obj) { String name = obj.str("name"); String title = obj.str("title"); String description = obj.str("abstract"); String user = SecurityContextHolder.getContext().getAuthentication().getName(); Date created = new Date(); CoordinateReferenceSystem crs = DefaultGeographicCRS.WGS84; if (obj.has("proj")) { String srs = obj.str("proj"); try {/*from w w w .j av a2 s .c om*/ crs = CRS.decode(srs); } catch (FactoryException e) { LOG.log(Level.FINE, wsName + "." + name + " unrecorgnized proj:" + srs, e); } } Envelope envelope = IO.bounds(obj.object("bbox")); ReferencedEnvelope bounds = new ReferencedEnvelope(envelope, crs); Catalog cat = geoServer.getCatalog(); LayerGroupInfo map = cat.getFactory().createLayerGroup(); map.setName(name); map.setAbstract(description); map.setTitle(title); map.setMode(Mode.SINGLE); map.setWorkspace(findWorkspace(wsName)); map.setBounds(bounds); Metadata.created(map, created); Metadata.modified(map, created); cat.add(map); return mapDetails(new JSONObj(), map, wsName); }
From source file:org.trustedanalytics.examples.hbase.api.ApiController.java
@RequestMapping(method = RequestMethod.POST, value = "/tables", consumes = "application/json") @ResponseStatus(HttpStatus.CREATED) public void createTable(@RequestBody TableDescription tableDescription) throws LoginException, IOException { LOG.info("tail for {}.", tableDescription.toString()); hbaseService.createTable(tableDescription); }
From source file:com.artivisi.belajar.restful.ui.controller.ProdukController.java
@RequestMapping(value = "/produk", method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) public void create(@RequestBody @Valid Produk x, HttpServletRequest request, HttpServletResponse response) { belajarRestfulService.save(x);/*from w ww . j a va 2 s . co m*/ String requestUrl = request.getRequestURL().toString(); URI uri = new UriTemplate("{requestUrl}/{id}").expand(requestUrl, x.getId()); response.setHeader("Location", uri.toASCIIString()); }
From source file:org.openbaton.autoscaling.api.RestElasticityManagementInterface.java
/** * Deactivates autoscaling for the passed NSR * * @param msg : NSR in payload to add for autoscaling *//*from w w w . j av a 2s.c o m*/ @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.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); NetworkServiceRecord nsr = mapper.fromJson(json.get("payload"), NetworkServiceRecord.class); log.trace("NSR=" + nsr); for (VirtualNetworkFunctionRecord vnfr : nsr.getVnfr()) { elasticityManagement.deactivate(nsr.getProjectId(), nsr.getId(), vnfr); } }
From source file:org.jug.bg.rest.hateoas.spring.poll.resource.PollResource.java
@RequestMapping(method = POST, produces = APPLICATION_HAL_JSON) public ResponseEntity<PollPayload> createPoll(@RequestBody PollParameter requestPayload) { String topic = requestPayload.getTopic(); if (topic == null || topic.isEmpty()) { throw new BadRequestException("Missing poll topic."); }//from w w w . j av a 2s .c om PollParameter parameter = PollParameter.Builder.builder().withTopic(topic).build(); Poll data = repository.storePoll(parameter); PollPayload payload = buildPayload(parameter, data); return new ResponseEntity<>(payload, HttpStatus.CREATED); }
From source file:io.spring.initializr.actuate.stat.ProjectGenerationStatPublisherTests.java
@Test public void publishSimpleDocument() { ProjectRequest request = createProjectRequest(); request.setGroupId("com.example.foo"); request.setArtifactId("my-project"); this.mockServer.expect(requestTo("http://example.com/elastic/initializr/request")) .andExpect(method(HttpMethod.POST)).andExpect(jsonPath("$.groupId").value("com.example.foo")) .andExpect(jsonPath("$.artifactId").value("my-project")) .andRespond(withStatus(HttpStatus.CREATED).body(mockResponse(UUID.randomUUID().toString(), true)) .contentType(MediaType.APPLICATION_JSON)); this.statPublisher.handleEvent(new ProjectGeneratedEvent(request)); this.mockServer.verify(); }
From source file:com.artivisi.belajar.restful.ui.controller.SaleController.java
@RequestMapping(value = "/sale", method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) public void create(@RequestBody @Valid Sale x, HttpServletRequest request, HttpServletResponse response) { belajarRestfulService.save(x);/* ww w . ja v a 2s .c om*/ String requestUrl = request.getRequestURL().toString(); URI uri = new UriTemplate("{requestUrl}/{idjual}").expand(requestUrl, x.getIdJual()); response.setHeader("Location", uri.toASCIIString()); }
From source file:rest.TorneoRestController.java
@RequestMapping(value = "/{torneo}/ronda/{ronda}", method = RequestMethod.PUT) public ResponseEntity<?> modificarRondaEnTorneo(@PathVariable int torneo, @PathVariable int ronda, @RequestBody InfoRonda ir) {/* w ww . j a v a 2s . c o m*/ logicaTorneo.modificarRondaEnTorneo(ir, ronda, torneo); return new ResponseEntity<>(HttpStatus.CREATED); }
From source file:org.avidj.zuul.rs.ZuulTest.java
@Test public void itShallCreateDeepWriteLockOnRoot() { final Zuul zuul = createZuul(); given().standaloneSetup(zuul).param("t", "w").param("s", "d").when().put("/s/1/").then() .statusCode(HttpStatus.CREATED.value()); given().standaloneSetup(zuul).when().get("/s/1/").then().statusCode(HttpStatus.OK.value()).and() .body("key", hasItem(Collections.emptyList())).and().body("session", hasItem("1")).and() .body("type", hasItem("WRITE")).and().body("scope", hasItem("DEEP")).and() .body("count", hasItem(1)); }
From source file:io.fourfinanceit.homework.controller.LoanControler.java
@RequestMapping(value = "/loan", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<LoanApplication> createLoanApplication(@RequestBody LoanApplication loanApplication, HttpServletRequest request) {// ww w . j a v a2 s .c o m loanApplication.setIpAddress(ipAddressDefiner.getIpAddress(request)); LoanApplication savedLoanApplication = loanApplicationRepository.save(loanApplication); if (savedLoanApplication.getStatus() == LoanApplicationStatusEnum.ACTIVE.getStatus()) { return new ResponseEntity<LoanApplication>(savedLoanApplication, HttpStatus.CREATED); } else { return new ResponseEntity<LoanApplication>(savedLoanApplication, HttpStatus.FORBIDDEN); } }