You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by fm...@apache.org on 2009/02/10 08:38:33 UTC
svn commit: r742875 - in /incubator/sling/trunk:
api/src/main/java/org/apache/sling/api/servlets/ servlets/post/
servlets/post/src/main/java/org/apache/sling/servlets/post/
servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/
Author: fmeschbe
Date: Tue Feb 10 07:38:30 2009
New Revision: 742875
URL: http://svn.apache.org/viewvc?rev=742875&view=rev
Log:
SLING-850 Record Node orderings:
- Make HtmlResponse.onChange public (for generic change recording)
- servlets/post now depends on most recent API to use new HtmlResponse.onChange method
- Add new ModificationType.ORDER
- Add support to record the ORDER
Modified:
incubator/sling/trunk/api/src/main/java/org/apache/sling/api/servlets/HtmlResponse.java
incubator/sling/trunk/servlets/post/pom.xml
incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/AbstractSlingPostOperation.java
incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/Modification.java
incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/ModificationType.java
incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCopyMoveOperation.java
incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/ModifyOperation.java
Modified: incubator/sling/trunk/api/src/main/java/org/apache/sling/api/servlets/HtmlResponse.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/api/src/main/java/org/apache/sling/api/servlets/HtmlResponse.java?rev=742875&r1=742874&r2=742875&view=diff
==============================================================================
--- incubator/sling/trunk/api/src/main/java/org/apache/sling/api/servlets/HtmlResponse.java (original)
+++ incubator/sling/trunk/api/src/main/java/org/apache/sling/api/servlets/HtmlResponse.java Tue Feb 10 07:38:30 2009
@@ -301,7 +301,30 @@
onChange("copied", srcPath, dstPath);
}
- private void onChange(String type, String... arguments) {
+ /**
+ * Records a generic change of the given <code>type</code>.
+ * <p>
+ * The change is added to the internal list of changes with the syntax of a
+ * method call, where the <code>type</code> is the method name and the
+ * <code>arguments</code> are the string arguments to the method enclosed in
+ * double quotes. For example, the the call
+ *
+ * <pre>
+ * onChange("sameple", "arg1", "arg2");
+ * </pre>
+ *
+ * is aded as
+ *
+ * <pre>
+ * sample("arg1", "arg2")
+ * </pre>
+ *
+ * to the internal list of changes.
+ *
+ * @param type The type of the modification
+ * @param arguments The arguments to the modifications
+ */
+ public void onChange(String type, String... arguments) {
changes.append(type);
String delim = "(";
for (String a : arguments) {
Modified: incubator/sling/trunk/servlets/post/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/servlets/post/pom.xml?rev=742875&r1=742874&r2=742875&view=diff
==============================================================================
--- incubator/sling/trunk/servlets/post/pom.xml (original)
+++ incubator/sling/trunk/servlets/post/pom.xml Tue Feb 10 07:38:30 2009
@@ -99,7 +99,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.api</artifactId>
- <version>2.0.2-incubator</version>
+ <version>2.0.3-incubator-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
Modified: incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/AbstractSlingPostOperation.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/AbstractSlingPostOperation.java?rev=742875&r1=742874&r2=742875&view=diff
==============================================================================
--- incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/AbstractSlingPostOperation.java (original)
+++ incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/AbstractSlingPostOperation.java Tue Feb 10 07:38:30 2009
@@ -99,6 +99,7 @@
case MOVE : response.onMoved(change.getSource(), change.getDestination()); break;
case COPY : response.onCopied(change.getSource(), change.getDestination()); break;
case CREATE : response.onCreated(change.getSource()); break;
+ case ORDER : response.onChange("ordered", change.getSource(), change.getDestination()); break;
}
}
if (session.hasPendingChanges()) {
@@ -247,8 +248,8 @@
* @param item node to order
* @throws RepositoryException if an error occurs
*/
- protected void orderNode(SlingHttpServletRequest request, Item item)
- throws RepositoryException {
+ protected void orderNode(SlingHttpServletRequest request, Item item,
+ List<Modification> changes) throws RepositoryException {
String command = request.getParameter(SlingPostConstants.RP_ORDER);
if (command == null || command.length() == 0) {
@@ -324,6 +325,7 @@
next = null;
}
parent.orderBefore(item.getName(), next);
+ changes.add(Modification.onOrder(item.getPath(), next));
if (log.isDebugEnabled()) {
log.debug("Node {} moved '{}'", item.getPath(), command);
}
Modified: incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/Modification.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/Modification.java?rev=742875&r1=742874&r2=742875&view=diff
==============================================================================
--- incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/Modification.java (original)
+++ incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/Modification.java Tue Feb 10 07:38:30 2009
@@ -23,9 +23,11 @@
private final ModificationType type;
private final String source;
+
private final String destination;
- public Modification(final ModificationType type, final String source, final String destination) {
+ public Modification(final ModificationType type, final String source,
+ final String destination) {
this.type = type;
this.source = source;
this.destination = destination;
@@ -45,7 +47,7 @@
/**
* Records a 'modified' change
- *
+ *
* @param path path of the item that was modified
*/
public static Modification onModified(String path) {
@@ -54,7 +56,7 @@
/**
* Records a 'created' change
- *
+ *
* @param path path of the item that was created
*/
public static Modification onCreated(String path) {
@@ -63,7 +65,7 @@
/**
* Records a 'deleted' change
- *
+ *
* @param path path of the item that was deleted
*/
public static Modification onDeleted(String path) {
@@ -71,10 +73,11 @@
}
/**
- * Records a 'moved' change. <p/> Note: the moved change only records the
- * basic move command. the implied changes on the moved properties and sub
- * nodes are not recorded.
- *
+ * Records a 'moved' change.
+ * <p/>
+ * Note: the moved change only records the basic move command. the implied
+ * changes on the moved properties and sub nodes are not recorded.
+ *
* @param srcPath source path of the node that was moved
* @param dstPath destination path of the node that was moved.
*/
@@ -83,10 +86,11 @@
}
/**
- * Records a 'copied' change. <p/> Note: the copy change only records the
- * basic copy command. the implied changes on the copied properties and sub
- * nodes are not recorded.
- *
+ * Records a 'copied' change.
+ * <p/>
+ * Note: the copy change only records the basic copy command. the implied
+ * changes on the copied properties and sub nodes are not recorded.
+ *
* @param srcPath source path of the node that was copied
* @param dstPath destination path of the node that was copied.
*/
@@ -94,6 +98,17 @@
return onChange(ModificationType.COPY, srcPath, dstPath);
}
+ /**
+ * Records a 'order' change.
+ *
+ * @param orderedPath Path of the node that was reordered
+ * @param beforeSibbling Name of the sibbling node before which the source node has
+ * been inserted.
+ */
+ public static Modification onOrder(String orderedPath, String beforeSibbling) {
+ return onChange(ModificationType.ORDER, orderedPath, beforeSibbling);
+ }
+
protected static Modification onChange(ModificationType type, String source) {
return onChange(type, source, null);
}
Modified: incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/ModificationType.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/ModificationType.java?rev=742875&r1=742874&r2=742875&view=diff
==============================================================================
--- incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/ModificationType.java (original)
+++ incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/ModificationType.java Tue Feb 10 07:38:30 2009
@@ -20,9 +20,43 @@
public enum ModificationType {
+ /**
+ * Content has been created or updated. The source path provides the path of
+ * the modified Item.
+ */
MODIFY,
+
+ /**
+ * An Item has been deleted. The source path provides the path of the
+ * deleted Item.
+ */
DELETE,
+
+ /**
+ * An Item has been moved to a new location. The source provides the
+ * original path of the Item, the destination provides the new path of the
+ * Item.
+ */
MOVE,
+
+ /**
+ * An Item has been copied to a new location. The source path provides the
+ * path of the copied Item, the destination path provides the path of the
+ * new Item.
+ */
COPY,
- CREATE
+
+ /**
+ * A Node has been created. The source path provides the path of the newly
+ * created Node.
+ */
+ CREATE,
+
+ /**
+ * A child Node has been reordered. The source path provides the path of the
+ * node, which has been reordered. The destination path provides the name of
+ * the sibbling node before which the source Node has been ordered. which
+ * the
+ */
+ ORDER
}
Modified: incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCopyMoveOperation.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCopyMoveOperation.java?rev=742875&r1=742874&r2=742875&view=diff
==============================================================================
--- incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCopyMoveOperation.java (original)
+++ incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCopyMoveOperation.java Tue Feb 10 07:38:30 2009
@@ -133,7 +133,7 @@
}
// finally apply the ordering parameter
- orderNode(request, session.getItem(dest));
+ orderNode(request, session.getItem(dest), changes);
}
/**
Modified: incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/ModifyOperation.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/ModifyOperation.java?rev=742875&r1=742874&r2=742875&view=diff
==============================================================================
--- incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/ModifyOperation.java (original)
+++ incubator/sling/trunk/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/ModifyOperation.java Tue Feb 10 07:38:30 2009
@@ -100,7 +100,7 @@
// order content
String path = response.getPath();
- orderNode(request, session.getItem(path));
+ orderNode(request, session.getItem(path), changes);
}
@Override