Author: cziegeler
Date: Thu Jun 14 09:18:04 2012
New Revision: 1350143
URL: http://svn.apache.org/viewvc?rev=1350143&view=rev
Log:
SLING-2396 : Add new resource provider interfaces
Added:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/AttributableResourceProvider.java
(with props)
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/DynamicResourceProvider.java
(with props)
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/QueriableResourceProvider.java
(with props)
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceProviderFactory.java
(with props)
Modified:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceProvider.java
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java
Added:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/AttributableResourceProvider.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/AttributableResourceProvider.java?rev=1350143&view=auto
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/AttributableResourceProvider.java
(added)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/AttributableResourceProvider.java
Thu Jun 14 09:18:04 2012
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.api.resource;
+
+import java.util.Collection;
+
+/**
+ * The attributes provider is an extensions of a {@link ResourceProvider}.
+ * It allows to add attributes to the set of available attributes from a
+ * resource resolver.
+ *
+ * This extension is supported for services directly implementing the
+ * {@link ResourceProvider} interface and {@link ResourceProvider}s
+ * returned through a {@link ResourceProviderFactory}.
+ *
+ * @see ResourceResolver#getAttribute(String)
+ * @see ResourceResolver#getAttributeNames()
+ *
+ * @since 2.2
+ */
+public interface AttributableResourceProvider {
+
+ /**
+ * Returns a collection of attribute names whose value can be retrieved
+ * calling the {@link #getAttribute(String)} method.
+ *
+ * @return A collection of attribute names or <code>null</code>
+ * @throws IllegalStateException if this resource provider has already been
+ * closed.
+ */
+ Collection<String> getAttributeNames();
+
+ /**
+ * Returns the value of the given resource provider attribute or
<code>null</code>
+ * if the attribute is not set or not visible (as e.g. security
+ * sensitive attributes).
+ *
+ * @param name
+ * The name of the attribute to access
+ * @return The value of the attribute or <code>null</code> if the attribute
+ * is not set or not accessible.
+ * @throws NullPointerException
+ * if <code>name</code> is <code>null</code>.
+ * @throws IllegalStateException
+ * if this resource provider has already been closed.
+ */
+ Object getAttribute(String name);
+}
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/AttributableResourceProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/AttributableResourceProvider.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/AttributableResourceProvider.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/DynamicResourceProvider.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/DynamicResourceProvider.java?rev=1350143&view=auto
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/DynamicResourceProvider.java
(added)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/DynamicResourceProvider.java
Thu Jun 14 09:18:04 2012
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.api.resource;
+
+/**
+ * A dynamic resource provider is an extension of a resource provider which
+ * is only supported if the resource provider has been created through
+ * a {@link ResourceProviderFactory}.
+ *
+ * A dynamic resource provider supports access to systems where the
+ * connection to the system is dynamic and might go away (due to network
+ * changes, updates etc.).
+ *
+ * The {@link #isLive()} method can be called to check whether the
+ * provider is still active.
+ * The {@link #close()} method should be called to free any resources
+ * held by this resource provider.
+ *
+ * @see ResourceProviderFactory#getResourceProvider(java.util.Map)
+ * @see
ResourceProviderFactory#getAdministrativeResourceProvider(java.util.Map)
+ *
+ * @since 2.2
+ */
+public interface DynamicResourceProvider {
+
+ /**
+ * Returns <code>true</code> if this resource provider has not been closed
+ * yet and can still be used.
+ * <p>
+ * This method will never throw an exception
+ * even after the resource provider has been closed
+ *
+ * @return <code>true</code> if the resource provider has not been closed
+ * yet and is still active.. Once the resource provider has been
closed
+ * or is not active anymore, this method returns
<code>false</code>.
+ */
+ boolean isLive();
+
+ /**
+ * Close the resource provider.
+ * Once the resource provider is not used anymore, it should be closed with
+ * this method.
+ */
+ void close();
+}
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/DynamicResourceProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/DynamicResourceProvider.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/DynamicResourceProvider.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/QueriableResourceProvider.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/QueriableResourceProvider.java?rev=1350143&view=auto
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/QueriableResourceProvider.java
(added)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/QueriableResourceProvider.java
Thu Jun 14 09:18:04 2012
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.api.resource;
+
+import java.util.Iterator;
+import java.util.Map;
+
+
+/**
+ * A queriable resource provider is an extension of a resource provider.
+ *
+ * This extension is supported for services directly implementing the
+ * {@link ResourceProvider} interface and {@link ResourceProvider}s
+ * returned through a {@link ResourceProviderFactory}.
+ *
+ * TODO - what should the resource provider do, if the language is not
supported?
+ *
+ * @since 2.2.0
+ */
+public interface QueriableResourceProvider {
+
+ /**
+ * Searches for resources using the given query formulated in the given
+ * language.
+ * <p>
+ * The semantic meaning of the query and language depend on the actual
+ * implementation and storage used for the resources. For JCR repository
+ * being used as storage, the query and lanuage parameters are used to
+ * create a JCR <code>Query</code> through the <code>QueryManager</code>.
+ * The result returned is then based on the <code>NodeIterator</code>
+ * provided by the query result.
+ *
+ * @param query The query string to use to find the resources.
+ * @param language The language in which the query is formulated.
+ * @return An <code>Iterator</code> of {@link Resource} objects matching
the
+ * query.
+ * @throws QuerySyntaxException If the query is not syntactically correct
+ * according to the query language indicator of if the query
+ * language is not supported.
+ * @throws org.apache.sling.api.SlingException If an error occurrs querying
+ * for the resources.
+ * @throws IllegalStateException if this resource provider has already been
+ * closed.
+ */
+ Iterator<Resource> findResources(ResourceResolver resolver, String query,
String language);
+
+ /**
+ * Queries the storage using the given query formulated in the given
+ * language.
+ * <p>
+ * The semantic meaning of the query and language depend on the actual
+ * implementation and storage used for the resources. For JCR repository
+ * being used as storage, the query and lanuage parameters are used to
+ * create a JCR <code>Query</code> through the <code>QueryManager</code>.
+ * The result returned is then based on the <code>RowIterator</code>
+ * provided by the query result. The map returned for each row is indexed
by
+ * the column name and the column value is the JCR <code>Value</code>
object
+ * converted into the respective Java object, such as <code>Boolean</code>
+ * for a value of property type <em>Boolean</em>.
+ *
+ * @param query The query string to use to find the resources.
+ * @param language The language in which the query is formulated.
+ * @return An <code>Iterator</code> of <code>Map</code> instances providing
+ * access to the query result.
+ * @throws QuerySyntaxException If the query is not syntactically correct
+ * according to the query language indicator of if the query
+ * language is not supported.
+ * @throws org.apache.sling.api.SlingException If an error occurrs querying
+ * for the resources.
+ * @throws IllegalStateException if this resource provider has already been
+ * closed.
+ */
+ Iterator<Map<String, Object>> queryResources(String query, String
language);
+}
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/QueriableResourceProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/QueriableResourceProvider.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/QueriableResourceProvider.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceProvider.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceProvider.java?rev=1350143&r1=1350142&r2=1350143&view=diff
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceProvider.java
(original)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceProvider.java
Thu Jun 14 09:18:04 2012
@@ -29,9 +29,14 @@ import org.apache.sling.api.SlingExcepti
* transparently access resources from different locations such as a JCR
* repository (the default) or OSGi bundles.
* <p>
- * This interface is intended to be implemented by providers of Resource
- * instances on behalf of the {@link ResourceResolver}. It is not intended to
- * be used by client applications directly.
+ * This interface is intended to be implemented by providers of resource
+ * instances on behalf of the {@link ResourceResolver}. It
+ * is not intended to be used by client applications directly. A resource
+ * provider can either directly implement this service interface, e.g.
+ * when no user authentication is provided (like for bundle resources)
+ * or a {@link ResourceProviderFactory} service can be implemented which
+ * upon successful authentication returns a resource provider with the
+ * given user credentials.
*/
public interface ResourceProvider {
@@ -50,7 +55,8 @@ public interface ResourceProvider {
/**
* The resource type be set on resources returned by the
- * {@link #listChildren(Resource)} method to enable traversing the resource
+ * {@link #listChildren(Resource)} method to enable traversing the
+ * resource
* tree down to a deeply nested provided resource which has no concrete
* parent hierarchy (value is"sling:syntheticResourceProviderResource").
*
@@ -63,61 +69,63 @@ public interface ResourceProvider {
* the resource provider cannot find it. The path should have one of the
* {@link #ROOTS} strings as its prefix.
* <p>
- * This method is called to resolve a resource for the given request. The
- * properties of the request, such as request parameters, may be use to
- * parametrize the resource resolution. An example of such parametrization
- * is support for a JSR-311 style resource provider to support the
- * parametrized URL patterns.
+ * This method is called to resolve a resource for the given request.
+ * The properties of the request, such as request
+ * parameters, may be use to parametrize the resource resolution. An
+ * example of such parametrization is support for a JSR-311
+ * style resource provider to support the parametrized URL patterns.
*
- * @param resourceResolver The {@link ResourceResolver} to which the
- * returned {@link Resource} is attached.
+ * @param resourceResolver
+ * The {@link ResourceResolver} to which the returned
+ * {@link Resource} is attached.
* @return <code>null</code> If this provider does not have a resource for
* the path.
- * @throws org.apache.sling.api.SlingException may be thrown in case of
any problem creating the
- * <code>Resource</code> instance.
+ * @throws org.apache.sling.api.SlingException
+ * may be thrown in case of any problem creating the
<code>Resource</code> instance.
+ * @deprecated since 2.3.0 (and JCR Resource 2.1.0), this method will not
be invoked.
*/
- Resource getResource(ResourceResolver resourceResolver,
- HttpServletRequest request, String path);
+ @Deprecated
+ Resource getResource(ResourceResolver resourceResolver, HttpServletRequest
request, String path);
/**
* Returns a resource from this resource provider or <code>null</code> if
- * the resource provider cannot find it. The path should have one of the
- * {@link #ROOTS} strings as its prefix.
+ * the resource provider cannot find it. The path should have one of the
{@link #ROOTS}
+ * strings as its prefix.
*
- * @param resourceResolver The {@link ResourceResolver} to which the
- * returned {@link Resource} is attached.
+ * @param resourceResolver
+ * The {@link ResourceResolver} to which the returned {@link
Resource} is attached.
* @return <code>null</code> If this provider does not have a resource for
* the path.
- * @throws org.apache.sling.api.SlingException may be thrown in case of
any problem creating the
- * <code>Resource</code> instance.
+ * @throws org.apache.sling.api.SlingException
+ * may be thrown in case of any problem creating the
<code>Resource</code> instance.
*/
Resource getResource(ResourceResolver resourceResolver, String path);
/**
- * Returns an <code>Iterator</code> of {@link Resource} objects loaded
- * from the children of the given <code>Resource</code>. The returned
- * {@link Resource} instances are attached to the same
+ * Returns an <code>Iterator</code> of {@link Resource} objects loaded from
+ * the children of the given <code>Resource</code>. The returned {@link
Resource} instances
+ * are attached to the same
* {@link ResourceResolver} as the given <code>parent</code> resource.
* <p>
- * This method may be called for resource providers whose root path list
- * contains a path such that the resource path is a prefix of the list
- * entry. This allows for the enumeration of deeply nested provided
- * resources for which no actual parent hierarchy exists.
+ * This method may be called for resource providers whose root path list
contains a path such
+ * that the resource path is a
+ * prefix of the list entry. This allows for the enumeration of deeply
nested provided resources
+ * for which no actual parent
+ * hierarchy exists.
* <p>
- * The returned iterator may in turn contain resources which do not
actually
- * exist but are required to traverse the resource tree. Such resources
- * SHOULD be {@link SyntheticResource} objects whose resource type MUST be
- * set to {@link #RESOURCE_TYPE_SYNTHETIC}.
+ * The returned iterator may in turn contain resources which do not
actually exist but are required
+ * to traverse the resource
+ * tree. Such resources SHOULD be {@link SyntheticResource} objects whose
resource type MUST be set to
+ * {@link #RESOURCE_TYPE_SYNTHETIC}.
*
- * @param parent The {@link Resource Resource} whose children are
requested.
- * @return An <code>Iterator</code> of {@link Resource} objects or
- * <code>null</code> if the resource provider has no children for
- * the given resource.
- * @throws NullPointerException If <code>parent</code> is
- * <code>null</code>.
- * @throws SlingException If any error occurs acquiring the child resource
- * iterator.
+ * @param parent
+ * The {@link Resource Resource} whose children are requested.
+ * @return An <code>Iterator</code> of {@link Resource} objects or
<code>null</code> if the resource
+ * provider has no children for the given resource.
+ * @throws NullPointerException
+ * If <code>parent</code> is <code>null</code>.
+ * @throws SlingException
+ * If any error occurs acquiring the child resource iterator.
*/
Iterator<Resource> listChildren(Resource parent);
-
}
Added:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceProviderFactory.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceProviderFactory.java?rev=1350143&view=auto
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceProviderFactory.java
(added)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceProviderFactory.java
Thu Jun 14 09:18:04 2012
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.api.resource;
+
+import java.util.Map;
+
+/**
+ * The <code>ResourceProviderFactory</code> defines the service API to get and
+ * create <code>ResourceProviders</code>s.
+ * <p>
+ * If the resource provider is not used anymore and implements the {@link
DynamicResourceProvider}
+ * interface, the close method should be called.
+ *
+ * @since 2.2.0
+ */
+public interface ResourceProviderFactory {
+
+ /**
+ * A required resource provider factory is accessed directly when a new
resource resolver
+ * is created. Only if authentication against all required resource
provider factories
+ * is successful, a resource resolver is created by the resource resolver
factory.
+ * Boolean service property, default vaule is <code>false</true>
+ */
+ String PROPERTY_REQUIRED = "required";
+
+ /**
+ * Returns a new {@link ResourceProvider} instance with further
+ * configuration taken from the given <code>authenticationInfo</code> map.
+ * Generally this map will contain a user name and password to
authenticate.
+ * <p>
+ * If the <code>authenticationInfo</code> map is <code>null</code> the
+ * <code>ResourceProvider</code> returned will generally not be
authenticated and only provide
+ * minimal privileges, if any at all.
+ *
+ * @param authenticationInfo
+ * A map of further credential information which may be used by
+ * the implementation to parametrize how the resource provider
is
+ * created. This may be <code>null</code>.
+ * @return A {@link ResourceProvider} according to the
<code>authenticationInfo</code>.
+ * @throws LoginException
+ * If an error occurrs creating the new
<code>ResourceProvider</code> with the
+ * provided credential data.
+ */
+ ResourceProvider getResourceProvider(Map<String, Object>
authenticationInfo) throws LoginException;
+
+ /**
+ * Returns a new {@link ResourceProvider} instance with administrative
+ * privileges with further configuration taken from the given
<code>authenticationInfo</code>
+ * map.
+ * <p>
+ * Note, that if the <code>authenticationInfo</code> map contains the
+ * {@link ResourceResolverFactory#USER_IMPERSONATION} attribute the
<code>ResourceProvider</code> returned will only
+ * have administrative privileges if the user identified by the property
has administrative
+ * privileges.
+ * <p>
+ * <b><i>NOTE: This method is intended for use by infrastructure bundles
to access the
+ * resource tree and provide general services. This method MUST not be
used to handle client
+ * requests of whatever kinds. To handle client requests a regular
authenticated resource
+ * provider retrieved through {@link #getResourceProvider(Map)} must be
used.</i></b>
+ *
+ * @param authenticationInfo
+ * A map of further credential information which may be used by
+ * the implementation to parametrize how the resource provider
is
+ * created. This may be <code>null</code>.
+ * @return A {@link ResourceProvider} with administrative privileges unless
+ * the {@link ResourceResolverFactory#USER_IMPERSONATION} was set
in the <code>authenticationInfo</code>.
+ * @throws LoginException
+ * If an error occurrs creating the new
<code>ResourceResolverFactory</code> with the
+ * provided credential data.
+ */
+ ResourceProvider getAdministrativeResourceProvider(Map<String, Object>
authenticationInfo) throws LoginException;
+}
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceProviderFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceProviderFactory.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceProviderFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java?rev=1350143&r1=1350142&r2=1350143&view=diff
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java
(original)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java
Thu Jun 14 09:18:04 2012
@@ -102,7 +102,9 @@ public interface ResourceResolver extend
* should be used to resolve the resource.
*
* @since 2.1
+ * @deprecated
*/
+ @Deprecated
String REQUEST_ATTR_WORKSPACE_INFO = ResourceResolver.class.getName()
+ "/use.workspace";
@@ -127,8 +129,7 @@ public interface ResourceResolver extend
* The difference between this method and the {@link #resolve(String)}
* method is, that this method may take request properties like the scheme,
* the host header or request parameters into account to resolve the
- * resource. If the {@link #REQUEST_ATTR_WORKSPACE_INFO} attribute is set,
- * the given workspace is used to resolve the resource.
+ * resource.
*
* @param request The http servlet request object providing more hints at
* how to resolve the <code>absPath</code>. This parameter may
be
@@ -186,9 +187,7 @@ public interface ResourceResolver extend
* anymore. Implementations are expected to implement this method calling
* the {@link #resolve(HttpServletRequest, String)} where the
* <code>absPath</code> argument is the result of calling the
- * <code>getPathInfo()</code> on the <code>request</code> object. If the
- * {@link #REQUEST_ATTR_WORKSPACE_INFO} attribute is set, the given
- * workspace is used to resolve the resource.
+ * <code>getPathInfo()</code> on the <code>request</code> object.
*
* @param request The http servlet request object used to resolve the
* resource for. This must not be <code>null</code>.
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=1350143&r1=1350142&r2=1350143&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
Thu Jun 14 09:18:04 2012
@@ -132,9 +132,9 @@ public class ResourceUtil {
if (path == null || "/".equals(path)) {
return null;
}
-
+
String workspaceName = null;
-
+
final int wsSepPos = path.indexOf(":/");
if (wsSepPos != -1) {
workspaceName = path.substring(0, wsSepPos);
@@ -150,17 +150,15 @@ public class ResourceUtil {
// parent is root
if (workspaceName != null) {
return workspaceName + ":/";
- } else {
- return "/";
}
+ return "/";
}
String parentPath = path.substring(0, lastSlash);
if (workspaceName != null) {
return workspaceName + ":" + parentPath;
- } else {
- return parentPath;
}
+ return parentPath;
}
/**
@@ -170,6 +168,7 @@ public class ResourceUtil {
* @return The parent resource or null if the rsrc is the root.
* @deprecated since 2.1.0, use {@link Resource#getParent()} instead
*/
+ @Deprecated
public static Resource getParent(Resource rsrc) {
final String parentPath = ResourceUtil.getParent(rsrc.getPath());
if (parentPath == null) {
@@ -184,6 +183,7 @@ public class ResourceUtil {
* @throws NullPointerException If <code>rsrc</code> is <code>null</code>.
* @deprecated since 2.1.0, use {@link Resource#getName()} instead
*/
+ @Deprecated
public static String getName(Resource rsrc) {
/*
* Same as AbstractResource.getName() implementation to prevent
problems
@@ -306,6 +306,7 @@ public class ResourceUtil {
* @see ResourceResolver#listChildren(Resource)
* @deprecated since 2.1.0, use {@link Resource#listChildren()} instead
*/
+ @Deprecated
public static Iterator<Resource> listChildren(Resource parent) {
/*
* Same as AbstractResource.listChildren() implementation to prevent