sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r787987 - in /sling/trunk/bundles/jcr/resource: ./ src/main/java/org/apache/sling/jcr/resource/ src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/ src/main/java/org/apache/sling/jcr/resource/internal/helper/starresource/
Date Wed, 24 Jun 2009 11:52:35 GMT
Author: cziegeler
Date: Wed Jun 24 11:52:35 2009
New Revision: 787987

URL: http://svn.apache.org/viewvc?rev=787987&view=rev
Log:
SLING-1020 : Deprecate getResourceSuperType, resourceTypeToPath from JcrResourceUtil and improve
resource super handling.

Modified:
    sling/trunk/bundles/jcr/resource/pom.xml
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrResourceUtil.java
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrItemResource.java
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResource.java
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/starresource/StarResource.java

Modified: sling/trunk/bundles/jcr/resource/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/pom.xml?rev=787987&r1=787986&r2=787987&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/pom.xml (original)
+++ sling/trunk/bundles/jcr/resource/pom.xml Wed Jun 24 11:52:35 2009
@@ -112,7 +112,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.api</artifactId>
-            <version>2.0.4-incubator</version>
+            <version>2.0.5-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>

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=787987&r1=787986&r2=787987&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
Wed Jun 24 11:52:35 2009
@@ -35,6 +35,7 @@
 
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceUtil;
 import org.apache.sling.jcr.resource.internal.helper.LazyInputStream;
 
 /**
@@ -166,7 +167,9 @@
      *
      * @param type The resource type to be converted into a path
      * @return The resource type as a path.
+     * @deprecated Use {@link ResourceUtil#resourceTypeToPath(String)}
      */
+    @Deprecated
     public static String resourceTypeToPath(String type) {
         return type.replaceAll("\\:", "/");
     }
