Return-Path: Delivered-To: apmail-incubator-sling-commits-archive@locus.apache.org Received: (qmail 20048 invoked from network); 1 Nov 2007 13:35:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 1 Nov 2007 13:35:48 -0000 Received: (qmail 4954 invoked by uid 500); 1 Nov 2007 13:35:22 -0000 Delivered-To: apmail-incubator-sling-commits-archive@incubator.apache.org Received: (qmail 4930 invoked by uid 500); 1 Nov 2007 13:35:22 -0000 Mailing-List: contact sling-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: sling-dev@incubator.apache.org Delivered-To: mailing list sling-commits@incubator.apache.org Received: (qmail 4921 invoked by uid 99); 1 Nov 2007 13:35:22 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Nov 2007 06:35:22 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Nov 2007 13:35:22 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 1FB561A9838; Thu, 1 Nov 2007 06:35:02 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: sling-commits@incubator.apache.org From: fmeschbe@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071101133502.1FB561A9838@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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. + *

+ * 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 * Resource object. * @return The Resource 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. null + * 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 type. * @throws java.security.AccessControlException if an item exists at the * path 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 - * type. * @throws SlingException If an error occurrs trying to load the resource * object from the path or if base is * null and path 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 ServletRequest. + *

+ * 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 null. * * @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 * ResourceNotFoundException is thrown. - * @return The Resource object loaded from the path. + * @return The Resource object loaded from the path or + * null if the path does not resolve to a resource. * @throws java.security.AccessControlException if an item exists at the * path 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 base is * null and path 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 . (current location) and * .. (parent location), which are resolved by * this method. - * @return The Resource object loaded from the path. + * @return The Resource object loaded from the path or + * null if the path does not resolve to a resource. * @throws java.security.AccessControlException if an item exists at the * path but the session of this resource manager * has no read access to the item. @@ -105,22 +109,21 @@ * object from the path or if base is * null and path is relative. */ - Resource getResource(Resource base, String path) - throws ResourceNotFoundException, SlingException; + Resource getResource(Resource base, String path) throws SlingException; /** - * Returns an Iterator of {@link Resource} objects loaded from - * the children of the given Resource. + * Returns an Iterator of {@link Resource} objects loaded + * from the children of the given Resource. *

* 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 - * Item of the given Resource. + * {@link Resource} objects loaded from child items of the Item + * of the given Resource. * - * @param parent The {@link Resource Resource} whose children are - * requested. If null the children of this - * request's Resource are returned. + * @param parent The {@link Resource Resource} whose children are requested. + * If null the children of this request's Resource + * are returned. * @return An Iterator of {@link Resource} objects. * @throws NullPointerException If parent is * null.