Example usage for org.springframework.data.rest.webmvc RootResourceInformation getSupportedMethods

List of usage examples for org.springframework.data.rest.webmvc RootResourceInformation getSupportedMethods

Introduction

In this page you can find the example usage for org.springframework.data.rest.webmvc RootResourceInformation getSupportedMethods.

Prototype

public SupportedHttpMethods getSupportedMethods() 

Source Link

Usage

From source file:org.springframework.data.rest.webmvc.alps.RootResourceInformationToAlpsDescriptorConverter.java

public Alps convert(RootResourceInformation resourceInformation) {

    Class<?> type = resourceInformation.getDomainType();
    List<Descriptor> descriptors = new ArrayList<Descriptor>();

    Descriptor representationDescriptor = buildRepresentationDescriptor(type);

    descriptors.add(representationDescriptor);

    SupportedHttpMethods supportedHttpMethods = resourceInformation.getSupportedMethods();

    for (HttpMethod method : supportedHttpMethods.getMethodsFor(ResourceType.COLLECTION)) {

        if (!UNDOCUMENTED_METHODS.contains(method)) {
            descriptors.add(buildCollectionResourceDescriptor(type, resourceInformation,
                    representationDescriptor, method));
        }//from ww  w  . j a  v  a2s .  co m
    }

    for (HttpMethod method : supportedHttpMethods.getMethodsFor(ResourceType.ITEM)) {

        if (!UNDOCUMENTED_METHODS.contains(method)) {
            descriptors.add(buildItemResourceDescriptor(resourceInformation, representationDescriptor, method));
        }
    }

    descriptors.addAll(buildSearchResourceDescriptors(resourceInformation.getPersistentEntity()));

    return Alps.alps().descriptors(descriptors).build();
}