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.netflix.genie.web.controllers.ApplicationRestController.java

/**
 * Add new dependency files for a given application.
 *
 * @param id           The id of the application to add the dependency file to. Not
 *                     null/empty/blank.
 * @param dependencies The dependency files to add. Not null.
 * @throws GenieException For any error//  w  w w . j  a  va  2s.co  m
 */
@PostMapping(value = "/{id}/dependencies", consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void addDependenciesForApplication(@PathVariable("id") final String id,
        @RequestBody final Set<String> dependencies) throws GenieException {
    log.debug("Called with id {} and dependencies {}", id, dependencies);
    this.applicationService.addDependenciesForApplication(id, dependencies);
}

From source file:edu.mayo.cts2.framework.webapp.rest.controller.AbstractMessageWrappingController.java

protected <I> Object doDelete(HttpServletResponse response, I identifier, String changeSetUri,
        BaseMaintenanceService<?, ?, I> service) {

    this.deleteHandler.delete(identifier, changeSetUri, service);

    response.setStatus(HttpStatus.NO_CONTENT.value());

    //TODO: Add a ModelAndView return type
    return null;/*w w  w . j a  v a 2s .  c  o  m*/
}

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

/**
 * Endpoint delete /v2/entities/{entityId}
 * @param entityId the entity ID//from   w  w  w .j a  v a  2 s  . co  m
 * @param type an optional type of entity
 * @return http status 204 (no content)
 * @throws Exception
 */
@RequestMapping(method = RequestMethod.DELETE, value = { "/entities/{entityId}" })
final public ResponseEntity removeEntityEndpoint(@PathVariable String entityId,
        @RequestParam Optional<String> type) throws Exception {

    validateSyntax(entityId);
    type.ifPresent(this::validateSyntax);
    removeEntity(entityId);
    return new ResponseEntity(HttpStatus.NO_CONTENT);
}

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

/**
 * Add new dependency files for a given cluster.
 *
 * @param id           The id of the cluster to add the dependency file to. Not
 *                     null/empty/blank.
 * @param dependencies The dependency files to add. Not null.
 * @throws GenieException For any error//from   w  w w .j  a  v  a  2s .  com
 */
@PostMapping(value = "/{id}/dependencies", consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void addDependenciesForCluster(@PathVariable("id") final String id,
        @RequestBody final Set<String> dependencies) throws GenieException {
    log.debug("Called with id {} and dependencies {}", id, dependencies);
    this.clusterService.addDependenciesForCluster(id, dependencies);
}

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

/**
 * Add new dependency files for a given command.
 *
 * @param id           The id of the command to add the dependency file to. Not
 *                     null/empty/blank.
 * @param dependencies The dependency files to add. Not null.
 * @throws GenieException For any error//from w  w  w.j a v a2  s  .c  o  m
 */
@PostMapping(value = "/{id}/dependencies", consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void addDependenciesForCommand(@PathVariable("id") final String id,
        @RequestBody final Set<String> dependencies) throws GenieException {
    log.debug("Called with id {} and dependencies {}", id, dependencies);
    this.commandService.addDependenciesForCommand(id, dependencies);
}

From source file:com.gooddata.dataload.processes.ProcessService.java

/**
 * Run given execution under given process
 *
 * @param execution to run//from  ww  w.  j av a  2 s .c  o m
 * @return result of the execution
 * @throws com.gooddata.dataload.processes.ProcessExecutionException in case process can't be executed
 */
public FutureResult<ProcessExecutionDetail> executeProcess(ProcessExecution execution) {
    notNull(execution, "execution");
    ProcessExecutionTask executionTask;
    try {
        executionTask = restTemplate.postForObject(execution.getExecutionsUri(), execution,
                ProcessExecutionTask.class);
    } catch (GoodDataException | RestClientException e) {
        throw new ProcessExecutionException("Cannot execute process", e);
    }

    if (executionTask == null) {
        throw new ProcessExecutionException("Cannot find started execution.");
    }

    final String detailLink = executionTask.getDetailUri();

    return new PollResult<>(this, new AbstractPollHandler<Void, ProcessExecutionDetail>(
            executionTask.getPollUri(), Void.class, ProcessExecutionDetail.class) {
        @Override
        public boolean isFinished(ClientHttpResponse response) throws IOException {
            return HttpStatus.NO_CONTENT.equals(response.getStatusCode());
        }

        @Override
        public void handlePollResult(Void pollResult) {
            final ProcessExecutionDetail executionDetail = getProcessExecutionDetailByUri(detailLink);
            if (!executionDetail.isSuccess()) {
                throw new ProcessExecutionException("Execution was not successful", executionDetail);
            } else {
                setResult(executionDetail);
            }
        }

        @Override
        public void handlePollException(final GoodDataRestException e) {
            ProcessExecutionDetail detail = null;
            try {
                detail = getProcessExecutionDetailByUri(detailLink);
            } catch (GoodDataException ignored) {
            }
            throw new ProcessExecutionException("Can't execute " + e.getText(), detail, e);
        }

        private ProcessExecutionDetail getProcessExecutionDetailByUri(final String uri) {
            try {
                return restTemplate.getForObject(uri, ProcessExecutionDetail.class);
            } catch (GoodDataException | RestClientException e) {
                throw new ProcessExecutionException("Execution finished, but cannot get its result.", e, uri);
            }
        }

    });
}

From source file:edu.pitt.dbmi.ccd.anno.group.GroupController.java

@RequestMapping(value = GroupLinks.JOIN, method = RequestMethod.POST)
@ResponseStatus(HttpStatus.NO_CONTENT)
@ResponseBody// ww w .  jav a  2  s  .c o m
public void join(@AuthenticationPrincipal UserAccountDetails principal, @PathVariable String name)
        throws NotFoundException {
    final UserAccount requester = principal.getUserAccount();
    final Group group = groupService.findByName(name);
    if (group == null) {
        throw new GroupNotFoundException(name);
    }
    if (Stream.concat(group.getModerators().stream(), group.getMembers().stream()).map(UserAccount::getId)
            .noneMatch(u -> u.equals(requester.getId()))) {
        group.addRequester(requester);
        groupService.save(group);
    }
}

From source file:edu.mayo.cts2.framework.webapp.rest.controller.AbstractMessageWrappingController.java

protected <T extends IsChangeable, R extends IsChangeable, I> Object doUpdate(HttpServletResponse response,
        T resource, String changeSetUri, I identifier, BaseMaintenanceService<T, R, I> service) {

    this.updateHandler.update(resource, changeSetUri, identifier, service);

    response.setStatus(HttpStatus.NO_CONTENT.value());

    //TODO: Add a ModelAndView return type
    return null;/*from w w  w.  j a  va  2  s .c  o m*/
}

From source file:net.slkdev.swagger.confluence.service.impl.XHtmlToConfluenceServiceImplTest.java

@Test
public void testUpdatePageWithPaginationModeIndividual() {
    final SwaggerConfluenceConfig swaggerConfluenceConfig = getTestSwaggerConfluenceConfig();
    swaggerConfluenceConfig.setPaginationMode(PaginationMode.INDIVIDUAL_PAGES);

    final String xhtml = IOUtils.readFull(
            AsciiDocToXHtmlServiceImplTest.class.getResourceAsStream("/swagger-petstore-xhtml-example.html"));

    final ResponseEntity<String> postResponseEntity = new ResponseEntity<>(POST_RESPONSE, HttpStatus.OK);

    final List<String> returnJson = new ArrayList<>();

    when(restTemplate.exchange(any(URI.class), eq(HttpMethod.GET), any(RequestEntity.class), eq(String.class)))
            .thenReturn(responseEntity);

    for (int i = 0; i < 34; i++) {
        if (i > 0) {
            returnJson.add(GET_RESPONSE_FOUND);
        }/*from w  w  w. j a  va 2s.c om*/

        if (CATEGORY_INDEXES.contains(i)) {
            returnJson.add(GET_CHILDREN);
        }
    }

    final String[] returnJsonArray = new String[returnJson.size()];
    returnJson.toArray(returnJsonArray);

    when(responseEntity.getBody()).thenReturn(GET_RESPONSE_FOUND, returnJsonArray);

    when(restTemplate.exchange(any(URI.class), eq(HttpMethod.DELETE), any(RequestEntity.class),
            eq(String.class))).thenReturn(responseEntity);
    when(responseEntity.getStatusCode()).thenReturn(HttpStatus.NO_CONTENT);

    when(restTemplate.exchange(any(URI.class), eq(HttpMethod.PUT), any(RequestEntity.class), eq(String.class)))
            .thenReturn(postResponseEntity);

    final ArgumentCaptor<HttpEntity> httpEntityCaptor = ArgumentCaptor.forClass(HttpEntity.class);

    xHtmlToConfluenceService.postXHtmlToConfluence(swaggerConfluenceConfig, xhtml);

    verify(restTemplate, times(38)).exchange(any(URI.class), eq(HttpMethod.GET), any(RequestEntity.class),
            eq(String.class));
    verify(restTemplate, times(34)).exchange(any(URI.class), eq(HttpMethod.PUT), httpEntityCaptor.capture(),
            eq(String.class));

    final HttpEntity<String> capturedHttpEntity = httpEntityCaptor.getAllValues().get(30);

    final String expectedPostBody = IOUtils.readFull(AsciiDocToXHtmlServiceImplTest.class
            .getResourceAsStream("/swagger-confluence-update-json-body-user-example.json"));

    assertNotNull("Failed to Capture RequestEntity for POST", capturedHttpEntity);
    // We'll do a full check on the last page versus a resource; not doing all of them as it
    // would be a pain to maintain, but this should give us a nod of confidence.
    assertEquals("Unexpected JSON Post Body", expectedPostBody, capturedHttpEntity.getBody());
}