Author: cziegeler
Date: Wed Nov 7 19:33:22 2012
New Revision: 1406768
URL: http://svn.apache.org/viewvc?rev=1406768&view=rev
Log:
SLING-2530 : Implement CRUD based on resources
Modified:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/QueriableResourceProvider.java
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/RootResourceProviderEntry.java
Modified:
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=1406768&r1=1406767&r2=1406768&view=diff
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/QueriableResourceProvider.java
(original)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/QueriableResourceProvider.java
Wed Nov 7 19:33:22 2012
@@ -19,7 +19,6 @@
package org.apache.sling.api.resource;
import java.util.Iterator;
-import java.util.Map;
/**
@@ -47,7 +46,7 @@ public interface QueriableResourceProvid
* <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
+ * 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.
@@ -60,7 +59,7 @@ public interface QueriableResourceProvid
* @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 occurrs querying
+ * @throws org.apache.sling.api.SlingException If an error occurs querying
* for the resources.
* @throws IllegalStateException if this resource provider has already been
* closed.
@@ -73,7 +72,7 @@ public interface QueriableResourceProvid
* <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
+ * 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
@@ -89,10 +88,10 @@ public interface QueriableResourceProvid
* @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 occurrs querying
+ * @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<Map<String, Object>> queryResources(ResourceResolver resolver,
String query, String language);
+ Iterator<ValueMap> queryResources(ResourceResolver resolver, String query,
String language);
}
Modified:
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java?rev=1406768&r1=1406767&r2=1406768&view=diff
==============================================================================
---
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java
(original)
+++
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java
Wed Nov 7 19:33:22 2012
@@ -49,6 +49,8 @@ import org.apache.sling.api.resource.Res
import org.apache.sling.api.resource.ResourceProvider;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ResourceResolverFactory;
+import org.apache.sling.api.resource.ValueMap;
+import org.apache.sling.api.wrappers.ValueMapDecorator;
import org.apache.sling.jcr.resource.JcrResourceUtil;
import org.apache.sling.jcr.resource.internal.JcrModifiableValueMap;
import org.slf4j.Logger;
@@ -257,7 +259,7 @@ public class JcrResourceProvider
/**
* @see
org.apache.sling.api.resource.QueriableResourceProvider#queryResources(ResourceResolver,
java.lang.String, java.lang.String)
*/
- public Iterator<Map<String, Object>> queryResources(final ResourceResolver
resolver, final String query, final String language) {
+ public Iterator<ValueMap> queryResources(final ResourceResolver resolver,
final String query, final String language) {
checkClosed();
final String queryLanguage = isSupportedQueryLanguage(language) ?
language : DEFAULT_QUERY_LANGUAGE;
@@ -267,13 +269,13 @@ public class JcrResourceProvider
queryLanguage);
final String[] colNames = result.getColumnNames();
final RowIterator rows = result.getRows();
- return new Iterator<Map<String, Object>>() {
+ return new Iterator<ValueMap>() {
public boolean hasNext() {
return rows.hasNext();
};
- public Map<String, Object> next() {
- Map<String, Object> row = new HashMap<String, Object>();
+ public ValueMap next() {
+ final Map<String, Object> row = new HashMap<String,
Object>();
try {
Row jcrRow = rows.nextRow();
boolean didPath = false;
@@ -305,7 +307,7 @@ public class JcrResourceProvider
"queryResources$next: Problem accessing row
values",
re);
}
- return row;
+ return new ValueMapDecorator(row);
}
public void remove() {
Modified:
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/RootResourceProviderEntry.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/RootResourceProviderEntry.java?rev=1406768&r1=1406767&r2=1406768&view=diff
==============================================================================
---
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/RootResourceProviderEntry.java
(original)
+++
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/RootResourceProviderEntry.java
Wed Nov 7 19:33:22 2012
@@ -40,6 +40,7 @@ import org.apache.sling.api.resource.Res
import org.apache.sling.api.resource.ResourceProviderFactory;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ResourceResolverFactory;
+import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.commons.osgi.PropertiesUtil;
import org.apache.sling.resourceresolver.impl.helper.ResourceResolverContext;
import org.apache.sling.resourceresolver.impl.helper.SortedProviderList;
@@ -198,12 +199,12 @@ public class RootResourceProviderEntry e
});
return new Iterator<Map<String, Object>>() {
- private Map<String, Object> nextObject = this.seek();
+ private ValueMap nextObject = this.seek();
- private Iterator<Map<String, Object>> nextResourceIter;
+ private Iterator<ValueMap> nextResourceIter;
- private Map<String, Object> seek() {
- Map<String, Object> result = null;
+ private ValueMap seek() {
+ ValueMap result = null;
if ( nextResourceIter == null || !nextResourceIter.hasNext() )
{
nextResourceIter = null;
while ( i.hasNext() && nextResourceIter == null ) {
@@ -232,11 +233,11 @@ public class RootResourceProviderEntry e
/**
* @see java.util.Iterator#next()
*/
- public Map<String, Object> next() {
+ public ValueMap next() {
if ( this.nextObject == null ) {
throw new NoSuchElementException();
}
- final Map<String, Object> result = this.nextObject;
+ final ValueMap result = this.nextObject;
this.nextObject = this.seek();
return result;
}