Example usage for org.springframework.http HttpStatus NO_CONTENT

List of usage examples for org.springframework.http HttpStatus NO_CONTENT

Introduction

In this page you can find the example usage for org.springframework.http HttpStatus NO_CONTENT.

Prototype

HttpStatus NO_CONTENT

To view the source code for org.springframework.http HttpStatus NO_CONTENT.

Click Source Link

Document

204 No Content .

Usage

From source file:de.sainth.recipe.backend.rest.controller.CookbookController.java

@Secured({ "ROLE_USER", "ROLE_ADMIN" })
@RequestMapping(value = "{id}", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
void delete(@PathVariable("id") Long id) {
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    if (authentication instanceof RecipeManagerAuthenticationToken) {
        RecipeManagerAuthenticationToken token = (RecipeManagerAuthenticationToken) authentication;
        if (ROLE_ADMIN.name().equals(token.getRole())) {
            repository.delete(id);/* w  w w  . j av a  2s  .c o m*/
        } else {
            repository.delete(id, token.getPrincipal());
        }
    }
}

From source file:cn.cdwx.jpa.web.account.TaskRestController.java

@RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaTypes.JSON)
public ResponseEntity<?> update(@RequestBody Task task) {
    // JSR303 Bean Validator, RestExceptionHandler?.
    BeanValidators.validateWithException(validator, task);
    // ?/*from  w w  w .j ava 2s.  c  o  m*/
    taskService.saveTask(task);

    // Restful204??, . ?200??.
    return new ResponseEntity(HttpStatus.NO_CONTENT);
}

From source file:com.gazbert.bxbot.rest.api.EngineConfigController.java

/**
 * Updates Engine configuration for the bot.
 *
 * @return 204 'No Content' HTTP status code if engine config was updated successfully, some other HTTP status code otherwise.
 *//* w w w.j ava 2  s. c o  m*/
@RequestMapping(value = "/engine", method = RequestMethod.PUT)
public ResponseEntity<?> updateEngine(@AuthenticationPrincipal User user, @RequestBody EngineConfig config) {

    engineConfigService.updateConfig(config);
    final HttpHeaders httpHeaders = new HttpHeaders();
    httpHeaders
            .setLocation(ServletUriComponentsBuilder.fromCurrentRequest().path("/").buildAndExpand().toUri());
    return new ResponseEntity<>(null, httpHeaders, HttpStatus.NO_CONTENT);
}

From source file:cn.aozhi.songify.rest.TaskRestController.java

@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void delete(@PathVariable("id") Long id) {
    taskService.deleteTask(id);/*from  ww w.j  a  v  a 2 s . com*/
}

From source file:com.thesoftwareguild.capstoneblog.controller.HomeController.java

@RequestMapping(value = "/post/{id}", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void removePost(@PathVariable("id") int id) {
    dao.removePost(id);//from  www  .j av a  2s . co m
}

From source file:org.openwms.tms.api.TransportationController.java

@PatchMapping
@ResponseStatus(HttpStatus.NO_CONTENT)
public void updateTO(@RequestBody CreateTransportOrderVO vo) {
    validatePriority(vo);//from   w  w  w .j a v  a  2s . c o m
    service.update(m.map(vo, TransportOrder.class));
}

From source file:com.sap.csc.poc.ems.service.admin.entitlement.EntitlementServiceImpl.java

@Override
@RequestMapping(value = "entitlements/search", method = RequestMethod.GET)
public ResponseEntity<Page<EntitlementInfo>> search(
        // Keyword
        @RequestParam(value = "keyword", required = false) String keyword,
        // Page/*  ww w.  ja  v  a2 s .  co  m*/
        @RequestParam(value = "page", required = false, defaultValue = PageConstant.DEFAULT_PAGE_INDEX) Integer page,
        // Size
        @RequestParam(value = "size", required = false, defaultValue = PageConstant.DEFAULT_PAGE_SIZE) Integer size,
        // Sort
        @RequestParam(value = "sort", required = false, defaultValue = PageConstant.DEFAULT_SORT) String sort) {
    Page<EntitlementInfo> entitlementPage = entitlementHeaderRepository
            .search(keyword, new PageRequest(page, size, StringUtils.isBlank(sort)
                    // Search with default sort
                    ? new Sort(Direction.DESC, EntitlementHeader_.updateOn.getName())
                    // Search with custom sort
                    : new Sort(Arrays.asList(sort.split(",")).stream().map(order -> order.split(" "))
                            .map(order -> new Order(Direction.fromString(order[1]), order[0]))
                            .collect(Collectors.toList()))))
            // Convert to dto
            .map(entitlement -> new EntitlementInfo(entitlement));
    if (entitlementPage.hasContent()) {
        return new ResponseEntity<>(entitlementPage, HttpStatus.OK);
    } else {
        return new ResponseEntity<>(entitlementPage, HttpStatus.NO_CONTENT);
    }
}

From source file:org.openbaton.nfvo.api.RestKeys.java

@RequestMapping(value = "/multipledelete", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void multipleDelete(@RequestHeader(value = "project-id") String projectId,
        @RequestBody @Valid List<String> ids) throws NotFoundException {
    for (String id : ids) {
        keyManagement.delete(projectId, id);
    }/*from w ww  .  j  ava  2s  . c o m*/
}

From source file:com.tsguild.upsproject.controller.HomeController.java

@ResponseStatus(HttpStatus.NO_CONTENT)
@RequestMapping(value = "/cannister/{cannisterId}", method = RequestMethod.PUT)
public void updateCannister(@PathVariable("cannisterId") int cannisterId,
        @RequestBody Cannister updatedCannister) {
    updatedCannister.setId(cannisterId);
    dao.updateCannister(updatedCannister);
}

From source file:de.codecentric.boot.admin.controller.RegistryControllerTest.java

@Test
public void unregister() {
    Application app = new Application("http://localhost", "FOO");
    app = controller.register(app).getBody();

    ResponseEntity<?> response = controller.unregister(app.getId());
    assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
    assertEquals(app, response.getBody());

    assertEquals(HttpStatus.NOT_FOUND, controller.get(app.getId()).getStatusCode());
}