Author: bdelacretaz
Date: Mon Jun 23 01:36:57 2008
New Revision: 670480

URL: http://svn.apache.org/viewvc?rev=670480&view=rev
Log:
SLING-552 - Freemarker wrappers for JCR Nodes and properties - contributed by 
Bryce Ewing, thanks!

Added:
    
incubator/sling/trunk/scripting/freemarker/src/main/java/org/apache/sling/scripting/freemarker/wrapper/
    
incubator/sling/trunk/scripting/freemarker/src/main/java/org/apache/sling/scripting/freemarker/wrapper/NodeListModel.java
   (with props)
    
incubator/sling/trunk/scripting/freemarker/src/main/java/org/apache/sling/scripting/freemarker/wrapper/NodeModel.java
   (with props)
    
incubator/sling/trunk/scripting/freemarker/src/main/java/org/apache/sling/scripting/freemarker/wrapper/PropertyListModel.java
   (with props)
    
incubator/sling/trunk/scripting/freemarker/src/main/java/org/apache/sling/scripting/freemarker/wrapper/PropertyModel.java
   (with props)
    incubator/sling/trunk/scripting/freemarker/src/test/
    incubator/sling/trunk/scripting/freemarker/src/test/java/
    incubator/sling/trunk/scripting/freemarker/src/test/java/org/
    incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/
    incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/
    
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/
    
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/
    
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/FreemarkerEngineHelper.java
   (with props)
    
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/FreemarkerTestBase.java
   (with props)
    
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/wrapper/
    
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/wrapper/NodeListModelTest.java
   (with props)
    
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/wrapper/NodeModelTest.java
   (with props)
    
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/wrapper/PropertyListModelTest.java
   (with props)
    
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/wrapper/PropertyModelTest.java
   (with props)
    incubator/sling/trunk/scripting/freemarker/src/test/test-config/
    
incubator/sling/trunk/scripting/freemarker/src/test/test-config/jackrabbit-test-config.xml
   (with props)
Modified:
    incubator/sling/trunk/scripting/freemarker/pom.xml
    
incubator/sling/trunk/scripting/freemarker/src/main/java/org/apache/sling/scripting/freemarker/FreemarkerScriptEngine.java

Modified: incubator/sling/trunk/scripting/freemarker/pom.xml
URL: 
http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/freemarker/pom.xml?rev=670480&r1=670479&r2=670480&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/freemarker/pom.xml (original)
+++ incubator/sling/trunk/scripting/freemarker/pom.xml Mon Jun 23 01:36:57 2008
@@ -35,15 +35,9 @@
     <description>Support for Freemarker scripting</description>
 
     <scm>
-        <connection>
-            
scm:svn:http://svn.apache.org/repos/asf/incubator/sling/trunk/scripting/freemarker
-        </connection>
-        <developerConnection>
-            
scm:svn:https://svn.apache.org/repos/asf/incubator/sling/trunk/scripting/freemarker
-        </developerConnection>
-        <url>
-            
http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/freemarker
-        </url>
+        
<connection>scm:svn:http://svn.apache.org/repos/asf/incubator/sling/trunk/scripting/freemarker</connection>
+        
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/sling/trunk/scripting/freemarker</developerConnection>
+        
<url>http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/freemarker</url>
     </scm>
 
     <build>
@@ -59,7 +53,7 @@
                 <configuration>
                     <instructions>
                         <Private-Package>
-                            org.apache.sling.scripting.freemarker
+                            org.apache.sling.scripting.freemarker.*
                         </Private-Package>
 
                         
<Embed-Dependency>freemarker;inline=true</Embed-Dependency>
@@ -107,10 +101,30 @@
             <version>2.0.3-incubator-SNAPSHOT</version>
         </dependency>
         <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.jcr.resource</artifactId>
+            <version>2.0.3-incubator-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.commons.testing</artifactId>
+            <version>2.0.3-incubator-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-core</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>javax.servlet</groupId>
             <artifactId>servlet-api</artifactId>
         </dependency>
         <dependency>
+            <groupId>javax.jcr</groupId>
+            <artifactId>jcr</artifactId>
+        </dependency>
+        <dependency>
             <groupId>freemarker</groupId>
             <artifactId>freemarker</artifactId>
             <version>2.3.6</version>
