You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ed...@apache.org on 2005/08/11 20:06:07 UTC

svn commit: r231495 [5/7] - in /incubator/jackrabbit/trunk/contrib/jcr-commands: ./ applications/test/ applications/test/fs/ applications/test/fs/dummy folder/ benchmarking/ src/java/ src/java/org/apache/jackrabbit/chain/ src/java/org/apache/jackrabbit...

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/RemoveItem.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/RemoveItem.java?rev=231495&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/RemoveItem.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/RemoveItem.java Thu Aug 11 11:04:29 2005
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.jackrabbit.chain.command;
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.jackrabbit.chain.CtxHelper;
+
+/**
+ * Removes the item at the given path. <br>
+ * The Command attributes are set from the specified literal values, or from the
+ * context attributes stored under the given keys.
+ */
+public class RemoveItem implements Command
+{
+
+    // ---------------------------- < literals >
+
+    /** path to the current node */
+    private String path;
+
+    // ---------------------------- < keys >
+
+    /** context attribute key for the path attribute */
+    private String pathKey;
+
+    /**
+     * @inheritDoc
+     */
+    public boolean execute(Context ctx) throws Exception
+    {
+        String path = CtxHelper.getAttr(this.path, this.pathKey, ctx);
+        CtxHelper.getItem(ctx, path).remove();
+        return false;
+    }
+
+    /**
+     * @return Returns the path.
+     */
+    public String getPath()
+    {
+        return path;
+    }
+
+    /**
+     * @param path
+     *            The path to set.
+     */
+    public void setPath(String path)
+    {
+        this.path = path;
+    }
+
+    /**
+     * @return Returns the pathKey.
+     */
+    public String getPathKey()
+    {
+        return pathKey;
+    }
+
+    /**
+     * @param pathKey
+     *            Set the context attribute key for the path attribute.
+     */
+    public void setPathKey(String pathKey)
+    {
+        this.pathKey = pathKey;
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/RemoveItem.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/RemoveItems.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/RemoveItems.java?rev=231495&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/RemoveItems.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/RemoveItems.java Thu Aug 11 11:04:29 2005
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.jackrabbit.chain.command;
+
+import java.util.Iterator;
+
+import javax.jcr.Item;
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.jackrabbit.chain.CtxHelper;
+
+/**
+ * Removes any item under the current working node that match the given name
+ * pattern. <br>
+ * The Command attributes are set from the specified literal values, or from the
+ * context attributes stored under the given keys.
+ */
+public class RemoveItems implements Command
+{
+
+    // ---------------------------- < literals >
+
+    /** item pattern */
+    private String pattern;
+
+    // ---------------------------- < keys >
+    /** item pattern key */
+    private String patternKey;
+
+    /**
+     * @inheritDoc
+     */
+    public boolean execute(Context ctx) throws Exception
+    {
+        String pattern = CtxHelper.getAttr(this.pattern,
+            this.patternKey, ctx);
+
+        Iterator items = CtxHelper.getItems(ctx, pattern);
+
+        while (items.hasNext())
+        {
+            Item item = (Item) items.next();
+            item.remove();
+        }
+
+        return false;
+    }
+
+    public String getPattern()
+    {
+        return pattern;
+    }
+
+    public void setPattern(String pattern)
+    {
+        this.pattern = pattern;
+    }
+
+    /**
+     * @return Returns the patternKey.
+     */
+    public String getPatternKey()
+    {
+        return patternKey;
+    }
+
+    /**
+     * @param patternKey
+     *            Set the context attribute key for the pattern attribute.
+     */
+    public void setPatternKey(String patternKey)
+    {
+        this.patternKey = patternKey;
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/RemoveItems.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/RemoveMixin.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/RemoveMixin.java?rev=231495&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/RemoveMixin.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/RemoveMixin.java Thu Aug 11 11:04:29 2005
@@ -0,0 +1,126 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.jackrabbit.chain.command;
+
+import javax.jcr.Node;
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.jackrabbit.chain.CtxHelper;
+
+/**
+ * Remove a mixin from the given node
+ */
+public class RemoveMixin implements Command
+{
+    // ---------------------------- < literals >
+    /** node path */
+    private String path;
+
+    /** mixin name */
+    private String mixinName;
+
+    // ---------------------------- < keys >
+    /** node path */
+    private String pathKey;
+
+    /** mixin name */
+    private String mixinNameKey;
+
+    /**
+     * @return Returns the mixinName.
+     */
+    public String getMixinName()
+    {
+        return mixinName;
+    }
+
+    /**
+     * @param mixinName
+     *            The mixinName to set.
+     */
+    public void setMixinName(String mixinName)
+    {
+        this.mixinName = mixinName;
+    }
+
+    /**
+     * @return Returns the mixinNameKey.
+     */
+    public String getMixinNameKey()
+    {
+        return mixinNameKey;
+    }
+
+    /**
+     * @param mixinNameKey
+     *            The mixinNameKey to set.
+     */
+    public void setMixinNameKey(String mixinNameKey)
+    {
+        this.mixinNameKey = mixinNameKey;
+    }
+
+    /**
+     * @return Returns the path.
+     */
+    public String getPath()
+    {
+        return path;
+    }
+
+    /**
+     * @param path
+     *            The path to set.
+     */
+    public void setPath(String path)
+    {
+        this.path = path;
+    }
+
+    /**
+     * @return Returns the pathKey.
+     */
+    public String getPathKey()
+    {
+        return pathKey;
+    }
+
+    /**
+     * @param pathKey
+     *            The pathKey to set.
+     */
+    public void setPathKey(String pathKey)
+    {
+        this.pathKey = pathKey;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public boolean execute(Context ctx) throws Exception
+    {
+        String path = CtxHelper.getAttr(this.path, this.pathKey, ctx);
+        String mixin = CtxHelper
+            .getAttr(this.mixinName, this.mixinNameKey, ctx);
+
+        Node n = CtxHelper.getNode(ctx, path);
+        n.removeMixin(mixin);
+
+        return false;
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/RemoveMixin.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/Rename.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/Rename.java?rev=231495&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/Rename.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/Rename.java Thu Aug 11 11:04:29 2005
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.jackrabbit.chain.command;
+
+import javax.jcr.Node;
+import javax.jcr.Session;
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.jackrabbit.chain.CtxHelper;
+
+/**
+ * Rename a node
+ */
+public class Rename implements Command
+{
+    // ---------------------------- < literals >
+    /** source path */
+    private String from;
+
+    /** destination path */
+    private String to;
+
+    // ---------------------------- < keys >
+    /** source path */
+    private String fromKey;
+
+    /** destination path */
+    private String toKey;
+
+    /**
+     * @return Returns the from.
+     */
+    public String getFrom()
+    {
+        return from;
+    }
+
+    /**
+     * @param from
+     *            The from to set.
+     */
+    public void setFrom(String from)
+    {
+        this.from = from;
+    }
+
+    /**
+     * @return Returns the fromKey.
+     */
+    public String getFromKey()
+    {
+        return fromKey;
+    }
+
+    /**
+     * @param fromKey
+     *            The fromKey to set.
+     */
+    public void setFromKey(String fromKey)
+    {
+        this.fromKey = fromKey;
+    }
+
+    /**
+     * @return Returns the to.
+     */
+    public String getTo()
+    {
+        return to;
+    }
+
+    /**
+     * @param to
+     *            The to to set.
+     */
+    public void setTo(String to)
+    {
+        this.to = to;
+    }
+
+    /**
+     * @return Returns the toKey.
+     */
+    public String getToKey()
+    {
+        return toKey;
+    }
+
+    /**
+     * @param toKey
+     *            The toKey to set.
+     */
+    public void setToKey(String toKey)
+    {
+        this.toKey = toKey;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public boolean execute(Context ctx) throws Exception
+    {
+        String from = CtxHelper.getAttr(this.from, this.fromKey, ctx);
+        String to = CtxHelper.getAttr(this.to, this.toKey, ctx);
+
+        Session s = CtxHelper.getSession(ctx);
+
+        Node n = CtxHelper.getCurrentNode(ctx);
+
+        Node nodeFrom = n.getNode(from);
+
+        if (nodeFrom.getDepth() == 1)
+        {
+            s.move(nodeFrom.getPath(), "/" + to);
+        } else
+        {
+            s.move(nodeFrom.getPath(), nodeFrom.getParent().getPath() + "/"
+                    + to);
+        }
+
+        return false;
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/Rename.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/SaveNode.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/SaveNode.java?rev=231495&r1=231494&r2=231495&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/SaveNode.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/SaveNode.java Thu Aug 11 11:04:29 2005
@@ -20,7 +20,7 @@
 
 import org.apache.commons.chain.Command;
 import org.apache.commons.chain.Context;
-import org.apache.jackrabbit.chain.ContextHelper;
+import org.apache.jackrabbit.chain.CtxHelper;
 
 /**
  * Saves the current working node.
@@ -32,7 +32,7 @@
 	 * @see org.apache.commons.chain.Command#execute(org.apache.commons.chain.Context)
 	 */
 	public boolean execute(Context ctx) throws Exception {
-		Node node = ContextHelper.getCurrentNode(ctx);
+		Node node = CtxHelper.getCurrentNode(ctx);
 		node.save() ;
 		return false;
 	}

Modified: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/SaveSession.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/SaveSession.java?rev=231495&r1=231494&r2=231495&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/SaveSession.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/SaveSession.java Thu Aug 11 11:04:29 2005
@@ -20,7 +20,7 @@
 
 import org.apache.commons.chain.Command;
 import org.apache.commons.chain.Context;
-import org.apache.jackrabbit.chain.ContextHelper;
+import org.apache.jackrabbit.chain.CtxHelper;
 
 /**
  * Saves the current Session.
@@ -32,7 +32,7 @@
 	 * @see org.apache.commons.chain.Command#execute(org.apache.commons.chain.Context)
 	 */
 	public boolean execute(Context ctx) throws Exception {
-		Session s = ContextHelper.getSession(ctx);
+		Session s = CtxHelper.getSession(ctx);
 		s.save() ;
 		return false;
 	}

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/SetMultivalueProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/SetMultivalueProperty.java?rev=231495&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/SetMultivalueProperty.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/SetMultivalueProperty.java Thu Aug 11 11:04:29 2005
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.jackrabbit.chain.command;
+
+import javax.jcr.Node;
+import javax.jcr.PropertyType;
+
+import org.apache.commons.chain.Context;
+import org.apache.jackrabbit.chain.CtxHelper;
+
+/**
+ * Set a multivalue property to the current working node. <br>
+ * The default regular expression is ",". <br>
+ * The Command attributes are set from the specified literal values, or from the
+ * context attributes stored under the given keys.
+ */
+public class SetMultivalueProperty extends AbstractSetProperty
+{
+
+    // ---------------------------- < literals >
+
+    /** regular expression */
+    private String regExp;
+
+    // ---------------------------- < keys >
+
+    /** regular expression key */
+    private String regExpKey;
+
+    /**
+     * @inheritDoc
+     */
+    public boolean execute(Context ctx) throws Exception
+    {
+        String regExp = CtxHelper.getAttr(this.regExp, this.regExpKey,
+            ",", ctx);
+
+        String value = CtxHelper.getAttr(this.value, this.valueKey,
+            ctx);
+
+        String name = CtxHelper.getAttr(this.propertyName, this.propertyNameKey, ctx);
+
+        String propertyType = CtxHelper.getAttr(this.propertyType,
+            this.propertyTypeKey, PropertyType.TYPENAME_STRING, ctx);
+
+        String[] values = value.split(regExp);
+        Node node = CtxHelper.getCurrentNode(ctx);
+        node
+            .setProperty(name, values, PropertyType.valueFromName(propertyType));
+
+        return false;
+    }
+
+    /**
+     * @return Returns the regExp.
+     */
+    public String getRegExp()
+    {
+        return regExp;
+    }
+
+    /**
+     * @param regExp
+     *            The regExp to set.
+     */
+    public void setRegExp(String regExp)
+    {
+        this.regExp = regExp;
+    }
+
+    /**
+     * @return Returns the regExpKey.
+     */
+    public String getRegExpKey()
+    {
+        return regExpKey;
+    }
+
+    /**
+     * @param regExpKey
+     *            Set the context attribute key for the regExp attribute.
+     */
+    public void setRegExpKey(String regExpKey)
+    {
+        this.regExpKey = regExpKey;
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/SetMultivalueProperty.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/SetProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/SetProperty.java?rev=231495&r1=231494&r2=231495&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/SetProperty.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/SetProperty.java Thu Aug 11 11:04:29 2005
@@ -19,23 +19,14 @@
 import javax.jcr.Node;
 import javax.jcr.PropertyType;
 
-import org.apache.commons.chain.Command;
 import org.apache.commons.chain.Context;
-import org.apache.jackrabbit.chain.ContextHelper;
+import org.apache.jackrabbit.chain.CtxHelper;
 
 /**
- * Sets a property to the current working Node
+ * Set a property to the current working Node
  */
-public class SetProperty implements Command
+public class SetProperty extends AbstractSetProperty
 {
-    /** Property name */
-    private String name;
-
-    /** Propety type */
-    private String propertyType;
-
-    /** Property value */
-    private String value;
 
     /*
      * (non-Javadoc)
@@ -44,53 +35,19 @@
      */
     public boolean execute(Context ctx) throws Exception
     {
-        Node node = ContextHelper.getCurrentNode(ctx);
-        node.setProperty(name, value, PropertyType.valueFromName(propertyType));
-        return false;
-    }
+        String value = CtxHelper.getAttr(this.value, this.valueKey,
+            ctx);
 
-    /**
-     * @return Returns the name.
-     */
-    public String getName()
-    {
-        return name;
-    }
+        String name = CtxHelper.getAttr(this.propertyName, this.propertyNameKey, ctx);
 
-    /**
-     * @param name
-     *            The name to set.
-     */
-    public void setName(String name)
-    {
-        this.name = name;
-    }
+        String propertyType = CtxHelper.getAttr(this.propertyType,
+            this.propertyTypeKey, PropertyType.TYPENAME_STRING, ctx);
 
-    /**
-     * @return Returns the type.
-     */
-    public String getPropertyType()
-    {
-        return propertyType;
-    }
+        Node node = CtxHelper.getCurrentNode(ctx);
 
-    /**
-     * @param type
-     *            The type to set.
-     */
-    public void setPropertyType(String type)
-    {
-        this.propertyType = type;
-    }
+        node.setProperty(name, value, PropertyType.valueFromName(propertyType));
 
-    public String getValue()
-    {
-        return value;
+        return false;
     }
 
-    public void setValue(String value)
-    {
-        this.value = value;
-    }
-    
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/StartJackrabbit.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/StartJackrabbit.java?rev=231495&r1=231494&r2=231495&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/StartJackrabbit.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/StartJackrabbit.java Thu Aug 11 11:04:29 2005
@@ -20,12 +20,12 @@
 
 import org.apache.commons.chain.Command;
 import org.apache.commons.chain.Context;
-import org.apache.jackrabbit.chain.ContextHelper;
+import org.apache.jackrabbit.chain.CtxHelper;
 import org.apache.jackrabbit.core.RepositoryImpl;
 import org.apache.jackrabbit.core.config.RepositoryConfig;
 
 /**
- * Starts Jackrabbit. <br>
+ * Start Jackrabbit. <br>
  * Note that this command doesn't check whether there's a Jackrabbit
  * instance already running with the same configuration. Remember that two
  * jackrabbit instances using the same persistence storage might lead to a
@@ -48,7 +48,7 @@
     {
         RepositoryConfig conf = RepositoryConfig.create(config, home);
         Repository repo = RepositoryImpl.create(conf);
-        ContextHelper.setRepository(ctx, repo);
+        CtxHelper.setRepository(ctx, repo);
         return false;
     }
 

Modified: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/StartOrGetJackrabbitSingleton.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/StartOrGetJackrabbitSingleton.java?rev=231495&r1=231494&r2=231495&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/StartOrGetJackrabbitSingleton.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/StartOrGetJackrabbitSingleton.java Thu Aug 11 11:04:29 2005
@@ -22,14 +22,14 @@
 import org.apache.commons.chain.Context;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.jackrabbit.chain.ContextHelper;
+import org.apache.jackrabbit.chain.CtxHelper;
 import org.apache.jackrabbit.chain.RepositoryPool;
 import org.apache.jackrabbit.core.RepositoryImpl;
 import org.apache.jackrabbit.core.config.RepositoryConfig;
 
 /**
  * <p>
- * Gets a Jackrabbit instance from the RepositoryPool and put in the Commons
+ * Get a Jackrabbit instance from the RepositoryPool and put in the Commons
  * Chain Context. If there's no Repository for the given config then it will
  * create a new instance and will add it to the pool.
  * </p>
@@ -72,7 +72,7 @@
                     repo = RepositoryImpl.create(conf);
                     pool.put(config, home, repo);
                 }
-                ContextHelper.setRepository(ctx, repo);
+                CtxHelper.setRepository(ctx, repo);
             }
         } catch (Exception e)
         {

Modified: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/StopJackrabbit.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/StopJackrabbit.java?rev=231495&r1=231494&r2=231495&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/StopJackrabbit.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/StopJackrabbit.java Thu Aug 11 11:04:29 2005
@@ -18,11 +18,11 @@
 
 import org.apache.commons.chain.Command;
 import org.apache.commons.chain.Context;
-import org.apache.jackrabbit.chain.ContextHelper;
+import org.apache.jackrabbit.chain.CtxHelper;
 import org.apache.jackrabbit.core.RepositoryImpl;
 
 /**
- * Stops Jackrabbit  
+ * Stop Jackrabbit  
  */
 public class StopJackrabbit implements Command {
 
@@ -30,8 +30,15 @@
 	 * @see org.apache.commons.chain.Command#execute(org.apache.commons.chain.Context)
 	 */
 	public boolean execute(Context ctx) throws Exception {
-		RepositoryImpl repo = (RepositoryImpl) ContextHelper.getRepository(ctx) ;
-		repo.shutdown() ;
+		RepositoryImpl repo = (RepositoryImpl) CtxHelper.getRepository(ctx) ;
+        if (repo==null) {
+            throw new IllegalStateException("No current working repository") ;
+        }
+        if (!(repo instanceof RepositoryImpl)) {
+            throw new IllegalStateException("Jackrabbit is not the current working repository") ;
+        }
+        repo.shutdown() ;
+        CtxHelper.setRepository(ctx, null);
 		return false;
 	}
 }

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/fs/ExportFileSystem.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/fs/ExportFileSystem.java?rev=231495&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/fs/ExportFileSystem.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/fs/ExportFileSystem.java Thu Aug 11 11:04:29 2005
@@ -0,0 +1,290 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.jackrabbit.chain.command.fs;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+import javax.jcr.ValueFormatException;
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.jackrabbit.chain.CtxHelper;
+import org.apache.jackrabbit.chain.JcrCommandException;
+
+/**
+ * Exports a node of type nt:file or nt:folder to the given file system path.<br>
+ * The Command attributes are set from the specified literal values, or from the
+ * context attributes stored under the given keys.
+ */
+public class ExportFileSystem implements Command
+{
+    // ---------------------------- < literals >
+
+    /** Node path */
+    private String from;
+
+    /** File system path */
+    private String to;
+
+    /** Overwrite flag */
+    private String overwrite;
+
+    // ---------------------------- < keys >
+
+    /** Node path key */
+    private String fromKey;
+
+    /** File system path key */
+    private String toKey;
+
+    /** Overwrite flag key */
+    private String overwriteKey;
+
+    /**
+     * @inheritDoc
+     */
+    public boolean execute(Context ctx) throws Exception
+    {
+        String from = CtxHelper.getAttr(this.from, this.fromKey, ctx);
+
+        String to = CtxHelper.getAttr(this.to, this.toKey, ctx);
+
+        boolean overwrite = CtxHelper.getBooleanAttr(this.overwrite,
+            this.overwriteKey, false, ctx);
+
+        Node node = CtxHelper.getNode(ctx, from);
+
+        File f = new File(to);
+
+        // check if the file exists
+        if (f.exists() && !overwrite)
+        {
+            throw new JcrCommandException("file.exists", new String[]
+            {
+                to
+            });
+        }
+
+        // export either a file or a folder
+        if (node.isNodeType("nt:file"))
+        {
+            this.createFile(node, f);
+        } else if (node.isNodeType("nt:folder"))
+        {
+            this.addFolder(node, f);
+        } else
+        {
+            throw new JcrCommandException("not.file.or.folder", new String[]
+            {
+                node.getPrimaryNodeType().getName()
+            });
+        }
+
+        return false;
+    }
+
+    /**
+     * Exports a nt:file to the file system
+     * 
+     * @param node
+     * @param file
+     * @throws IOException
+     * @throws JcrCommandException
+     * @throws ValueFormatException
+     * @throws PathNotFoundException
+     * @throws RepositoryException
+     */
+    private void createFile(Node node, File file) throws IOException,
+            JcrCommandException, ValueFormatException, PathNotFoundException,
+            RepositoryException
+    {
+
+        boolean created = file.createNewFile();
+        if (!created)
+        {
+            throw new JcrCommandException("file.not.created", new String[]
+            {
+                file.getPath()
+            });
+        }
+        BufferedOutputStream out = new BufferedOutputStream(
+            new FileOutputStream(file));
+        InputStream in = node.getNode("jcr:content").getProperty("jcr:data")
+            .getStream();
+
+        int c;
+
+        while ((c = in.read()) != -1)
+        {
+            out.write(c);
+        }
+        in.close();
+        out.flush();
+        out.close();
+    }
+
+    /**
+     * Exports a nt:folder and all its children to the file system
+     * 
+     * @param node
+     * @param file
+     * @throws JcrCommandException
+     * @throws RepositoryException
+     * @throws IOException
+     */
+    private void addFolder(Node node, File file) throws JcrCommandException,
+            RepositoryException, IOException
+    {
+        boolean created = file.mkdir();
+
+        if (!created)
+        {
+            throw new JcrCommandException("folder.not.created", new String[]
+            {
+                file.getPath()
+            });
+        }
+
+        NodeIterator iter = node.getNodes();
+        while (iter.hasNext())
+        {
+            Node child = iter.nextNode();
+            // File
+            if (child.isNodeType("nt:file"))
+            {
+                File childFile = new File(file, child.getName());
+                createFile(child, childFile);
+            } else if (child.isNodeType("nt:folder"))
+            {
+                File childFolder = new File(file, child.getName());
+                addFolder(child, childFolder);
+            }
+        }
+    }
+
+    /**
+     * @return file system path
+     */
+    public String getTo()
+    {
+        return to;
+    }
+
+    /**
+     * Sets the file system path
+     * 
+     * @param to
+     */
+    public void setTo(String to)
+    {
+        this.to = to;
+    }
+
+    /**
+     * @return jcr node path
+     */
+    public String getFrom()
+    {
+        return from;
+    }
+
+    /**
+     * Set the jcr node path
+     * 
+     * @param from
+     */
+    public void setFrom(String from)
+    {
+        this.from = from;
+    }
+
+    /**
+     * @return Returns the fromKey.
+     */
+    public String getFromKey()
+    {
+        return fromKey;
+    }
+
+    /**
+     * @param fromKey
+     *            Set the context attribute key for the from attribute.
+     */
+    public void setFromKey(String fromKey)
+    {
+        this.fromKey = fromKey;
+    }
+
+    /**
+     * @return Returns the overwrite.
+     */
+    public String getOverwrite()
+    {
+        return overwrite;
+    }
+
+    /**
+     * @param overwrite
+     *            The overwrite to set.
+     */
+    public void setOverwrite(String overwrite)
+    {
+        this.overwrite = overwrite;
+    }
+
+    /**
+     * @return Returns the toKey.
+     */
+    public String getToKey()
+    {
+        return toKey;
+    }
+
+    /**
+     * @param toKey
+     *            Set the context attribute key for the to attribute
+     */
+    public void setToKey(String toKey)
+    {
+        this.toKey = toKey;
+    }
+
+    /**
+     * @return Returns the overwriteKey.
+     */
+    public String getOverwriteKey()
+    {
+        return overwriteKey;
+    }
+
+    /**
+     * @param overwriteKey
+     *            Set the context attribute key for the overwrite attribute
+     */
+    public void setOverwriteKey(String overwriteKey)
+    {
+        this.overwriteKey = overwriteKey;
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/fs/ExportFileSystem.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/fs/ExportPropertyToFile.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/fs/ExportPropertyToFile.java?rev=231495&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/fs/ExportPropertyToFile.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/fs/ExportPropertyToFile.java Thu Aug 11 11:04:29 2005
@@ -0,0 +1,294 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.jackrabbit.chain.command.fs;
+
+import java.io.BufferedOutputStream;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringReader;
+
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.jackrabbit.chain.CtxHelper;
+import org.apache.jackrabbit.chain.JcrCommandException;
+
+/**
+ * Exports the property value to the file system. <br>
+ * The Command attributes are set from the specified literal values, or from the
+ * context attributes stored under the given keys.
+ */
+public class ExportPropertyToFile implements Command
+{
+    // ---------------------------- < literals >
+
+    /** property name */
+    private String name;
+
+    /** value index */
+    private String index;
+
+    /** target file */
+    private String to;
+
+    /** overwrite the target file if necessary */
+    private String overwrite;
+
+    // ---------------------------- < keys >
+
+    /** property name */
+    private String nameKey;
+
+    /** value index */
+    private String indexKey;
+
+    /** target file */
+    private String toKey;
+
+    /** overwrite the target file if necessary */
+    private String overwriteKey;
+
+    /**
+     * @inheritDoc
+     */
+    public boolean execute(Context ctx) throws Exception
+    {
+        String name = CtxHelper.getAttr(this.name, this.nameKey, ctx);
+
+        int index = CtxHelper.getIntAttr(this.index, this.indexKey, 0,
+            ctx);
+
+        Node n = CtxHelper.getCurrentNode(ctx);
+        Property p = n.getProperty(name);
+        if (p.getDefinition().isMultiple())
+        {
+            exportValue(ctx, p.getValues()[index]);
+        } else
+        {
+            exportValue(ctx, p.getValue());
+        }
+        return false;
+    }
+
+    /**
+     * Export th given value to a File
+     * 
+     * @param ctx
+     * @param value
+     * @throws JcrCommandException
+     * @throws IOException
+     * @throws RepositoryException
+     * @throws IllegalStateException
+     */
+    private void exportValue(Context ctx, Value value)
+            throws JcrCommandException, IOException, IllegalStateException,
+            RepositoryException
+    {
+        String to = CtxHelper.getAttr(this.to, this.toKey, ctx) ;
+        boolean overwrite = CtxHelper.getBooleanAttr(this.overwrite, this.overwriteKey, false, ctx) ; 
+
+        File file = new File(to);
+
+        // Check if there's a file at the given target path
+        if (file.exists() && !overwrite)
+        {
+            throw new JcrCommandException("file.exists", new String[]
+            {
+                to
+            });
+        }
+
+        // If it doesn't exists create the file
+        if (!file.exists())
+        {
+            file.createNewFile();
+        }
+
+        if (value.getType() == PropertyType.BINARY)
+        {
+            InputStream in = value.getStream();
+            BufferedOutputStream out = new BufferedOutputStream(
+                new FileOutputStream(file));
+            int c;
+            while ((c = in.read()) != -1)
+            {
+                out.write(c);
+            }
+            in.close();
+            out.flush();
+            out.close();
+        } else
+        {
+            Reader in = new StringReader(value.getString());
+            BufferedWriter out = new BufferedWriter(new FileWriter(file));
+            int c;
+            while ((c = in.read()) != -1)
+            {
+                out.write(c);
+            }
+            in.close();
+            out.flush();
+            out.close();
+        }
+    }
+
+    /**
+     * @return Returns the index.
+     */
+    public String getIndex()
+    {
+        return index;
+    }
+
+    /**
+     * @param index
+     *            The index to set.
+     */
+    public void setIndex(String index)
+    {
+        this.index = index;
+    }
+
+    /**
+     * @return Returns the indexKey.
+     */
+    public String getIndexKey()
+    {
+        return indexKey;
+    }
+
+    /**
+     * @param indexKey
+     *            Set the context attribute key for the index attribute.
+     */
+    public void setIndexKey(String indexKey)
+    {
+        this.indexKey = indexKey;
+    }
+
+    /**
+     * @return Returns the name.
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+    /**
+     * @param name
+     *            The name to set.
+     */
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+
+    /**
+     * @return Returns the nameKey.
+     */
+    public String getNameKey()
+    {
+        return nameKey;
+    }
+
+    /**
+     * @param nameKey
+     *            Set the context attribute key for the name attribute.
+     */
+    public void setNameKey(String nameKey)
+    {
+        this.nameKey = nameKey;
+    }
+
+    /**
+     * @return Returns the overwrite.
+     */
+    public String getOverwrite()
+    {
+        return overwrite;
+    }
+
+    /**
+     * @param overwrite
+     *            The overwrite to set.
+     */
+    public void setOverwrite(String overwrite)
+    {
+        this.overwrite = overwrite;
+    }
+
+    /**
+     * @return Returns the overwriteKey.
+     */
+    public String getOverwriteKey()
+    {
+        return overwriteKey;
+    }
+
+    /**
+     * @param overwriteKey
+     *            Set the context attribute key for the overwrite attribute.
+     */
+    public void setOverwriteKey(String overwriteKey)
+    {
+        this.overwriteKey = overwriteKey;
+    }
+
+    /**
+     * @return Returns the to.
+     */
+    public String getTo()
+    {
+        return to;
+    }
+
+    /**
+     * @param to
+     *            The to to set.
+     */
+    public void setTo(String to)
+    {
+        this.to = to;
+    }
+
+    /**
+     * @return Returns the toKey.
+     */
+    public String getToKey()
+    {
+        return toKey;
+    }
+
+    /**
+     * @param toKey
+     *            Set the context attribute key for the to attribute.
+     */
+    public void setToKey(String toKey)
+    {
+        this.toKey = toKey;
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/fs/ExportPropertyToFile.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/fs/ImportFileSystem.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/fs/ImportFileSystem.java?rev=231495&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/fs/ImportFileSystem.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/fs/ImportFileSystem.java Thu Aug 11 11:04:29 2005
@@ -0,0 +1,215 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.jackrabbit.chain.command.fs;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Calendar;
+import java.util.Properties;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jackrabbit.chain.CtxHelper;
+import org.apache.jackrabbit.chain.JcrCommandException;
+
+/**
+ * This command imports data from the file system. <br>
+ * If the given path refers to a file, it's imported from the repository to a
+ * node of type nt:file under the current working node. <br>
+ * If the given path refers to a folder, the given folder and all the subtree is
+ * imported <br>
+ * The Command attributes are set from the specified literal values, or from the
+ * context attributes stored under the given keys.
+ */
+public class ImportFileSystem implements Command
+{
+    /** logger */
+    private static Log log = LogFactory.getLog(ImportFileSystem.class);
+
+    /** extension to mime type mapping */
+    private static Properties mimeTypes;
+
+    static
+    {
+        try
+        {
+            mimeTypes = new Properties();
+            mimeTypes.load(ImportFileSystem.class
+                .getResourceAsStream("mimetypes.properties"));
+        } catch (Exception e)
+        {
+            log.error("unable to load mime types", e);
+        }
+    }
+
+    // ---------------------------- < literals >
+
+    /** File system path */
+    private String from;
+
+    // ---------------------------- < keys >
+
+    /** File system path key */
+    private String fromKey;
+
+    public boolean execute(Context ctx) throws Exception
+    {
+        String file = CtxHelper.getAttr(this.from, this.fromKey, ctx);
+
+        if (file == null)
+        {
+            throw new JcrCommandException("fspath.is.null");
+        }
+
+        File f = new File(file);
+
+        if (!f.exists())
+        {
+            throw new JcrCommandException("file.not.found", new String[]
+            {
+                file
+            });
+        }
+
+        Node parent = CtxHelper.getCurrentNode(ctx);
+        if (f.isFile())
+        {
+            this.importFile(parent, f);
+        } else
+        {
+            Node folder = parent.addNode(f.getName(), "nt:folder");
+            this.importFolder(folder, f);
+        }
+
+        return false;
+    }
+
+    /**
+     * Imports a File.
+     * 
+     * @param parentnode
+     *            Parent Repository Node
+     * @param file
+     *            File to be imported
+     * @throws RepositoryException
+     *             on repository errors, IOException on io errors
+     */
+
+    private void importFile(Node parentnode, File file)
+            throws RepositoryException, IOException
+    {
+        String mimeType = null;
+        String extension = getExtension(file.getName());
+        if (extension != null)
+        {
+            mimeType = mimeTypes.getProperty(extension);
+        }
+        if (mimeType == null)
+        {
+            mimeType = "application/octet-stream";
+        }
+
+        Node fileNode = parentnode.addNode(file.getName(), "nt:file");
+        Node resNode = fileNode.addNode("jcr:content", "nt:resource");
+        resNode.setProperty("jcr:mimeType", mimeType);
+        resNode.setProperty("jcr:encoding", "");
+        resNode.setProperty("jcr:data", new FileInputStream(file));
+        Calendar lastModified = Calendar.getInstance();
+        lastModified.setTimeInMillis(file.lastModified());
+        resNode.setProperty("jcr:lastModified", lastModified);
+    }
+
+    /**
+     * Import a Folder.
+     * 
+     * @param parentnode
+     *            Parent Repository Node
+     * @param directory
+     *            Directory to be traversed
+     * @throws RepositoryException
+     *             on repository errors, IOException on io errors
+     */
+
+    private void importFolder(Node parentnode, File directory)
+            throws RepositoryException, IOException
+    {
+        File[] direntries = directory.listFiles();
+        for (int i = 0; i < direntries.length; i++)
+        {
+            File direntry = direntries[i];
+            if (direntry.isDirectory())
+            {
+                Node childnode = parentnode.addNode(direntry.getName(),
+                    "nt:folder");
+                importFolder(childnode, direntry);
+            } else
+            {
+                importFile(parentnode, direntry);
+            }
+        }
+    }
+
+    private String getExtension(String name)
+    {
+        String ext = null;
+        if (name.lastIndexOf('.') != -1)
+        {
+            ext = name.substring(name.lastIndexOf('.') + 1);
+        }
+        return ext;
+    }
+
+    /**
+     * @return Returns the from.
+     */
+    public String getFrom()
+    {
+        return from;
+    }
+
+    /**
+     * @param from
+     *            The from to set.
+     */
+    public void setFrom(String from)
+    {
+        this.from = from;
+    }
+
+    /**
+     * @return Returns the fromKey.
+     */
+    public String getFromKey()
+    {
+        return fromKey;
+    }
+
+    /**
+     * @param fromKey
+     *            Set the context attribute key for the from attribute.
+     */
+    public void setFromKey(String fromKey)
+    {
+        this.fromKey = fromKey;
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/fs/ImportFileSystem.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/fs/SetPropertyFromFile.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/fs/SetPropertyFromFile.java?rev=231495&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/fs/SetPropertyFromFile.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/fs/SetPropertyFromFile.java Thu Aug 11 11:04:29 2005
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.jackrabbit.chain.command.fs;
+
+import java.io.BufferedReader;
+import java.io.CharArrayWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileReader;
+import java.io.PrintWriter;
+
+import javax.jcr.Node;
+import javax.jcr.PropertyType;
+
+import org.apache.commons.chain.Context;
+import org.apache.jackrabbit.chain.CtxHelper;
+import org.apache.jackrabbit.chain.JcrCommandException;
+import org.apache.jackrabbit.chain.command.AbstractSetProperty;
+
+/**
+ * Set a property value with the contents of the given files. The PropertyType
+ * may be specified.
+ */
+public class SetPropertyFromFile extends AbstractSetProperty
+{
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.commons.chain.Command#execute(org.apache.commons.chain.Context)
+     */
+    public boolean execute(Context ctx) throws Exception
+    {
+        String value = CtxHelper.getAttr(this.value, this.valueKey, ctx);
+
+        String name = CtxHelper.getAttr(this.propertyName,
+            this.propertyNameKey, ctx);
+
+        String propertyType = CtxHelper.getAttr(this.propertyType,
+            this.propertyTypeKey, PropertyType.TYPENAME_STRING, ctx);
+
+        File f = new File(value);
+        if (!f.exists())
+        {
+            throw new JcrCommandException("file.not.found", new String[]
+            {
+                value
+            });
+        }
+        Node node = CtxHelper.getCurrentNode(ctx);
+
+        if (propertyType.equals(PropertyType.TYPENAME_BINARY))
+        {
+            node.setProperty(name, new FileInputStream(f));
+        } else
+        {
+            CharArrayWriter cw = new CharArrayWriter();
+            PrintWriter out = new PrintWriter(cw);
+            BufferedReader in = new BufferedReader(new FileReader(f));
+            String str;
+            while ((str = in.readLine()) != null)
+            {
+                out.println(str);
+            }
+            in.close();
+            node.setProperty(name, cw.toString(), PropertyType
+                .valueFromName(propertyType));
+        }
+        return false;
+    }
+
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/fs/SetPropertyFromFile.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/fs/mimetypes.properties
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/fs/mimetypes.properties?rev=231495&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/fs/mimetypes.properties (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/fs/mimetypes.properties Thu Aug 11 11:04:29 2005
@@ -0,0 +1,133 @@
+ai=application/postscript	
+aif=audio/x-aiff
+aifc=audio/x-aiff
+aiff=audio/x-aiff
+any=text/any
+asc=text/plain
+au=audio/basic
+avi=video/x-msvideo
+bcpio=application/x-bcpio
+bin=application/octet-stream
+bz2=application/x-bzip2
+cdf=application/x-netcdf
+class=application/octet-stream
+cpio=application/x-cpio
+cpt=application/mac-compactpro
+cq=application/cq-durboser
+crx=application/crx-durboser
+csh=application/x-csh
+css=text/css
+dcr=application/x-director
+dir=application/x-director
+dms=application/octet-stream
+doc=application/msword
+dvi=application/x-dvi
+dxr=application/x-director
+ecma=text/qhtml
+eps=application/postscript
+esp=text/qhtml
+etx=text/x-setext
+exe=application/octet-stream
+ez=application/andrew-inset
+gif=image/gif
+gtar=application/x-gtar
+gz=application/x-gzip
+hdf=application/x-hdf
+hqx=application/mac-binhex40
+htm=text/html
+html=text/html
+ice=x-conference/x-cooltalk
+ief=image/ief
+iges=model/iges
+igs=model/iges
+jpe=image/jpeg
+jpeg=image/jpeg
+jpg=image/jpeg
+js=application/x-javascript
+kar=audio/midi
+latex=application/x-latex
+lha=application/octet-stream
+lzh=application/octet-stream
+man=application/x-troff-man
+mdb=application/msaccess
+me=application/x-troff-me
+mesh=model/mesh
+mid=audio/midi
+midi=audio/midi
+mif=application/vnd=mif
+mov=video/quicktime
+movie=video/x-sgi-movie
+mp2=audio/mpeg
+mp3=audio/mpeg
+mpe=video/mpeg
+mpeg=video/mpeg
+mpg=video/mpeg
+mpga=audio/mpeg
+ms=application/x-troff-ms
+msh=model/mesh
+nc=application/x-netcdf
+oda=application/oda
+pbm=image/x-portable-bitmap
+pdb=chemical/x-pdb
+pdf=application/pdf
+pgm=image/x-portable-graymap
+pgn=application/x-chess-pgn
+png=image/png
+pnm=image/x-portable-anymap
+ppm=image/x-portable-pixmap
+ppt=application/vnd=ms-powerpoint
+ps=application/postscript
+qhtml=text/qhtml
+qt=video/quicktime
+ra=audio/x-realaudio
+ram=audio/x-pn-realaudio
+ras=image/x-cmu-raster
+rgb=image/x-rgb
+rm=audio/x-pn-realaudio
+roff=application/x-troff
+rpm=application/x-rpm
+rtf=application/rtf
+rtf=text/rtf
+rtx=text/richtext
+sgm=text/sgml
+sgml=text/sgml
+sh=application/x-sh
+shar=application/x-shar
+silo=model/mesh
+sit=application/x-stuffit
+skd=application/x-koan
+skm=application/x-koan
+skp=application/x-koan
+skt=application/x-koan
+smi=application/smil
+smil=application/smil
+snd=audio/basic
+spl=application/x-futuresplash
+src=application/x-wais-source
+sv4cpio=application/x-sv4cpio
+sv4crc=application/x-sv4crc
+swf=application/x-shockwave-flash
+t=application/x-troff
+tar=application/x-tar
+tcl=application/x-tcl
+tex=application/x-tex
+texi=application/x-texinfo
+texinfo=application/x-texinfo
+tgz=application/x-gzip
+tif=image/tiff
+tiff=image/tiff
+tr=application/x-troff
+tsv=text/tab-separated-values
+txt=text/plain
+ustar=application/x-ustar
+vcd=application/x-cdlink
+vrml=model/vrml
+wav=audio/x-wav
+wrl=model/vrml
+xbm=image/x-xbitmap
+xls=application/msexcel
+xml=text/xml
+xpm=image/x-xpixmap
+xwd=image/x-xwindowdump
+xyz=chemical/x-pdb
+zip=application/zip
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/fs/mimetypes.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/info/AbstractInfoCommand.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/info/AbstractInfoCommand.java?rev=231495&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/info/AbstractInfoCommand.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/info/AbstractInfoCommand.java Thu Aug 11 11:04:29 2005
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.jackrabbit.chain.command.info;
+
+import java.util.ResourceBundle;
+
+import org.apache.commons.chain.Command;
+
+/**
+ * Info Command superclass
+ */
+public abstract class AbstractInfoCommand implements Command
+{
+    /** Resource bundle */
+    protected ResourceBundle bundle = ResourceBundle.getBundle(this.getClass()
+        .getPackage().getName()
+            + ".resources");    
+
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/info/AbstractInfoCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/info/AbstractLs.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/info/AbstractLs.java?rev=231495&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/info/AbstractLs.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/info/AbstractLs.java Thu Aug 11 11:04:29 2005
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.jackrabbit.chain.command.info;
+
+import java.util.Iterator;
+
+import javax.jcr.NodeIterator;
+import javax.jcr.PropertyIterator;
+
+import org.apache.commons.chain.Context;
+import org.apache.jackrabbit.chain.CtxHelper;
+
+/**
+ * Ls superclass
+ */
+public abstract class AbstractLs extends AbstractInfoCommand
+{
+    /** long width */
+    protected int longWidth = 10;
+
+    /** max items to list */
+    protected int defaultMaxItems = 100;
+
+    private String maxItemsKey ;
+
+    private boolean path;
+
+    protected void printFooter(Context ctx, Iterator iter)
+    {
+        CtxHelper.getOutput(ctx).println() ;
+        CtxHelper.getOutput(ctx).println(bundle.getString("total"));
+        if (iter instanceof NodeIterator)
+        {
+            printFooter(ctx, (NodeIterator) iter);
+        } else if (iter instanceof PropertyIterator)
+        {
+            printFooter(ctx, (PropertyIterator) iter);
+        }
+    }
+
+    private void printFooter(Context ctx, NodeIterator iter)
+    {
+        CtxHelper.getOutput(ctx).println(
+            iter.getSize() + " " + bundle.getString("nodes"));
+    }
+
+    private void printFooter(Context ctx, PropertyIterator iter)
+    {
+        CtxHelper.getOutput(ctx).println(
+            iter.getSize() + " " + bundle.getString("properties"));
+    }
+
+    public int getDefaultMaxItems()
+    {
+        return defaultMaxItems;
+    }
+
+    public void setDefaultMaxItems(int maxItems)
+    {
+        this.defaultMaxItems = maxItems;
+    }
+
+    /**
+     * @return Returns the path.
+     */
+    public boolean isPath()
+    {
+        return path;
+    }
+
+    /**
+     * @param path
+     *            The path to set.
+     */
+    public void setPath(boolean path)
+    {
+        this.path = path;
+    }
+
+    /**
+     * @return Returns the maxItemsKey.
+     */
+    public String getMaxItemsKey()
+    {
+        return maxItemsKey;
+    }
+
+    /**
+     * @param maxItemsKey
+     *            The maxItemsKey to set.
+     */
+    public void setMaxItemsKey(String maxItemsKey)
+    {
+        this.maxItemsKey = maxItemsKey;
+    }
+
+    protected int getMaxItems(Context ctx)
+    {
+        return CtxHelper.getIntAttr(null, maxItemsKey, defaultMaxItems, ctx);
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/info/AbstractLs.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/info/AbstractLsItems.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/info/AbstractLsItems.java?rev=231495&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/info/AbstractLsItems.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/info/AbstractLsItems.java Thu Aug 11 11:04:29 2005
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.jackrabbit.chain.command.info;
+
+import java.util.Iterator;
+
+import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+
+import org.apache.commons.chain.Context;
+import org.apache.jackrabbit.chain.JcrCommandException;
+
+/**
+ * List items superclass
+ */
+public abstract class AbstractLsItems extends AbstractLs
+{
+    /** name width */
+    private int nameWidth = 40;
+
+    /** node type width */
+    private int typeWidth = 15;
+
+    /**
+     * 
+     * @param ctx
+     * @return Iterator containing the Items to list
+     * @throws JcrCommandException
+     * @throws RepositoryException
+     */
+    protected abstract Iterator getItems(Context ctx)
+            throws JcrCommandException, RepositoryException;
+
+    /**
+     * @inheritDoc
+     */
+    public final boolean execute(Context ctx) throws Exception
+    {
+        int nodes = 0;
+        int properties = 0;
+
+        // header
+        int[] width = new int[]
+        {
+                nameWidth, typeWidth, longWidth, longWidth, longWidth
+        };
+        String[] header = new String[]
+        {
+                bundle.getString("name"), bundle.getString("type"),
+                bundle.getString("isnode"), bundle.getString("isnew"),
+                bundle.getString("ismodified")
+        };
+
+        // print header
+        PrintHelper.printRow(ctx, width, header);
+
+        // print separator
+        PrintHelper.printSeparatorRow(ctx, width, '-');
+
+        // nodes
+        Iterator iter = getItems(ctx);
+
+        int index = 0;
+
+        int maxItems = getMaxItems(ctx);
+
+        // Print nodes
+        while (iter.hasNext() && index < maxItems)
+        {
+            Item i = (Item) iter.next();
+
+            String type = null;
+
+            // Show name or path
+            String name = null;
+            if (this.isPath())
+            {
+                name = i.getPath();
+            } else
+            {
+                name = i.getName();
+            }
+
+            if (i.isNode())
+            {
+                nodes++;
+                // name
+                Node n = (Node) i;
+                if (!isPath() && n.getIndex() > 1)
+                {
+                    name = n.getName() + "[" + n.getIndex() + "]";
+                }
+                // type
+                type = n.getPrimaryNodeType().getName();
+            } else
+            {
+                properties++;
+                type = PropertyType.nameFromValue(((Property) i).getType());
+            }
+
+            PrintHelper.printRow(ctx, width, new String[]
+            {
+                    name, type, Boolean.toString(i.isNode()),
+                    Boolean.valueOf(i.isNew()).toString(),
+                    Boolean.valueOf(i.isModified()).toString()
+            });
+            index++;
+        }
+
+        // Footer
+        printFooter(ctx, iter);
+
+        return false;
+    }
+
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/info/AbstractLsItems.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/info/AbstractLsNodes.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/info/AbstractLsNodes.java?rev=231495&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/info/AbstractLsNodes.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/info/AbstractLsNodes.java Thu Aug 11 11:04:29 2005
@@ -0,0 +1,797 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.jackrabbit.chain.command.info;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.NodeType;
+
+import org.apache.commons.chain.Context;
+import org.apache.jackrabbit.JcrConstants;
+import org.apache.jackrabbit.chain.CtxHelper;
+import org.apache.jackrabbit.chain.JcrCommandException;
+
+/**
+ * List nodes. <br>
+ * The following attributes will be used in order to customize the output:
+ * <ul>
+ * <li>pathKey</li>
+ * <li>uuidKey</li>
+ * <li>mixinKey</li>
+ * <li>nodesSizeKey</li>
+ * <li>propertiesSizeKey</li>
+ * <li>referencesSizeKey</li>
+ * <li>versionableKey</li>
+ * <li>lockableKey</li>
+ * <li>referenceableKey</li>
+ * <li>lockedKey</li>
+ * <li>hasLockKey</li>
+ * <li>new_Key</li>
+ * <li>modifiedKey</li>
+ * </ul>
+ */
+public abstract class AbstractLsNodes extends AbstractLs
+{
+    // show path
+    private String pathKey;
+
+    // show uuid
+    private String uuidKey;
+
+    // show mixin
+    private String mixinKey;
+
+    // show node size
+    private String nodesSizeKey;
+
+    // show properties size
+    private String propertiesSizeKey;
+
+    // show references size
+    private String referencesSizeKey;
+
+    // show is versionable
+    private String versionableKey;
+
+    // show is lockable
+    private String lockableKey;
+
+    // show is referenceable
+    private String referenceableKey;
+
+    // show is locked
+    private String lockedKey;
+
+    // show has lock
+    private String hasLockKey;
+
+    // show is new
+    private String new_Key;
+
+    // show is modified
+    private String modifiedKey;
+
+    /** uuid width */
+    private int uuidWidth = 36;
+
+    /** path width */
+    private int nameWidth = 30;
+
+    /** node type width */
+    private int nodeTypeWidth = 20;
+
+    /** node type width */
+    private int pathWidth = 40;
+
+    /** referenceable width */
+    private int mixinWidth = 30;
+
+    /**
+     * @inheritDoc
+     */
+    public final boolean execute(Context ctx) throws Exception
+    {
+        OptionHolder oh = new OptionHolder(ctx);
+
+        // Get children
+        Iterator iter = getNodes(ctx);
+
+        // write header
+        writeHeader(ctx, oh);
+
+        int index = 0;
+
+        int maxItems = getMaxItems(ctx);
+
+        // Write item
+        while (iter.hasNext() && index < maxItems)
+        {
+            Node n = (Node) iter.next();
+            writeItem(ctx, n, oh);
+            index++;
+        }
+
+        // Write footer
+        printFooter(ctx, iter);
+
+        return false;
+    }
+
+    /**
+     * Get nodes to show
+     * 
+     * @param ctx
+     * @return
+     * @throws RepositoryException
+     * @throws JcrCommandException
+     */
+    protected abstract Iterator getNodes(Context ctx)
+            throws JcrCommandException, RepositoryException;
+
+    /**
+     * Write a node to the current output
+     * 
+     * @param ctx
+     * @param n
+     * @throws RepositoryException
+     * @throws JcrCommandException
+     */
+    void writeItem(Context ctx, Node n, OptionHolder oh)
+            throws RepositoryException, JcrCommandException
+    {
+        // TODO do something with this long piece of code
+        Collection widths = new ArrayList();
+        Collection texts = new ArrayList();
+
+        widths.add(new Integer(this.nameWidth));
+
+        String name = n.getName();
+        if (n.getIndex() > 1)
+        {
+            name += "[" + n.getIndex() + "]";
+        }
+        texts.add(name);
+
+        widths.add(new Integer(this.nodeTypeWidth));
+        texts.add(n.getPrimaryNodeType().getName());
+
+        // uuid
+        if (oh.isUuid())
+        {
+            widths.add(new Integer(this.uuidWidth));
+            if (n.isNodeType(JcrConstants.MIX_REFERENCEABLE))
+            {
+                texts.add(n.getUUID());
+            } else
+            {
+                texts.add("");
+            }
+        }
+
+        // is new
+        if (oh.isNew_())
+        {
+            widths.add(new Integer(this.longWidth));
+            texts.add(Boolean.toString(n.isNew()));
+        }
+
+        // is new
+        if (oh.isModified())
+        {
+            widths.add(new Integer(this.longWidth));
+            texts.add(Boolean.toString(n.isModified()));
+        }
+
+        // mixin
+        if (oh.isMixin())
+        {
+            widths.add(new Integer(this.mixinWidth));
+            Collection mixins = new ArrayList();
+            // Assigned mixin types
+            NodeType[] assigned = n.getMixinNodeTypes();
+            for (int i = 0; i < assigned.length; i++)
+            {
+                mixins.add(assigned[i].getName());
+            }
+
+            // Inherited mixin types
+            NodeType[] nt = n.getPrimaryNodeType().getSupertypes();
+            for (int i = 0; i < nt.length; i++)
+            {
+                if (nt[i].isMixin())
+                {
+                    mixins.add(nt[i].getName());
+                }
+            }
+            texts.add(mixins);
+        }
+
+        // node size
+        if (oh.isNodesSize())
+        {
+            widths.add(new Integer(this.longWidth));
+            texts.add(Long.toString(n.getNodes().getSize()));
+        }
+
+        // prop size
+        if (oh.isPropertiesSize())
+        {
+            widths.add(new Integer(this.longWidth));
+            texts.add(Long.toString(n.getProperties().getSize()));
+        }
+
+        // ref size
+        if (oh.isReferencesSize())
+        {
+            widths.add(new Integer(this.longWidth));
+            texts.add(Long.toString(n.getReferences().getSize()));
+        }
+
+        // is versionable
+        if (oh.isVersionable())
+        {
+            widths.add(new Integer(this.longWidth));
+            texts.add(Boolean.toString(n
+                .isNodeType(JcrConstants.MIX_VERSIONABLE)));
+        }
+
+        // is lockable
+        if (oh.isLockable())
+        {
+            widths.add(new Integer(this.longWidth));
+            texts
+                .add(Boolean.toString(n.isNodeType(JcrConstants.MIX_LOCKABLE)));
+        }
+
+        // is referenceable
+        if (oh.isReferenceable())
+        {
+            widths.add(new Integer(this.longWidth));
+            texts.add(Boolean.toString(n
+                .isNodeType(JcrConstants.MIX_REFERENCEABLE)));
+        }
+
+        // is locked
+        if (oh.isLocked())
+        {
+            widths.add(new Integer(this.longWidth));
+            texts.add(Boolean.toString(n.isLocked()));
+        }
+
+        // has lock
+        if (oh.isHasLock())
+        {
+            widths.add(new Integer(this.longWidth));
+            texts.add(Boolean.toString(n.holdsLock()));
+        }
+
+        // path
+        if (oh.isPath())
+        {
+            widths.add(new Integer(this.pathWidth));
+            texts.add(n.getPath());
+        }
+
+        PrintHelper.printRow(ctx, widths, texts);
+    }
+
+    /**
+     * Prints the header
+     * 
+     * @param ctx
+     * @throws JcrCommandException
+     */
+    void writeHeader(Context ctx, OptionHolder oh) throws JcrCommandException
+    {
+        // TODO do something with this long piece of code
+        Collection widths = new ArrayList();
+        Collection texts = new ArrayList();
+        widths.add(new Integer(this.nameWidth));
+        texts.add(bundle.getString("name"));
+        widths.add(new Integer(this.nodeTypeWidth));
+        texts.add(bundle.getString("nodetype"));
+
+        // uuid
+        if (oh.isUuid())
+        {
+            widths.add(new Integer(this.uuidWidth));
+            texts.add("uuid");
+        }
+
+        // is new
+        if (oh.isNew_())
+        {
+            widths.add(new Integer(this.longWidth));
+            texts.add(bundle.getString("new"));
+        }
+
+        // is new
+        if (oh.isModified())
+        {
+            widths.add(new Integer(this.longWidth));
+            texts.add(bundle.getString("modified"));
+        }
+
+        // mixin
+        if (oh.isMixin())
+        {
+            widths.add(new Integer(this.mixinWidth));
+            texts.add("mixin");
+        }
+
+        // node size
+        if (oh.isNodesSize())
+        {
+            widths.add(new Integer(this.longWidth));
+            texts.add(bundle.getString("nodes"));
+        }
+
+        // prop size
+        if (oh.isPropertiesSize())
+        {
+            widths.add(new Integer(this.longWidth));
+            texts.add(bundle.getString("properties"));
+        }
+
+        // ref size
+        if (oh.isReferencesSize())
+        {
+            widths.add(new Integer(this.longWidth));
+            texts.add(bundle.getString("references"));
+        }
+
+        // is versionable
+        if (oh.isVersionable())
+        {
+            widths.add(new Integer(this.longWidth));
+            texts.add(bundle.getString("versionable"));
+        }
+
+        // is lockable
+        if (oh.isLockable())
+        {
+            widths.add(new Integer(this.longWidth));
+            texts.add(bundle.getString("lockable"));
+        }
+
+        // is referenceable
+        if (oh.isReferenceable())
+        {
+            widths.add(new Integer(this.longWidth));
+            texts.add(bundle.getString("referenceable"));
+        }
+
+        // is locked
+        if (oh.isLocked())
+        {
+            widths.add(new Integer(this.longWidth));
+            texts.add(bundle.getString("locked"));
+        }
+
+        // has lock
+        if (oh.isHasLock())
+        {
+            widths.add(new Integer(this.longWidth));
+            texts.add(bundle.getString("has.lock"));
+        }
+
+        // path
+        if (oh.isPath())
+        {
+            widths.add(new Integer(this.pathWidth));
+            texts.add(bundle.getString("path"));
+        }
+
+        PrintHelper.printRow(ctx, widths, texts);
+        PrintHelper.printSeparatorRow(ctx, widths, '-');
+    }
+
+    private class OptionHolder
+    {
+        // show path
+        boolean path = false;
+
+        // show uuid
+        boolean uuid = false;
+
+        // show mixin
+        boolean mixin = false;
+
+        // show node size
+        boolean nodesSize = false;
+
+        // show properties size
+        boolean propertiesSize = false;
+
+        // show references size
+        boolean referencesSize = false;
+
+        // show is versionable
+        boolean versionable = false;
+
+        // show is lockable
+        boolean lockable = false;
+
+        // show is referenceable
+        boolean referenceable = false;
+
+        // show is locked
+        boolean locked = false;
+
+        // show has lock
+        boolean hasLock = false;
+
+        // show is new
+        boolean new_ = false;
+
+        // show is modified
+        boolean modified = false;
+
+        /**
+         * 
+         */
+        public OptionHolder(Context ctx)
+        {
+            super();
+            path = CtxHelper.getBooleanAttr(pathKey, false, ctx);
+            uuid = CtxHelper.getBooleanAttr(uuidKey, false, ctx);
+            mixin = CtxHelper.getBooleanAttr(mixinKey, false, ctx);
+            nodesSize = CtxHelper.getBooleanAttr(nodesSizeKey, false, ctx);
+            propertiesSize = CtxHelper.getBooleanAttr(propertiesSizeKey, false,
+                ctx);
+            referencesSize = CtxHelper.getBooleanAttr(referenceableKey, false,
+                ctx);
+            versionable = CtxHelper.getBooleanAttr(versionableKey, false, ctx);
+            lockable = CtxHelper.getBooleanAttr(lockableKey, false, ctx);
+            referenceable = CtxHelper.getBooleanAttr(referenceableKey, false,
+                ctx);
+            locked = CtxHelper.getBooleanAttr(lockedKey, false, ctx);
+            hasLock = CtxHelper.getBooleanAttr(hasLockKey, false, ctx);
+            new_ = CtxHelper.getBooleanAttr(new_Key, false, ctx);
+            modified = CtxHelper.getBooleanAttr(modifiedKey, false, ctx);
+        }
+
+        /**
+         * @return Returns the hasLock.
+         */
+        public boolean isHasLock()
+        {
+            return hasLock;
+        }
+
+        /**
+         * @return Returns the lockable.
+         */
+        public boolean isLockable()
+        {
+            return lockable;
+        }
+
+        /**
+         * @return Returns the locked.
+         */
+        public boolean isLocked()
+        {
+            return locked;
+        }
+
+        /**
+         * @return Returns the mixin.
+         */
+        public boolean isMixin()
+        {
+            return mixin;
+        }
+
+        /**
+         * @return Returns the modified.
+         */
+        public boolean isModified()
+        {
+            return modified;
+        }
+
+        /**
+         * @return Returns the new_.
+         */
+        public boolean isNew_()
+        {
+            return new_;
+        }
+
+        /**
+         * @return Returns the nodesSize.
+         */
+        public boolean isNodesSize()
+        {
+            return nodesSize;
+        }
+
+        /**
+         * @return Returns the propertiesSize.
+         */
+        public boolean isPropertiesSize()
+        {
+            return propertiesSize;
+        }
+
+        /**
+         * @return Returns the referenceable.
+         */
+        public boolean isReferenceable()
+        {
+            return referenceable;
+        }
+
+        /**
+         * @return Returns the referencesSize.
+         */
+        public boolean isReferencesSize()
+        {
+            return referencesSize;
+        }
+
+        /**
+         * @return Returns the uuid.
+         */
+        public boolean isUuid()
+        {
+            return uuid;
+        }
+
+        /**
+         * @return Returns the versionable.
+         */
+        public boolean isVersionable()
+        {
+            return versionable;
+        }
+
+        /**
+         * @return Returns the path.
+         */
+        public boolean isPath()
+        {
+            return path;
+        }
+    }
+
+    /**
+     * @return Returns the hasLockKey.
+     */
+    public String getHasLockKey()
+    {
+        return hasLockKey;
+    }
+
+    /**
+     * @param hasLockKey
+     *            The hasLockKey to set.
+     */
+    public void setHasLockKey(String hasLockKey)
+    {
+        this.hasLockKey = hasLockKey;
+    }
+
+    /**
+     * @return Returns the lockableKey.
+     */
+    public String getLockableKey()
+    {
+        return lockableKey;
+    }
+
+    /**
+     * @param lockableKey
+     *            The lockableKey to set.
+     */
+    public void setLockableKey(String lockableKey)
+    {
+        this.lockableKey = lockableKey;
+    }
+
+    /**
+     * @return Returns the lockedKey.
+     */
+    public String getLockedKey()
+    {
+        return lockedKey;
+    }
+
+    /**
+     * @param lockedKey
+     *            The lockedKey to set.
+     */
+    public void setLockedKey(String lockedKey)
+    {
+        this.lockedKey = lockedKey;
+    }
+
+    /**
+     * @return Returns the mixinKey.
+     */
+    public String getMixinKey()
+    {
+        return mixinKey;
+    }
+
+    /**
+     * @param mixinKey
+     *            The mixinKey to set.
+     */
+    public void setMixinKey(String mixinKey)
+    {
+        this.mixinKey = mixinKey;
+    }
+
+    /**
+     * @return Returns the modifiedKey.
+     */
+    public String getModifiedKey()
+    {
+        return modifiedKey;
+    }
+
+    /**
+     * @param modifiedKey
+     *            The modifiedKey to set.
+     */
+    public void setModifiedKey(String modifiedKey)
+    {
+        this.modifiedKey = modifiedKey;
+    }
+
+    /**
+     * @return Returns the new_Key.
+     */
+    public String getNew_Key()
+    {
+        return new_Key;
+    }
+
+    /**
+     * @param new_Key
+     *            The new_Key to set.
+     */
+    public void setNew_Key(String new_Key)
+    {
+        this.new_Key = new_Key;
+    }
+
+    /**
+     * @return Returns the nodesSizeKey.
+     */
+    public String getNodesSizeKey()
+    {
+        return nodesSizeKey;
+    }
+
+    /**
+     * @param nodesSizeKey
+     *            The nodesSizeKey to set.
+     */
+    public void setNodesSizeKey(String nodesSizeKey)
+    {
+        this.nodesSizeKey = nodesSizeKey;
+    }
+
+    /**
+     * @return Returns the pathKey.
+     */
+    public String getPathKey()
+    {
+        return pathKey;
+    }
+
+    /**
+     * @param pathKey
+     *            The pathKey to set.
+     */
+    public void setPathKey(String pathKey)
+    {
+        this.pathKey = pathKey;
+    }
+
+    /**
+     * @return Returns the propertiesSizeKey.
+     */
+    public String getPropertiesSizeKey()
+    {
+        return propertiesSizeKey;
+    }
+
+    /**
+     * @param propertiesSizeKey
+     *            The propertiesSizeKey to set.
+     */
+    public void setPropertiesSizeKey(String propertiesSizeKey)
+    {
+        this.propertiesSizeKey = propertiesSizeKey;
+    }
+
+    /**
+     * @return Returns the referenceableKey.
+     */
+    public String getReferenceableKey()
+    {
+        return referenceableKey;
+    }
+
+    /**
+     * @param referenceableKey
+     *            The referenceableKey to set.
+     */
+    public void setReferenceableKey(String referenceableKey)
+    {
+        this.referenceableKey = referenceableKey;
+    }
+
+    /**
+     * @return Returns the referencesSizeKey.
+     */
+    public String getReferencesSizeKey()
+    {
+        return referencesSizeKey;
+    }
+
+    /**
+     * @param referencesSizeKey
+     *            The referencesSizeKey to set.
+     */
+    public void setReferencesSizeKey(String referencesSizeKey)
+    {
+        this.referencesSizeKey = referencesSizeKey;
+    }
+
+    /**
+     * @return Returns the uuidKey.
+     */
+    public String getUuidKey()
+    {
+        return uuidKey;
+    }
+
+    /**
+     * @param uuidKey
+     *            The uuidKey to set.
+     */
+    public void setUuidKey(String uuidKey)
+    {
+        this.uuidKey = uuidKey;
+    }
+
+    /**
+     * @return Returns the versionableKey.
+     */
+    public String getVersionableKey()
+    {
+        return versionableKey;
+    }
+
+    /**
+     * @param versionableKey
+     *            The versionableKey to set.
+     */
+    public void setVersionableKey(String versionableKey)
+    {
+        this.versionableKey = versionableKey;
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/command/info/AbstractLsNodes.java
------------------------------------------------------------------------------
    svn:eol-style = native