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:com.jiwhiz.rest.author.AuthorBlogCommentRestController.java

@RequestMapping(method = RequestMethod.PATCH, value = URL_AUTHOR_BLOGS_BLOG_COMMENTS_COMMENT)
@Transactional// www. j  a  va2s  .com
public HttpEntity<Void> updateCommentPost(@PathVariable("blogId") String blogId,
        @PathVariable("commentId") String commentId, @RequestBody Map<String, String> updateMap)
        throws ResourceNotFoundException {
    BlogPost blogPost = getBlogByIdAndCheckAuthor(blogId);
    CommentPost commentPost = getCommentByIdAndCheckBlog(commentId, blogPost);

    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 {
            log.info("Invalid Comment Status:" + statusString);
            //TODO throw exception for invalid status ??

        }
    }
    commentPostRepository.save(commentPost);

    return new ResponseEntity<Void>(HttpStatus.NO_CONTENT);
}

From source file:fr.gmjgav.controller.BarController.java

@RequestMapping(value = "/{barId}/{beerId}", method = DELETE)
public ResponseEntity<?> deleteBeerInBar(@PathVariable long barId, @PathVariable long beerId) {
    Bar bar = barRepository.findOne(barId);
    List<Beer> beersOfTheBar = bar.getBeers();
    Beer searchedBeer = beerRepository.findOne(beerId);
    beersOfTheBar.remove(searchedBeer);//from   w  w  w.  j a  va 2  s .  c om
    bar.setBeers(beersOfTheBar);
    barRepository.save(bar);
    return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}

From source file:io.syndesis.runtime.BaseITCase.java

protected <T> ResponseEntity<T> delete(String url, Class<T> responseClass, String token) {
    return delete(url, responseClass, token, HttpStatus.NO_CONTENT);
}

From source file:org.mitre.uma.web.PolicyAPI.java

/**
 * Delete the indicated resource set//from   w  w w  .  j a  v a2 s .  c  o m
 * @param rsid
 * @param m
 * @param auth
 * @return
 */
@RequestMapping(value = "/{rsid}", method = RequestMethod.DELETE, produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
public String deleteResourceSet(@PathVariable(value = "rsid") Long rsid, Model m, Authentication auth) {

    ResourceSet rs = resourceSetService.getById(rsid);

    if (rs == null) {
        m.addAttribute(HttpCodeView.CODE, HttpStatus.NOT_FOUND);
        return HttpCodeView.VIEWNAME;
    }

    if (!rs.getOwner().equals(auth.getName())) {
        logger.warn("Unauthorized resource set request from bad user; expected " + rs.getOwner() + " got "
                + auth.getName());

        // authenticated user didn't match the owner of the resource set
        m.addAttribute(HttpCodeView.CODE, HttpStatus.FORBIDDEN);
        return HttpCodeView.VIEWNAME;
    }

    resourceSetService.remove(rs);
    m.addAttribute(HttpCodeView.CODE, HttpStatus.NO_CONTENT);
    return HttpCodeView.VIEWNAME;

}

From source file:com.iggroup.oss.sample.web.controller.SampleController.java

/**
 * Update a sample or return a list of validation errors
 * /*from www.  j  a  v  a2s. c  o m*/
 * @param sample fully populated sample object
 */
@RequestMapping(value = "/samples", method = { RequestMethod.PUT })
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void updateSample(@Valid @RequestBody Sample sample) {

    LOGGER.info("updateSample " + sample.getReference());

    validate(sample);

    service.updateSample(sample);

}

From source file:am.ik.categolj2.api.file.FileRestController.java

@RequestMapping(value = "{fileId}/{fileName:.+}", method = RequestMethod.DELETE, headers = Categolj2Headers.X_ADMIN)
public ResponseEntity<Void> deleteFile(@PathVariable("fileId") String fileId,
        @PathVariable("fileName") String fileName) {
    uploadFileService.delete(fileId);/*from   w ww  .java2s  .c  o  m*/
    return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}

From source file:com.wisemapping.rest.AdminController.java

@ApiOperation("Note: Administration permissions required.")
@RequestMapping(method = RequestMethod.PUT, value = "admin/users/{id}/password", consumes = { "text/plain" })
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void changePassword(@RequestBody @ApiParam(required = true) String password,
        @PathVariable @ApiParam(required = true, value = "User Id", allowableValues = "range[1,"
                + Long.MAX_VALUE + "]") long id)
        throws WiseMappingException {
    if (password == null) {
        throw new IllegalArgumentException("Password can not be null");
    }/*  ww  w .j  a v  a2 s  .  co  m*/

    final User user = userService.getUserBy(id);
    if (user == null) {
        throw new IllegalArgumentException("User '" + id + "' could not be found");
    }
    user.setPassword(password);
    userService.changePassword(user);
}

From source file:ca.qhrtech.controllers.GameController.java

@ApiMethod(description = "Deletes a game from the bgl database")
@RequestMapping(value = "/game/{id}", method = RequestMethod.DELETE)
public ResponseEntity<Game> deleteGame(@PathVariable("id") long id) {
    if (gameService.findGameById(id) == null) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }// w  w  w  .j a v a 2  s . c om
    gameService.deleteGame(id);
    return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}

From source file:org.nekorp.workflow.backend.controller.imp.ClienteControllerImp.java

@Override
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
public void borrarCliente(@PathVariable final Long id, final HttpServletResponse response) {
    Cliente respuesta = this.clienteDao.consultar(id);
    if (respuesta == null) {
        //no hay nada que responder
        response.setStatus(HttpStatus.NO_CONTENT.value());
        return;// www  .j av  a  2s .c o  m
    }
    clienteDao.borrar(respuesta);
    //se acepto la peticion de borrado, no quiere decir que sucede de inmediato.
    response.setStatus(HttpStatus.ACCEPTED.value());
}

From source file:com.epam.ta.reportportal.ws.controller.impl.FileStorageController.java

/**
 * Copies provided {@link BinaryData} to Response
 * /*w  w  w.ja v  a  2s. co  m*/
 * @param response
 * @param binaryData
 */
private void toResponse(HttpServletResponse response, BinaryData binaryData) {
    if (binaryData != null) {
        response.setContentType(binaryData.getContentType());
        response.setContentLength(binaryData.getLength().intValue());

        try {
            IOUtils.copy(binaryData.getInputStream(), response.getOutputStream());
        } catch (IOException e) {
            throw new ReportPortalException("Unable to retrieve binary data from data storage", e);
        }
    } else {
        response.setStatus(HttpStatus.NO_CONTENT.value());
    }
}