private static Set<MediaType> getCollectionProduces(ClassMetadata metadata) { Set<MediaType> produces = new HashSet<MediaType>(); for (MethodMetadata method : metadata.getResourceMethods()) { produces.addAll(method.getProduces()); } for (MethodMetadata method : metadata.getSubResourceMethods()) { produces.addAll(method.getProduces()); } return produces; }
private static Set<MediaType> getCollectionConsumes(ClassMetadata metadata) { Set<MediaType> consumes = new HashSet<MediaType>(); for (MethodMetadata method : metadata.getResourceMethods()) { if (method.getHttpMethod().equals(HttpMethod.POST)) { consumes.addAll(method.getConsumes()); } } for (MethodMetadata method : metadata.getSubResourceMethods()) { if (method.getHttpMethod().equals(HttpMethod.POST)) { consumes.addAll(method.getConsumes()); } } return consumes; }
private Set<SyndLink> build(Set<SyndLink> set, UriBuilder selfUriBuilder, ResourceRecord record) { List<MethodMetadata> methods = null; if (subResourcePath != null && subResourcePath.length() > 0) { // 1) find all the sub-resources that match the sub-resource path List<SubResourceInstance> subResources = record.getMatchingSubResourceMethods(subResourcePath); methods = new LinkedList<MethodMetadata>(); for (SubResourceInstance sub : subResources) { methods.add(sub.getMetadata()); } // 2) add the sub-resource path to the uri builder selfUriBuilder.path(subResourcePath); } else { methods = record.getMetadata().getResourceMethods(); } return build(set, selfUriBuilder, methods); }
/** * Attempts to find a resource method to invoke in the specified resource * * @param resource the resource to find the method in * @param variablesValues a multivalued map of variables values that stores * the variables of the templates that are matched during the * search * @param context the context of the current request * @return */ public MethodRecord findMethod(ResourceInstance resource, RuntimeContext context) throws WebApplicationException { List<MethodMetadata> methods = resource.getRecord().getMetadata().getResourceMethods(); List<MethodMetadataRecord> records = new LinkedList<MethodMetadataRecord>(); for (MethodMetadata metadata : methods) { records.add(new MethodMetadataRecord(metadata)); } // filter the methods according to the spec filterDispatchMethods(resource, records, context); // select the best matching method return selectBestMatchingMethod(records, context); }
logger.trace("Was resource method"); getMetadata().getResourceMethods().add(methodMetadata);
allMethodMetadata.addAll(classMetadata.getResourceMethods()); allMethodMetadata.addAll(classMetadata.getSubResourceMethods());
private boolean providesOpenSearch(ResourceRecord record) { for (MethodMetadata method : record.getMetadata().getResourceMethods()) { if (providesOpenSearch(method)) { return true; } } for (MethodMetadata method : record.getMetadata().getSubResourceMethods()) { if (providesOpenSearch(method)) { return true; } } return false; }
public Set<String> getOptions(ResourceInstance resource) { Set<String> set = new HashSet<String>(); List<MethodMetadata> resourceMethods; if (resource.isExactMatch()) { resourceMethods = resource.getRecord().getMetadata().getResourceMethods(); } else { String uri = UriTemplateProcessor.normalizeUri(resource.getMatcher().getTail(false)); List<SubResourceInstance> matchingMethods = resource.getRecord().getMatchingSubResourceMethods(uri); resourceMethods = new LinkedList<MethodMetadata>(); for (SubResourceInstance subResource : matchingMethods) { resourceMethods.add(subResource.getRecord().getMetadata()); } } for (MethodMetadata method : resourceMethods) { set.add(method.getHttpMethod()); } return set; }
final ClassMetadata resourceMetadata = record.getMetadata(); final String resourcePath = resourceMetadata.getPath(); for (MethodMetadata methodMetadata : resourceMetadata.getResourceMethods()) { ++counter; try {
private Resource buildResource(ResourceRecord record) { Resource newResource = resourcesObjectFactory.createResource(); // Add dispatched URIs UriTemplateProcessor uriTemplate = record.getTemplateProcessor(); newResource.setUri(SLASH + uriTemplate.getTemplate()); // Add Collection/Workspace data newResource.setWorkspace(record.getMetadata().getWorkspaceName()); newResource.setCollection(record.getMetadata().getCollectionTitle()); // Add supported HTTP methods List<MethodMetadata> methodRecords = new LinkedList<MethodMetadata>(); methodRecords.addAll(record.getMetadata().getResourceMethods()); org.apache.wink.common.internal.model.admin.Methods methods = resourcesObjectFactory.createMethods(); addResourceMethods(methodRecords, methods); newResource.setMethods(methods); return newResource; }
List<Param> resourceParams = r.getParam(); List<MethodMetadata> methodMetadata = metadata.getResourceMethods();