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.sms.server.controller.AdminController.java

@RequestMapping(value = "/media/all", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void deleteAllMediaElements() {
    mediaDao.removeAllMediaElements();
}

From source file:com.sothawo.taboo2.Taboo2Service.java

/**
 * tries to load the title for a web page.
 *
 * @param url//from  w  ww. j a va2s . co m
 *         url for which the title shall be loaded
 * @return ResponseEntity with the title
 */
@RequestMapping(value = MAPPING_TITLE, method = RequestMethod.GET)
@ResponseBody
public final ResponseEntity<Bookmark> loadTitle(
        @RequestParam(value = "url", required = true) final String url) {
    if (MAGIC_TEST_URL.equals(url)) {
        return new ResponseEntity<>(aBookmark().withUrl(url).build(), HttpStatus.OK);
    }

    String urlString = url;
    if (null != urlString && !urlString.isEmpty()) {
        if (!urlString.startsWith("http")) {
            urlString = "http://" + urlString;
        }
        final String finalUrl = urlString;
        LOG.info("loading title for url {}", finalUrl);
        try {
            String htmlTitle = Jsoup.connect(finalUrl).timeout(5000).userAgent(JSOUP_USER_AGENT).get().title();
            LOG.info("got title: {}", htmlTitle);
            return new ResponseEntity<>(aBookmark().withUrl(finalUrl).withTitle(htmlTitle).build(),
                    HttpStatus.OK);
        } catch (HttpStatusException e) {
            LOG.info("loading url http error", e);
            return new ResponseEntity<>(HttpStatus.valueOf(e.getStatusCode()));
        } catch (IOException e) {
            LOG.info("loading url error", e);
        }
    }
    return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}

From source file:com.netflix.genie.web.controllers.ClusterRestController.java

/**
 * Update the configuration files for a given cluster.
 *
 * @param id      The id of the cluster to update the configuration files for.
 *                Not null/empty/blank.// w w  w  . j  av a2  s.  co  m
 * @param configs The configuration files to replace existing configuration
 *                files with. Not null/empty/blank.
 * @throws GenieException For any error
 */
@PutMapping(value = "/{id}/configs", consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void updateConfigsForCluster(@PathVariable("id") final String id, @RequestBody final Set<String> configs)
        throws GenieException {
    log.debug("Called with id {} and configs {}", id, configs);
    this.clusterService.updateConfigsForCluster(id, configs);
}

From source file:com.netflix.genie.web.controllers.CommandRestController.java

/**
 * Update the configuration files for a given command.
 *
 * @param id      The id of the command to update the configuration files for.
 *                Not null/empty/blank.//from   ww  w . j a v a 2s .c om
 * @param configs The configuration files to replace existing configuration
 *                files with. Not null/empty/blank.
 * @throws GenieException For any error
 */
@PutMapping(value = "/{id}/configs", consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void updateConfigsForCommand(@PathVariable("id") final String id, @RequestBody final Set<String> configs)
        throws GenieException {
    log.debug("Called with id {} and configs {}", id, configs);
    this.commandService.updateConfigsForCommand(id, configs);
}

From source file:com.netflix.genie.web.controllers.ApplicationRestController.java

/**
 * Delete the all configuration files from a given application.
 *
 * @param id The id of the application to delete the configuration files
 *           from. Not null/empty/blank.
 * @throws GenieException For any error//from  w w  w .jav a 2  s.  c  o  m
 */
@DeleteMapping(value = "/{id}/configs")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void removeAllConfigsForApplication(@PathVariable("id") final String id) throws GenieException {
    log.debug("Called with id {}", id);
    this.applicationService.removeAllConfigsForApplication(id);
}

From source file:nu.yona.server.device.rest.DeviceController.java

@RequestMapping(value = "/{deviceId}", method = RequestMethod.DELETE)
@ResponseBody//from w  w w .j a v a 2s. c o  m
@ResponseStatus(HttpStatus.NO_CONTENT)
public void deleteDevice(@RequestHeader(value = PASSWORD_HEADER) Optional<String> password,
        @PathVariable UUID userId, @PathVariable UUID deviceId,
        @RequestParam(value = UserController.REQUESTING_DEVICE_ID_PARAM, required = false) String requestingDeviceIdStr) {
    try (CryptoSession cryptoSession = CryptoSession.start(password,
            () -> userService.doPreparationsAndCheckCanAccessPrivateData(userId))) {
        deviceService.deleteDevice(userId, deviceId);
    }
}

From source file:com.orange.ngsi2.server.Ngsi2BaseController.java

/**
 * Endpoint put /v2/entities/{entityId}/*from   ww w . ja  va 2 s  .  c  o  m*/
 * @param entityId the entity ID
 * @param attributes the new set of attributes
 * @param type an optional type of entity
 * @param options keyValues is not supported.
 * @return http status 204 (no content)
 * @throws Exception
 */
@RequestMapping(method = RequestMethod.PUT, value = {
        "/entities/{entityId}" }, consumes = MediaType.APPLICATION_JSON_VALUE)
final public ResponseEntity replaceAllEntityAttributesEndpoint(@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());
    }
    replaceAllEntityAttributes(entityId, type.orElse(null), attributes);
    return new ResponseEntity(HttpStatus.NO_CONTENT);
}

From source file:com.netflix.genie.web.controllers.ClusterRestController.java

/**
 * Delete the all configuration files from a given cluster.
 *
 * @param id The id of the cluster to delete the configuration files from.
 *           Not null/empty/blank.//from w  ww  .ja  v a  2  s. c o m
 * @throws GenieException For any error
 */
@DeleteMapping(value = "/{id}/configs")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void removeAllConfigsForCluster(@PathVariable("id") final String id) throws GenieException {
    log.debug("Called with id {}", id);
    this.clusterService.removeAllConfigsForCluster(id);
}

From source file:com.netflix.genie.web.controllers.CommandRestController.java

/**
 * Delete the all configuration files from a given command.
 *
 * @param id The id of the command to delete the configuration files from.
 *           Not null/empty/blank.//w  w  w  .j  a va 2  s . co  m
 * @throws GenieException For any error
 */
@DeleteMapping(value = "/{id}/configs")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void removeAllConfigsForCommand(@PathVariable("id") final String id) throws GenieException {
    log.debug("Called with id {}", id);
    this.commandService.removeAllConfigsForCommand(id);
}

From source file:org.springsource.restbucks.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.
 * /*w  ww . j  a  v a2s .  c o m*/
 * @param response
 * @return
 * @throws Exception
 */
private MockHttpServletResponse pollUntilOrderHasReceiptLink(MockHttpServletResponse response)
        throws Exception {

    // Grab
    String content = response.getContentAsString();
    Link orderLink = links.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 = links.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;
}