List of usage examples for org.springframework.http HttpStatus NO_CONTENT
HttpStatus NO_CONTENT
To view the source code for org.springframework.http HttpStatus NO_CONTENT.
Click Source Link
From source file:net.eusashead.hateoas.conditional.interceptor.AsyncTestControllerITCase.java
@Test public void testPutPreconditionOK() throws Exception { // Expected result HttpHeaders headers = new HttpHeaders(); headers.setETag("\"123456\""); ResponseEntity<String> expectedResult = new ResponseEntity<String>(headers, HttpStatus.NO_CONTENT); // 204 should be returned MvcResult mvcResult = this.mockMvc .perform(put("http://localhost/async/123").contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON).header("If-Match", "\"123456\"")) .andExpect(request().asyncStarted()).andExpect(request().asyncResult(expectedResult)).andReturn(); // Perform asynchronous dispatch this.mockMvc.perform(asyncDispatch(mvcResult)).andExpect(status().isNoContent()) .andExpect(header().string("ETag", "\"123456\"")).andExpect(content().string("")); }
From source file:com.aquest.emailmarketing.web.controllers.RestfulController.java
@RequestMapping(value = "/api/getbcasttemps", method = RequestMethod.GET) @ResponseBody/* w w w . j a va 2s . com*/ public ResponseEntity<List<BcastTempOutput>> getBcastTemplates() { List<BroadcastTemplate> bcastTemps = broadcastTemplateService.getDefinedBroadcasts(); List<BcastTempOutput> bcastTempsOutput = new ArrayList<BcastTempOutput>(); for (BroadcastTemplate bcastTemp : bcastTemps) { BcastTempOutput bcastTempOutput = new BcastTempOutput(); bcastTempOutput.setBroadcast_id(bcastTemp.getId()); bcastTempOutput.setBroadcast_name(bcastTemp.getB_template_name()); bcastTempsOutput.add(bcastTempOutput); } if (bcastTemps.isEmpty()) { return new ResponseEntity<List<BcastTempOutput>>(HttpStatus.NO_CONTENT); } return new ResponseEntity<List<BcastTempOutput>>(bcastTempsOutput, HttpStatus.OK); }
From source file:be.solidx.hot.data.rest.RestDataStore.java
@RequestMapping(value = "/{dbname}/{entity}/{ids}", method = RequestMethod.DELETE) synchronized public DeferredResult<ResponseEntity<byte[]>> delete(final HttpServletRequest httpRequest, @PathVariable final String dbname, @PathVariable final String entity, @PathVariable final String ids) { Callable<ResponseEntity<byte[]>> blocking = new Callable<ResponseEntity<byte[]>>() { @Override/*from w w w. ja v a2s.c o m*/ public ResponseEntity<byte[]> call() throws Exception { DB<Map<String, Object>> db = dbMap.get(dbname); if (db == null) { return buildEmptyResponse(HttpStatus.NOT_FOUND); } if (!db.listCollections().contains(entity)) { return buildEmptyResponse(HttpStatus.NOT_FOUND); } Collection<Map<String, Object>> entityCollection = db.getCollection(entity); // Construct critria Map<String, Object> criteria = new LinkedHashMap<String, Object>(); String[] splittedIds = ids.split(","); for (int i = 0; i < splittedIds.length; i++) { criteria.put(db.getPrimaryKeys(entity).get(i), convert(splittedIds[i])); } // Retrieve data Map<String, ?> response = entityCollection.findOne(criteria); if (response == null) { return buildEmptyResponse(HttpStatus.NOT_FOUND); } else { entityCollection.remove(criteria); return buildEmptyResponse(HttpStatus.NO_CONTENT); } } }; return blockingCall(blocking); }
From source file:com.boundlessgeo.geoserver.api.controllers.IconController.java
@RequestMapping(value = "/{icon:.+}", method = RequestMethod.DELETE) @ResponseStatus(value = HttpStatus.NO_CONTENT) public void delete(@PathVariable String icon) throws IOException { delete(null, icon);//w w w.j a va 2 s . co m }
From source file:eu.freme.broker.integration_tests.UserControllerTest.java
@Test public void testAdmin() throws UnirestException { String username = "carlos"; String password = "carlosss"; logger.info("create user \"" + username + "\" and get token"); HttpResponse<String> response = Unirest.post(baseUrl + "/user").queryString("username", username) .queryString("password", password).asString(); response = Unirest.post(baseUrl + BaseRestController.authenticationEndpoint) .header("X-Auth-Username", username).header("X-Auth-Password", password).asString(); String token = new JSONObject(response.getBody()).getString("token"); logger.info("try to access /user endpoint from user account - should not work"); loggerIgnore(accessDeniedExceptions); response = Unirest.get(baseUrl + "/user").header("X-Auth-Token", token).asString(); assertTrue(response.getStatus() == HttpStatus.UNAUTHORIZED.value()); loggerUnignore(accessDeniedExceptions); logger.info("access /user endpoint with admin credentials"); response = Unirest.post(baseUrl + BaseRestController.authenticationEndpoint) .header("X-Auth-Username", adminUsername).header("X-Auth-Password", adminPassword).asString(); token = new JSONObject(response.getBody()).getString("token"); response = Unirest.get(baseUrl + "/user").header("X-Auth-Token", token).asString(); assertTrue(response.getStatus() == HttpStatus.OK.value()); logger.info("access user through access token passed via query string"); response = Unirest.get(baseUrl + "/user").queryString("token", token).asString(); assertTrue(response.getStatus() == HttpStatus.OK.value()); logger.info("admin can delete carlos"); response = Unirest.delete(baseUrl + "/user/" + username).header("X-Auth-Token", token).asString(); assertTrue(response.getStatus() == HttpStatus.NO_CONTENT.value()); response = Unirest.get(baseUrl + "/user").header("X-Auth-Token", token).asString(); assertTrue(response.getStatus() == HttpStatus.OK.value()); }
From source file:com.netflix.genie.web.controllers.ApplicationRestController.java
/** * Patch an application using JSON Patch. * * @param id The id of the application to patch * @param patch The JSON Patch instructions * @throws GenieException On error/* w w w. j a va2 s.co m*/ */ @PatchMapping(value = "/{id}", consumes = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.NO_CONTENT) public void patchApplication(@PathVariable("id") final String id, @RequestBody final JsonPatch patch) throws GenieException { log.debug("Called to patch application {} with patch {}", id, patch); this.applicationService.patchApplication(id, patch); }
From source file:springfox.documentation.spring.web.dummy.DummyClass.java
@ResponseBody @ResponseStatus(value = HttpStatus.NO_CONTENT) public void methodWithResponseStatusAnnotationAndEmptyReason() { }
From source file:com.netflix.genie.web.controllers.CommandRestController.java
/** * Patch a command using JSON Patch./*from ww w .j a va2 s .c o m*/ * * @param id The id of the command to patch * @param patch The JSON Patch instructions * @throws GenieException On error */ @PatchMapping(value = "/{id}", consumes = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.NO_CONTENT) public void patchCommand(@PathVariable("id") final String id, @RequestBody final JsonPatch patch) throws GenieException { log.debug("Called to patch command {} with patch {}", id, patch); this.commandService.patchCommand(id, patch); }
From source file:com.netflix.genie.web.controllers.ClusterRestController.java
/** * Patch a cluster using JSON Patch.// w w w.ja v a 2 s .com * * @param id The id of the cluster to patch * @param patch The JSON Patch instructions * @throws GenieException On error */ @PatchMapping(value = "/{id}", consumes = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.NO_CONTENT) public void patchCluster(@PathVariable("id") final String id, @RequestBody final JsonPatch patch) throws GenieException { log.debug("Called to patch cluster {} with patch {}", id, patch); this.clusterService.patchCluster(id, patch); }
From source file:com.ge.predix.test.utils.ZoneHelper.java
public HttpStatus deleteZone(final RestTemplate restTemplate, final String zoneName, final boolean registeredWithZac) { try {/*from w ww . j a v a 2 s . c om*/ restTemplate.delete(this.acsBaseUrl + ACS_ZONE_API_PATH + zoneName); if (registeredWithZac) { deleteServiceFromZac(zoneName); } return HttpStatus.NO_CONTENT; } catch (HttpClientErrorException httpException) { return httpException.getStatusCode(); } catch (JsonProcessingException e) { return HttpStatus.INTERNAL_SERVER_ERROR; } catch (RestClientException e) { return HttpStatus.INTERNAL_SERVER_ERROR; } }