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:am.ik.categolj2.api.user.UserRestController.java
@RequestMapping(value = "{username}", method = RequestMethod.DELETE, headers = Categolj2Headers.X_ADMIN) public ResponseEntity<Void> postUsers(@PathVariable("username") String username) { userService.delete(username);/*from www.j a v a 2s. c o m*/ return new ResponseEntity<>(HttpStatus.NO_CONTENT); }
From source file:com.iggroup.oss.sample.web.controller.SampleController.java
/** * Delete the sample indicated by the reference * /*ww w.j a va2 s .c o m*/ * @param reference the sample's reference, a 5 digit text field */ @RequestMapping(value = "/samples/{reference}", method = { RequestMethod.DELETE }) @ResponseStatus(value = HttpStatus.NO_CONTENT) public void deleteSample(@PathVariable String reference) { LOGGER.info("deleteSample " + reference); validate(new SampleReference(reference)); service.deleteSample(reference); }
From source file:fr.xebia.xke.metrics.web.WineController.java
@RequestMapping(value = "/cached/wine/search/{name}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<List<Wine>> findCachedByName(@PathVariable String name) { // TODO Exercise 9 - start timer for find.cached try {//from w w w . j a va 2 s . c om List<Wine> result = null; try { result = searchCache.get(name); log.info(searchCache.stats().toString()); return new ResponseEntity<List<Wine>>(result, HttpStatus.OK); } catch (ExecutionException e) { log.error("Failed to access data in cache", e); } return new ResponseEntity<List<Wine>>(new ArrayList<Wine>(), HttpStatus.NO_CONTENT); } finally { // TODO Exercise 9 - stop timer } }
From source file:nc.noumea.mairie.organigramme.core.ws.BaseWsConsumer.java
public <T> T readResponse(Class<T> targetClass, ClientResponse response, String url) { T result = null;// w w w .jav a 2s .c o m try { result = targetClass.newInstance(); } catch (Exception ex) { throw new WSConsumerException( "An error occured when instantiating return type when deserializing JSON from WS request.", ex); } if (response.getStatus() == HttpStatus.NO_CONTENT.value()) { return null; } if (response.getStatus() != HttpStatus.OK.value() && response.getStatus() != HttpStatus.CONFLICT.value()) { throw new WSConsumerException( String.format("An error occured when querying '%s'. Return code is : %s, content is %s", url, response.getStatus(), response.getEntity(String.class))); } String output = response.getEntity(String.class); result = new JSONDeserializer<T>().use(Date.class, new MSDateTransformer()).deserializeInto(output, result); return result; }
From source file:com.jiwhiz.rest.admin.CommentRestController.java
@RequestMapping(method = RequestMethod.PATCH, value = URL_ADMIN_COMMENTS_COMMENT) @Transactional/*www .j av a 2s .co m*/ public HttpEntity<Void> updateCommentPost(@PathVariable("commentId") String commentId, @RequestBody Map<String, String> updateMap) throws ResourceNotFoundException { CommentPost commentPost = getCommentById(commentId); String content = updateMap.get("content"); if (content != null) { commentPost.update(content); } String statusString = updateMap.get("status"); if (statusString != null) { CommentStatusType status = CommentStatusType.valueOf(statusString); if (status != null) { commentPost.setStatus(status); } else { //TODO throw exception for invalid status } } commentPostRepository.save(commentPost); return new ResponseEntity<Void>(HttpStatus.NO_CONTENT); }
From source file:com.wujiabo.opensource.feather.rest.controller.RbacRestController.java
@RequestMapping(value = "/group/{id}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.NO_CONTENT) public void delete(@PathVariable("id") Long id) { // taskService.deleteTask(id); }
From source file:com.sms.server.controller.AdminController.java
@RequestMapping(value = "/user/{username}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.NO_CONTENT) public void deleteUser(@PathVariable("username") String username) { LogService.getInstance().addLogEntry(Level.INFO, CLASS_NAME, "Removed user '" + username + "'.", null); userDao.removeUser(username);/* ww w . ja v a 2 s .c o m*/ }
From source file:com._8x8.presentation.restController.UserRestController.java
@RequestMapping(value = "/user/{id}", method = RequestMethod.DELETE) public ResponseEntity<User> deleteUser(@PathVariable("id") int id) { System.out.println("Fetching & Deleting User with id " + id); // User user = userService.findById(id); // if (user == null) { // System.out.println("Unable to delete. User with id " + id + " not found"); // return new ResponseEntity<User>(HttpStatus.NOT_FOUND); // }//from w ww .j av a2 s.co m _userService.RemoveUserById(id); return new ResponseEntity<User>(HttpStatus.NO_CONTENT); }
From source file:net.eusashead.hateoas.response.argumentresolver.AsyncEntityControllerITCase.java
@Test public void testHead() throws Exception { // Expected result HttpHeaders headers = new HttpHeaders(); headers.setETag("W/\"b0c689597eb9dd62c0a1fb90a7c5c5a5\""); ResponseEntity<Entity> expectedResult = new ResponseEntity<Entity>(headers, HttpStatus.NO_CONTENT); // Execute asynchronously MvcResult mvcResult = this.mockMvc .perform(request(HttpMethod.HEAD, "http://localhost/async/foo") .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andExpect(request().asyncStarted()).andExpect(request().asyncResult(expectedResult)).andReturn(); // Perform asynchronous dispatch this.mockMvc.perform(asyncDispatch(mvcResult)).andDo(print()).andExpect(status().isNoContent()) .andExpect(header().string("ETag", "W/\"b0c689597eb9dd62c0a1fb90a7c5c5a5\"")); }
From source file:com.mycompany.springrest.controllers.UserController.java
@RequestMapping(value = "/user/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<User> deleteUser(@PathVariable("id") int id) { logger.info("Fetching & Deleting User with id " + id); User user = userService.getUserById(id); if (user == null) { logger.info("Unable to delete. User with id " + id + " not found"); return new ResponseEntity<User>(HttpStatus.NOT_FOUND); }// w w w . j av a2 s . c o m userService.removeUser(id); return new ResponseEntity<User>(HttpStatus.NO_CONTENT); }