This is an automated email from the ASF dual-hosted git repository. kwin pushed a commit to branch feature/use-sling-reordering-api in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-servlets-post.git
commit 946256f06838e4f5005f5599d8361922b3d836c2 Author: Konrad Windszus <[email protected]> AuthorDate: Wed Oct 27 20:40:06 2021 +0200 SLING-7975 use resource reorder API --- pom.xml | 2 +- .../sling/servlets/post/SlingPostConstants.java | 8 +- .../servlets/post/impl/helper/JCRSupport.java | 8 -- .../servlets/post/impl/helper/JCRSupportImpl.java | 115 --------------------- .../impl/operations/AbstractCopyMoveOperation.java | 6 +- .../impl/operations/AbstractCreateOperation.java | 14 +-- .../impl/operations/AbstractPostOperation.java | 112 +++++++++++++++++++- .../post/impl/operations/CopyOperation.java | 6 +- .../post/impl/operations/DeleteOperation.java | 2 +- .../post/impl/operations/ModifyOperation.java | 32 +++--- .../post/impl/operations/MoveOperation.java | 8 +- 11 files changed, 148 insertions(+), 165 deletions(-) diff --git a/pom.xml b/pom.xml index 0452518..12328b6 100644 --- a/pom.xml +++ b/pom.xml @@ -143,7 +143,7 @@ <dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.api</artifactId> - <version>2.23.4</version> + <version>2.23.7-SNAPSHOT</version> <scope>provided</scope> </dependency> <dependency> diff --git a/src/main/java/org/apache/sling/servlets/post/SlingPostConstants.java b/src/main/java/org/apache/sling/servlets/post/SlingPostConstants.java index 2b65cbf..e6a9f92 100644 --- a/src/main/java/org/apache/sling/servlets/post/SlingPostConstants.java +++ b/src/main/java/org/apache/sling/servlets/post/SlingPostConstants.java @@ -236,28 +236,28 @@ public interface SlingPostConstants { /** * Possible value of the {@link #RP_ORDER} parameter indicating that the - * node by moved to the first position amongst its sibblings (value is + * node by moved to the first position amongst its siblings (value is * "first"). */ public static final String ORDER_FIRST = "first"; /** * Possible value of the {@link #RP_ORDER} parameter indicating that the - * node by moved immediately before the sibbling whose name is contained in + * node by moved immediately before the sibling whose name is contained in * the {@link #RP_ORDER} parameter (value is "before "). */ public static final String ORDER_BEFORE = "before "; /** * Possible value of the {@link #RP_ORDER} parameter indicating that the - * node by moved immediately after the sibbling whose name is contained in + * node by moved immediately after the sibling whose name is contained in * the {@link #RP_ORDER} parameter (value is "after "). */ public static final String ORDER_AFTER = "after "; /** * Possible value of the {@link #RP_ORDER} parameter indicating that the - * node by moved to the last position amongst its sibblings (value is + * node by moved to the last position amongst its siblings (value is * "last"). */ public static final String ORDER_LAST = "last"; diff --git a/src/main/java/org/apache/sling/servlets/post/impl/helper/JCRSupport.java b/src/main/java/org/apache/sling/servlets/post/impl/helper/JCRSupport.java index ef0c5b6..4e3994a 100644 --- a/src/main/java/org/apache/sling/servlets/post/impl/helper/JCRSupport.java +++ b/src/main/java/org/apache/sling/servlets/post/impl/helper/JCRSupport.java @@ -49,14 +49,6 @@ public class JCRSupport { this.supportImpl = impl; } - public void orderNode(final SlingHttpServletRequest request, - final Resource resource, - final List<Modification> changes) throws PersistenceException { - if ( supportImpl != null ) { - ((JCRSupportImpl)supportImpl).orderNode(request, resource, changes); - } - } - public boolean checkin(final Resource rsrc) throws PersistenceException { if ( rsrc != null && supportImpl != null ) { diff --git a/src/main/java/org/apache/sling/servlets/post/impl/helper/JCRSupportImpl.java b/src/main/java/org/apache/sling/servlets/post/impl/helper/JCRSupportImpl.java index 7d0eb3d..6cf7bff 100644 --- a/src/main/java/org/apache/sling/servlets/post/impl/helper/JCRSupportImpl.java +++ b/src/main/java/org/apache/sling/servlets/post/impl/helper/JCRSupportImpl.java @@ -45,131 +45,16 @@ import javax.jcr.nodetype.PropertyDefinition; import javax.jcr.version.VersionException; import org.apache.jackrabbit.JcrConstants; -import org.apache.sling.api.SlingHttpServletRequest; 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.servlets.post.Modification; -import org.apache.sling.servlets.post.SlingPostConstants; import org.apache.sling.servlets.post.VersioningConfiguration; import org.apache.sling.servlets.post.exceptions.PreconditionViolatedPersistenceException; import org.apache.sling.servlets.post.exceptions.TemporaryPersistenceException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class JCRSupportImpl { - /** Logger. */ - private final Logger logger = LoggerFactory.getLogger(this.getClass()); - - /** - * Orders the given node according to the specified command. The following - * syntax is supported: <xmp> | first | before all child nodes | before A | - * before child node A | after A | after child node A | last | after all - * nodes | N | at a specific position, N being an integer </xmp> - * - * @param request The http request - * @param resource the resource to order - * @param changes the list of modifications - * @throws PersistenceException in case the operation is not successful - */ - public void orderNode(final SlingHttpServletRequest request, - final Resource resource, - final List<Modification> changes) throws PersistenceException { - - final String command = request.getParameter(SlingPostConstants.RP_ORDER); - if (command == null || command.length() == 0) { - // nothing to do - return; - } - - final Node node = resource.adaptTo(Node.class); - if (node == null) { - return; - } - - try { - final Node parent = node.getParent(); - - String next = null; - if (command.equals(SlingPostConstants.ORDER_FIRST)) { - - next = parent.getNodes().nextNode().getName(); - - } else if (command.equals(SlingPostConstants.ORDER_LAST)) { - - next = ""; - - } else if (command.startsWith(SlingPostConstants.ORDER_BEFORE)) { - - next = command.substring(SlingPostConstants.ORDER_BEFORE.length()); - - } else if (command.startsWith(SlingPostConstants.ORDER_AFTER)) { - - String name = command.substring(SlingPostConstants.ORDER_AFTER.length()); - NodeIterator iter = parent.getNodes(); - while (iter.hasNext()) { - Node n = iter.nextNode(); - if (n.getName().equals(name)) { - if (iter.hasNext()) { - next = iter.nextNode().getName(); - } else { - next = ""; - } - } - } - - } else { - // check for integer - try { - // 01234 - // abcde move a -> 2 (above 3) - // bcade move a -> 1 (above 1) - // bacde - int newPos = Integer.parseInt(command); - next = ""; - NodeIterator iter = parent.getNodes(); - while (iter.hasNext() && newPos >= 0) { - Node n = iter.nextNode(); - if (n.getName().equals(node.getName())) { - // if old node is found before index, need to - // inc index - newPos++; - } - if (newPos == 0) { - next = n.getName(); - break; - } - newPos--; - } - } catch (NumberFormatException e) { - throw new IllegalArgumentException( - "provided node ordering command is invalid: " + command); - } - } - - if (next != null) { - if (next.equals("")) { - next = null; - } - parent.orderBefore(node.getName(), next); - changes.add(Modification.onOrder(node.getPath(), next)); - if (logger.isDebugEnabled()) { - logger.debug("Node {} moved '{}'", node.getPath(), command); - } - } else { - throw new IllegalArgumentException( - "provided node ordering command is invalid: " + command); - } - } catch (final VersionException|ConstraintViolationException|ItemNotFoundException e) { - throw new PreconditionViolatedPersistenceException("Unable to order resource", e, resource.getPath(), null); - } catch (final UnsupportedRepositoryOperationException|LockException e) { - throw new TemporaryPersistenceException("Unable to order resource", e, resource.getPath(), null); - } catch ( final RepositoryException re) { - throw new PersistenceException("Unable to order resource", re, resource.getPath(), null); - } - } - private boolean isVersionable(final Node node) throws RepositoryException { return node.isNodeType(JcrConstants.MIX_VERSIONABLE); } diff --git a/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCopyMoveOperation.java b/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCopyMoveOperation.java index e650508..c5c0d14 100644 --- a/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCopyMoveOperation.java +++ b/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCopyMoveOperation.java @@ -77,7 +77,7 @@ abstract class AbstractCopyMoveOperation extends AbstractPostOperation { + dest + ": destination exists"); return; } else { - this.jcrSsupport.checkoutIfNecessary(request.getResourceResolver().getResource(dstParent), + this.jcrSupport.checkoutIfNecessary(request.getResourceResolver().getResource(dstParent), changes, versioningConfiguration); } @@ -88,7 +88,7 @@ abstract class AbstractCopyMoveOperation extends AbstractPostOperation { if (!dstParent.equals("")) { final Resource parentResource = request.getResourceResolver().getResource(dstParent); if (parentResource != null ) { - this.jcrSsupport.checkoutIfNecessary(parentResource, changes, versioningConfiguration); + this.jcrSupport.checkoutIfNecessary(parentResource, changes, versioningConfiguration); } else { response.setStatus(HttpServletResponse.SC_PRECONDITION_FAILED, "Cannot " + getOperationName() + " " + resource + " to " @@ -135,7 +135,7 @@ abstract class AbstractCopyMoveOperation extends AbstractPostOperation { return; } // finally apply the ordering parameter - this.jcrSsupport.orderNode(request, destResource, changes); + this.orderNode(request, destResource, changes); } /** diff --git a/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCreateOperation.java b/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCreateOperation.java index 851c743..937f5d4 100644 --- a/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCreateOperation.java +++ b/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCreateOperation.java @@ -168,12 +168,12 @@ abstract class AbstractCreateOperation extends AbstractPostOperation { final Resource rsrc = resolver.getResource(path); final ModifiableValueMap mvm = rsrc.adaptTo(ModifiableValueMap.class); if ( mvm != null ) { - final Object node = this.jcrSsupport.getNode(rsrc); - final boolean wasVersionable = (node == null ? false : this.jcrSsupport.isVersionable(rsrc)); + final Object node = this.jcrSupport.getNode(rsrc); + final boolean wasVersionable = (node == null ? false : this.jcrSupport.isVersionable(rsrc)); if ( node != null ) { - this.jcrSsupport.checkoutIfNecessary(rsrc, changes, versioningConfiguration); - this.jcrSsupport.setPrimaryNodeType(node, nodeType); + this.jcrSupport.checkoutIfNecessary(rsrc, changes, versioningConfiguration); + this.jcrSupport.setPrimaryNodeType(node, nodeType); } else { mvm.put(JcrConstants.JCR_PRIMARYTYPE, nodeType); } @@ -183,7 +183,7 @@ abstract class AbstractCreateOperation extends AbstractPostOperation { // the mix:versionable mixin does an implicit checkout if (!wasVersionable && versioningConfiguration.isCheckinOnNewVersionableNode() && - this.jcrSsupport.isVersionable(rsrc)) { + this.jcrSupport.isVersionable(rsrc)) { changes.add(Modification.onCheckout(path)); } } @@ -203,7 +203,7 @@ abstract class AbstractCreateOperation extends AbstractPostOperation { final Resource rsrc = resolver.getResource(path); final ModifiableValueMap mvm = rsrc.adaptTo(ModifiableValueMap.class); if ( mvm != null ) { - this.jcrSsupport.checkoutIfNecessary(rsrc, changes, versioningConfiguration); + this.jcrSupport.checkoutIfNecessary(rsrc, changes, versioningConfiguration); mvm.put(JcrConstants.JCR_MIXINTYPES, mixins); for(final String mixin : mixins) { @@ -593,7 +593,7 @@ abstract class AbstractCreateOperation extends AbstractPostOperation { // check for node type final String nodeType = getPrimaryType(reqProperties, tmpPath); - this.jcrSsupport.checkoutIfNecessary(resource, changes, versioningConfiguration); + this.jcrSupport.checkoutIfNecessary(resource, changes, versioningConfiguration); try { final Map<String, Object> props = new HashMap<>(); diff --git a/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractPostOperation.java b/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractPostOperation.java index 0c0bdb4..28d6737 100644 --- a/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractPostOperation.java +++ b/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractPostOperation.java @@ -25,7 +25,16 @@ import java.util.List; import java.util.Map; import java.util.NoSuchElementException; import java.util.Set; - +import java.util.stream.StreamSupport; + +import javax.jcr.ItemNotFoundException; +import javax.jcr.Node; +import javax.jcr.NodeIterator; +import javax.jcr.RepositoryException; +import javax.jcr.UnsupportedRepositoryOperationException; +import javax.jcr.lock.LockException; +import javax.jcr.nodetype.ConstraintViolationException; +import javax.jcr.version.VersionException; import javax.servlet.http.HttpServletResponse; import org.apache.sling.api.SlingHttpServletRequest; @@ -43,6 +52,7 @@ import org.apache.sling.servlets.post.VersioningConfiguration; import org.apache.sling.servlets.post.exceptions.PreconditionViolatedPersistenceException; import org.apache.sling.servlets.post.exceptions.TemporaryPersistenceException; import org.apache.sling.servlets.post.impl.helper.JCRSupport; +import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -64,7 +74,7 @@ public abstract class AbstractPostOperation implements PostOperation { protected final Logger log = LoggerFactory.getLogger(getClass()); /** The JCR support provides additional functionality if the resources a backed up by JCR. */ - protected final JCRSupport jcrSsupport = JCRSupport.INSTANCE; + protected final JCRSupport jcrSupport = JCRSupport.INSTANCE; /** * Prepares and finalizes the actual operation. Preparation encompasses @@ -177,7 +187,7 @@ public abstract class AbstractPostOperation implements PostOperation { if (!isSkipCheckin(request)) { // now do the checkins for(String checkinPath : nodesToCheckin) { - if (this.jcrSsupport.checkin(request.getResourceResolver().getResource(checkinPath))) { + if (this.jcrSupport.checkin(request.getResourceResolver().getResource(checkinPath))) { response.onChange("checkin", checkinPath); } } @@ -313,6 +323,102 @@ public abstract class AbstractPostOperation implements PostOperation { return request.getResource().getPath(); } + + /** + * Orders the given node according to the specified command. The following + * syntax is supported: <xmp> | first | before all child nodes | before A | + * before child node A | after A | after child node A | last | after all + * nodes | N | at a specific position, N being an integer </xmp> + * + * @param request The http request + * @param resource the resource to order + * @param changes the list of modifications + * @throws PersistenceException in case the operation is not successful + */ + protected void orderNode(final SlingHttpServletRequest request, + final Resource resource, + final List<Modification> changes) throws PersistenceException { + + final String command = request.getParameter(SlingPostConstants.RP_ORDER); + if (command == null || command.length() == 0) { + // nothing to do + return; + } + + final Resource parent = resource.getParent(); + + String next = null; + if (command.equals(SlingPostConstants.ORDER_FIRST)) { + + next = parent.listChildren().next().getName(); + + } else if (command.equals(SlingPostConstants.ORDER_LAST)) { + + next = ""; + + } else if (command.startsWith(SlingPostConstants.ORDER_BEFORE)) { + + next = command.substring(SlingPostConstants.ORDER_BEFORE.length()); + + } else if (command.startsWith(SlingPostConstants.ORDER_AFTER)) { + + String name = command.substring(SlingPostConstants.ORDER_AFTER.length()); + Iterator<Resource> iter = parent.listChildren(); + while (iter.hasNext()) { + Resource r = iter.next(); + if (r.getName().equals(name)) { + if (iter.hasNext()) { + next = iter.next().getName(); + } else { + next = ""; + } + } + } + + } else { + // check for integer + try { + // 01234 + // abcde move a -> 2 (above 3) + // bcade move a -> 1 (above 1) + // bacde + int newPos = Integer.parseInt(command); + next = ""; + Iterator<Resource> iter = parent.listChildren(); + while (iter.hasNext() && newPos >= 0) { + Resource r = iter.next(); + if (r.getName().equals(resource.getName())) { + // if old node is found before index, need to + // inc index + newPos++; + } + if (newPos == 0) { + next = r.getName(); + break; + } + newPos--; + } + } catch (NumberFormatException e) { + throw new IllegalArgumentException( + "provided node ordering command is invalid: " + command); + } + } + + if (next != null) { + if (next.equals("")) { + next = null; + } + resource.getResourceResolver().orderBefore(parent, resource.getName(), next); + changes.add(Modification.onOrder(resource.getPath(), next)); + if (log.isDebugEnabled()) { + log.debug("Resource {} reordered '{}'", resource.getPath(), command); + } + } else { + throw new IllegalArgumentException( + "provided node ordering command is invalid: " + command); + } + } + private static class ApplyToIterator implements Iterator<Resource> { private final ResourceResolver resolver; diff --git a/src/main/java/org/apache/sling/servlets/post/impl/operations/CopyOperation.java b/src/main/java/org/apache/sling/servlets/post/impl/operations/CopyOperation.java index 340bf57..a921776 100644 --- a/src/main/java/org/apache/sling/servlets/post/impl/operations/CopyOperation.java +++ b/src/main/java/org/apache/sling/servlets/post/impl/operations/CopyOperation.java @@ -45,15 +45,15 @@ public class CopyOperation extends AbstractCopyMoveOperation { throws PersistenceException { final Resource parentRsrc = source.getResourceResolver().getResource(destParent); // check if the item is backed by JCR - final Object item = this.jcrSsupport.getItem(source); - final Object parentItem = this.jcrSsupport.getNode(parentRsrc); + final Object item = this.jcrSupport.getItem(source); + final Object parentItem = this.jcrSupport.getNode(parentRsrc); if ( item == null || parentItem == null ) { // no JCR, copy via resources final Resource result = copy(source, parentRsrc); changes.add(Modification.onCopied(source.getPath(), result.getPath())); return result; } else { - final String dest = this.jcrSsupport.copy(item, parentItem, destName); + final String dest = this.jcrSupport.copy(item, parentItem, destName); changes.add(Modification.onCopied(source.getPath(), dest)); log.debug("copy {} to {}", source, dest); return source.getResourceResolver().getResource(dest); diff --git a/src/main/java/org/apache/sling/servlets/post/impl/operations/DeleteOperation.java b/src/main/java/org/apache/sling/servlets/post/impl/operations/DeleteOperation.java index 37f5dc6..a21c7d6 100644 --- a/src/main/java/org/apache/sling/servlets/post/impl/operations/DeleteOperation.java +++ b/src/main/java/org/apache/sling/servlets/post/impl/operations/DeleteOperation.java @@ -94,7 +94,7 @@ public class DeleteOperation extends AbstractPostOperation { if (deleteChunks) { uploadHandler.deleteChunks(resource); } else { - this.jcrSsupport.checkoutIfNecessary(resource.getParent(), changes, + this.jcrSupport.checkoutIfNecessary(resource.getParent(), changes, versioningConfiguration); } diff --git a/src/main/java/org/apache/sling/servlets/post/impl/operations/ModifyOperation.java b/src/main/java/org/apache/sling/servlets/post/impl/operations/ModifyOperation.java index d22d10c..59d2944 100644 --- a/src/main/java/org/apache/sling/servlets/post/impl/operations/ModifyOperation.java +++ b/src/main/java/org/apache/sling/servlets/post/impl/operations/ModifyOperation.java @@ -94,7 +94,7 @@ public class ModifyOperation extends AbstractCreateOperation { // order content final Resource newResource = request.getResourceResolver().getResource(response.getPath()); - this.jcrSsupport.orderNode(request, newResource, changes); + this.orderNode(request, newResource, changes); } @Override @@ -237,39 +237,39 @@ public class ModifyOperation extends AbstractCreateOperation { // first, otherwise ensure the parent location if (resolver.getResource(propPath) != null) { final Resource parent = resolver.getResource(propPath).getParent(); - this.jcrSsupport.checkoutIfNecessary(parent, changes, versioningConfiguration); + this.jcrSupport.checkoutIfNecessary(parent, changes, versioningConfiguration); resolver.delete(resolver.getResource(propPath)); changes.add(Modification.onDeleted(propPath)); } else { Resource parent = deepGetOrCreateResource(resolver, property.getParentPath(), reqProperties, changes, versioningConfiguration); - this.jcrSsupport.checkoutIfNecessary(parent, changes, versioningConfiguration); + this.jcrSupport.checkoutIfNecessary(parent, changes, versioningConfiguration); } // move through the session and record operation // check if the item is backed by JCR Resource sourceRsrc = resolver.getResource(source); - final Object sourceItem = this.jcrSsupport.getItem(sourceRsrc); - final Object destItem = this.jcrSsupport.getItem(resolver.getResource(property.getParentPath())); + final Object sourceItem = this.jcrSupport.getItem(sourceRsrc); + final Object destItem = this.jcrSupport.getItem(resolver.getResource(property.getParentPath())); if ( sourceItem != null && destItem != null ) { - if ( this.jcrSsupport.isNode(sourceRsrc) ) { + if ( this.jcrSupport.isNode(sourceRsrc) ) { if ( isMove ) { - this.jcrSsupport.checkoutIfNecessary(sourceRsrc.getParent(), changes, versioningConfiguration); - this.jcrSsupport.move(sourceItem, destItem, ResourceUtil.getName(propPath)); + this.jcrSupport.checkoutIfNecessary(sourceRsrc.getParent(), changes, versioningConfiguration); + this.jcrSupport.move(sourceItem, destItem, ResourceUtil.getName(propPath)); } else { - this.jcrSsupport.checkoutIfNecessary(resolver.getResource(property.getParentPath()), changes, versioningConfiguration); - this.jcrSsupport.copy(sourceItem, destItem, property.getName()); + this.jcrSupport.checkoutIfNecessary(resolver.getResource(property.getParentPath()), changes, versioningConfiguration); + this.jcrSupport.copy(sourceItem, destItem, property.getName()); } } else { // property: move manually - this.jcrSsupport.checkoutIfNecessary(resolver.getResource(property.getParentPath()), changes, versioningConfiguration); + this.jcrSupport.checkoutIfNecessary(resolver.getResource(property.getParentPath()), changes, versioningConfiguration); // create destination property - this.jcrSsupport.copy(sourceItem, destItem, ResourceUtil.getName(source)); + this.jcrSupport.copy(sourceItem, destItem, ResourceUtil.getName(source)); // remove source property (if not just copying) if ( isMove ) { - this.jcrSsupport.checkoutIfNecessary(sourceRsrc.getParent(), changes, versioningConfiguration); + this.jcrSupport.checkoutIfNecessary(sourceRsrc.getParent(), changes, versioningConfiguration); resolver.delete(sourceRsrc); } } @@ -314,7 +314,7 @@ public class ModifyOperation extends AbstractCreateOperation { if ( parent == null ) { continue; } - this.jcrSsupport.checkoutIfNecessary(parent, changes, versioningConfiguration); + this.jcrSupport.checkoutIfNecessary(parent, changes, versioningConfiguration); final ValueMap vm = parent.adaptTo(ModifiableValueMap.class); if ( vm == null ) { @@ -351,14 +351,14 @@ public class ModifyOperation extends AbstractCreateOperation { throws PersistenceException { final SlingPropertyValueHandler propHandler = new SlingPropertyValueHandler( - dateParser, this.jcrSsupport, changes); + dateParser, this.jcrSupport, changes); for (final RequestProperty prop : reqProperties.values()) { if (prop.hasValues()) { final Resource parent = deepGetOrCreateResource(resolver, prop.getParentPath(), reqProperties, changes, versioningConfiguration); - this.jcrSsupport.checkoutIfNecessary(parent, changes, versioningConfiguration); + this.jcrSupport.checkoutIfNecessary(parent, changes, versioningConfiguration); // skip jcr special properties if (prop.getName().equals(JcrConstants.JCR_PRIMARYTYPE) diff --git a/src/main/java/org/apache/sling/servlets/post/impl/operations/MoveOperation.java b/src/main/java/org/apache/sling/servlets/post/impl/operations/MoveOperation.java index ddde17d..d315777 100644 --- a/src/main/java/org/apache/sling/servlets/post/impl/operations/MoveOperation.java +++ b/src/main/java/org/apache/sling/servlets/post/impl/operations/MoveOperation.java @@ -54,14 +54,14 @@ public class MoveOperation extends AbstractCopyMoveOperation { } // ensure we have an item underlying the request's resource - final Object item = this.jcrSsupport.getItem(source); - final Object target = this.jcrSsupport.getNode(destParentRsrc); + final Object item = this.jcrSupport.getItem(source); + final Object target = this.jcrSupport.getNode(destParentRsrc); if (item == null || target == null ) { move(source, destParentRsrc); } else { - this.jcrSsupport.checkoutIfNecessary(source.getParent(), changes, versioningConfiguration); - this.jcrSsupport.move(item, target, destName); + this.jcrSupport.checkoutIfNecessary(source.getParent(), changes, versioningConfiguration); + this.jcrSupport.move(item, target, destName); } final Resource result = destParentRsrc.getChild(destName); if ( result != null ) {