@@ -119,5 +133,15 @@
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
         </dependency>
+        <!-- Testing -->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-simple</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 </project>

Modified: 
incubator/sling/trunk/scripting/freemarker/src/main/java/org/apache/sling/scripting/freemarker/FreemarkerScriptEngine.java
URL: 
http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/freemarker/src/main/java/org/apache/sling/scripting/freemarker/FreemarkerScriptEngine.java?rev=670480&r1=670479&r2=670480&view=diff
==============================================================================
--- 
incubator/sling/trunk/scripting/freemarker/src/main/java/org/apache/sling/scripting/freemarker/FreemarkerScriptEngine.java
 (original)
+++ 
incubator/sling/trunk/scripting/freemarker/src/main/java/org/apache/sling/scripting/freemarker/FreemarkerScriptEngine.java
 Mon Jun 23 01:36:57 2008
@@ -22,10 +22,12 @@
 import javax.script.ScriptContext;
 import javax.script.ScriptEngineFactory;
 import javax.script.ScriptException;
+import javax.jcr.Node;
 
 import org.apache.sling.api.scripting.SlingBindings;
 import org.apache.sling.api.scripting.SlingScriptHelper;
 import org.apache.sling.scripting.api.AbstractSlingScriptEngine;
+import org.apache.sling.scripting.freemarker.wrapper.NodeModel;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -64,6 +66,7 @@
 
         try {
             Template tmpl = new Template(scriptName, reader, configuration);
+            bindings.put("currentNode", new NodeModel((Node) 
bindings.get("currentNode")));
             tmpl.process(bindings, scriptContext.getWriter());
         } catch (Throwable t) {
             log.error("Failure running Freemarker script.", t);

Added: 
incubator/sling/trunk/scripting/freemarker/src/main/java/org/apache/sling/scripting/freemarker/wrapper/NodeListModel.java
URL: 
http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/freemarker/src/main/java/org/apache/sling/scripting/freemarker/wrapper/NodeListModel.java?rev=670480&view=auto
==============================================================================
--- 
incubator/sling/trunk/scripting/freemarker/src/main/java/org/apache/sling/scripting/freemarker/wrapper/NodeListModel.java
 (added)
+++ 
incubator/sling/trunk/scripting/freemarker/src/main/java/org/apache/sling/scripting/freemarker/wrapper/NodeListModel.java
 Mon Jun 23 01:36:57 2008
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.scripting.freemarker.wrapper;
+
+import freemarker.template.TemplateSequenceModel;
+import freemarker.template.TemplateModel;
+import freemarker.template.TemplateModelException;
+
+import javax.jcr.NodeIterator;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * A wrapper for JCR node lists to support freemarker scripting.
+ */
+public class NodeListModel implements TemplateSequenceModel {
+
+    private List<Node> nodes;
+
+    public NodeListModel(NodeIterator nodes) {
+        this.nodes = new ArrayList<Node>();
+        while (nodes.hasNext()) {
+            this.nodes.add(nodes.nextNode());
+        }
+    }
+
+    /**
+     * Retrieves the i-th template model in this sequence.
+     *
+     * @return the item at the specified index, or <code>null</code> if
+     *         the index is out of bounds. Note that a <code>null</code> value 
is
+     *         interpreted by FreeMarker as "variable does not exist", and 
accessing
+     *         a missing variables is usually considered as an error in the 
FreeMarker
+     *         Template Language, so the usage of a bad index will not remain 
hidden.
+     */
+    public TemplateModel get(int index) throws TemplateModelException {
+        try {
+            return new NodeModel(nodes.get(index));
+        } catch (RepositoryException e) {
+            throw new TemplateModelException(e);
+        }
+    }
+
+    /**
+     * @return the number of items in the list.
+     */
+    public int size() throws TemplateModelException {
+        return nodes.size();
+    }
+}

Propchange: 
incubator/sling/trunk/scripting/freemarker/src/main/java/org/apache/sling/scripting/freemarker/wrapper/NodeListModel.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/sling/trunk/scripting/freemarker/src/main/java/org/apache/sling/scripting/freemarker/wrapper/NodeListModel.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: 
incubator/sling/trunk/scripting/freemarker/src/main/java/org/apache/sling/scripting/freemarker/wrapper/NodeModel.java
URL: 
http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/freemarker/src/main/java/org/apache/sling/scripting/freemarker/wrapper/NodeModel.java?rev=670480&view=auto
==============================================================================
--- 
incubator/sling/trunk/scripting/freemarker/src/main/java/org/apache/sling/scripting/freemarker/wrapper/NodeModel.java
 (added)
+++ 
incubator/sling/trunk/scripting/freemarker/src/main/java/org/apache/sling/scripting/freemarker/wrapper/NodeModel.java
 Mon Jun 23 01:36:57 2008
@@ -0,0 +1,206 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.scripting.freemarker.wrapper;
+
+import freemarker.template.*;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.PropertyType;
+
+/**
+ * A wrapper for JCR nodes to support freemarker scripting.
+ */
+public class NodeModel implements TemplateScalarModel, TemplateNodeModel, 
TemplateHashModel, TemplateSequenceModel, AdapterTemplateModel {
+
+    private Node node;
+    private NodeListModel nodeList;
+
+    public NodeModel(Node node) throws RepositoryException {
+        this.node = node;
+        this.nodeList = new NodeListModel(node.getNodes());
+    }
+
+    /**
+     * @return the parent of this node or null, in which case
+     *         this node is the root of the tree.
+     */
+    public TemplateNodeModel getParentNode() throws TemplateModelException {
+        try {
+            return new NodeModel(node.getParent());
+        } catch (ItemNotFoundException infe) {
+            return null;
+        } catch (RepositoryException e) {
+            throw new TemplateModelException(e);
+        }
+    }
+
+    /**
+     * @return a sequence containing this node's children.
+     *         If the returned value is null or empty, this is essentially
+     *         a leaf node.
+     */
+    public TemplateSequenceModel getChildNodes() throws TemplateModelException 
{
+        return this.nodeList;
+    }
+
+    /**
+     * @return a String that is used to determine the processing
+     *         routine to use. In the XML implementation, if the node
+     *         is an element, it returns the element's tag name.  If it
+     *         is an attribute, it returns the attribute's name. It
+     *         returns "@text" for text nodes, "@pi" for processing 
instructions,
+     *         and so on.
+     */
+    public String getNodeName() throws TemplateModelException {
+        try {
+            return node.getName();
+        } catch (RepositoryException e) {
+            throw new TemplateModelException(e);
+        }
+    }
+
+    /**
+     * @return a String describing the <em>type</em> of node this is.
+     *         In the W3C DOM, this should be "element", "text", "attribute", 
etc.
+     *         A TemplateNodeModel implementation that models other kinds of
+     *         trees could return whatever it appropriate for that 
application. It
+     *         can be null, if you don't want to use node-types.
+     */
+    public String getNodeType() throws TemplateModelException {
+        try {
+            return node.getPrimaryNodeType().getName();
+        } catch (RepositoryException e) {
+            throw new TemplateModelException(e);
+        }
+    }
+
+    /**
+     * @return the XML namespace URI with which this node is
+     *         associated. If this TemplateNodeModel implementation is
+     *         not XML-related, it will almost certainly be null. Even
+     *         for XML nodes, this will often be null.
+     */
+    public String getNodeNamespace() throws TemplateModelException {
+        return null;
+    }
+
+    /**
+     * Gets a <tt>TemplateModel</tt> from the hash.
+     *
+     * @param key the name by which the <tt>TemplateModel</tt>
+     *            is identified in the template.
+     * @return the <tt>TemplateModel</tt> referred to by the key,
+     *         or null if not found.
+     */
+    public TemplateModel get(String key) throws TemplateModelException {
+        if (key == null) return null;
+        if (key.startsWith("@")) {
+            try {
+                if (node.hasProperty(key.substring(1))) {
+                    if 
(node.getProperty(key.substring(1)).getDefinition().isMultiple()) {
+                        return new 
PropertyListModel(node.getProperty(key.substring(1)));
+                    }
+                    else {
+                        return new 
PropertyModel(node.getProperty(key.substring(1)));
+                    }
+                }
+                else return null;
+            } catch (RepositoryException e) {
+                throw new TemplateModelException(e);
+            }
+        }
+        else {
+            try {
+                if (node.hasNode(key)) {
+                    return new NodeModel(node.getNode(key));
+                }
+                else if (node.hasProperty(key) && 
node.getProperty(key).getType() == PropertyType.REFERENCE) {
+                    return new NodeModel(node.getProperty(key).getNode());
+                }
+                return null;
+            } catch (RepositoryException e) {
+                throw new TemplateModelException(e);
+            }
+        }
+    }
+
+    public boolean isEmpty() throws TemplateModelException {
+        try {
+            return !node.hasNodes() && ! node.hasProperties();
+        } catch (RepositoryException e) {
+            throw new TemplateModelException(e);
+        }
+    }
+
+    /**
+     * Retrieves the i-th template model in this sequence.
+     *
+     * @return the item at the specified index, or <code>null</code> if
+     *         the index is out of bounds. Note that a <code>null</code> value 
is
+     *         interpreted by FreeMarker as "variable does not exist", and 
accessing
+     *         a missing variables is usually considered as an error in the 
FreeMarker
+     *         Template Language, so the usage of a bad index will not remain 
hidden.
+     */
+    public TemplateModel get(int index) throws TemplateModelException {
+        return nodeList.get(index);
+    }
+
+    /**
+     * @return the number of items in the list.
+     */
+    public int size() throws TemplateModelException {
+        return nodeList.size();
+    }
+
+    /**
+     * Retrieves the underlying object, or some other object semantically
+     * equivalent to its value narrowed by the class hint.
+     *
+     * @param hint the desired class of the returned value. An implementation
+     *             should make reasonable effort to retrieve an object of the 
requested
+     *             class, but if that is impossible, it must at least return 
the underlying
+     *             object as-is. As a minimal requirement, an implementation 
must always
+     *             return the exact underlying object when
+     *             <tt>hint.isInstance(underlyingObject) == true</tt> holds. 
When called
+     *             with <tt>java.lang.Object.class</tt>, it should return a 
generic Java
+     *             object (i.e. if the model is wrapping a scripting lanugage 
object that is
+     *             further wrapping a Java object, the deepest underlying Java 
object should
+     *             be returned).
+     * @return the underlying object, or its value accommodated for the hint
+     *         class.
+     */
+    public Object getAdaptedObject(Class hint) {
+        return node;
+    }
+
+    /**
+     * Returns the string representation of this model. In general, avoid
+     * returning null. In compatibility mode the engine will convert
+     * null into empty string, however in normal mode it will
+     * throw an exception if you return null from this method.
+     */
+    public String getAsString() throws TemplateModelException {
+        try {
+            return node.getPath();
+        } catch (RepositoryException e) {
+            throw new TemplateModelException(e);
+        }
+    }
+    
+}

Propchange: 
incubator/sling/trunk/scripting/freemarker/src/main/java/org/apache/sling/scripting/freemarker/wrapper/NodeModel.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/sling/trunk/scripting/freemarker/src/main/java/org/apache/sling/scripting/freemarker/wrapper/NodeModel.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: 
incubator/sling/trunk/scripting/freemarker/src/main/java/org/apache/sling/scripting/freemarker/wrapper/PropertyListModel.java
URL: 
http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/freemarker/src/main/java/org/apache/sling/scripting/freemarker/wrapper/PropertyListModel.java?rev=670480&view=auto
==============================================================================
--- 
incubator/sling/trunk/scripting/freemarker/src/main/java/org/apache/sling/scripting/freemarker/wrapper/PropertyListModel.java
 (added)
+++ 
incubator/sling/trunk/scripting/freemarker/src/main/java/org/apache/sling/scripting/freemarker/wrapper/PropertyListModel.java
 Mon Jun 23 01:36:57 2008
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.scripting.freemarker.wrapper;
+
+import freemarker.template.TemplateModel;
+import freemarker.template.TemplateSequenceModel;
+import freemarker.template.TemplateModelException;
+import freemarker.template.SimpleScalar;
+
+import javax.jcr.Property;
+import javax.jcr.Value;
+import javax.jcr.RepositoryException;
+
+/**
+ * A wrapper for JCR multi value properties to support freemarker scripting.
+ */
+public class PropertyListModel implements TemplateSequenceModel {
+
+    private Value[] values;
+
+    public PropertyListModel(Property property) throws RepositoryException {
+        this.values = property.getValues();
+    }
+
+    /**
+     * Retrieves the i-th template model in this sequence.
+     *
+     * @return the item at the specified index, or <code>null</code> if
+     *         the index is out of bounds. Note that a <code>null</code> value 
is
+     *         interpreted by FreeMarker as "variable does not exist", and 
accessing
+     *         a missing variables is usually considered as an error in the 
FreeMarker
+     *         Template Language, so the usage of a bad index will not remain 
hidden.
+     */
+    public TemplateModel get(int index) throws TemplateModelException {
+        try {
+            return new SimpleScalar(values[index].getString());
+        } catch (RepositoryException e) {
+            throw new TemplateModelException(e);
+        }
+    }
+
+    /**
+     * @return the number of items in the list.
+     */
+    public int size() throws TemplateModelException {
+        return values.length;
+    }
+}

Propchange: 
incubator/sling/trunk/scripting/freemarker/src/main/java/org/apache/sling/scripting/freemarker/wrapper/PropertyListModel.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/sling/trunk/scripting/freemarker/src/main/java/org/apache/sling/scripting/freemarker/wrapper/PropertyListModel.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: 
incubator/sling/trunk/scripting/freemarker/src/main/java/org/apache/sling/scripting/freemarker/wrapper/PropertyModel.java
URL: 
http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/freemarker/src/main/java/org/apache/sling/scripting/freemarker/wrapper/PropertyModel.java?rev=670480&view=auto
==============================================================================
--- 
incubator/sling/trunk/scripting/freemarker/src/main/java/org/apache/sling/scripting/freemarker/wrapper/PropertyModel.java
 (added)
+++ 
incubator/sling/trunk/scripting/freemarker/src/main/java/org/apache/sling/scripting/freemarker/wrapper/PropertyModel.java
 Mon Jun 23 01:36:57 2008
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.scripting.freemarker.wrapper;
+
+import freemarker.template.TemplateModel;
+import freemarker.template.TemplateScalarModel;
+import freemarker.template.TemplateModelException;
+
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+
+/**
+ * A wrapper for JCR properties to support freemarker scripting.
+ */
+public class PropertyModel implements TemplateScalarModel {
+
+    private Property property;
+
+    public PropertyModel(Property property) {
+        this.property = property;
+    }
+
+    /**
+     * Returns the string representation of this model. In general, avoid
+     * returning null. In compatibility mode the engine will convert
+     * null into empty string, however in normal mode it will
+     * throw an exception if you return null from this method.
+     */
+    public String getAsString() throws TemplateModelException {
+        try {
+            return property.getString();
+        } catch (RepositoryException e) {
+            throw new TemplateModelException(e);
+        }
+    }
+}

Propchange: 
incubator/sling/trunk/scripting/freemarker/src/main/java/org/apache/sling/scripting/freemarker/wrapper/PropertyModel.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/sling/trunk/scripting/freemarker/src/main/java/org/apache/sling/scripting/freemarker/wrapper/PropertyModel.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: 
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/FreemarkerEngineHelper.java
URL: 
http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/FreemarkerEngineHelper.java?rev=670480&view=auto
==============================================================================
--- 
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/FreemarkerEngineHelper.java
 (added)
+++ 
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/FreemarkerEngineHelper.java
 Mon Jun 23 01:36:57 2008
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.scripting.freemarker;
+
+import freemarker.template.Configuration;
+import freemarker.template.Template;
+import freemarker.template.TemplateModel;
+
+import javax.jcr.Node;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.Map;
+import java.util.HashMap;
+
+import org.apache.sling.scripting.freemarker.wrapper.NodeModel;
+
+public class FreemarkerEngineHelper {
+
+    private Configuration configuration;
+    private Node node;
+
+    public FreemarkerEngineHelper(Node node) {
+        configuration = new Configuration();
+        this.node = node;
+    }
+
+    public String evalToString(String templateContent) throws Exception {
+        StringReader reader = new StringReader(templateContent);
+        Template template = new Template("test", reader, configuration);
+        
+        Map<String, TemplateModel> data = new HashMap<String, TemplateModel>();
+        data.put("node", new NodeModel(node));
+
+        StringWriter writer = new StringWriter();
+        template.process(data, writer);
+        return writer.toString();
+    }
+
+}

Propchange: 
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/FreemarkerEngineHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/FreemarkerEngineHelper.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: 
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/FreemarkerTestBase.java
URL: 
http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/FreemarkerTestBase.java?rev=670480&view=auto
==============================================================================
--- 
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/FreemarkerTestBase.java
 (added)
+++ 
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/FreemarkerTestBase.java
 Mon Jun 23 01:36:57 2008
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.scripting.freemarker;
+
+import org.apache.sling.commons.testing.jcr.RepositoryTestBase;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.naming.NamingException;
+
+public class FreemarkerTestBase extends RepositoryTestBase {
+    
+    protected FreemarkerEngineHelper freemarker;
+    private int counter;
+    protected Node rootNode;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        rootNode = getTestRootNode();
+        freemarker = new FreemarkerEngineHelper(rootNode);
+    }
+
+    protected Node getNewNode() throws RepositoryException, NamingException {
+        return getTestRootNode().addNode("test-" + (++counter));
+    }
+
+}

