Author: cziegeler
Date: Wed Sep 26 09:51:49 2012
New Revision: 1390359
URL: http://svn.apache.org/viewvc?rev=1390359&view=rev
Log:
SLING-2530 : Implement CRUD based on resources
Modified:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ModifyingResourceProvider.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/ResourceResolverImpl.java
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/ResourceResolverContext.java
Modified:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ModifyingResourceProvider.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ModifyingResourceProvider.java?rev=1390359&r1=1390358&r2=1390359&view=diff
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ModifyingResourceProvider.java
(original)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ModifyingResourceProvider.java
Wed Sep 26 09:51:49 2012
@@ -28,8 +28,8 @@ import java.util.Map;
* A modifying resource provider allows to create, update, and delete
* resources. Update is handled through {@link ModifiableValueMap}.
*
- * All changes should be kept in a transient store until {@link #commit()}
- * is called. {@link #revert()} discards all transient changes.
+ * All changes should be kept in a transient store until {@link
#commit(ResourceResolver)}
+ * is called. {@link #revert(ResourceResolver)} discards all transient changes.
*
* If the modifying resource provider needs to clean up resources when it
* is discarded like removing objects from the transient state which are
@@ -46,7 +46,7 @@ public interface ModifyingResourceProvid
/**
* Create a new resource at the given path.
* The new resource is put into the transient space of this provider
- * until {@link #commit()} is called.
+ * until {@link #commit(ResourceResolver)} is called.
*
* @param resolver The current resource resolver.
* @param path The resource path.
@@ -61,7 +61,7 @@ public interface ModifyingResourceProvid
/**
* Delete the resource at the given path.
* This change is kept in the transient space of this provider
- * until {@link #commit()} is called.
+ * until {@link #commit(ResourceResolver)} is called.
*
* @param resolver The current resource resolver.
* @param path The resource path.
@@ -73,19 +73,25 @@ public interface ModifyingResourceProvid
/**
* Revert all transient changes: create, delete and updates.
+ *
+ * @param resolver The current resource resolver.
*/
- void revert();
+ void revert(ResourceResolver resolver);
/**
* Commit all transient changes: create, delete and updates
*
+ * @param resolver The current resource resolver.
+ *
* @throws PersistenceException If anything fails
*/
- void commit()
+ void commit(ResourceResolver resolver)
throws PersistenceException;
/**
* Are there any transient changes?
+ *
+ * @param resolver The current resource resolver.
*/
- boolean hasChanges();
+ boolean hasChanges(ResourceResolver resolver);
}
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=1390359&r1=1390358&r2=1390359&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 Sep 26 09:51:49 2012
@@ -438,9 +438,9 @@ public class JcrResourceProvider
}
/**
- * @see org.apache.sling.api.resource.ModifyingResourceProvider#revert()
+ * @see
org.apache.sling.api.resource.ModifyingResourceProvider#revert(ResourceResolver)
*/
- public void revert() {
+ public void revert(final ResourceResolver resolver) {
try {
this.session.refresh(false);
} catch (final RepositoryException ignore) {
@@ -449,9 +449,9 @@ public class JcrResourceProvider
}
/**
- * @see org.apache.sling.api.resource.ModifyingResourceProvider#commit()
+ * @see
org.apache.sling.api.resource.ModifyingResourceProvider#commit(ResourceResolver)
*/
- public void commit() throws PersistenceException {
+ public void commit(final ResourceResolver resolver) throws
PersistenceException {
try {
this.session.save();
} catch (final RepositoryException e) {
@@ -460,9 +460,9 @@ public class JcrResourceProvider
}
/**
- * @see
org.apache.sling.api.resource.ModifyingResourceProvider#hasChanges()
+ * @see
org.apache.sling.api.resource.ModifyingResourceProvider#hasChanges(ResourceResolver)
*/
- public boolean hasChanges() {
+ public boolean hasChanges(final ResourceResolver resolver) {
try {
return this.session.hasPendingChanges();
} catch (final RepositoryException ignore) {
Modified:
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java?rev=1390359&r1=1390358&r2=1390359&view=diff
==============================================================================
---
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java
(original)
+++
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java
Wed Sep 26 09:51:49 2012
@@ -863,7 +863,7 @@ public class ResourceResolverImpl extend
// we do not have a child with the exact name, so we look for
// a child, whose alias matches the childName
-
+
final Map<String, String> aliases =
factory.getMapEntries().getAliasMap(parent.getPath());
if (aliases != null) {
if (aliases.containsKey(childName)) {
@@ -1043,20 +1043,20 @@ public class ResourceResolverImpl extend
* @see org.apache.sling.api.resource.ResourceResolver#revert()
*/
public void revert() {
- this.context.revert();
+ this.context.revert(this);
}
/**
* @see org.apache.sling.api.resource.ResourceResolver#commit()
*/
public void commit() throws PersistenceException {
- this.context.commit();
+ this.context.commit(this);
}
/**
* @see org.apache.sling.api.resource.ResourceResolver#hasChanges()
*/
public boolean hasChanges() {
- return this.context.hasChanges();
+ return this.context.hasChanges(this);
}
}
Modified:
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/ResourceResolverContext.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/ResourceResolverContext.java?rev=1390359&r1=1390358&r2=1390359&view=diff
==============================================================================
---
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/ResourceResolverContext.java
(original)
+++
sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/ResourceResolverContext.java
Wed Sep 26 09:51:49 2012
@@ -26,6 +26,7 @@ import org.apache.sling.api.resource.Dyn
import org.apache.sling.api.resource.ModifyingResourceProvider;
import org.apache.sling.api.resource.PersistenceException;
import org.apache.sling.api.resource.ResourceProvider;
+import org.apache.sling.api.resource.ResourceResolver;
/**
* This class keeps track of the used resource providers for a
@@ -125,27 +126,27 @@ public class ResourceResolverContext {
/**
* Revert all transient changes.
*/
- public void revert() {
+ public void revert(final ResourceResolver resolver) {
for(final ModifyingResourceProvider provider :
this.modifyingProviders) {
- provider.revert();
+ provider.revert(resolver);
}
}
/**
* Commit all transient changes
*/
- public void commit() throws PersistenceException {
+ public void commit(final ResourceResolver resolver) throws
PersistenceException {
for(final ModifyingResourceProvider provider :
this.modifyingProviders) {
- provider.commit();
+ provider.commit(resolver);
}
}
/**
* Do we have changes?
*/
- public boolean hasChanges() {
+ public boolean hasChanges(final ResourceResolver resolver) {
for(final ModifyingResourceProvider provider :
this.modifyingProviders) {
- if ( provider.hasChanges() ) {
+ if ( provider.hasChanges(resolver) ) {
return true;
}
}