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.LogoutController.java

@RequestMapping()
@ResponseStatus(HttpStatus.NO_CONTENT)
void logout(HttpServletRequest request, HttpServletResponse response) {
    if ("/logout".equals(request.getServletPath())) {
        Optional<Cookie> cookie = Arrays.stream(request.getCookies())
                .filter(c -> "recipe_bearer".equals(c.getName())).findFirst();
        if (cookie.isPresent()) {
            Cookie c = cookie.get();/*from w  w  w  .  j a va 2 s .  co  m*/
            c.setValue("");
            c.setPath("/");
            c.setMaxAge(0);
            response.addCookie(c);
        }
        response.setStatus(HttpServletResponse.SC_NO_CONTENT);
    }
}

From source file:com.baidu.terminator.manager.action.LogAction.java

@RequestMapping(value = "/{linkId}", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void deleteLog(@PathVariable int linkId) {
    logService.deleteLog(linkId);//from w ww  .ja  v  a 2 s .c  o  m
}

From source file:sample.mvc.RestDemoController.java

@RequestMapping("/logout")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void logout(HttpSession session) {
    session.invalidate();
}

From source file:com.seabee.snapdragon.controller.CommentsController.java

@RequestMapping(value = "/{commentId}", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void deleteComment(@PathVariable("commentId") int id) {
    dao.deleteCommentById(id);//w w  w  . ja  v  a2s  . co m
}

From source file:com.ge.predix.acs.commons.web.ResponseEntityBuilder.java

/**
 * Creates a typed ResponseEntity with HTTP status code 201/204 with a given location.
 *
 * @param location//  w  w w.  jav  a2  s.co m
 *            The location of the created resource
 * @param noContent
 *            false means updated resource which returns 204, true means created resource which returns 201
 * @return The corresponding ResponseEntity
 */
public static <T> ResponseEntity<T> created(final String location, final boolean noContent) {
    HttpStatus status = noContent ? HttpStatus.NO_CONTENT : HttpStatus.CREATED;

    if (location != null) {

        HttpHeaders headers = new HttpHeaders();
        headers.setLocation(URI.create(location));
        return new ResponseEntity<T>(headers, status);
    }
    return new ResponseEntity<T>(status);
}

From source file:net.eusashead.hateoas.response.impl.DeleteResponseBuilderImpl.java

@Override
public ResponseEntity<Void> build() {
    return new ResponseEntity<Void>(HttpStatus.NO_CONTENT);
}

From source file:nu.yona.server.analysis.rest.InactivityManagementController.java

@RequestMapping(value = "/{userAnonymizedId}/inactivity/", method = RequestMethod.POST)
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void createInactivityEntities(@PathVariable UUID userAnonymizedId,
        @RequestBody Set<IntervalInactivityDto> intervalInactivities) {
    inactivityManagementService.createInactivityEntities(userAnonymizedId, intervalInactivities);
}

From source file:com.brunomcustodio.dojo.springboot.BookServiceController.java

@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void deleteBook(@PathVariable("id") int id) {
    try {//from  ww  w . j  a v a2  s  .  c o m
        repository.delete(id);
    } catch (EmptyResultDataAccessException ex) {
        throw new BookNotFoundException(ex);
    }
}

From source file:rest.DependenciaRestController.java

@RequestMapping(value = "/dependencias/", method = RequestMethod.GET)
public ResponseEntity<List<DependenciaBean>> listAll() {
    List<DependenciaBean> dependencias = dependenciaService.findAll();
    if (dependencias.isEmpty()) {
        return new ResponseEntity<List<DependenciaBean>>(HttpStatus.NO_CONTENT);
    }/* w w  w.  j  a  v  a  2  s.co  m*/
    return new ResponseEntity<List<DependenciaBean>>(dependencias, HttpStatus.OK);
}

From source file:de.tobiasbruns.fs20.sender.SenderController.java

@ResponseStatus(HttpStatus.NO_CONTENT)
@RequestMapping(method = RequestMethod.POST)
public void sendRequest(@RequestBody FS20Request request) {
    FS20Result result = service.executeRequest(request);
    if (result.getResultCode().isError())
        throw new CommandErrorException(result.getResultCode());
}