You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2017/03/29 12:40:25 UTC
svn commit: r1789349 -
/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/
Author: cziegeler
Date: Wed Mar 29 12:40:25 2017
New Revision: 1789349
URL: http://svn.apache.org/viewvc?rev=1789349&view=rev
Log:
SLING-6723 : Make dependency to javax.jcr, jcr.contentloader and jcr.api optional
Modified:
sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCopyMoveOperation.java
sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCreateOperation.java
sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractPostOperation.java
sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/CheckinOperation.java
sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/CheckoutOperation.java
sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/DeleteOperation.java
sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/JCRSupport.java
sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/JCRSupportImpl.java
sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/ModifyOperation.java
sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/MoveOperation.java
Modified: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCopyMoveOperation.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCopyMoveOperation.java?rev=1789349&r1=1789348&r2=1789349&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCopyMoveOperation.java (original)
+++ sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCopyMoveOperation.java Wed Mar 29 12:40:25 2017
@@ -19,7 +19,6 @@ package org.apache.sling.servlets.post.i
import java.util.Iterator;
import java.util.List;
-import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.servlet.http.HttpServletResponse;
@@ -70,7 +69,7 @@ abstract class AbstractCopyMoveOperation
dest = ResourceUtil.normalize(dest);
// destination parent and name
- String dstParent = trailingSlash ? dest : ResourceUtil.getParent(dest);
+ final String dstParent = trailingSlash ? dest : ResourceUtil.getParent(dest);
// delete destination if already exists
if (!trailingSlash && session.itemExists(dest)) {
@@ -83,7 +82,8 @@ abstract class AbstractCopyMoveOperation
+ dest + ": destination exists");
return;
} else {
- checkoutIfNecessary(session.getItem(dest).getParent(), changes, versioningConfiguration);
+ checkoutIfNecessary(request.getResourceResolver().getResource(dstParent),
+ changes, versioningConfiguration);
}
} else {
@@ -91,8 +91,9 @@ abstract class AbstractCopyMoveOperation
// check if path to destination exists and create it, but only
// if it's a descendant of the current node
if (!dstParent.equals("")) {
- if (session.itemExists(dstParent)) {
- checkoutIfNecessary((Node) session.getItem(dstParent), changes, versioningConfiguration);
+ final Resource parentResource = request.getResourceResolver().getResource(dstParent);
+ if (parentResource != null ) {
+ checkoutIfNecessary(parentResource, changes, versioningConfiguration);
} else {
response.setStatus(HttpServletResponse.SC_PRECONDITION_FAILED,
"Cannot " + getOperationName() + " " + resource + " to "
@@ -167,6 +168,7 @@ abstract class AbstractCopyMoveOperation
protected abstract Resource execute(List<Modification> changes, Resource source,
String destParent,
String destName,
- VersioningConfiguration versioningConfiguration) throws RepositoryException;
+ VersioningConfiguration versioningConfiguration)
+ throws PersistenceException, RepositoryException;
}
Modified: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCreateOperation.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCreateOperation.java?rev=1789349&r1=1789348&r2=1789349&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCreateOperation.java (original)
+++ sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCreateOperation.java Wed Mar 29 12:40:25 2017
@@ -18,6 +18,7 @@
package org.apache.sling.servlets.post.impl.operations;
import java.util.Arrays;
+import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
@@ -88,6 +89,52 @@ abstract class AbstractCreateOperation e
}
/**
+ * Returns true if any of the request parameters starts with
+ * {@link SlingPostConstants#ITEM_PREFIX_RELATIVE_CURRENT <code>./</code>}.
+ * In this case only parameters starting with either of the prefixes
+ * {@link SlingPostConstants#ITEM_PREFIX_RELATIVE_CURRENT <code>./</code>},
+ * {@link SlingPostConstants#ITEM_PREFIX_RELATIVE_PARENT <code>../</code>}
+ * and {@link SlingPostConstants#ITEM_PREFIX_ABSOLUTE <code>/</code>} are
+ * considered as providing content to be stored. Otherwise all parameters
+ * not starting with the command prefix <code>:</code> are considered as
+ * parameters to be stored.
+ *
+ * @param request The http request
+ * @return If a prefix is required.
+ */
+ private final boolean requireItemPathPrefix(
+ SlingHttpServletRequest request) {
+
+ boolean requirePrefix = false;
+
+ Enumeration<?> names = request.getParameterNames();
+ while (names.hasMoreElements() && !requirePrefix) {
+ String name = (String) names.nextElement();
+ requirePrefix = name.startsWith(SlingPostConstants.ITEM_PREFIX_RELATIVE_CURRENT);
+ }
+
+ return requirePrefix;
+ }
+
+
+
+ /**
+ * Returns <code>true</code> if the <code>name</code> starts with either
+ * of the prefixes
+ * {@link SlingPostConstants#ITEM_PREFIX_RELATIVE_CURRENT <code>./</code>},
+ * {@link SlingPostConstants#ITEM_PREFIX_RELATIVE_PARENT <code>../</code>}
+ * and {@link SlingPostConstants#ITEM_PREFIX_ABSOLUTE <code>/</code>}.
+ *
+ * @param name The name
+ * @return {@code true} if the name has a prefix
+ */
+ private boolean hasItemPathPrefix(String name) {
+ return name.startsWith(SlingPostConstants.ITEM_PREFIX_ABSOLUTE)
+ || name.startsWith(SlingPostConstants.ITEM_PREFIX_RELATIVE_CURRENT)
+ || name.startsWith(SlingPostConstants.ITEM_PREFIX_RELATIVE_PARENT);
+ }
+
+ /**
* Create node(s) according to current request
*
* @throws RepositoryException if a repository error occurs
@@ -117,7 +164,7 @@ abstract class AbstractCreateOperation e
final Map<String, RequestProperty> reqProperties,
final List<Modification> changes,
final VersioningConfiguration versioningConfiguration)
- throws RepositoryException {
+ throws PersistenceException, RepositoryException {
final String nodeType = getPrimaryType(reqProperties, path);
if (nodeType != null) {
final Resource rsrc = resolver.getResource(path);
@@ -127,7 +174,7 @@ abstract class AbstractCreateOperation e
final boolean wasVersionable = (node == null ? false : isVersionable(node));
if ( node != null ) {
- checkoutIfNecessary(node, changes, versioningConfiguration);
+ checkoutIfNecessary(rsrc, changes, versioningConfiguration);
node.setPrimaryType(nodeType);
} else {
mvm.put("jcr:primaryType", nodeType);
@@ -151,7 +198,7 @@ abstract class AbstractCreateOperation e
final Map<String, RequestProperty> reqProperties,
final List<Modification> changes,
final VersioningConfiguration versioningConfiguration)
- throws RepositoryException {
+ throws PersistenceException, RepositoryException {
final String[] mixins = getMixinTypes(reqProperties, path);
if (mixins != null) {
@@ -165,7 +212,7 @@ abstract class AbstractCreateOperation e
// clear existing mixins first
if ( node != null ) {
- checkoutIfNecessary(node, changes, versioningConfiguration);
+ checkoutIfNecessary(rsrc, changes, versioningConfiguration);
for (NodeType mixin : node.getMixinNodeTypes()) {
String mixinName = mixin.getName();
if (!newMixins.remove(mixinName)) {
@@ -563,10 +610,7 @@ abstract class AbstractCreateOperation e
// check for node type
final String nodeType = getPrimaryType(reqProperties, tmpPath);
- final Node node = resource.adaptTo(Node.class);
- if ( node != null ) {
- checkoutIfNecessary(node, changes, versioningConfiguration);
- }
+ checkoutIfNecessary(resource, changes, versioningConfiguration);
try {
final Map<String, Object> props = new HashMap<>();
Modified: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractPostOperation.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractPostOperation.java?rev=1789349&r1=1789348&r2=1789349&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractPostOperation.java (original)
+++ sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractPostOperation.java Wed Mar 29 12:40:25 2017
@@ -17,7 +17,6 @@
package org.apache.sling.servlets.post.impl.operations;
import java.util.ArrayList;
-import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -169,7 +168,7 @@ public abstract class AbstractPostOperat
if (!isSkipCheckin(request)) {
// now do the checkins
for(String checkinPath : nodesToCheckin) {
- if (checkin(request.getResourceResolver(), checkinPath)) {
+ if (this.jcrSsupport.checkin(request.getResourceResolver().getResource(checkinPath))) {
response.onChange("checkin", checkinPath);
}
}
@@ -262,7 +261,7 @@ public abstract class AbstractPostOperat
* <code>null</code> if the parameter is not set in the request.
*/
protected Iterator<Resource> getApplyToResources(
- SlingHttpServletRequest request) {
+ final SlingHttpServletRequest request) {
final String[] applyTo = request.getParameterValues(SlingPostConstants.RP_APPLY_TO);
if (applyTo == null) {
@@ -280,8 +279,8 @@ public abstract class AbstractPostOperat
* @param path the path to externalize
* @return the url
*/
- protected final String externalizePath(SlingHttpServletRequest request,
- String path) {
+ protected final String externalizePath(final SlingHttpServletRequest request,
+ final String path) {
StringBuilder ret = new StringBuilder();
ret.append(SlingRequestPaths.getContextPath(request));
ret.append(request.getResourceResolver().map(path));
@@ -299,22 +298,7 @@ public abstract class AbstractPostOperat
}
/**
- * Resolves the given path with respect to the current root path.
- *
- * @param absPath The absolute base path
- * @param relPath the path to resolve
- * @return the given path if it starts with a '/'; a resolved path
- * otherwise.
- */
- protected final String resolvePath(String absPath, String relPath) {
- if (relPath.startsWith("/")) {
- return relPath;
- }
- return absPath + "/" + relPath;
- }
-
- /**
- * Returns the path of the resource of the request as the item path.
+ * Returns the path of the resource of the request as the resource path.
* <p>
* This method may be overwritten by extension if the operation has
* different requirements on path processing.
@@ -325,51 +309,7 @@ public abstract class AbstractPostOperat
return request.getResource().getPath();
}
- /**
- * Returns true if any of the request parameters starts with
- * {@link SlingPostConstants#ITEM_PREFIX_RELATIVE_CURRENT <code>./</code>}.
- * In this case only parameters starting with either of the prefixes
- * {@link SlingPostConstants#ITEM_PREFIX_RELATIVE_CURRENT <code>./</code>},
- * {@link SlingPostConstants#ITEM_PREFIX_RELATIVE_PARENT <code>../</code>}
- * and {@link SlingPostConstants#ITEM_PREFIX_ABSOLUTE <code>/</code>} are
- * considered as providing content to be stored. Otherwise all parameters
- * not starting with the command prefix <code>:</code> are considered as
- * parameters to be stored.
- *
- * @param request The http request
- * @return If a prefix is required.
- */
- protected final boolean requireItemPathPrefix(
- SlingHttpServletRequest request) {
-
- boolean requirePrefix = false;
-
- Enumeration<?> names = request.getParameterNames();
- while (names.hasMoreElements() && !requirePrefix) {
- String name = (String) names.nextElement();
- requirePrefix = name.startsWith(SlingPostConstants.ITEM_PREFIX_RELATIVE_CURRENT);
- }
-
- return requirePrefix;
- }
-
- /**
- * Returns <code>true</code> if the <code>name</code> starts with either
- * of the prefixes
- * {@link SlingPostConstants#ITEM_PREFIX_RELATIVE_CURRENT <code>./</code>},
- * {@link SlingPostConstants#ITEM_PREFIX_RELATIVE_PARENT <code>../</code>}
- * and {@link SlingPostConstants#ITEM_PREFIX_ABSOLUTE <code>/</code>}.
- *
- * @param name The name
- * @return {@code true} if the name has a prefix
- */
- protected boolean hasItemPathPrefix(String name) {
- return name.startsWith(SlingPostConstants.ITEM_PREFIX_ABSOLUTE)
- || name.startsWith(SlingPostConstants.ITEM_PREFIX_RELATIVE_CURRENT)
- || name.startsWith(SlingPostConstants.ITEM_PREFIX_RELATIVE_PARENT);
- }
-
- protected Node findVersionableAncestor(Node node) throws RepositoryException {
+ private Node findVersionableAncestor(Node node) throws RepositoryException {
if (isVersionable(node)) {
return node;
}
@@ -386,31 +326,28 @@ public abstract class AbstractPostOperat
return node.isNodeType("mix:versionable");
}
- protected void checkoutIfNecessary(Node node, List<Modification> changes,
- VersioningConfiguration versioningConfiguration) throws RepositoryException {
- if (versioningConfiguration.isAutoCheckout()) {
- Node versionableNode = findVersionableAncestor(node);
- if (versionableNode != null) {
- if (!versionableNode.isCheckedOut()) {
- versionableNode.checkout();
- changes.add(Modification.onCheckout(versionableNode.getPath()));
+ protected void checkoutIfNecessary(final Resource resource,
+ final List<Modification> changes,
+ final VersioningConfiguration versioningConfiguration)
+ throws PersistenceException {
+ if (resource != null && versioningConfiguration.isAutoCheckout()) {
+ final Node node = resource.adaptTo(Node.class);
+ if ( node != null ) {
+ try {
+ Node versionableNode = findVersionableAncestor(node);
+ if (versionableNode != null) {
+ if (!versionableNode.isCheckedOut()) {
+ versionableNode.getSession().getWorkspace().getVersionManager().checkout(versionableNode.getPath());
+ changes.add(Modification.onCheckout(versionableNode.getPath()));
+ }
+ }
+ } catch ( final RepositoryException re) {
+ throw new PersistenceException(re.getMessage(), re);
}
}
}
}
- private boolean checkin(final ResourceResolver resolver, final String path) throws RepositoryException {
- final Resource rsrc = resolver.getResource(path);
- final Node node = (rsrc == null ? null : rsrc.adaptTo(Node.class));
- if (node != null) {
- if (node.isCheckedOut() && isVersionable(node)) {
- node.checkin();
- return true;
- }
- }
- return false;
- }
-
private static class ApplyToIterator implements Iterator<Resource> {
private final ResourceResolver resolver;
Modified: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/CheckinOperation.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/CheckinOperation.java?rev=1789349&r1=1789348&r2=1789349&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/CheckinOperation.java (original)
+++ sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/CheckinOperation.java Wed Mar 29 12:40:25 2017
@@ -51,7 +51,7 @@ public class CheckinOperation extends Ab
return;
}
- node.checkin();
+ node.getSession().getWorkspace().getVersionManager().checkin(node.getPath());
changes.add(Modification.onCheckin(resource.getPath()));
} else {
@@ -60,7 +60,7 @@ public class CheckinOperation extends Ab
Resource resource = res.next();
Node node = resource.adaptTo(Node.class);
if (node != null) {
- node.checkin();
+ node.getSession().getWorkspace().getVersionManager().checkin(node.getPath());
changes.add(Modification.onCheckin(resource.getPath()));
}
}
Modified: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/CheckoutOperation.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/CheckoutOperation.java?rev=1789349&r1=1789348&r2=1789349&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/CheckoutOperation.java (original)
+++ sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/CheckoutOperation.java Wed Mar 29 12:40:25 2017
@@ -50,7 +50,7 @@ public class CheckoutOperation extends A
return;
}
- node.checkout();
+ node.getSession().getWorkspace().getVersionManager().checkout(node.getPath());
changes.add(Modification.onCheckout(resource.getPath()));
} else {
@@ -59,7 +59,7 @@ public class CheckoutOperation extends A
Resource resource = res.next();
Node node = resource.adaptTo(Node.class);
if (node != null) {
- node.checkout();
+ node.getSession().getWorkspace().getVersionManager().checkout(node.getPath());
changes.add(Modification.onCheckout(resource.getPath()));
}
}
Modified: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/DeleteOperation.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/DeleteOperation.java?rev=1789349&r1=1789348&r2=1789349&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/DeleteOperation.java (original)
+++ sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/DeleteOperation.java Wed Mar 29 12:40:25 2017
@@ -94,25 +94,20 @@ public class DeleteOperation extends Abs
*/
private void deleteResource(final Resource resource,
final List<Modification> changes,
- VersioningConfiguration versioningConfiguration,
- boolean deleteChunks) throws RepositoryException {
- final Node node = resource.adaptTo(Node.class);
- if (node != null) {
- if (deleteChunks) {
+ final VersioningConfiguration versioningConfiguration,
+ final boolean deleteChunks)
+ throws PersistenceException, RepositoryException {
+ if (deleteChunks) {
+ final Node node = resource.adaptTo(Node.class);
+ if (node != null) {
uploadHandler.deleteChunks(node);
- } else {
- checkoutIfNecessary(node.getParent(), changes,
- versioningConfiguration);
}
+ } else {
+ checkoutIfNecessary(resource.getParent(), changes,
+ versioningConfiguration);
}
- try {
- resource.getResourceResolver().delete(resource);
- } catch (final PersistenceException pe) {
- if (pe.getCause() instanceof RepositoryException) {
- throw (RepositoryException) pe.getCause();
- }
- throw new RepositoryException(pe);
- }
+
+ resource.getResourceResolver().delete(resource);
changes.add(Modification.onDeleted(resource.getPath()));
}
Modified: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/JCRSupport.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/JCRSupport.java?rev=1789349&r1=1789348&r2=1789349&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/JCRSupport.java (original)
+++ sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/JCRSupport.java Wed Mar 29 12:40:25 2017
@@ -54,4 +54,12 @@ public class JCRSupport {
((JCRSupportImpl)supportImpl).orderNode(request, resource, changes);
}
}
+
+ public boolean checkin(final Resource rsrc)
+ throws PersistenceException {
+ if ( rsrc != null && supportImpl != null ) {
+ return ((JCRSupportImpl)supportImpl).checkin(rsrc);
+ }
+ return false;
+ }
}
Modified: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/JCRSupportImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/JCRSupportImpl.java?rev=1789349&r1=1789348&r2=1789349&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/JCRSupportImpl.java (original)
+++ sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/JCRSupportImpl.java Wed Mar 29 12:40:25 2017
@@ -140,4 +140,24 @@ public class JCRSupportImpl {
throw new PersistenceException("Unable to order resource", re, resource.getPath(), null);
}
}
+
+ private boolean isVersionable(final Node node) throws RepositoryException {
+ return node.isNodeType("mix:versionable");
+ }
+
+ public boolean checkin(final Resource rsrc)
+ throws PersistenceException {
+ final Node node = rsrc.adaptTo(Node.class);
+ if (node != null) {
+ try {
+ if (node.isCheckedOut() && isVersionable(node)) {
+ node.getSession().getWorkspace().getVersionManager().checkin(node.getPath());
+ return true;
+ }
+ } catch ( final RepositoryException re) {
+ throw new PersistenceException(re.getMessage(), re, rsrc.getPath(), null);
+ }
+ }
+ return false;
+ }
}
Modified: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/ModifyOperation.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/ModifyOperation.java?rev=1789349&r1=1789348&r2=1789349&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/ModifyOperation.java (original)
+++ sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/ModifyOperation.java Wed Mar 29 12:40:25 2017
@@ -249,17 +249,14 @@ public class ModifyOperation extends Abs
// first, otherwise ensure the parent location
if (session.itemExists(propPath)) {
Node parent = session.getItem(propPath).getParent();
- checkoutIfNecessary(parent, changes, versioningConfiguration);
+ checkoutIfNecessary(resolver.getResource(parent.getPath()), changes, versioningConfiguration);
session.getItem(propPath).remove();
changes.add(Modification.onDeleted(propPath));
} else {
Resource parent = deepGetOrCreateNode(resolver, property.getParentPath(),
reqProperties, changes, versioningConfiguration);
- final Node node = parent.adaptTo(Node.class);
- if ( node != null ) {
- checkoutIfNecessary(node, changes, versioningConfiguration);
- }
+ checkoutIfNecessary(parent, changes, versioningConfiguration);
}
// move through the session and record operation
@@ -268,12 +265,12 @@ public class ModifyOperation extends Abs
// node move/copy through session
if (isMove) {
- checkoutIfNecessary(sourceItem.getParent(), changes, versioningConfiguration);
+ checkoutIfNecessary(resolver.getResource(sourceItem.getParent().getPath()), changes, versioningConfiguration);
session.move(source, propPath);
} else {
Node sourceNode = (Node) sourceItem;
Node destParent = (Node) session.getItem(property.getParentPath());
- checkoutIfNecessary(destParent, changes, versioningConfiguration);
+ checkoutIfNecessary(resolver.getResource(destParent.getPath()), changes, versioningConfiguration);
CopyOperation.copy(sourceNode, destParent,
property.getName());
}
@@ -285,12 +282,12 @@ public class ModifyOperation extends Abs
// create destination property
Node destParent = (Node) session.getItem(property.getParentPath());
- checkoutIfNecessary(destParent, changes, versioningConfiguration);
+ checkoutIfNecessary(resolver.getResource(destParent.getPath()), changes, versioningConfiguration);
CopyOperation.copy(sourceProperty, destParent, null);
// remove source property (if not just copying)
if (isMove) {
- checkoutIfNecessary(sourceProperty.getParent(), changes, versioningConfiguration);
+ checkoutIfNecessary(resolver.getResource(sourceProperty.getParent().getPath()), changes, versioningConfiguration);
sourceProperty.remove();
}
}
@@ -337,7 +334,7 @@ public class ModifyOperation extends Abs
final Node parentNode = parent.adaptTo(Node.class);
if ( parentNode != null ) {
- checkoutIfNecessary(parentNode, changes, versioningConfiguration);
+ checkoutIfNecessary(parent, changes, versioningConfiguration);
if (property.getName().equals("jcr:mixinTypes")) {
@@ -388,10 +385,7 @@ public class ModifyOperation extends Abs
final Resource parent = deepGetOrCreateNode(resolver,
prop.getParentPath(), reqProperties, changes, versioningConfiguration);
- final Node parentNode = parent.adaptTo(Node.class);
- if ( parentNode != null ) {
- checkoutIfNecessary(parentNode, changes, versioningConfiguration);
- }
+ checkoutIfNecessary(parent, changes, versioningConfiguration);
// skip jcr special properties
if (prop.getName().equals("jcr:primaryType")
Modified: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/MoveOperation.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/MoveOperation.java?rev=1789349&r1=1789348&r2=1789349&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/MoveOperation.java (original)
+++ sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/MoveOperation.java Wed Mar 29 12:40:25 2017
@@ -22,6 +22,7 @@ import javax.jcr.Item;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
+import org.apache.sling.api.resource.PersistenceException;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.servlets.post.Modification;
import org.apache.sling.servlets.post.VersioningConfiguration;
@@ -42,7 +43,7 @@ public class MoveOperation extends Abstr
protected Resource execute(List<Modification> changes, Resource source,
String destParent, String destName,
VersioningConfiguration versioningConfiguration)
- throws RepositoryException {
+ throws PersistenceException, RepositoryException {
// ensure we have an item underlying the request's resource
Item item = source.adaptTo(Item.class);
if (item == null) {
@@ -60,7 +61,7 @@ public class MoveOperation extends Abstr
String destPath = destParent + "/" + destName;
Session session = item.getSession();
- checkoutIfNecessary(item.getParent(), changes, versioningConfiguration);
+ checkoutIfNecessary(source.getParent(), changes, versioningConfiguration);
if (session.itemExists(destPath)) {
session.getItem(destPath).remove();