You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by re...@apache.org on 2010/02/02 11:25:54 UTC
svn commit: r905565 - in /incubator/clerezza/issues/CLEREZZA-94: ./
org.apache.clerezza.triaxrs/
org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResourceExecutorImpl.java
Author: reto
Date: Tue Feb 2 10:25:53 2010
New Revision: 905565
URL: http://svn.apache.org/viewvc?rev=905565&view=rev
Log:
CLEREZZA-94: applied pacth agron
Added:
incubator/clerezza/issues/CLEREZZA-94/
incubator/clerezza/issues/CLEREZZA-94/org.apache.clerezza.triaxrs/
- copied from r905561, incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.triaxrs/
Modified:
incubator/clerezza/issues/CLEREZZA-94/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResourceExecutorImpl.java
Modified: incubator/clerezza/issues/CLEREZZA-94/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResourceExecutorImpl.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-94/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResourceExecutorImpl.java?rev=905565&r1=905561&r2=905565&view=diff
==============================================================================
--- incubator/clerezza/issues/CLEREZZA-94/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResourceExecutorImpl.java (original)
+++ incubator/clerezza/issues/CLEREZZA-94/org.apache.clerezza.triaxrs/org.apache.clerezza.triaxrs/src/main/java/org/apache/clerezza/triaxrs/RootResourceExecutorImpl.java Tue Feb 2 10:25:53 2010
@@ -239,46 +239,60 @@
for (Method method : result) {
method2PathParams.put(method, inheritedPathParams);
}
+
+ if(result.size() == 0){
+ return getSubResourceMethods(request, instance, remainingPath,
+ method2PathParams, inheritedPathParams);
+ } else {
+ return new MethodsAndInstance(result, instance);
+ }
+
} else {
- SortedSet<MethodDescriptor> methodDescriptors = getSubThingMethodDescriptors(instance
- .getClass());
- result = new HashSet<Method>();
- URITemplate uriTemplateOfFirstMatchingRM = null;
- Map<String, String> subPathParam = null;
- for (MethodDescriptor methodDescriptor : methodDescriptors) {
- final URITemplate currentUriTemplate = methodDescriptor
- .getUriTemplate();
- if (uriTemplateOfFirstMatchingRM != null) {
- if (uriTemplateOfFirstMatchingRM.equals(currentUriTemplate)
- && !methodDescriptor.isSubResourceLocator()) {
- result.add(methodDescriptor.getMethod());
- method2PathParams.put(methodDescriptor.getMethod(),
- subPathParam);
- continue;
- }
- break;
- }
- PathMatching subPathMatching = currentUriTemplate
- .match(remainingPath);
- if (subPathMatching == null) {
- continue;
- }
- subPathParam = new HashMap<String, String>(inheritedPathParams);
- subPathParam.putAll(subPathMatching.getParameters());
- if (methodDescriptor.isSubResourceLocator()) {
- return getCandidateMethods(request, getSubResource(
- instance, methodDescriptor.getMethod(), request,
- subPathMatching), subPathMatching
- .getRemainingURIPath(), method2PathParams,
+ return getSubResourceMethods(request, instance, remainingPath,
+ method2PathParams, inheritedPathParams);
+ }
+ }
+
+ private MethodsAndInstance getSubResourceMethods(WebRequest request,
+ Object instance, String remainingPath,
+ Map<Method, Map<String, String>> method2PathParams,
+ Map<String, String> inheritedPathParams) throws HandlerException,
+ UnsupportedFieldType {
+ SortedSet<MethodDescriptor> methodDescriptors = getSubThingMethodDescriptors(instance.getClass());
+ Set<Method> result;
+ result = new HashSet<Method>();
+ URITemplate uriTemplateOfFirstMatchingRM = null;
+ Map<String, String> subPathParam = null;
+ for (MethodDescriptor methodDescriptor : methodDescriptors) {
+ final URITemplate currentUriTemplate = methodDescriptor.getUriTemplate();
+ if (uriTemplateOfFirstMatchingRM != null) {
+ if (uriTemplateOfFirstMatchingRM.equals(currentUriTemplate)
+ && !methodDescriptor.isSubResourceLocator()) {
+ result.add(methodDescriptor.getMethod());
+ method2PathParams.put(methodDescriptor.getMethod(),
subPathParam);
+ continue;
}
- if (subPathMatching.isSlashOrEmpty()) {
- if (!methodDescriptor.isSubResourceLocator()) {
- Method method = methodDescriptor.getMethod();
- result.add(method);
- uriTemplateOfFirstMatchingRM = currentUriTemplate;
- method2PathParams.put(method, subPathParam);
- }
+ break;
+ }
+ PathMatching subPathMatching = currentUriTemplate.match(remainingPath);
+ if (subPathMatching == null) {
+ continue;
+ }
+ subPathParam = new HashMap<String, String>(inheritedPathParams);
+ subPathParam.putAll(subPathMatching.getParameters());
+ if (methodDescriptor.isSubResourceLocator()) {
+ return getCandidateMethods(request, getSubResource(
+ instance, methodDescriptor.getMethod(), request,
+ subPathMatching), subPathMatching.getRemainingURIPath(), method2PathParams,
+ subPathParam);
+ }
+ if (subPathMatching.isSlashOrEmpty()) {
+ if (!methodDescriptor.isSubResourceLocator()) {
+ Method method = methodDescriptor.getMethod();
+ result.add(method);
+ uriTemplateOfFirstMatchingRM = currentUriTemplate;
+ method2PathParams.put(method, subPathParam);
}
}
}