Search in sources :

Example 1 with PathBasedResourceGroupImpl

use of com.webcohesion.enunciate.modules.spring_web.api.impl.PathBasedResourceGroupImpl in project enunciate by stoicflame.

the class EnunciateSpringWebContext method getResourceGroupsByPath.

public List<ResourceGroup> getResourceGroupsByPath(ApiRegistrationContext registrationContext) {
    Map<String, PathBasedResourceGroupImpl> resourcesByPath = new HashMap<String, PathBasedResourceGroupImpl>();
    FacetFilter facetFilter = registrationContext.getFacetFilter();
    for (SpringController springController : controllers) {
        if (!facetFilter.accept(springController)) {
            continue;
        }
        for (RequestMapping method : springController.getRequestMappings()) {
            if (facetFilter.accept(method)) {
                String path = method.getFullpath();
                PathBasedResourceGroupImpl resourceGroup = resourcesByPath.get(path);
                if (resourceGroup == null) {
                    resourceGroup = new PathBasedResourceGroupImpl(relativeContextPath, 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;
}
Also used : ResourceImpl(com.webcohesion.enunciate.modules.spring_web.api.impl.ResourceImpl) FacetFilter(com.webcohesion.enunciate.facets.FacetFilter) PathBasedResourceGroupImpl(com.webcohesion.enunciate.modules.spring_web.api.impl.PathBasedResourceGroupImpl) SpringController(com.webcohesion.enunciate.modules.spring_web.model.SpringController) ResourceGroup(com.webcohesion.enunciate.api.resources.ResourceGroup) RequestMapping(com.webcohesion.enunciate.modules.spring_web.model.RequestMapping)

Aggregations

ResourceGroup (com.webcohesion.enunciate.api.resources.ResourceGroup)1 FacetFilter (com.webcohesion.enunciate.facets.FacetFilter)1 PathBasedResourceGroupImpl (com.webcohesion.enunciate.modules.spring_web.api.impl.PathBasedResourceGroupImpl)1 ResourceImpl (com.webcohesion.enunciate.modules.spring_web.api.impl.ResourceImpl)1 RequestMapping (com.webcohesion.enunciate.modules.spring_web.model.RequestMapping)1 SpringController (com.webcohesion.enunciate.modules.spring_web.model.SpringController)1