Author: cziegeler
Date: Sat Jun 13 15:49:04 2015
New Revision: 1685278
URL: http://svn.apache.org/r1685278
Log:
SLING-4750 : New resource query API
SLING-4751 : New Observation Support
SLING-4752 : New resource query API
Added:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ResourceChange.java
(with props)
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ResourceListener.java
(with props)
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/UserAwareResourceListener.java
(with props)
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/package-info.java
(with props)
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/PropertyBuilder.java
(with props)
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/Query.java
(with props)
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/QueryBuilder.java
(with props)
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/QueryInstructions.java
(with props)
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/QueryInstructionsBuilder.java
(with props)
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/QueryManager.java
(with props)
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/package-info.java
(with props)
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/JCRQueryProvider.java
(with props)
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ObservationReporter.java
(with props)
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/QueryProvider.java
(with props)
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/QueryResult.java
(with props)
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ResolveContext.java
(with props)
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ResourceProvider.java
(with props)
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/package-info.java
(with props)
Modified:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/AbstractResource.java
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/Resource.java
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java
Modified:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/AbstractResource.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/AbstractResource.java?rev=1685278&r1=1685277&r2=1685278&view=diff
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/AbstractResource.java
(original)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/AbstractResource.java
Sat Jun 13 15:49:04 2015
@@ -61,11 +61,7 @@ public abstract class AbstractResource
* retrieve that resource from the resource resolver.
*/
public Resource getParent() {
- final String parentPath = ResourceUtil.getParent(getPath());
- if (parentPath == null) {
- return null;
- }
- return getResourceResolver().getResource(parentPath);
+ return getResourceResolver().getParent(this);
}
/**
Modified:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/Resource.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/Resource.java?rev=1685278&r1=1685277&r2=1685278&view=diff
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/Resource.java
(original)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/Resource.java
Sat Jun 13 15:49:04 2015
@@ -84,6 +84,7 @@ public interface Resource extends Adapta
* @throws IllegalStateException if the resource resolver has already been
* closed}.
* @since 2.1 (Sling API Bundle 2.1.0)
+ * @see ResourceResolver#getParent(Resource)
*/
@CheckForNull Resource getParent();
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=1685278&r1=1685277&r2=1685278&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
Sat Jun 13 15:49:04 2015
@@ -383,6 +383,24 @@ public interface ResourceResolver extend
@Nonnull Iterator<Resource> listChildren(@Nonnull Resource parent);
/**
+ * Returns the parent resource of this resource.
+ * <p>
+ * This method is implemented by getting the parent resource path first
+ * calling the {@link ResourceUtil#getParent(String)} method and then to
+ * retrieve that resource.
+ *
+ * @param child The {@link Resource Resource} whose parent is requested.
+ * @return The parent resource or {@code null}.
+ * @throws NullPointerException If <code>child</code> is <code>null</code>.
+ * @throws org.apache.sling.api.SlingException If any error occurs
acquiring
+ * the parent resource.
+ * @throws IllegalStateException if this resource resolver has already been
+ * {@link #close() closed}.
+ * @since 2.9 (Sling API Bundle 2.10.0)
+ */
+ @CheckForNull Resource getParent(@Nonnull Resource child);
+
+ /**
* Returns an <code>Iterable</code> of {@link Resource} objects loaded from
* the children of the given <code>Resource</code>.
* <p>
@@ -690,4 +708,49 @@ public interface ResourceResolver extend
*/
void refresh();
+ /**
+ * This method copies the subgraph rooted at, and including, the resource
at
+ * <code>srcAbsPath</code> to the new location at <code>destAbsPath</code>.
+ * <p>
+ * TODO - clarify whether destAbsPath is the parent of the new tree or the
root
+ *
+ * If the copy operation is within a single resource provider, the
resource provider
+ * can use an optimized copy operation. Otherwise the resource resolver
copies resources
+ * from one provider to another.
+ *
+ * @param srcAbsPath the path of the resource to be copied.
+ * @param destAbsPath the location to which the resource at
+ * <code>srcAbsPath</code> is to be copied.
+ * @throws PersistenceException
+ * @throws org.apache.sling.api.SlingException
+ * @throws IllegalStateException if this resource resolver has already been
+ * {@link #close() closed}.
+ * @since 2.9 (Sling API Bundle 2.10.0)
+ */
+ void copy(final String srcAbsPath,
+ final String destAbsPath,
+ final boolean persistImmediately) throws PersistenceException;
+
+ /**
+ * This method moves the subgraph rooted at, and including, the resource at
+ * <code>srcAbsPath</code> to the new location at <code>destAbsPath</code>.
+ * <p>
+ * TODO - clarify whether destAbsPath is the parent of the new tree or the
root
+ *
+ * If the move operation is within a single resource provider, the
resource provider
+ * can use an optimized move operation. Otherwise the resource resolver
moves resources
+ * from one provider to another.
+ *
+ * @param srcAbsPath the path of the resource to be copied.
+ * @param destAbsPath the location to which the resource at
+ * <code>srcAbsPath</code> is to be copied.
+ * @throws PersistenceException
+ * @throws org.apache.sling.api.SlingException
+ * @throws IllegalStateException if this resource resolver has already been
+ * {@link #close() closed}.
+ * @since 2.9 (Sling API Bundle 2.10.0)
+ */
+ void move(final String srcAbsPath,
+ final String destAbsPath,
+ final boolean persistImmediately) throws PersistenceException;
}
Added:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ResourceChange.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ResourceChange.java?rev=1685278&view=auto
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ResourceChange.java
(added)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ResourceChange.java
Sat Jun 13 15:49:04 2015
@@ -0,0 +1,111 @@
+/*
+ * 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.observation;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
+
+import aQute.bnd.annotation.ConsumerType;
+
+/**
+ * A resource change event might be implemented in a lazy manner, however
+ * it is immutable.
+ */
+@ConsumerType
+public abstract class ResourceChange {
+
+ public enum ChangeType {
+ ADDED,
+ REMOVED,
+ CHANGED,
+ PROVIDER_ADDED,
+ PROVIDER_REMOVED
+ }
+
+ private final String path;
+ private final ChangeType changeType;
+
+ /**
+ * Create a new change object
+ * @param changeType The change type
+ * @param path The resource path
+ */
+ public ResourceChange(final @Nonnull ChangeType changeType, final @Nonnull
String path) {
+ this.path = path;
+ this.changeType = changeType;
+ }
+
+ /**
+ * Get the resource path.
+ * @return The path to the resource.
+ */
+ public @Nonnull String getPath() {
+ return this.path;
+ }
+
+ /**
+ * Get the user id of the user initiating the change
+ * @return The user id or {@code null} if it's not available.
+ */
+ public @CheckForNull String getUserId() {
+ return null;
+ }
+
+ /**
+ * Get the resource type.
+ * TODO Clarify when this might be available - and as this is lazy
+ * it might not be available even for added/changed resources.
+ * @return The resource type or {@code null}
+ */
+ public @CheckForNull String getResourceType() {
+ return null;
+ }
+
+ /**
+ * Get the type of change
+ * @return The type of change
+ */
+ public @Nonnull ChangeType getType() {
+ return this.changeType;
+ }
+
+ /**
+ * Optional information about changed properties.
+ * TODO Clarify when these might be available.
+ */
+ public @CheckForNull String[] getChangedAttributeNames() {
+ return null;
+ }
+
+ /**
+ * Optional information about added properties.
+ * TODO Clarify when these might be available.
+ */
+ public @CheckForNull String[] getAddedAttributeNames() {
+ return null;
+ }
+
+ /**
+ * Optional information about removed properties.
+ * TODO Clarify when these might be available.
+ */
+ public @CheckForNull String[] getRemovedAttributeNames() {
+ return null;
+ }
+}
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ResourceChange.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ResourceChange.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Added:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ResourceListener.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ResourceListener.java?rev=1685278&view=auto
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ResourceListener.java
(added)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ResourceListener.java
Sat Jun 13 15:49:04 2015
@@ -0,0 +1,62 @@
+/*
+ * 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.observation;
+
+import java.util.List;
+
+import javax.annotation.Nonnull;
+
+import aQute.bnd.annotation.ConsumerType;
+
+/**
+ * Listener for resource events.
+ *
+ * <p>
+ * {@code ResourceListener} objects are registered with the Framework service
+ * registry and are notified with {@code ResourceChange} objects when a
+ * change occurs.
+ * <p>
+ * {@code ResourceListener} objects can inspect the received {@code
ResourceChange} objects to
+ * determine the type of change, location and other properties.
+ *
+ * <p>
+ * {@code ResourceListener} objects must be registered with a service property
+ * {@link ResourceListener#PATHS} whose value is the list of resource paths
for which
+ * the listener is interested in getting change events.
+ */
+@ConsumerType
+public interface ResourceListener {
+
+ /**
+ * Array of paths - required.
+ */
+ String PATHS = "resource.paths";
+
+ /**
+ * Array of change types - optional.
+ * If this property is missing, added, removed and changed events are
reported.
+ */
+ String CHANGES = "resource.change.types";
+
+ /**
+ * Report a resource change based on the filter properties of this
listener.
+ * @param changes The changes.
+ */
+ void onChange(@Nonnull List<ResourceChange> changes);
+}
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ResourceListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/ResourceListener.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Added:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/UserAwareResourceListener.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/UserAwareResourceListener.java?rev=1685278&view=auto
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/UserAwareResourceListener.java
(added)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/UserAwareResourceListener.java
Sat Jun 13 15:49:04 2015
@@ -0,0 +1,66 @@
+/*
+ * 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.observation;
+
+import java.util.List;
+
+import javax.annotation.Nonnull;
+
+import org.apache.sling.api.resource.ResourceResolver;
+
+import aQute.bnd.annotation.ConsumerType;
+
+/**
+ * A resource listener which allows to act on the changes in the context of
the user
+ * who initiated the changes. If that information is not known, a resolver
using the
+ * access rights of a configured service user is used.
+ */
+@ConsumerType
+public interface UserAwareResourceListener {
+
+ /**
+ * Array of paths - required.
+ */
+ String PATHS = "resource.paths";
+
+ /**
+ * Array of change types - optional.
+ * If this property is missing, added, removed and changed events are
reported.
+ */
+ String CHANGES = "resource.change.types";
+
+ /**
+ * Required property containing the service user name to use for the
ResourceResolver
+ * passed to onChange, if the change event does not provide the actual
user.
+ * The value of this property must be of type string.
+ */
+ String SERVICE_USER = "resource.serviceuser";
+
+ /**
+ * Report a resource change based on the filter properties of this
listener.
+ * @param resolver A resolver using the access rights of the user who
initiated
+ * the change or the configured service user
+ * @param changes The changes.
+ * @param usesInitiatingUser {@code true} if the resolver uses the user
initiating
+ * the changes.
+ */
+ void onChange(@Nonnull ResourceResolver resolver,
+ @Nonnull List<ResourceChange> changes,
+ boolean usesInitiatingUser);
+}
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/UserAwareResourceListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/UserAwareResourceListener.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Added:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/package-info.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/package-info.java?rev=1685278&view=auto
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/package-info.java
(added)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/package-info.java
Sat Jun 13 15:49:04 2015
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+@Version("1.0.0")
+package org.apache.sling.api.resource.observation;
+
+import aQute.bnd.annotation.Version;
+
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/observation/package-info.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Added:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/PropertyBuilder.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/PropertyBuilder.java?rev=1685278&view=auto
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/PropertyBuilder.java
(added)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/PropertyBuilder.java
Sat Jun 13 15:49:04 2015
@@ -0,0 +1,78 @@
+/*
+ * 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.query;
+
+import javax.annotation.Nonnull;
+
+import aQute.bnd.annotation.ProviderType;
+
+/**
+ * Builder for creating a property part of a query.
+ */
+@ProviderType
+public interface PropertyBuilder {
+
+ /**
+ * Create a property constraint for equality test.
+ * @param value The value to check
+ * @return A query builder to continue creating the query.
+ */
+ @Nonnull QueryBuilder eq(@Nonnull Object value);
+
+ /**
+ * Create a property constraint for is greater than test.
+ * @param value The value to check
+ * @return A query builder to continue creating the query.
+ */
+ @Nonnull QueryBuilder isGreater(@Nonnull Object value);
+
+ /**
+ * Create a property constraint for is greater or equals than test.
+ * @param value The value to check
+ * @return A query builder to continue creating the query.
+ */
+ @Nonnull QueryBuilder isGreaterOrEq(@Nonnull Object value);
+
+ /**
+ * Create a property constraint for is less than test.
+ * @param value The value to check
+ * @return A query builder to continue creating the query.
+ */
+ @Nonnull QueryBuilder isLess(@Nonnull Object value);
+
+ /**
+ * Create a property constraint for is less or equals than test.
+ * @param value The value to check
+ * @return A query builder to continue creating the query.
+ */
+ @Nonnull QueryBuilder isLessOrEq(@Nonnull Object value);
+
+ /**
+ * Create a property constraint for a contains test.
+ * @param value The value to check
+ * @return A query builder to continue creating the query.
+ */
+ @Nonnull QueryBuilder contains(@Nonnull Object value);
+
+ /**
+ * Create a property constraint for an existence test.
+ * @return A query builder to continue creating the query.
+ */
+ @Nonnull QueryBuilder exists();
+}
\ No newline at end of file
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/PropertyBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/PropertyBuilder.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Added:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/Query.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/Query.java?rev=1685278&view=auto
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/Query.java
(added)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/Query.java
Sat Jun 13 15:49:04 2015
@@ -0,0 +1,144 @@
+/*
+ * 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.query;
+
+import java.util.List;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
+
+import aQute.bnd.annotation.ProviderType;
+
+/**
+ * A query object describes a query to be executed. Each query has a unique
+ * and stable id which can be used by implementations to cache the parsing
+ * of the query object.
+ *
+ * A query can either be a compound query, combining other queries or
+ * it can be an actual query over resource paths, names, types and
+ * properties. The method {@link #getQueryType()} can be used
+ * to identify the type of the query.
+ */
+@ProviderType
+public interface Query {
+
+ /**
+ * Enumeration defining whether the query is a compound or
+ * single query.
+ */
+ public enum QueryType {
+ SINGLE,
+ COMPOUND_AND,
+ COMPOUND_OR
+ };
+
+ /**
+ * The different property operations.
+ */
+ public enum PropertyOperator {
+ EXISTS, // property exists
+ EQ, // property has an equal value
+ GT, // property is greater than the value
+ GT_OR_EQ, // property is greater or equal to the value
+ LT, // property is less than the value
+ LT_OR_EQ, // property is less or equal to the value
+ CONTAINS // property contains the value
+ };
+
+ /**
+ * A property constraint describes a constraint on a property.
+ * The operator defines the comparison operation and the name
+ * the name of the property to check. The property name might
+ * be a relative path pointing to a property of a child
+ * resource or it might consist of the special name {code *}
+ * denoting any property.
+ */
+ public interface PropertyConstraint {
+
+ /**
+ * The operator to use to compare the property value.
+ * @return The operator
+ */
+ @Nonnull PropertyOperator getOperator();
+
+ /**
+ * The property name
+ * @return The name of the property, relative path or {@code *}.
+ */
+ @Nonnull String getName();
+
+ /**
+ * The value to compare against.
+ * @return The value to compare or {@code null}.
+ */
+ @CheckForNull Object getValue();
+ }
+
+ /**
+ * Unique global id.
+ * The id can be used by implementations to cache the parsed query.
+ * The id is ensured to be the same for two identical queries.
+ * @return A unique global id.
+ */
+ @Nonnull String getId();
+
+ /**
+ * Returns constraints on the resource paths.
+ * This method returns an empty list if it's a compound query.
+ * @return The list of paths, might be empty.
+ */
+ @CheckForNull List<String> getPaths();
+
+ /**
+ * Returns constraints on the resource names.
+ * This method returns an empty list if it's a compound query.
+ * @return The list of names, might be empty.
+ */
+ @CheckForNull List<String> getResourceNames();
+
+ /**
+ * Returns constraints on the resource types.
+ * This method returns an empty list if it's a compound query.
+ * @return The list of types, might be empty.
+ */
+ @CheckForNull List<String> getIsA();
+
+ /**
+ * Return the list of property constraints.
+ * This method only returns constraints, if the query type
+ * is {@link QueryType#SINGLE}.
+ * @return The list of property constraints or {@code null}.
+ */
+ @CheckForNull List<PropertyConstraint> getPropertyConstraints();
+
+ /**
+ * Returns the queries if {@link #getPartOperatorType()} does not
+ * return {@link PartOperatorType#NONE}.
+ * @return The parts or {@code null} if this query is not an operation
+ * on other queries.
+ */
+ @CheckForNull List<Query> getParts();
+
+ /**
+ * Return the type of the query.
+ * @return The query type.
+ */
+ @Nonnull QueryType getQueryType();
+
+}
\ No newline at end of file
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/Query.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/Query.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Added:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/QueryBuilder.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/QueryBuilder.java?rev=1685278&view=auto
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/QueryBuilder.java
(added)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/QueryBuilder.java
Sat Jun 13 15:49:04 2015
@@ -0,0 +1,97 @@
+/*
+ * 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.query;
+
+import javax.annotation.Nonnull;
+
+import org.apache.sling.api.resource.Resource;
+
+import aQute.bnd.annotation.ProviderType;
+
+/**
+ * The query builder can be used to build a query
+ * for resources.
+ */
+@ProviderType
+public interface QueryBuilder {
+
+ /**
+ * Build the query.
+ *
+ * @return The query.
+ *
+ * @throws IllegalArgumentException If the query is not valid.
+ */
+ @Nonnull Query build();
+
+ /**
+ * At a path condition to the query.
+ * If several paths are added to the query, these are handled as an or.
+ * If no path is specified for a query, the search paths of the resource
+ * resolver are used.
+ *
+ * @param path An absolute resource path
+ * @return The query builder to construct the query
+ *
+ * @throws IllegalArgumentException If the argument is not valid.
+ */
+ @Nonnull QueryBuilder at(@Nonnull String... path);
+
+ /**
+ * Add a condition to check whether the resource is of a specific resource
type.
+ * If more than one resource type is specified, the conditions are handled
with
+ * an or operation.
+ * The operation is similar to {@link Resource#isResourceType(String)}
+ * @param resourceType The resource type to check.
+ * @return The query builder to construct the query.
+ *
+ * @throws IllegalArgumentException If the argument is not valid.
+ */
+ @Nonnull QueryBuilder isA(@Nonnull String resourceType);
+
+ /**
+ * Add a condition to check whether the resource has a specific name.
+ * If more than one resource name is specified, the conditions are handled
with
+ * an or operation.
+ * @param name The name to check.
+ * @return The query builder to construct the query.
+ *
+ * @throws IllegalArgumentException If the argument is not valid.
+ */
+ @Nonnull QueryBuilder name(@Nonnull String resourceName);
+
+ /**
+ * Add a property condition for the resources.
+ * If more than one property condition is specified, the conditions are
+ * handled with an and operation.
+ * The property might be a relative path pointing to a property of a child
+ * resource. In this case the child resource must be provided by the same
+ * resource provider. A relative path pointing to a parent resource or
+ * any resource which is not a child resource is not valid.
+ * The special name {@code *} can be used to mean any property of the
current resource.
+ * @param name The name of the property to check. The name can be a path
specifying
+ * a property of a known child resource of the returned resource.
+ * @return A property builder to specify the operation on the property
value.
+ *
+ * @throws IllegalArgumentException If the argument is not valid.
+ */
+ @Nonnull PropertyBuilder property(@Nonnull String name);
+
+
+}
\ No newline at end of file
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/QueryBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/QueryBuilder.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Added:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/QueryInstructions.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/QueryInstructions.java?rev=1685278&view=auto
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/QueryInstructions.java
(added)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/QueryInstructions.java
Sat Jun 13 15:49:04 2015
@@ -0,0 +1,69 @@
+/*
+ * 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.query;
+
+import java.util.List;
+
+import javax.annotation.Nonnull;
+
+import aQute.bnd.annotation.ProviderType;
+
+/**
+ * Query instructions are used to further specify runtime specific
+ * instructions for a query.
+ */
+@ProviderType
+public interface QueryInstructions {
+
+ public interface SortCriteria {
+ String getPropertyName();
+ boolean isAscending();
+ }
+ /**
+ * Unique global id.
+ * The id can be used by implementations to cache the parsed query.
+ * The id is ensured to be the same for two identical query instructions.
+ * The only variable is the continuation key.
+ * @return A unique global id.
+ */
+ @Nonnull String getId();
+
+ /**
+ * Get the limit of the query. By default the query is unlimited.
+ * @return The limit. If a negative value is returned, there is no limit.
+ */
+ int getLimit();
+
+ /**
+ * Generate a continuation key to be used with {@link
QueryInstructionsBuilder#continueAt(String)}.
+ * The continuation can be used for paging: the last resource of a page is
feed into this
+ * method to get a key to be used to get the start for the next page.
+ * A continuation key can only be generated if the result is sorted.
+ * @param resource The last resource of a page
+ * @return A continuation key for the next resource after this one,
according to the sorting.
+ * @throws IllegalArgumentException if the resource is {@code null}
+ */
+ @Nonnull String getContinuationKey();
+
+ /**
+ * Unmodifiable list with the sort criteria.
+ * @return The sort criteria, the list might be empty.
+ */
+ @Nonnull List<SortCriteria> getSortCriteria();
+}
\ No newline at end of file
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/QueryInstructions.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/QueryInstructions.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Added:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/QueryInstructionsBuilder.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/QueryInstructionsBuilder.java?rev=1685278&view=auto
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/QueryInstructionsBuilder.java
(added)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/QueryInstructionsBuilder.java
Sat Jun 13 15:49:04 2015
@@ -0,0 +1,71 @@
+/*
+ * 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.query;
+
+import javax.annotation.Nonnull;
+
+import aQute.bnd.annotation.ProviderType;
+
+/**
+ * Query instructions are used to further specify runtime specific
+ * instructions for a query.
+ */
+@ProviderType
+public interface QueryInstructionsBuilder {
+
+ /**
+ * Specify the limit of the query. By default the query is unlimited.
+ * @param limit The new limit. If a value less than 1 is used, there is no
limit.
+ * @return The query instructions.
+ */
+ @Nonnull QueryInstructionsBuilder limit(int limit);
+
+ /**
+ * Specify the continuation key.
+ */
+ @Nonnull QueryInstructionsBuilder continueAt(@Nonnull String
continuationKey);
+
+ /**
+ * Sort the result in ascending order by this property.
+ * If more than one sort criteria is specified, the result is sorted first
by the
+ * first criteria, within that sorting the second criteria is applied and
so on.
+ * @param propName The name of the property
+ * @return The query builder to construct the query.
+ *
+ * @throws IllegalArgumentException If the argument is {@code null}.
+ */
+ @Nonnull QueryInstructionsBuilder sortAscendingBy(@Nonnull String
propName);
+
+ /**
+ * Sort the result in descending order by this property.
+ * If more than one sort criteria is specified, the result is sorted first
by the
+ * first criteria, within that sorting the second criteria is applied and
so on.
+ * @param propName The name of the property
+ * @return The query builder to construct the query.
+ *
+ * @throws IllegalArgumentException If the argument is {@code null}.
+ */
+ @Nonnull QueryInstructionsBuilder sortDescendingBy(@Nonnull String
propName);
+
+ /**
+ * Build the query instructions object.
+ * @return The query instructions.
+ */
+ @Nonnull QueryInstructions build();
+}
\ No newline at end of file
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/QueryInstructionsBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/QueryInstructionsBuilder.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Added:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/QueryManager.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/QueryManager.java?rev=1685278&view=auto
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/QueryManager.java
(added)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/QueryManager.java
Sat Jun 13 15:49:04 2015
@@ -0,0 +1,81 @@
+/*
+ * 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.query;
+
+import java.util.Iterator;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+
+import aQute.bnd.annotation.ProviderType;
+
+/**
+ * The query manager allows to run a query in the context
+ * of a resource resolver.
+ */
+@ProviderType
+public interface QueryManager {
+
+ /**
+ * Execute the given query in the context of the resource resolver.
+ *
+ * @param resolver The resource resolver
+ * @param q The query
+ * @param qi The optional query instructions
+ * @return An iterator of resources - the result might be empty.
+ */
+ @Nonnull Iterator<Resource> find(@Nonnull ResourceResolver resolver,
+ @Nonnull Query q,
+ @CheckForNull QueryInstructions qi);
+
+ /**
+ * Create a new query.
+ * @return A query builder to build the query.
+ */
+ @Nonnull QueryBuilder query();
+
+ /**
+ * Create a new query based on combining two or more queries in an and
fashion.
+ *
+ * @param q1 First query
+ * @param q2 Additional queries
+ * @return The new query
+ */
+ @Nonnull Query andQuery(@Nonnull Query q1, @Nonnull Query... q2);
+
+ /**
+ * Create a new query based on combining two or more queries in an or
fashion.
+ *
+ * @param q1 First query
+ * @param q2 Additional queries
+ * @return The new query
+ *
+ * @throws IllegalArgumentException If the argument is not valid.
+ */
+ @Nonnull Query orQuery(@Nonnull Query q1, @Nonnull Query... q2);
+
+ /**
+ * Create query instructions.
+ * @return A new query instruction builder.
+ */
+ @Nonnull QueryInstructionsBuilder instructions();
+}
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/QueryManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/QueryManager.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Added:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/package-info.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/package-info.java?rev=1685278&view=auto
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/package-info.java
(added)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/package-info.java
Sat Jun 13 15:49:04 2015
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+@Version("1.0.0")
+package org.apache.sling.api.resource.query;
+
+import aQute.bnd.annotation.Version;
+
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/query/package-info.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Added:
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/JCRQueryProvider.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/JCRQueryProvider.java?rev=1685278&view=auto
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/JCRQueryProvider.java
(added)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/JCRQueryProvider.java
Sat Jun 13 15:49:04 2015
@@ -0,0 +1,101 @@
+/*
+ * 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.spi.resource.provider;
+
+import java.util.Iterator;
+
+import javax.annotation.Nonnull;
+
+import org.apache.sling.api.resource.QuerySyntaxException;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ValueMap;
+
+import aQute.bnd.annotation.ConsumerType;
+
+
+/**
+ * The JCR query provider supports querying based on the JCR spec.
+ * Calls from {@link ResourceResolver#findResources(String, String)} and
+ * {@link ResourceResolver#queryResources(String, String)} are passed on
+ * to this object.
+ */
+@ConsumerType
+public interface JCRQueryProvider<T> {
+
+ /**
+ * The supported languages of the resource provider.
+ */
+ String getSupportedLanguages();
+
+ /**
+ * 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 language 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. If no resources match, <code>null</code> might be
+ * returned instead of an empty iterator.
+ * @throws QuerySyntaxException If the query is not syntactically correct
+ * according to the query language indicator or if the query
+ * language is not supported as specified in {@link
#LANGUAGES}.
+ * @throws org.apache.sling.api.SlingException If an error occurs querying
+ * for the resources.
+ * @throws IllegalStateException if this resource provider has already been
+ * closed.
+ */
+ Iterator<Resource> findResources(@Nonnull ResolveContext<T> ctx, 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 language 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. If no resources match,
<code>null</code>
+ * might be returned instead of an empty iterator.
+ * @throws QuerySyntaxException If the query is not syntactically correct
+ * according to the query language indicator or if the query
+ * language is not supported as specified in {@link
#LANGUAGES}.
+ * @throws org.apache.sling.api.SlingException If an error occurs querying
+ * for the resources.
+ * @throws IllegalStateException if this resource provider has already been
+ * closed.
+ */
+ Iterator<ValueMap> queryResources(@Nonnull ResolveContext<T> ctx, String
query, String language);
+}
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/JCRQueryProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/JCRQueryProvider.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Added:
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ObservationReporter.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ObservationReporter.java?rev=1685278&view=auto
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ObservationReporter.java
(added)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ObservationReporter.java
Sat Jun 13 15:49:04 2015
@@ -0,0 +1,37 @@
+/*
+ * 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.spi.resource.provider;
+
+import java.util.List;
+
+import javax.annotation.Nonnull;
+
+import org.apache.sling.api.resource.observation.ResourceChange;
+
+import aQute.bnd.annotation.ProviderType;
+
+/**
+ * A {@code ResourceProvider} must use an observation reporter
+ * to report changes to resources.
+ */
+@ProviderType
+public interface ObservationReporter {
+
+ void reportChanges(@Nonnull List<ResourceChange> changes);
+}
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ObservationReporter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ObservationReporter.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Added:
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/QueryProvider.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/QueryProvider.java?rev=1685278&view=auto
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/QueryProvider.java
(added)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/QueryProvider.java
Sat Jun 13 15:49:04 2015
@@ -0,0 +1,42 @@
+/*
+ * 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.spi.resource.provider;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
+
+import org.apache.sling.api.resource.query.Query;
+import org.apache.sling.api.resource.query.QueryInstructions;
+
+import aQute.bnd.annotation.ConsumerType;
+
+@ConsumerType
+public interface QueryProvider <T> {
+
+ /**
+ * Execute the query within the context of the provided resource resolver
+ * @param ctx The resource context-
+ * @param q The query
+ * @param qi The query instructions
+ * @return A query result or {@code null}.
+ */
+ @CheckForNull QueryResult find(@Nonnull ResolveContext<T> ctx,
+ @Nonnull Query q,
+ @Nonnull QueryInstructions qi);
+}
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/QueryProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/QueryProvider.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Added:
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/QueryResult.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/QueryResult.java?rev=1685278&view=auto
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/QueryResult.java
(added)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/QueryResult.java
Sat Jun 13 15:49:04 2015
@@ -0,0 +1,35 @@
+/*
+ * 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.spi.resource.provider;
+
+import javax.annotation.Nonnull;
+
+import org.apache.sling.api.resource.Resource;
+
+import aQute.bnd.annotation.ConsumerType;
+
+@ConsumerType
+public abstract class QueryResult {
+
+ public abstract @Nonnull Iterable<Resource> getResources();
+
+ public String getContinuationKey() {
+ return null;
+ }
+}
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/QueryResult.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/QueryResult.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Added:
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ResolveContext.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ResolveContext.java?rev=1685278&view=auto
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ResolveContext.java
(added)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ResolveContext.java
Sat Jun 13 15:49:04 2015
@@ -0,0 +1,73 @@
+/*
+ * 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.spi.resource.provider;
+
+import java.util.Map;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
+
+import org.apache.sling.api.resource.ResourceResolver;
+
+import aQute.bnd.annotation.ProviderType;
+
+/**
+ * The resolve context is passed to most of the methods of the {@link
ResourceProvider}
+ * to provide additional context information for the provider.
+ *
+ * If the provider requires authentication, the object returned by {@link
ResourceProvider#authenticate(Map)}
+ * is returned in {@link #getProviderState()}.
+ */
+@ProviderType
+public interface ResolveContext<T> {
+
+ /**
+ * Get the current resource resolver.
+ * @return The resource resolver.
+ */
+ @Nonnull ResourceResolver getResourceResolver();
+
+ /**
+ * Return optional parameters for resolving the resource
+ * @return A non empty map with parameters or {@code null}.
+ */
+ @CheckForNull Map<String, String> getResolveParameters();
+
+ /**
+ * This is the object returned by {@link
ResourceProvider#authenticate(Map)}
+ * @return The data object or {@code null}
+ */
+ @CheckForNull T getProviderState();
+
+ /**
+ * Return a resolve context for the parent resource provider.
+ * @return A resolve context or {@code null} if there is no parent.
+ * @see #getParentResourceProvider()
+ */
+ @CheckForNull ResolveContext<?> getParentResolveContext();
+
+ /**
+ * Return the parent resource provider.
+ * If the parent should be used for resolving, a context created with
+ * {@link #getParentResolveContext()} should be passed to that
+ * instance.
+ * @return The parent provider or {@code null} if there is no parent.
+ */
+ @CheckForNull ResourceProvider<?> getParentResourceProvider();
+}
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ResolveContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ResolveContext.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Added:
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ResourceProvider.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ResourceProvider.java?rev=1685278&view=auto
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ResourceProvider.java
(added)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ResourceProvider.java
Sat Jun 13 15:49:04 2015
@@ -0,0 +1,443 @@
+/*
+ * 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.spi.resource.provider;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
+
+import org.apache.sling.api.SlingException;
+import org.apache.sling.api.resource.LoginException;
+import org.apache.sling.api.resource.PersistenceException;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceResolverFactory;
+import org.apache.sling.api.resource.ResourceUtil;
+import org.apache.sling.api.resource.SyntheticResource;
+
+import aQute.bnd.annotation.ConsumerType;
+
+/**
+ * API for providers of resources. Used by the {@link ResourceResolver} to
+ * transparently access resources from different locations such as a JCR
+ * repository, a database, or bundle resources.
+ * <p>
+ * This extension point is defined by an abstract class (in contrast to
+ * an interface) as this will allow to add new functionality in new versions
+ * without breaking any implementation.
+ * <p>
+ * This service 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 implements this service by extending this class.
+ * <p>
+ * TODO - authentication / logout (Closeable)
+ * TODO - context support
+ * TODO - query
+ * TODO - observation
+ * TODO - service ranking
+ */
+@ConsumerType
+public abstract class ResourceProvider<T> {
+
+ /**
+ * The name of the service registration property containing the root path
+ * of the resources provided by this provider.
+ * If this property is missing, empty or invalid, the provider is ignored.
+ * (value is "provider.root")
+ */
+ public static final String PROPERTY_ROOT = "provider.root";
+
+ /**
+ * The name of the service registration property containing a boolean
+ * flag indicating if the ResourceAccessSecurity service should be used for
+ * this provider or not. ResourceAccessSecurity should only be used if the
+ * underlying storage does not provide access control
+ * The default for this value is <code>false</code>.
+ * (value is "provider.useResourceAccessSecurity")
+ */
+ public static final String PROPERTY_USE_RESOURCE_ACCESS_SECURITY =
"provider.useResourceAccessSecurity";
+
+ /**
+ * A required resource provider is accessed directly when a new
+ * resource resolver is created. The resource resolver implementation
+ * will call the {@link #authenticate(Map)}. 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 value
+ * is <code>false</true>.
+ * (value is "provider.required")
+ */
+ public static final String PROPERTY_REQUIRED = "provider.required";
+
+ /**
+ * If a resource provider needs the user to be authenticated this flag
must be set
+ * to {@code true}. In this case {@link #authenticate(Map)} is called
first and only
+ * if authentication is successful, this provider instance is used for the
current
+ * resource resolver.
+ * Boolean service property, default value is <code>false</true>.
+ * (value is "provider.authenticate")
+ */
+ public static final String PROPERTY_AUTHENTICATE = "provider.authenticate";
+
+ /**
+ * A modifiable resource provider is capable of creating, changing and
deleting resources.
+ * This means the methods {@link #create(ResolveContext, String, Map)},
+ * {@link #delete(ResolveContext, Resource)} and adapting a resource to a
modifiable
+ * value map is supported.
+ * If this flag is set to {@code false}, the resource resolver does not
take this
+ * provider into account for modifications and modification operations to
this provider
+ * always result in an exception.
+ * If this is set to {@code true}, the property {@link
ResourceProvider#PROPERTY_AUTHENTICATE}
+ * is automatically set to {@code true} as well.
+ * Boolean service property, default value is <code>false</true>.
+ * (value is "provider.modifiable")
+ */
+ public static final String PROPERTY_MODIFIABLE = "provider.modifiable";
+
+ /**
+ * The authentication information property referring to the bundle
+ * providing a service for which a resource provider is to be retrieved. If
+ * this property is provided, the
+ * {@link ResourceResolverFactory#SUBSERVICE} property may also be
+ * present.
+ * <p>
+ * {@link ResourceResolverFactory} implementations must provide this
+ * property if their implementation of the
+ * {@link ResourceResolverFactory#getServiceResourceResolver(Map)} method
+ * use a resource provider factory.
+ * <p>
+ * The type of this property, if present, is
+ * <code>org.osgi.framework.Bundle</code>.
+ */
+ public static final String AUTH_SERVICE_BUNDLE = "sling.service.bundle";
+
+ /**
+ * Authenticate against the resource provider.
+ * <p>
+ * Returns a provider context object if authentication is successful. The
+ * context object is passed to the resource provider in all messages
through
+ * the {@link ResolveContext}. A valid implementation might return {@code
null}
+ * as the context information.
+ * <p>
+ * If authentication fails a {@code LoginException} must be thrown.
+ * <p>
+ * The returned context object grants access to the provided resources with
+ * privileges assigned to the service provided by the calling bundle.
+ * <p>
+ * The <code>authenticationInfo</code> map will in general contain the same
+ * information as provided to the respective {@link ResourceResolver}
+ * method. For
+ * <p>
+ * The provided {@code authenticationInfo} map may be used to provide
+ * additional information such as the {@link #AUTH_SERVICE_BUNDLE}.
+ * If this property is provided, additional information like
+ * {@link ResourceResolverFactory#SUBSERVICE} might be provided, but the
+ * {@link #USER} and {@link #PASSWORD} properties provided in the map must
+ * be ignored.
+ * <p>
+ * The {@link #USER_IMPERSONATION} property is obeyed but requires that the
+ * authenticated user has permission to impersonate as the requested user.
+ * If such permission is missing, a {@code LoginException} is thrown.
+ * <p>
+ * If the returned context data object implements {@link
java.io.Closeable},
+ * the resource resolver implementation will call the close method once
+ * the resource resolver is closed.
+ *
+ * @param authenticationInfo A map of further credential information which
+ * may be used by the implementation to parameterize how the
+ * resource resolver is created.
+ * @return A context data object according to the
+ * <code>authenticationInfo</code>.
+ * @throws LoginException If an error occurs authenticating with the
+ * provided credential data.
+ *
+ * @see <a
+ *
href="http://sling.apache.org/documentation/the-sling-engine/service-authentication.html">Service
+ * Authentication</a>
+ */
+ @Nonnull T authenticate(final @Nonnull Map<String, Object>
authenticationInfo)
+ throws LoginException {
+ return null;
+ }
+
+ /**
+ * The provider is updated to reflect the latest state.
+ * Resources which have changes pending are not discarded.
+ * {@link #revert(ResolveContext)} can be called to discard changes.
+ *
+ * @param ctx The {@link ResolveContext} to which the returned {@link
Resource} is attached.
+ */
+ public void refresh(final @Nonnull ResolveContext<T> ctx) {
+ // nothing to do here
+ }
+
+ /**
+ * 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
+ *
+ * @param ctx The {@link ResolveContext} to which the returned {@link
Resource} is attached.
+ * @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>.
+ */
+ public boolean isLive(final @Nonnull ResolveContext<T> ctx) {
+ return true;
+ }
+
+ /**
+ * Returns the parent resource from this resource provider or
<code>null</code> if
+ * the resource provider cannot find it.
+ *
+ * The resource provider must not return cached instances for a resource as
+ * the resource resolver will update the resource metadata of the resource
+ * at the end of the resolution process and this metadata might be
different
+ * depending on the full path of resource resolution passed into the
+ * resource resolver.
+ *
+ * @param ctx The {@link ResolveContext} to which the returned {@link
Resource} is attached.
+ * @param child The child resource.
+ * @return <code>null</code> if this provider does not have a resource for
+ * the parent.
+ * @throws org.apache.sling.api.SlingException
+ * may be thrown in case of any problem creating the
<code>Resource</code> instance.
+ */
+ public @CheckForNull Resource getParent(final @Nonnull ResolveContext<T>
ctx,final @Nonnull Resource child) {
+ final String parentPath = ResourceUtil.getParent(child.getPath());
+ if (parentPath == null) {
+ return null;
+ }
+ return this.getResource(ctx, parentPath, null);
+ }
+
+ /**
+ * Returns a resource from this resource provider or <code>null</code> if
+ * the resource provider cannot find it. The path must have the {@link
#PROPERTY_ROOT}
+ * strings as its prefix.
+ *
+ * The resource provider must not return cached instances for a resource as
+ * the resource resolver will update the resource metadata of the resource
+ * at the end of the resolution process and this metadata might be
different
+ * depending on the full path of resource resolution passed into the
+ * resource resolver.
+ *
+ * @param resourceResolver
+ * The {@link ResourceResolver} to which the returned {@link
Resource} is attached.
+ * @param path The full path of the resource.
+ * @param parent Optional parent resource
+ * @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.
+ */
+ public abstract @CheckForNull Resource getResource(@Nonnull final
ResolveContext<T> ctx,
+ @Nonnull final String path,
+ @CheckForNull final Resource parent);
+
+ /**
+ * 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.
+ * <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}.
+ *
+ * As with {@link #getResource(ResourceResolver, String)} the returned
Resource objects must
+ * not be cached objects.
+ *
+ * @param ctx The {@link ResolveContext} to which the returned {@link
Resource} is attached.
+ * @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.
+ */
+ public abstract @CheckForNull Iterator<Resource> listChildren(final
@Nonnull ResolveContext<T> ctx, final @Nonnull Resource parent);
+
+ /**
+ * Returns a collection of attribute names whose value can be retrieved
+ * calling the {@link #getAttribute(ResourceResolver, String)} method.
+ *
+ * @param ctx The {@link ResolveContext} to which the returned {@link
Resource} is attached.
+ * @return A collection of attribute names or <code>null</code>
+ * @throws IllegalStateException if this resource provider has already been
+ * closed.
+ */
+ public Collection<String> getAttributeNames(final @Nonnull
ResolveContext<T> ctx) {
+ return null;
+ }
+
+ /**
+ * 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 ctx The {@link ResolveContext} to which the returned {@link
Resource} is attached.
+ * @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 IllegalStateException
+ * if this resource provider has already been closed.
+ */
+ public Object getAttribute(final @Nonnull ResolveContext<T> ctx, final
@Nonnull String name) {
+ return null;
+ }
+
+ /**
+ * Create a new resource at the given path.
+ * The new resource is put into the transient space of this provider
+ * until {@link #commit(ResourceResolver)} is called.
+ *
+ * A resource provider should value {@link
ResourceResolver#PROPERTY_RESOURCE_TYPE}
+ * to set the resource type of a resource.
+ *
+ * @param ctx The {@link ResolveContext} to which the returned {@link
Resource} is attached.
+ * @param path The resource path.
+ * @param properties Optional properties
+ * @return The new resource.
+ *
+ * @throws PersistenceException If anything fails
+ */
+ public Resource create(final @Nonnull ResolveContext<T> ctx, final String
path, final Map<String, Object> properties)
+ throws PersistenceException {
+ throw new PersistenceException("create is not supported.");
+ }
+
+ /**
+ * Delete the resource at the given path.
+ * This change is kept in the transient space of this provider
+ * until {@link #commit(ResourceResolver)} is called.
+ *
+ * @param ctx The {@link ResolveContext} to which the returned {@link
Resource} is attached.
+ * @param resource The resource to delete.
+ *
+ * @throws PersistenceException If anything fails
+ */
+ public void delete(final @Nonnull ResolveContext<T> ctx, final @Nonnull
Resource resource)
+ throws PersistenceException {
+ throw new PersistenceException("delete is not supported.");
+ }
+
+ /**
+ * Revert all transient changes: create, delete and updates.
+ *
+ * @param ctx The {@link ResolveContext} to which the returned {@link
Resource} is attached.
+ */
+ public void revert(final @Nonnull ResolveContext<T> ctx) {
+ // nothing to do here
+ }
+
+ /**
+ * Commit all transient changes: create, delete and updates
+ *
+ * @param ctx The {@link ResolveContext} to which the returned {@link
Resource} is attached.
+ *
+ * @throws PersistenceException If anything fails
+ */
+ public void commit(final @Nonnull ResolveContext<T> ctx)
+ throws PersistenceException {
+ // nothing to do here
+ }
+
+ /**
+ * Are there any transient changes?
+ *
+ * @param ctx The {@link ResolveContext} to which the returned {@link
Resource} is attached.
+ */
+ public boolean hasChanges(final @Nonnull ResolveContext<T> ctx) {
+ return false;
+ }
+
+ /**
+ * Get the optional query provider.
+ *
+ * @return A query provider if this resource provider supports this type
of querying.
+ */
+ public @CheckForNull QueryProvider<T> getQueryProvider() {
+ return null;
+ }
+
+ /**
+ * Get the optional JCR query provider.
+ *
+ * @return A JCR query provider if this resource provider supports this
type of querying.
+ */
+ public @CheckForNull JCRQueryProvider<T> getJCRQueryProvider() {
+ return null;
+ }
+
+ /**
+ * Adapts the provider to another type.
+ * <p>
+ * Please not that it is explicitly left as an implementation detail
whether
+ * each call to this method with the same <code>type</code> yields the same
+ * object or a new object on each call.
+ * <p>
+ * Implementations of this method should document their adapted types as
+ * well as their behaviour with respect to returning newly created or not
+ * instance on each call.
+ *
+ * @param ctx The {@link ResolveContext}.
+ * @param type The generic type to which this resource is adapted to.
+ * @return The adapter target or {@code null} if the provider cannot
+ * be adapt to the requested type.
+ */
+ public @CheckForNull <AdapterType> AdapterType adaptTo(final @Nonnull
ResolveContext<T> ctx, final @Nonnull Class<AdapterType> type) {
+ return null;
+ }
+
+ /**
+ * TODO
+ * @return {@code true} if the provider can perform the copy
+ */
+ public boolean copy(final String srcAbsPath,
+ final String destAbsPath,
+ final boolean persistImmediately) throws PersistenceException {
+ return false;
+ }
+
+ /**
+ * TODO
+ * @return {@code true} if the provider can perform the move
+ */
+
+ public boolean move(final String srcAbsPath,
+ final String destAbsPath,
+ final boolean persistImmediately) throws PersistenceException {
+ return false;
+ }
+}
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ResourceProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/ResourceProvider.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Added:
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/package-info.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/package-info.java?rev=1685278&view=auto
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/package-info.java
(added)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/package-info.java
Sat Jun 13 15:49:04 2015
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+@Version("1.0.0")
+package org.apache.sling.spi.resource.provider;
+
+import aQute.bnd.annotation.Version;
+
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/trunk/bundles/api/src/main/java/org/apache/sling/spi/resource/provider/package-info.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url