Author: cziegeler
Date: Fri Jul 10 14:11:10 2009
New Revision: 792958
URL: http://svn.apache.org/viewvc?rev=792958&view=rev
Log:
Add a helper method to find the resource super type for a resource.
Modified:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrResourceUtil.java
Modified:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java?rev=792958&r1=792957&r2=792958&view=diff
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java
(original)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java
Fri Jul 10 14:11:10 2009
@@ -353,4 +353,24 @@
}
return null;
}
+
+ /**
+ * Returns the super type of the given resource.
+ * This method checks first if the resource itself knows its super type
+ * by calling {...@link Resource#getResourceSuperType()}. If that returns
+ * <code>null</code> {...@link #getResourceSuperType(ResourceResolver,
String)}
+ * is invoked with the resource type of the resource.
+ *
+ * @param resource The resource to return the resource super type for.
+ * @return the super type of the <code>resource</code> or
+ * <code>null</code> if no super type could be computed.
+ * @since 2.0.6
+ */
+ public static String findResourceSuperType(final Resource resource) {
+ String resourceSuperType = resource.getResourceSuperType();
+ if ( resourceSuperType == null ) {
+ resourceSuperType =
getResourceSuperType(resource.getResourceResolver(),
resource.getResourceType());
+ }
+ return resourceSuperType;
+ }
}
Modified:
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrResourceUtil.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrResourceUtil.java?rev=792958&r1=792957&r2=792958&view=diff
==============================================================================
---
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrResourceUtil.java
(original)
+++
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrResourceUtil.java
Fri Jul 10 14:11:10 2009
@@ -218,8 +218,7 @@
* requested.
* @return The resource super type or <code>null</code> if the algorithm
* described above does not yield a resource super type.
- * @deprecated Call {...@link Resource#getResourceSuperType()} and if
- * that returns <code>null</code> {...@link
ResourceUtil#getResourceSuperType(ResourceResolver, String)}
+ * @deprecated Call {...@link ResourceUtil#findResourceSuperType(Resource)}
*/
@Deprecated
public static String getResourceSuperType(Resource resource) {