use of com.webcohesion.enunciate.modules.jaxrs.api.impl.PathBasedResourceGroupImpl in project enunciate by stoicflame.
the class EnunciateJaxrsContext method getResourceGroupsByPath.
public List<ResourceGroup> getResourceGroupsByPath(ApiRegistrationContext registrationContext) {
Map<String, PathBasedResourceGroupImpl> resourcesByPath = new HashMap<String, PathBasedResourceGroupImpl>();
FacetFilter facetFilter = registrationContext.getFacetFilter();
for (RootResource rootResource : rootResources) {
if (!facetFilter.accept(rootResource)) {
continue;
}
for (ResourceMethod method : rootResource.getResourceMethods(true)) {
if (facetFilter.accept(method)) {
com.webcohesion.enunciate.metadata.rs.ServiceContextRoot context = method.getAnnotation(com.webcohesion.enunciate.metadata.rs.ServiceContextRoot.class);
com.webcohesion.enunciate.modules.jaxrs.model.Resource resource = method.getParent();
while (context == null && resource != null) {
context = resource.getAnnotation(com.webcohesion.enunciate.metadata.rs.ServiceContextRoot.class);
resource = resource.getParent();
}
String path = method.getFullpath();
PathBasedResourceGroupImpl resourceGroup = resourcesByPath.get(path);
if (resourceGroup == null) {
String contextPath = context != null ? JaxrsModule.sanitizeContextPath(context.value()) : this.relativeContextPath;
resourceGroup = new PathBasedResourceGroupImpl(contextPath, path, new ArrayList<Resource>());
resourcesByPath.put(path, resourceGroup);
}
resourceGroup.getResources().add(new ResourceImpl(method, resourceGroup, registrationContext));
}
}
}
ArrayList<ResourceGroup> resourceGroups = new ArrayList<ResourceGroup>(resourcesByPath.values());
Collections.sort(resourceGroups, new ResourceGroupComparator(this.pathSortStrategy));
return resourceGroups;
}
Aggregations