Example usage for org.springframework.http ResponseEntity noContent

List of usage examples for org.springframework.http ResponseEntity noContent

Introduction

In this page you can find the example usage for org.springframework.http ResponseEntity noContent.

Prototype

public static HeadersBuilder<?> noContent() 

Source Link

Document

Create a builder with a HttpStatus#NO_CONTENT NO_CONTENT status.

Usage

From source file:com.fns.grivet.controller.NamedQueryController.java

@PreAuthorize("hasAuthority('write:query')")
@PostMapping("/api/v1/query")
public ResponseEntity<?> createNamedQuery(@RequestBody NamedQuery query) {
    ResponseEntity<?> result = ResponseEntity.unprocessableEntity().build();
    Assert.isTrue(StringUtils.isNotBlank(query.getName()), "Query name must not be null, empty or blank.");
    Assert.notNull(query.getQuery(), "Query string must not be null!");
    Assert.isTrue(isSupportedQuery(query), "Query must start with either CALL or SELECT");
    // check for named parameters; but only if they exist
    if (!query.getParams().isEmpty()) {
        query.getParams().keySet()//from   ww  w .j a v a2 s  . c  o  m
                .forEach(k -> Assert.isTrue(query.getQuery().contains(String.format(":%s", k)),
                        String.format("Query must contain named parameter [%s]", k)));
    }
    namedQueryService.create(query);
    log.info("Named Query \n\n{}\n\n successfully registered!", query);
    UriComponentsBuilder ucb = UriComponentsBuilder.newInstance();
    if (query.getParams().isEmpty()) {
        result = ResponseEntity
                .created(ucb.path("/api/v1/query/{name}").buildAndExpand(query.getName()).toUri()).build();
    } else {
        result = ResponseEntity.noContent().build();
    }
    return result;
}

From source file:io.ignitr.dispatchr.manager.controller.client.ClientController.java

/**
 * Deletes a specific client.//  ww w .j  av a2  s.c o m
 *
 * @param clientId client identifier
 * @return an HTTP 204 response if the client was deleted or an HTTP 404 if the client does not exist
 */
@RequestMapping(method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public DeferredResult<ResponseEntity<?>> unregister(@PathVariable("clientId") String clientId,
        HttpServletRequest httpRequest) {
    final DeferredResult<ResponseEntity<?>> deferredResult = new DeferredResult<>();

    service.unregister(clientId).lift(new RequestContextStashOperator<>()).last().subscribeOn(Schedulers.io())
            .subscribe(complete -> {
                deferredResult.setResult(ResponseEntity.noContent().build());
            }, error -> {
                deferredResult.setErrorResult(errorHandler.handleError(httpRequest, error));
            });

    return deferredResult;
}

From source file:org.lecture.controller.UserController.java

@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
public ResponseEntity<?> delete(@PathVariable String id) {
    userRepository.delete(id);//  w w w  . j av a 2 s  .  c  om
    nats.publish("authentication-service.delete-user", id);
    return ResponseEntity.noContent().build();
}

From source file:org.lecture.controller.TutorialController.java

/**
 * Deletes one tutorial.//from   w ww.j  a  v  a2s  .  co  m
 * @param id The tutorial id.
 * @return a response.
 */
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
public ResponseEntity<?> delete(@PathVariable String id) {
    tutorialRepository.delete(id);
    return ResponseEntity.noContent().build();
}

From source file:io.pivotal.strepsirrhini.chaosloris.web.ScheduleController.java

@Transactional
@RequestMapping(method = DELETE, value = "/{id}")
public ResponseEntity delete(@PathVariable Long id) {
    this.scheduleRepository.delete(id);
    this.applicationEventPublisher.publishEvent(new ScheduleDeletedEvent(this, id));

    return ResponseEntity.noContent().build();
}

From source file:org.lecture.controller.UserController.java

@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
public ResponseEntity<?> update(@PathVariable String id, @RequestBody User newValues) {
    newValues.setId(id);/*from  w w w . ja va 2 s.c  o m*/
    userRepository.save(newValues);
    return ResponseEntity.noContent().build();
}

From source file:org.lecture.controller.TestCaseController.java

@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
public ResponseEntity<?> delete(@PathVariable String id) {

    testRepository.delete(id);/*from w ww.j a v  a  2 s .c om*/
    return ResponseEntity.noContent().build();
}

From source file:curly.artifact.ArtifactResourceController.java

@RequestMapping(value = "/{id}", method = DELETE)
public Callable<HttpEntity<?>> deleteResource(@PathVariable("id") String id,
        @GitHubAuthentication OctoUser octoUser) {
    log.trace("Performing deletion operations based on user {}", octoUser.getId());
    artifactService.delete(id, octoUser);
    return () -> ResponseEntity.noContent().build();
}

From source file:io.ignitr.dispatchr.manager.controller.topic.TopicController.java

/**
 * Checks whether or not the supplied topic is registered with Dispatchr.
 *
 * @param topicName the name of the topic to check
 * @param httpRequest http request//  ww  w . j av  a2  s  .c o  m
 * @return an HTTP 204 response if the topic is registered; otherwise an HTTP 404 if the topic is not registered
 */
@RequestMapping(method = RequestMethod.GET, value = "/registered", produces = MediaType.APPLICATION_JSON_VALUE)
public DeferredResult<ResponseEntity<?>> isRegistered(@PathVariable("name") String topicName,
        HttpServletRequest httpRequest) {
    final DeferredResult<ResponseEntity<?>> deferredResult = new DeferredResult<>();

    service.isRegistered(topicName).lift(new RequestContextStashOperator<>()).last()
            .subscribeOn(Schedulers.io()).subscribe(isRegistered -> {
                if (isRegistered) {
                    deferredResult.setResult(ResponseEntity.noContent().build());
                } else {
                    deferredResult.setResult(ResponseEntity.notFound().build());
                }
            }, error -> {
                deferredResult.setErrorResult(errorHandler.handleError(httpRequest, error));
            });

    return deferredResult;
}

From source file:io.pivotal.strepsirrhini.chaosloris.web.ChaosController.java

@Transactional
@RequestMapping(method = DELETE, value = "/{id}")
public ResponseEntity delete(@PathVariable Long id) {
    this.chaosRepository.delete(id);
    return ResponseEntity.noContent().build();
}