incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r591001 - in /incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/resource: Resource.java ResourceManager.java ResourceNotFoundException.java ResourceResolver.java
Date Thu, 01 Nov 2007 13:35:01 GMT
Author: fmeschbe
Date: Thu Nov  1 06:35:00 2007
New Revision: 591001

URL: http://svn.apache.org/viewvc?rev=591001&view=rev
Log:
SLING-28 Adapt ResourceResolver/Manager as discussed on the list
(http://www.mail-archive.com/sling-dev@incubator.apache.org/msg00755.html)

Removed:
    incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/resource/ResourceNotFoundException.java
Modified:
    incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/resource/Resource.java
    incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/resource/ResourceManager.java
    incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java

Modified: incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/resource/Resource.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/resource/Resource.java?rev=591001&r1=591000&r2=591001&view=diff
==============================================================================
--- incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/resource/Resource.java
(original)
+++ incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/resource/Resource.java
Thu Nov  1 06:35:00 2007
@@ -20,6 +20,17 @@
 public interface Resource {
 
     /**
+     * The special resource type for resource instances representing nonexisting
+     * resources (value is "sling:nonexisting"). This resource type is used
+     * by {@link ResourceResolver} instances to mark a resource which could not
+     * actually be resolved.
+     *
+     * @see #getResourceType()
+     * @see ResourceResolver#resolve(javax.servlet.ServletRequest)
+     */
+    static final String RESOURCE_TYPE_NON_EXISTING = "sling:nonexisting";
+
+    /**
      * This resource's URI - for now that could be a JCR path, but having an URI
      * makes it possible to use other data sources.
      */
@@ -28,8 +39,13 @@
     /**
      * The resource type is meant to point to rendering/processing scripts,
      * editing dialogs, etc. It is usually a path in the repository, where
-     * scripts and other tools definitions are found, but the 
-     * {@link ResourceResolver} is free to set this to any suitable value.
+     * scripts and other tools definitions are found, but the
+     * {@link ResourceResolver} is free to set this to any suitable value such
+     * as the primary node type of the JCR node from which the resource is
+     * created.
+     * <p>
+     * If the resource instance represents a resource which is not actually
+     * existing, this method returns the {@link #RESOURCE_TYPE_NON_EXISTING}.
      */
     String getResourceType();
 

Modified: incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/resource/ResourceManager.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/resource/ResourceManager.java?rev=591001&r1=591000&r2=591001&view=diff
==============================================================================
--- incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/resource/ResourceManager.java
(original)
+++ incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/resource/ResourceManager.java
Thu Nov  1 06:35:00 2007
@@ -68,20 +68,18 @@
      * @param type The required concrete type of the loaded data of the
      *            <code>Resource</code> object.
      * @return The <code>Resource</code> object loaded from the path with the
-     *         data field set to an object of the given type.
+     *         data field set to an object of the given type. <code>null</code>
+     *         is returned if no resource can be resolved at the resolved path
+     *         or if the path is not an absolute path or if the data cannot be
+     *         mapped to an object of the requested <code>type</code>.
      * @throws java.security.AccessControlException if an item exists at the
      *             <code>path</code> but the session of this resource manager
      *             has no read access to the item.
-     * @throws ResourceNotFoundException If no resource can be resolved at the
-     *             resolved path or if the path is not an absolute path or if
-     *             the data cannot be mapped to an object of the requested
-     *             <code>type</code>.
      * @throws SlingException If an error occurrs trying to load the resource
      *             object from the path or if <code>base</code> is
      *             <code>null</code> and <code>path</code> is relative.
      */
-    Resource getResource(String path, Class<?> type)
-            throws ResourceNotFoundException, SlingException;
+    Resource getResource(String path, Class<?> type) throws SlingException;
 
     /**
      * Deletes the persistent data at the location pointed to by the

Modified: incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java?rev=591001&r1=591000&r2=591001&view=diff
==============================================================================
--- incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java
(original)
+++ incubator/sling/trunk/sling-api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java
Thu Nov  1 06:35:00 2007
@@ -36,16 +36,21 @@
 
     /**
      * Resolves the resource from the given <code>ServletRequest</code>.
+     * <p>
+     * If the request cannot be resolved to an existing resource, a
+     * {@link Resource} object is returned whose
+     * {@link Resource#getResourceType() resource type} is set to
+     * {@link Resource#RESOURCE_TYPE_NON_EXISTING} and the
+     * {@link Resource#getURI() resource URI} set to the request URI. Both the
+     * {@link Resource#getRawData() raw data} and
+     * {@link Resource#getObject() object} fields will be <code>null</code>.
      *
      * @param request The servlet request object used to resolve the resource
      *            for.
      * @return The {@link Resource} for the request.
-     * @throws ResourceNotFoundException May be thrown if no resource can be
-     *             resolved for for the request.
      * @throws SlingException May be thrown if another error occurrs.
      */
-    Resource resolve(ServletRequest request) throws SlingException,
-            ResourceNotFoundException;
+    Resource resolve(ServletRequest request) throws SlingException;
 
     /**
      * Returns a {@link Resource} object for data located at the given path.
@@ -62,18 +67,16 @@
      *            which are resolved by this method. If the path is relative,
      *            that is the first character is not a slash, a
      *            <code>ResourceNotFoundException</code> is thrown.
-     * @return The <code>Resource</code> object loaded from the path.
+     * @return The <code>Resource</code> object loaded from the path or
+     *         <code>null</code> if the path does not resolve to a resource.
      * @throws java.security.AccessControlException if an item exists at the
      *             <code>path</code> but the session of this resource manager
      *             has no read access to the item.
-     * @throws ResourceNotFoundException If no resource can be resolved at the
-     *             resolved path or if the path is not an absolute path.
      * @throws SlingException If an error occurrs trying to load the resource
      *             object from the path or if <code>base</code> is
      *             <code>null</code> and <code>path</code> is relative.
      */
-    Resource getResource(String path) throws ResourceNotFoundException,
-            SlingException;
+    Resource getResource(String path) throws SlingException;
 
     /**
      * Returns a {@link Resource} object for data located at the given path.
@@ -95,7 +98,8 @@
      *            specifiers like <code>.</code> (current location) and
      *            <code>..</code> (parent location), which are resolved by
      *            this method.
-     * @return The <code>Resource</code> object loaded from the path.
+     * @return The <code>Resource</code> object loaded from the path or
+     *         <code>null</code> if the path does not resolve to a resource.
      * @throws java.security.AccessControlException if an item exists at the
      *             <code>path</code> but the session of this resource manager
      *             has no read access to the item.
@@ -105,22 +109,21 @@
      *             object from the path or if <code>base</code> is
      *             <code>null</code> and <code>path</code> is relative.
      */
-    Resource getResource(Resource base, String path)
-            throws ResourceNotFoundException, SlingException;
+    Resource getResource(Resource base, String path) throws SlingException;
 
     /**
-     * Returns an <code>Iterator</code> of {@link Resource} objects loaded from
-     * the children of the given <code>Resource</code>.
+     * Returns an <code>Iterator</code> of {@link Resource} objects loaded
+     * from the children of the given <code>Resource</code>.
      * <p>
      * This specification does not define what the term "child" means. This is
      * left to the implementation to define. For example an implementation
      * reading content from a Java Content Repository, the children could be the
-     * {@link Resource} objects loaded from child items of the
-     * <code>Item</code> of the given <code>Resource</code>.
+     * {@link Resource} objects loaded from child items of the <code>Item</code>
+     * of the given <code>Resource</code>.
      *
-     * @param parent The {@link Resource Resource} whose children are
-     *            requested. If <code>null</code> the children of this
-     *            request's Resource are returned.
+     * @param parent The {@link Resource Resource} whose children are requested.
+     *            If <code>null</code> the children of this request's Resource
+     *            are returned.
      * @return An <code>Iterator</code> of {@link Resource} objects.
      * @throws NullPointerException If <code>parent</code> is
      *             <code>null</code>.



Mime
View raw message