Example usage for org.springframework.http RequestEntity delete

List of usage examples for org.springframework.http RequestEntity delete

Introduction

In this page you can find the example usage for org.springframework.http RequestEntity delete.

Prototype

public static HeadersBuilder<?> delete(URI url) 

Source Link

Document

Create an HTTP DELETE builder with the given url.

Usage

From source file:at.ac.tuwien.dsg.cloud.utilities.gateway.registry.UserController.java

@RequestMapping(method = RequestMethod.DELETE, value = REST_USER_PATH_VARIABLE)
public ResponseEntity<String> remove(@PathVariable String user) {
    boolean res = this.kongUsers.getUsers().removeIf((KongUser u) -> {
        if (u.getUserName().equals(user)) {
            RequestEntity<Void> request = RequestEntity
                    .delete(URI.create(this.kongUris.getKongConsumerIdUri(u.getId()))).accept(MediaType.ALL)
                    .build();//from   w  w w. ja  v  a 2s .  com

            ResponseEntity<String> resp = restUtilities.simpleRestExchange(request, String.class);

            if (resp == null || resp.getStatusCode() != HttpStatus.NO_CONTENT) {
                return false;
            }

            return true;
        }
        return false;
    });

    if (!res) {
        return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
    }

    return new ResponseEntity<>(HttpStatus.OK);
}