@@ -191,20 +194,12 @@
      *         resource
      *         {@link JcrResourceConstants#SLING_RESOURCE_SUPER_TYPE_PROPERTY}
      *         adapting to a string.
+     * @deprecated Use {@link ResourceUtil#getResourceSuperType(ResourceResolver, String)}
      */
+    @Deprecated
     public static String getResourceSuperType(
             ResourceResolver resourceResolver, String resourceType) {
-        // normalize resource type to a path string
-        String rtPath = resourceTypeToPath(resourceType);
-
-        // create the path to the resource containing the super type
-        rtPath += "/" + JcrResourceConstants.SLING_RESOURCE_SUPER_TYPE_PROPERTY;
-
-        // get a resource for the resource supert type
-        Resource rtResource = resourceResolver.getResource(rtPath);
-
-        // get the resource super type from the resource
-        return (rtResource != null) ? rtResource.adaptTo(String.class) : null;
+        return ResourceUtil.getResourceSuperType(resourceResolver, resourceType);
     }
 
     /**
@@ -223,7 +218,10 @@
      *            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(Resource)}
      */
+    @Deprecated
     public static String getResourceSuperType(Resource resource) {
         ResourceResolver resolver = resource.getResourceResolver();
 

Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrItemResource.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrItemResource.java?rev=787987&r1=787986&r2=787987&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrItemResource.java
(original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrItemResource.java
Wed Jun 24 11:52:35 2009
@@ -18,8 +18,6 @@
  */
 package org.apache.sling.jcr.resource.internal.helper.jcr;
 
-import static org.apache.sling.jcr.resource.JcrResourceConstants.SLING_RESOURCE_TYPE_PROPERTY;
-
 import java.util.Iterator;
 
 import javax.jcr.Node;
@@ -29,13 +27,14 @@
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceMetadata;
 import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceUtil;
+import org.apache.sling.jcr.resource.JcrResourceConstants;
 import org.apache.sling.jcr.resource.JcrResourceTypeProvider;
-import org.apache.sling.jcr.resource.JcrResourceUtil;
 
 abstract class JcrItemResource extends SlingAdaptable implements Resource {
 
     /** marker value for the resourceSupertType before trying to evaluate */
-    private static final String UNSET_RESOURCE_SUPER_TYPE = "<unset>";
+    protected static final String UNSET_RESOURCE_SUPER_TYPE = "<unset>";
 
     private final ResourceResolver resourceResolver;
 
@@ -43,7 +42,7 @@
 
     private final ResourceMetadata metadata;
 
-    private String resourceSuperType;
+    protected String resourceSuperType;
 
     protected final JcrResourceTypeProvider[] resourceTypeProviders;
 
@@ -71,7 +70,7 @@
 
     public String getResourceSuperType() {
         if (resourceSuperType == UNSET_RESOURCE_SUPER_TYPE) {
-            resourceSuperType = JcrResourceUtil.getResourceSuperType(this);
+            resourceSuperType = ResourceUtil.getResourceSuperType(this);
         }
         return resourceSuperType;
     }
@@ -89,8 +88,8 @@
             throws RepositoryException {
         String result = null;
 
-        if (node.hasProperty(SLING_RESOURCE_TYPE_PROPERTY)) {
-            result = node.getProperty(SLING_RESOURCE_TYPE_PROPERTY).getValue().getString();
+        if (node.hasProperty(JcrResourceConstants.SLING_RESOURCE_TYPE_PROPERTY)) {
+            result = node.getProperty(JcrResourceConstants.SLING_RESOURCE_TYPE_PROPERTY).getValue().getString();
         }
 
         if (result == null && this.resourceTypeProviders != null) {

Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResource.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResource.java?rev=787987&r1=787986&r2=787987&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResource.java
(original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResource.java
Wed Jun 24 11:52:35 2009
@@ -45,6 +45,7 @@
 import org.apache.sling.api.resource.ValueMap;
 import org.apache.sling.jcr.resource.JcrModifiablePropertyMap;
 import org.apache.sling.jcr.resource.JcrPropertyMap;
+import org.apache.sling.jcr.resource.JcrResourceConstants;
 import org.apache.sling.jcr.resource.JcrResourceTypeProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -74,6 +75,22 @@
         return resourceType;
     }
 
+    public String getResourceSuperType() {
+        if ( resourceSuperType == UNSET_RESOURCE_SUPER_TYPE ) {
+            try {
+                if (node.hasProperty(JcrResourceConstants.SLING_RESOURCE_SUPER_TYPE_PROPERTY))
{
+                    resourceSuperType = node.getProperty(JcrResourceConstants.SLING_RESOURCE_SUPER_TYPE_PROPERTY).getValue().getString();
+                }
+            } catch (RepositoryException re) {
+                // we ignore this
+            }
+            if ( resourceSuperType == UNSET_RESOURCE_SUPER_TYPE ) {
+                return super.getResourceSuperType();
+            }
+        }
+        return resourceSuperType;
+    }
+
     @SuppressWarnings("unchecked")
     public <Type> Type adaptTo(Class<Type> type) {
         if (type == Node.class || type == Item.class) {

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=787987&r1=787986&r2=787987&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
Wed Jun 24 11:52:35 2009
@@ -25,9 +25,9 @@
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceMetadata;
 import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceUtil;
 import org.apache.sling.api.resource.SyntheticResource;
 import org.apache.sling.jcr.resource.JcrResourceTypeProvider;
-import org.apache.sling.jcr.resource.JcrResourceUtil;
 
 /** Used to provide the equivalent of an empty Node for GET requests
  *  to *.something (SLING-344)
@@ -102,12 +102,12 @@
     }
 
     /**
-     * Calls {@link JcrResourceUtil#getResourceSuperType(Resource)} method
+     * Calls {@link ResourceUtil#getResourceSuperType(Resource)} method
      * to dynamically resolve the resource super type of this star resource.
      */
     public String getResourceSuperType() {
         if (resourceSuperType == UNSET_RESOURCE_SUPER_TYPE) {
-            resourceSuperType = JcrResourceUtil.getResourceSuperType(this);
+            resourceSuperType = ResourceUtil.getResourceSuperType(this);
         }
         return resourceSuperType;
     }



Mime
View raw message