incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r802844 - in /sling/trunk/contrib/scripting/scala: engine/src/main/java/org/apache/sling/scripting/scala/engine/ScalaScriptEngineFactory.java interpreter/src/main/scala/org/apache/sling/scripting/scala/interpreter/JcrFS.scala
Date Mon, 10 Aug 2009 16:18:31 GMT
Author: bdelacretaz
Date: Mon Aug 10 16:18:31 2009
New Revision: 802844

URL: http://svn.apache.org/viewvc?rev=802844&view=rev
Log:
fix failing scala integration tests (/var/classes was not created)

Modified:
    sling/trunk/contrib/scripting/scala/engine/src/main/java/org/apache/sling/scripting/scala/engine/ScalaScriptEngineFactory.java
    sling/trunk/contrib/scripting/scala/interpreter/src/main/scala/org/apache/sling/scripting/scala/interpreter/JcrFS.scala

Modified: sling/trunk/contrib/scripting/scala/engine/src/main/java/org/apache/sling/scripting/scala/engine/ScalaScriptEngineFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/scala/engine/src/main/java/org/apache/sling/scripting/scala/engine/ScalaScriptEngineFactory.java?rev=802844&r1=802843&r2=802844&view=diff
==============================================================================
--- sling/trunk/contrib/scripting/scala/engine/src/main/java/org/apache/sling/scripting/scala/engine/ScalaScriptEngineFactory.java
(original)
+++ sling/trunk/contrib/scripting/scala/engine/src/main/java/org/apache/sling/scripting/scala/engine/ScalaScriptEngineFactory.java
Mon Aug 10 16:18:31 2009
@@ -26,6 +26,7 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 
+import javax.jcr.Item;
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
@@ -114,7 +115,7 @@
                             createFolder(path)),
                         this);
             }
-            catch (final RepositoryException e) {
+            catch (final Exception e) {
                 return new AbstractSlingScriptEngine(this) {
                     public Object eval(Reader reader, ScriptContext context) throws ScriptException
{
                         throw initCause(new ScriptException("Cannot access output directory:
" + path), e);
@@ -174,10 +175,36 @@
         return bundleFs;
     }
 
-    private AbstractFile createFolder(String path) throws RepositoryException {
+    private AbstractFile createFolder(String path) throws Exception {
         Session session = repository.loginAdministrative(null);
-        Node node = (Node) session.getItem(path);
-        return JcrFS.create(node);
+        try {
+            Node node = deepCreateNode(path, session, "sling:Folder");
+            if(node == null) {
+            	throw new Exception("Unable to create node " + path);
+            }
+            return JcrFS.create(node);
+        } finally {
+        	if(session != null) {
+        		session.logout();
+        	}
+        }
+    }
+    
+    private Node deepCreateNode(String path, Session session, String nodeType) throws RepositoryException
{
+    	Node result = null;
+    	if(session.itemExists(path)) {
+    		final Item it = session.getItem(path);
+    		if(it.isNode()) {
+    			result = (Node)it;
+    		}
+    	} else {
+    		final int slashPos = path.lastIndexOf("/");
+    		final String parentPath = path.substring(0, slashPos);
+    		final String childPath = path.substring(slashPos + 1);
+    		result = deepCreateNode(parentPath, session, nodeType).addNode(childPath, nodeType);
+    		session.save();
+    	}
+    	return result;
     }
 
     private static URL[] getBootUrls(Bundle bundle) {

Modified: sling/trunk/contrib/scripting/scala/interpreter/src/main/scala/org/apache/sling/scripting/scala/interpreter/JcrFS.scala
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/scala/interpreter/src/main/scala/org/apache/sling/scripting/scala/interpreter/JcrFS.scala?rev=802844&r1=802843&r2=802844&view=diff
==============================================================================
--- sling/trunk/contrib/scripting/scala/interpreter/src/main/scala/org/apache/sling/scripting/scala/interpreter/JcrFS.scala
(original)
+++ sling/trunk/contrib/scripting/scala/interpreter/src/main/scala/org/apache/sling/scripting/scala/interpreter/JcrFS.scala
Mon Aug 10 16:18:31 2009
@@ -35,6 +35,7 @@
   def create(node: Node): JcrNode = node.getPrimaryNodeType.getName match {
     case "nt:file" => JcrFile(node) // todo fix: dont hc ns prefixes
     case "nt:folder" => JcrFolder(node)
+    case "sling:Folder" => JcrFolder(node)
     case _ => throw new IOException("Neither file nor folder: " + node.getPath)
   }
 
@@ -250,4 +251,4 @@
 
 }
 
-}
\ No newline at end of file
+}



Mime
View raw message