You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2008/04/17 15:45:39 UTC
svn commit: r649098 - in /incubator/sling/trunk/scripting/javascript/src:
main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableNode.java
test/java/org/apache/sling/scripting/wrapper/ScriptableNodeTest.java
Author: bdelacretaz
Date: Thu Apr 17 06:45:34 2008
New Revision: 649098
URL: http://svn.apache.org/viewvc?rev=649098&view=rev
Log:
#SLING-385 - ScriptableNode.remove() and hasNode(path) methods added
Modified:
incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableNode.java
incubator/sling/trunk/scripting/javascript/src/test/java/org/apache/sling/scripting/wrapper/ScriptableNodeTest.java
Modified: incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableNode.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableNode.java?rev=649098&r1=649097&r2=649098&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableNode.java (original)
+++ incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableNode.java Thu Apr 17 06:45:34 2008
@@ -30,7 +30,10 @@
import javax.jcr.RepositoryException;
import javax.jcr.Value;
import javax.jcr.ValueFormatException;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
import javax.jcr.nodetype.NodeType;
+import javax.jcr.version.VersionException;
import org.apache.sling.jcr.resource.JcrResourceUtil;
import org.apache.sling.scripting.javascript.helper.SlingWrapper;
@@ -269,6 +272,14 @@
public boolean jsFunction_getModified() {
return node.isModified();
+ }
+
+ public void jsFunction_remove() throws RepositoryException {
+ node.remove();
+ }
+
+ public boolean jsFunction_hasNode(String path) throws RepositoryException {
+ return node.hasNode(path);
}
/**
Modified: incubator/sling/trunk/scripting/javascript/src/test/java/org/apache/sling/scripting/wrapper/ScriptableNodeTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/javascript/src/test/java/org/apache/sling/scripting/wrapper/ScriptableNodeTest.java?rev=649098&r1=649097&r2=649098&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/javascript/src/test/java/org/apache/sling/scripting/wrapper/ScriptableNodeTest.java (original)
+++ incubator/sling/trunk/scripting/javascript/src/test/java/org/apache/sling/scripting/wrapper/ScriptableNodeTest.java Thu Apr 17 06:45:34 2008
@@ -216,4 +216,15 @@
;
assertEquals("1_" + path + "_A 1_" + path + "_B ", script.evalToString(code, data));
}
+
+ public void testRemoveNode() throws Exception {
+ final String code =
+ "node.addNode('toremove');\n"
+ + "out.print(node.hasNode('toremove'))\n"
+ + "out.print(' ')\n"
+ + "node.getNode('toremove').remove()\n"
+ + "out.print(node.hasNode('toremove'))\n"
+ ;
+ assertEquals("true false", script.evalToString(code, data));
+ }
}