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.github.shredder121.gh_event_api.filter.GithubMACChecker.java

@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
        FilterChain filterChain) throws IOException, ServletException {
    String signatureHeader = request.getHeader(GITHUB_SIGNATURE_HEADER);
    if (shouldFilter(request)) {
        if (signatureHeader != null) {
            HttpServletRequest preReadRequest = new PreReadRequest(request);
            byte[] requestBytes = ByteStreams.toByteArray(preReadRequest.getInputStream());
            String signatureString = "sha1=" + hexDigest(requestBytes);
            if (signatureString.hashCode() != signatureHeader.hashCode()) {
                logger.warn("bad signature {} {}", signatureString, signatureHeader);
                response.sendError(HttpStatus.NO_CONTENT.value());
                // drops the payload
            } else {
                filterChain.doFilter(preReadRequest, response);
            }//  w w  w .  j  av  a  2  s .  com
        } else {
            response.sendError(HttpStatus.NOT_FOUND.value());
        }
    } else {
        if (signatureHeader != null) {
            logger.warn("Signature checking requested, but Mac is not set up.");
        }
        filterChain.doFilter(request, response);
    }
}

From source file:nc.noumea.mairie.organigramme.core.ws.BaseWsConsumer.java

public String readResponseAsString(ClientResponse response, String url) {

    if (response.getStatus() == HttpStatus.NO_CONTENT.value()) {
        return null;
    }/*from w w w .j  a v a2  s.c o m*/

    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)));
    }

    return response.getEntity(String.class);
}

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

@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void delete(@PathVariable("id") String id) {
    taskService.deleteTask(id);//from  w  ww .  ja v a  2s .  c o  m
}

From source file:com.github.lynxdb.server.api.http.handlers.EpPut.java

@RequestMapping(path = "", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity put(Authentication _authentication, @RequestBody @Valid List<Metric> _request,
        BindingResult _bindingResult) {/* w  ww  .j  av  a  2 s .c  om*/

    User user = (User) _authentication.getPrincipal();

    if (_bindingResult.hasErrors()) {
        ArrayList<String> errors = new ArrayList();
        _bindingResult.getFieldErrors().forEach((FieldError t) -> {
            errors.add(t.getField() + ": " + t.getDefaultMessage());
        });
        return new ErrorResponse(mapper, HttpStatus.BAD_REQUEST, errors.toString(), null).response();
    }

    List<com.github.lynxdb.server.core.Metric> metricList = new ArrayList<>();
    _request.stream().forEach((m) -> {
        metricList.add(new com.github.lynxdb.server.core.Metric(m));
    });

    try {
        entries.insertBulk(vhosts.byId(user.getVhost()), metricList);
    } catch (Exception ex) {
        throw ex;
    }
    return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
}

From source file:com.swcguild.addressbookmvc.controller.HomeController.java

@RequestMapping(value = "/contact/{id}", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void deleteContact(@PathVariable("id") int id) {
    dao.removeContact(id);/*  w  w w .  jav  a2  s.c  om*/
}

From source file:org.energyos.espi.datacustodian.oauth.OauthAdminController.java

@RequestMapping(value = "custodian/oauth/tokens/{token}/retailcustomers/{userId}", method = RequestMethod.DELETE)
public ResponseEntity<Void> revokeToken(@PathVariable String userId, @PathVariable String token,
        Principal principal) throws Exception {
    checkResourceOwner(userId, principal);
    if (tokenServices.revokeToken(token)) {
        return new ResponseEntity<Void>(HttpStatus.NO_CONTENT);
    } else {//from www.  j av  a  2  s  . c o  m
        return new ResponseEntity<Void>(HttpStatus.NOT_FOUND);
    }
}

From source file:com.example.notes.TagsController.java

@RequestMapping(value = "/{id}", method = RequestMethod.PATCH)
@ResponseStatus(HttpStatus.NO_CONTENT)
void updateTag(@PathVariable("id") long id, @RequestBody TagPatchInput tagInput) {
    Tag tag = findTagById(id);//  w w  w. j a  va  2 s.  c  om
    if (tagInput.getName() != null) {
        tag.setName(tagInput.getName());
    }
    this.repository.save(tag);
}

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

/**
 * Unregister an application within this admin application.
 * /*from w ww. j  a va 2s  .  c o m*/
 * @param id The application id.
 */
@RequestMapping(value = "/api/application/{id}", method = RequestMethod.DELETE)
public ResponseEntity<Application> unregister(@PathVariable String id) {
    LOGGER.debug("Unregister application with ID '{}'", id);
    Application app = registry.unregister(id);
    if (app != null) {
        return new ResponseEntity<Application>(app, HttpStatus.NO_CONTENT);
    } else {
        return new ResponseEntity<Application>(HttpStatus.NOT_FOUND);
    }
}

From source file:com.baby.web.DisconnectController.java

@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<String> disconnect(@RequestParam("signed_request") String signedRequest) {
    try {/*from   w  ww . java2s .  c om*/
        String userId = getUserId(signedRequest);
        logger.info(
                "Deauthorization request received for Facebook User ID: " + userId + "; Removing connections.");
        Set<String> providerUserIds = new HashSet<String>();
        providerUserIds.add(userId);
        Set<String> localUserIds = usersConnectionRepository.findUserIdsConnectedTo("facebook",
                providerUserIds);
        for (String localUserId : localUserIds) {
            ConnectionRepository connectionRepository = usersConnectionRepository
                    .createConnectionRepository(localUserId);
            logger.info("  Removing Facebook connection for local user '" + localUserId + "'");
            connectionRepository.removeConnection(new ConnectionKey("facebook", userId));
        }
        return new ResponseEntity<String>(HttpStatus.NO_CONTENT);
    } catch (SignedRequestException e) {
        return new ResponseEntity<String>(HttpStatus.BAD_REQUEST);
    }
}

From source file:io.fourfinanceit.homework.controller.ClientController.java

@RequestMapping(value = "/client/{id}", method = RequestMethod.DELETE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Client> deleteGreeting(@PathVariable("id") Long id, @RequestBody Client client) {

    if (clientRepository.findOne(id) != null) {

        clientRepository.delete(id);/* w w  w.j ava2  s  . co m*/
        return new ResponseEntity<Client>(HttpStatus.INTERNAL_SERVER_ERROR);
    } else {
        return new ResponseEntity<Client>(HttpStatus.NO_CONTENT);
    }

}