Propchange: 
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/FreemarkerTestBase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/FreemarkerTestBase.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: 
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/wrapper/NodeListModelTest.java
URL: 
http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/wrapper/NodeListModelTest.java?rev=670480&view=auto
==============================================================================
--- 
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/wrapper/NodeListModelTest.java
 (added)
+++ 
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/wrapper/NodeListModelTest.java
 Mon Jun 23 01:36:57 2008
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.scripting.freemarker.wrapper;
+
+import org.apache.sling.scripting.freemarker.FreemarkerTestBase;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+
+/**
+ * Test freemarker node list model.
+ */
+public class NodeListModelTest extends FreemarkerTestBase {
+    private Node node1;
+    private Node node2;
+    private Node node3;
+
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        node1 = rootNode.addNode("Test-1-" + System.currentTimeMillis());
+        node2 = rootNode.addNode("Test-2-" + System.currentTimeMillis());
+        node3 = rootNode.addNode("Test-3-" + System.currentTimeMillis());
+    }
+
+    public void testGetByIndex() throws Exception {
+        assertEquals(node1.getPath(), freemarker.evalToString("${node[0]}"));
+        assertEquals(node2.getPath(), freemarker.evalToString("${node[1]}"));
+        assertEquals(node3.getPath(), freemarker.evalToString("${node[2]}"));
+    }
+
+    public void testGetSize() throws Exception {
+        assertEquals("3", freemarker.evalToString("${node?size}"));
+    }
+
+    public void testIteration() throws Exception {
+        String expect = "";
+        NodeIterator iter = rootNode.getNodes();
+        while (iter.hasNext()) {
+            expect += iter.nextNode().getPath();
+        }
+        assertEquals(expect, freemarker.evalToString("<#list node as 
child>${child}</#list>"));
+    }
+
+}

Propchange: 
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/wrapper/NodeListModelTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/wrapper/NodeListModelTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: 
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/wrapper/NodeModelTest.java
URL: 
http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/wrapper/NodeModelTest.java?rev=670480&view=auto
==============================================================================
--- 
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/wrapper/NodeModelTest.java
 (added)
+++ 
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/wrapper/NodeModelTest.java
 Mon Jun 23 01:36:57 2008
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.scripting.freemarker.wrapper;
+
+import org.apache.sling.scripting.freemarker.FreemarkerTestBase;
+
+import javax.jcr.Node;
+
+/**
+ * Test freemarker node model.
+ */
+public class NodeModelTest extends FreemarkerTestBase {
+    private Node node1;
+    private Node node2;
+    private Node node3;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        node1 = rootNode.addNode("child1");
+        node1.setProperty("text", "Test-" + System.currentTimeMillis());
+        node2 = rootNode.addNode("child2", "nt:unstructured");
+        node3 = node1.addNode("grandchild1");
+    }
+
+    public void testDefaultValue() throws Exception {
+        assertEquals(rootNode.getPath(), freemarker.evalToString("${node}"));
+    }
+
+    public void testParentNode() throws Exception {
+        assertEquals(node1.getPath(), 
freemarker.evalToString("${node.child1.grandchild1?parent}"));
+    }
+
+    public void testRootNode() throws Exception {
+        assertEquals("/", 
freemarker.evalToString("${node.child1.grandchild1?root}"));
+    }
+
+    public void testChildrenSequence() throws Exception {
+        assertEquals("2", freemarker.evalToString("${node?children?size}"));
+    }
+
+    public void testNodeName() throws Exception {
+        assertEquals(rootNode.getName(), 
freemarker.evalToString("${node?node_name}"));
+    }
+
+    public void testNodeType() throws Exception {
+        assertEquals(node2.getPrimaryNodeType().getName(), 
freemarker.evalToString("${node.child2?node_type}"));
+    }
+
+    public void testChildNodeByName() throws Exception {
+        assertEquals(node2.getPath(), 
freemarker.evalToString("${node.child2}"));
+    }
+
+    public void testChildPropertyByName() throws Exception {
+        assertEquals(node1.getProperty("text").getString(), 
freemarker.evalToString("[EMAIL PROTECTED]"));
+    }
+
+    public void testIsEmpty() throws Exception {
+        assertEquals("true", freemarker.evalToString("<#if 
node.child1?has_content>true<#else>false</#if>"));
+        assertEquals("false", freemarker.evalToString("<#if 
node.child2?has_content>true<#else>false</#if>"));
+    }
+
+}

Propchange: 
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/wrapper/NodeModelTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/wrapper/NodeModelTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: 
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/wrapper/PropertyListModelTest.java
URL: 
http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/wrapper/PropertyListModelTest.java?rev=670480&view=auto
==============================================================================
--- 
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/wrapper/PropertyListModelTest.java
 (added)
+++ 
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/wrapper/PropertyListModelTest.java
 Mon Jun 23 01:36:57 2008
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.scripting.freemarker.wrapper;
+
+import org.apache.sling.scripting.freemarker.FreemarkerTestBase;
+
+import javax.jcr.Value;
+
+/**
+ * Test freemarker property list model.
+ */
+public class PropertyListModelTest extends FreemarkerTestBase {
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        rootNode.setProperty("text", new String[] {
+            "Test-1-" + System.currentTimeMillis(),
+            "Test-2-" + System.currentTimeMillis(),
+            "Test-3-" + System.currentTimeMillis()
+        });
+    }
+
+    public void testGetByIndex() throws Exception {
+        Value[] values = rootNode.getProperty("text").getValues();
+        assertEquals(values[0].getString(), freemarker.evalToString("[EMAIL 
PROTECTED]"));
+        assertEquals(values[1].getString(), freemarker.evalToString("[EMAIL 
PROTECTED]"));
+        assertEquals(values[2].getString(), freemarker.evalToString("[EMAIL 
PROTECTED]"));
+    }
+
+    public void testGetSize() throws Exception {
+        assertEquals("3", freemarker.evalToString("[EMAIL PROTECTED]"));
+    }
+
+    public void testIteration() throws Exception {
+        String expect = "";
+        for (Value value : rootNode.getProperty("text").getValues()) {
+            expect += value.getString();
+        }
+        assertEquals(expect, freemarker.evalToString("<#list [EMAIL PROTECTED] 
as text>${text}</#list>"));
+    }
+
+}

Propchange: 
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/wrapper/PropertyListModelTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/wrapper/PropertyListModelTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: 
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/wrapper/PropertyModelTest.java
URL: 
http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/wrapper/PropertyModelTest.java?rev=670480&view=auto
==============================================================================
--- 
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/wrapper/PropertyModelTest.java
 (added)
+++ 
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/wrapper/PropertyModelTest.java
 Mon Jun 23 01:36:57 2008
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.scripting.freemarker.wrapper;
+
+import org.apache.sling.scripting.freemarker.FreemarkerTestBase;
+
+import javax.jcr.Node;
+
+/**
+ * Test freemarker property model.
+ */
+public class PropertyModelTest extends FreemarkerTestBase {
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        rootNode.setProperty("text", "Test-" + System.currentTimeMillis());
+    }
+
+    public void testDefaultValue() throws Exception {
+        assertEquals(rootNode.getProperty("text").getString(), 
freemarker.evalToString("[EMAIL PROTECTED]"));
+    }
+
+}

Propchange: 
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/wrapper/PropertyModelTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/sling/trunk/scripting/freemarker/src/test/java/org/apache/sling/scripting/freemarker/wrapper/PropertyModelTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: 
incubator/sling/trunk/scripting/freemarker/src/test/test-config/jackrabbit-test-config.xml
URL: 
http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/freemarker/src/test/test-config/jackrabbit-test-config.xml?rev=670480&view=auto
==============================================================================
--- 
incubator/sling/trunk/scripting/freemarker/src/test/test-config/jackrabbit-test-config.xml
 (added)
+++ 
incubator/sling/trunk/scripting/freemarker/src/test/test-config/jackrabbit-test-config.xml
 Mon Jun 23 01:36:57 2008
@@ -0,0 +1,117 @@
+<?xml version="1.0"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<!DOCTYPE Repository PUBLIC "-//The Apache Software Foundation//DTD Jackrabbit 
1.2//EN"
+                            
"http://jackrabbit.apache.org/dtd/repository-1.2.dtd";>
+<Repository>
+    <!--
+        virtual file system where the repository stores global state
+        (e.g. registered namespaces, custom node types, etc.)
+    -->
+    <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+        <param name="path" value="${rep.home}/repository"/>
+    </FileSystem>
+
+    <!--
+        security configuration
+    -->
+    <Security appName="Jackrabbit">
+        <!--
+            access manager:
+            class: FQN of class implementing the AccessManager interface
+        -->
+        <AccessManager 
class="org.apache.jackrabbit.core.security.SimpleAccessManager">
+            <!-- <param name="config" value="${rep.home}/access.xml"/> -->
+        </AccessManager>
+
+        <LoginModule 
class="org.apache.jackrabbit.core.security.SimpleLoginModule">
+           <!-- anonymous user name ('anonymous' is the default value) -->
+           <param name="anonymousId" value="anonymous"/>
+           <!--
+              default user name to be used instead of the anonymous user
+              when no login credentials are provided (unset by default)
+           -->
+           <param name="defaultUserId" value="superuser"/>
+        </LoginModule>
+    </Security>
+
+    <!--
+        location of workspaces root directory and name of default workspace
+    -->
+    <Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="default"/>
+    <!--
+        workspace configuration template:
+        used to create the initial workspace if there's no workspace yet
+    -->
+    <Workspace name="Jackrabbit Core">
+        <!--
+            virtual file system of the workspace:
+            class: FQN of class implementing the FileSystem interface
+        -->
+        <FileSystem 
class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+            <param name="path" value="${wsp.home}"/>
+        </FileSystem>
+        <!--
+            persistence manager of the workspace:
+            class: FQN of class implementing the PersistenceManager interface
+        -->
+        <PersistenceManager 
class="org.apache.jackrabbit.core.persistence.db.DerbyPersistenceManager">
+          <param name="url" value="jdbc:derby:${wsp.home}/db;create=true"/>
+          <param name="schemaObjectPrefix" value="Jackrabbit Core_"/>
+        </PersistenceManager>
+        <!--
+            Search index and the file system it uses.
+            class: FQN of class implementing the QueryHandler interface
+        -->
+        <SearchIndex 
class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+            <param name="path" value="${wsp.home}/index"/>
+        </SearchIndex>
+    </Workspace>
+
+    <!--
+        Configures the versioning
+    -->
+    <Versioning rootPath="${rep.home}/version">
+        <!--
+            Configures the filesystem to use for versioning for the respective
+            persistence manager
+        -->
+        <FileSystem 
class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+            <param name="path" value="${rep.home}/version" />
+        </FileSystem>
+
+        <!--
+            Configures the persistence manager to be used for persisting 
version state.
+            Please note that the current versioning implementation is based on
+            a 'normal' persistence manager, but this could change in future
+            implementations.
+        -->
+        <PersistenceManager 
class="org.apache.jackrabbit.core.persistence.db.DerbyPersistenceManager">
+          <param name="url" 
value="jdbc:derby:${rep.home}/version/db;create=true"/>
+          <param name="schemaObjectPrefix" value="version_"/>
+        </PersistenceManager>
+    </Versioning>
+
+    <!--
+        Search index for content that is shared repository wide
+        (/jcr:system tree, contains mainly versions)
+    -->
+    <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+        <param name="path" value="${rep.home}/repository/index"/>
+    </SearchIndex>
+</Repository>
+

Propchange: 
incubator/sling/trunk/scripting/freemarker/src/test/test-config/jackrabbit-test-config.xml
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to