Author: cziegeler
Date: Mon Jul 20 14:45:37 2009
New Revision: 795865
URL: http://svn.apache.org/viewvc?rev=795865&view=rev
Log:
Pass resource type through constructor.
Modified:
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/starresource/StarResource.java
Modified:
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/starresource/StarResource.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/starresource/StarResource.java?rev=795865&r1=795864&r2=795865&view=diff
==============================================================================
---
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/starresource/StarResource.java
(original)
+++
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/starresource/StarResource.java
Mon Jul 20 14:45:37 2009
@@ -64,27 +64,7 @@
}
public StarResource(ResourceResolver resourceResolver, String path,
JcrResourceTypeProvider[] jcrProviders) throws SlingException {
- super(resourceResolver, getResourceMetadata(path), null);
-
- // The only way we can set a meaningful resource type is via the drtp
- final Node n = new FakeNode(getPath());
- String resourceType = null;
- if (jcrProviders != null) {
- try {
- int index = 0;
- while ( resourceType == null && index < jcrProviders.length ) {
- resourceType =
jcrProviders[index].getResourceTypeForNode(n);
- index++;
- }
- } catch(RepositoryException re) {
- throw new
SyntheticStarResourceException("getResourceTypeForNode failed", re);
- }
- }
- if(resourceType == null) {
- resourceType = DEFAULT_RESOURCE_TYPE;
- }
- setResourceType(resourceType);
-
+ super(resourceResolver, getResourceMetadata(path),
getResourceType(jcrProviders, path));
resourceSuperType = UNSET_RESOURCE_SUPER_TYPE;
}
@@ -127,4 +107,27 @@
}
return result;
}
+
+ /** Get the resource type for the given path */
+ static String getResourceType(final JcrResourceTypeProvider[] jcrProviders,
+ final String path) {
+ // The only way we can set a meaningful resource type is via the drtp
+ final Node n = new
FakeNode(getResourceMetadata(path).getResolutionPath());
+ String resourceType = null;
+ if (jcrProviders != null) {
+ try {
+ int index = 0;
+ while ( resourceType == null && index < jcrProviders.length ) {
+ resourceType =
jcrProviders[index].getResourceTypeForNode(n);
+ index++;
+ }
+ } catch (RepositoryException re) {
+ throw new
SyntheticStarResourceException("getResourceTypeForNode failed", re);
+ }
+ }
+ if (resourceType == null) {
+ resourceType = DEFAULT_RESOURCE_TYPE;
+ }
+ return resourceType;
+ }
}
\ No newline at end of file