List of usage examples for org.springframework.data.rest.core.mapping ResourceType COLLECTION
ResourceType COLLECTION
To view the source code for org.springframework.data.rest.core.mapping ResourceType COLLECTION.
Click Source Link
From source file:springfox.documentation.spring.data.rest.EntitySearchRequestTemplate.java
Collection<? extends RequestHandler> operations() { List<RequestHandler> requestHandlers = newArrayList(); boolean collectionHandlerAdded = false; for (ResourceMetadata resource : mappings) { for (MethodResourceMapping searchResource : resource.getSearchResourceMappings()) { EntitySearchRequestHandler handler = new EntitySearchRequestHandler(resolver, requestMapping, new HandlerMethod(searchResource.getMethod().getClass(), searchResource.getMethod()), searchResource, resource); if (handler.resourceType() == ResourceType.ITEM || !collectionHandlerAdded) { requestHandlers.add(handler); if (!collectionHandlerAdded) { collectionHandlerAdded = (handler.resourceType() == ResourceType.COLLECTION); }/* w w w. j a v a 2 s .c om*/ } } } return requestHandlers; }
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 w ww. j av a 2 s .c o 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(); }
From source file:springfox.documentation.spring.data.rest.EntityRequestHandler.java
@Override public ResolvedType getReturnType() { if (resourceType == ResourceType.COLLECTION) { if (COLLECTION_COMPACT_MEDIA_TYPES .containsAll(requestMapping.getProducesCondition().getProducibleMediaTypes())) { return resolver.resolve(Resources.class, Link.class); } else if (requestMapping.getMethodsCondition().getMethods().contains(RequestMethod.HEAD) || requestMapping.getMethodsCondition().getMethods().contains(RequestMethod.OPTIONS)) { return resolver.resolve(Void.TYPE); } else if (requestMapping.getMethodsCondition().getMethods().contains(RequestMethod.POST)) { return resolver.resolve(Resource.class, domainType); }//ww w . j a va2 s . c o m return resolver.resolve(Resources.class, domainType); } else { if (requestMapping.getMethodsCondition().getMethods().contains(RequestMethod.GET) || requestMapping.getMethodsCondition().getMethods().contains(RequestMethod.PUT) || requestMapping.getMethodsCondition().getMethods().contains(RequestMethod.PATCH)) { return resolver.resolve(Resource.class, domainType); } } return resolver.resolve(Void.TYPE); }
From source file:springfox.documentation.spring.data.rest.EntityRequestHandler.java
private ResourceType resourceType() { if (requestMapping.getPatternsCondition().getPatterns().contains("/{search}")) { return ResourceType.ITEM; } else {/* w ww . j av a2 s. c o m*/ return ResourceType.COLLECTION; } }
From source file:springfox.documentation.spring.data.rest.EntitySearchRequestHandler.java
ResourceType resourceType() { Set<String> patterns = requestMapping.getPatternsCondition().getPatterns(); if (any(patterns, endsWith("/{search}"))) { return ResourceType.ITEM; } else {//from w w w . j av a 2 s . c o m return ResourceType.COLLECTION; } }