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:io.github.microcks.web.DynamicMockRestController.java
@RequestMapping(value = "/{service}/{version}/{resource}/{resourceId}", method = RequestMethod.DELETE) public ResponseEntity<String> deleteResource(@PathVariable("service") String serviceName, @PathVariable("version") String version, @PathVariable("resource") String resource, @PathVariable("resourceId") String resourceId, @RequestParam(value = "delay", required = false) Long delay) { log.debug("Update resource '{}:{}' for service '{}-{}'", resource, resourceId, serviceName, version); long startTime = System.currentTimeMillis(); MockContext mockContext = getMockContext(serviceName, version, "DELETE /" + resource + "/:id"); if (mockContext != null) { genericResourceRepository.delete(resourceId); // Wait if specified before returning. waitForDelay(startTime, delay, mockContext); // Return a 204 code : done and no content returned. return new ResponseEntity<>(HttpStatus.NO_CONTENT); }/*from w ww . j a v a 2 s. c om*/ // Return a 400 code : bad request. return new ResponseEntity<>(HttpStatus.BAD_REQUEST); }
From source file:org.openbaton.nfvo.api.RestNetworkServiceDescriptor.java
@RequestMapping(value = "{idNsd}/vnfdependencies/{idVnfd}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.NO_CONTENT) public void deleteVNFDependency(@PathVariable("idNsd") String idNsd, @PathVariable("idVnfd") String idVnfd, @RequestHeader(value = "project-id") String projectId) throws NotFoundException { networkServiceDescriptorManagement.deleteVNFDependency(idNsd, idVnfd, projectId); }
From source file:org.openbaton.nfvo.api.RestNetworkServiceRecord.java
/** * Removes the VirtualNetworkFunctionRecord with idVnf into NSR with idNsr * * @param idNsr/*from ww w. j ava2s . co m*/ * @param idVnf * @throws NotFoundException */ @RequestMapping(value = "{idNsr}/vnfrecords/{idVnf}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.NO_CONTENT) public void deleteVNFRecord(@PathVariable("idNsr") String idNsr, @PathVariable("idVnf") String idVnf, @RequestHeader(value = "project-id") String projectId) throws NotFoundException { networkServiceRecordManagement.deleteVNFRecord(idNsr, idVnf, projectId); }
From source file:de.thm.arsnova.controller.LecturerQuestionController.java
/** * returns a JSON document which represents the given answer of a question. * * @param sessionKey/*from ww w . j av a2 s . c o m*/ * Session Keyword to which the question belongs to * @param questionId * CouchDB Question ID for which the given answer should be * retrieved * @return JSON Document of {@link Answer} or {@link NotFoundException} * @throws NotFoundException * if wrong session, wrong question or no answer was given by * the current user * @throws ForbiddenException * if not logged in */ @DeprecatedApi @RequestMapping(value = "/{questionId}/myanswer", method = RequestMethod.GET) public Answer getMyAnswer(@PathVariable final String questionId, final HttpServletResponse response) { final Answer answer = questionService.getMyAnswer(questionId); if (answer == null) { response.setStatus(HttpStatus.NO_CONTENT.value()); return null; } return answer; }
From source file:org.springsource.restbucks.training.payment.web.PaymentProcessIntegrationTest.java
/** * Polls the order resource every 2 seconds and uses an {@code If-None-Match} header alongside the {@code ETag} of the * first response to avoid sending the representation over and over again. * /*from w ww . j a v a 2s .com*/ * @param response * @return * @throws Exception */ private MockHttpServletResponse pollUntilOrderHasReceiptLink(MockHttpServletResponse response) throws Exception { // Grab String content = response.getContentAsString(); LinkDiscoverer discoverer = getDiscovererFor(response); Link orderLink = discoverer.findLinkWithRel(ORDER_REL, content); // Poll order until receipt link is set Link receiptLink = null; String etag = null; MockHttpServletResponse pollResponse; do { HttpHeaders headers = new HttpHeaders(); if (etag != null) { headers.setIfNoneMatch(etag); } log.info("Poll state of order until receipt is ready"); ResultActions action = mvc.perform(get(orderLink.getHref()).headers(headers)); pollResponse = action.andReturn().getResponse(); int status = pollResponse.getStatus(); etag = pollResponse.getHeader("ETag"); log.info(String.format("Received %s with ETag of %s", status, etag)); if (status == HttpStatus.OK.value()) { action.andExpect(linkWithRelIsPresent(Link.REL_SELF)). // andExpect(linkWithRelIsNotPresent(UPDATE_REL)). // andExpect(linkWithRelIsNotPresent(CANCEL_REL)); receiptLink = discoverer.findLinkWithRel(RECEIPT_REL, pollResponse.getContentAsString()); } else if (status == HttpStatus.NO_CONTENT.value()) { action.andExpect(content().string(isEmptyOrNullString())); } if (receiptLink == null) { Thread.sleep(2000); } } while (receiptLink == null); return pollResponse; }
From source file:com.orange.ngsi2.server.Ngsi2BaseController.java
/** * Endpoint patch /v2/entities/{entityId} * @param entityId the entity ID//ww w .jav a 2 s . c om * @param attributes the attributes to update * @param type an optional type of entity * @param options keyValues is not supported. * @return http status 204 (no content) * @throws Exception */ @RequestMapping(method = RequestMethod.PATCH, value = { "/entities/{entityId}" }, consumes = MediaType.APPLICATION_JSON_VALUE) final public ResponseEntity updateExistingEntityAttributesEndpoint(@PathVariable String entityId, @RequestBody HashMap<String, Attribute> attributes, @RequestParam Optional<String> type, @RequestParam Optional<String> options) throws Exception { validateSyntax(entityId, type.orElse(null), attributes); //TODO: to support keyValues as options if (options.isPresent()) { throw new UnsupportedOptionException(options.get()); } updateExistingEntityAttributes(entityId, type.orElse(null), attributes); return new ResponseEntity(HttpStatus.NO_CONTENT); }
From source file:org.springsource.restbucks.payment.web.PaymentProcessIntegrationTest.java
/** * Polls the order resource every 2 seconds and uses an {@code If-None-Match} header alongside the {@code ETag} of the * first response to avoid sending the representation over and over again. * /* www . j a va 2 s. c om*/ * @param response * @return * @throws Exception */ private MockHttpServletResponse pollUntilOrderHasReceiptLink(MockHttpServletResponse response) throws Exception { // Grab String content = response.getContentAsString(); LinkDiscoverer discoverer = getDiscovererFor(response); Link orderLink = discoverer.findLinkWithRel(ORDER_REL, content); // Poll order until receipt link is set Link receiptLink = null; String etag = null; MockHttpServletResponse pollResponse; do { HttpHeaders headers = new HttpHeaders(); if (etag != null) { headers.setIfNoneMatch(etag); } LOG.info("Poll state of order until receipt is ready"); ResultActions action = mvc.perform(get(orderLink.expand().getHref()).headers(headers)); pollResponse = action.andReturn().getResponse(); int status = pollResponse.getStatus(); etag = pollResponse.getHeader("ETag"); LOG.info(String.format("Received %s with ETag of %s", status, etag)); if (status == HttpStatus.OK.value()) { action.andExpect(linkWithRelIsPresent(Link.REL_SELF)). // andExpect(linkWithRelIsNotPresent(UPDATE_REL)). // andExpect(linkWithRelIsNotPresent(CANCEL_REL)); receiptLink = discoverer.findLinkWithRel(RECEIPT_REL, pollResponse.getContentAsString()); } else if (status == HttpStatus.NO_CONTENT.value()) { action.andExpect(content().string(isEmptyOrNullString())); } if (receiptLink == null) { Thread.sleep(2000); } } while (receiptLink == null); return pollResponse; }
From source file:edu.pitt.dbmi.ccd.anno.group.GroupController.java
@RequestMapping(value = GroupLinks.REQUESTS, method = RequestMethod.POST) @ResponseStatus(HttpStatus.NO_CONTENT) @ResponseBody//from w w w . j a va 2 s .c o m public void requestResponse(@AuthenticationPrincipal UserAccountDetails principal, @PathVariable String name, @RequestParam(value = "accept", required = false) String accept, @RequestParam(value = "deny", required = false) String deny, @RequestParam(value = "mod", required = false) Boolean mod) throws NotFoundException { final UserAccount requester = principal.getUserAccount(); final Group group = groupService.findByName(name); if (group == null) { throw new GroupNotFoundException(name); } if (group.getModerators().stream().map(UserAccount::getId).anyMatch(u -> u.equals(requester.getId()))) { if (!isEmpty(accept)) { final UserAccount user = userService.findByUsername(accept); if (user == null) { throw new UserNotFoundException(accept); } if (group.hasRequester(user)) { group.removeRequester(user); group.addMember(user); if (mod != null && mod) { group.addModerator(user); } groupService.save(group); } } if (!isEmpty(deny)) { final UserAccount user = userService.findByUsername(accept); if (user == null) { throw new UserNotFoundException(accept); } if (group.hasRequester(user)) { group.removeRequester(user); groupService.save(group); } } } else { throw new ForbiddenException(requester, request); } }
From source file:com.sms.server.controller.AdminController.java
@RequestMapping(value = "/media/{id}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.NO_CONTENT) public void deleteMediaElement(@PathVariable("id") Long id) { mediaDao.removeMediaElement(id);/* w w w . ja v a2 s . c o m*/ }
From source file:com.netflix.genie.web.controllers.ApplicationRestController.java
/** * Update the configuration files for a given application. * * @param id The id of the application to update the configuration files * for. Not null/empty/blank. * @param configs The configuration files to replace existing configuration * files with. Not null/empty/blank. * @throws GenieException For any error/* ww w . j a va2s . c o m*/ */ @PutMapping(value = "/{id}/configs", consumes = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.NO_CONTENT) public void updateConfigsForApplication(@PathVariable("id") final String id, @RequestBody final Set<String> configs) throws GenieException { log.debug("Called with id {} and configs {}", id, configs); this.applicationService.updateConfigsForApplication(id, configs); }