jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edgarp...@apache.org
Subject svn commit: r294914 [3/6] - in /incubator/jackrabbit/trunk/contrib/jcr-commands: ./ applications/test/ applications/test/fs/ benchmarking/ src/cli/ src/java/ src/java/META-INF/ src/java/org/apache/jackrabbit/chain/ src/java/org/apache/jackrabbit/comman...
Date Tue, 04 Oct 2005 20:54:30 GMT
Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/ReadValue.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/ReadValue.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/ReadValue.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/ReadValue.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,132 @@
+/*
+ * 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.command.core;
+
+import javax.jcr.Property;
+
+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.command.CommandHelper;
+
+/**
+ * Read the Value of the given property and store it under the given context
+ * attribute.
+ */
+public class ReadValue implements Command
+{
+	/** logger */
+	private static Log log = LogFactory.getLog(ReadValue.class);
+
+	// ---------------------------- < keys >
+
+	/** property path key */
+	private String srcPathKey = "srcPath";
+
+	/** value index key */
+	private String srcIndexKey = "srcIndex";
+
+	/** destination context attribute */
+	private String destKey = "dest";
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.commons.chain.Command#execute(org.apache.commons.chain.Context)
+	 */
+	public boolean execute(Context ctx) throws Exception
+	{
+		String path = (String) ctx.get(this.srcPathKey);
+		int index = 1;
+		if (ctx.get(this.srcIndexKey) != null)
+		{
+			index = Integer.valueOf(((String) ctx.get(this.srcIndexKey)))
+					.intValue();
+		}
+
+		String dest = (String) ctx.get(this.destKey);
+
+		if (log.isDebugEnabled())
+		{
+			log.debug("reading value from " + path + "[" + index + "] to "
+					+ dest);
+		}
+
+		Property p = (Property) CommandHelper.getItem(ctx, path);
+
+		if (p.getDefinition().isMultiple())
+		{
+			ctx.put(dest, p.getValues()[index].getString());
+		} else
+		{
+			ctx.put(dest, p.getValue().getString());
+		}
+		return false;
+	}
+
+	/**
+	 * @return Returns the destKey.
+	 */
+	public String getDestKey()
+	{
+		return destKey;
+	}
+
+	/**
+	 * @param destKey
+	 *            The destKey to set.
+	 */
+	public void setDestKey(String destKey)
+	{
+		this.destKey = destKey;
+	}
+
+	/**
+	 * @return Returns the srcIndexKey.
+	 */
+	public String getSrcIndexKey()
+	{
+		return srcIndexKey;
+	}
+
+	/**
+	 * @param srcIndexKey
+	 *            The srcIndexKey to set.
+	 */
+	public void setSrcIndexKey(String srcIndexKey)
+	{
+		this.srcIndexKey = srcIndexKey;
+	}
+
+	/**
+	 * @return Returns the srcPathKey.
+	 */
+	public String getSrcPathKey()
+	{
+		return srcPathKey;
+	}
+
+	/**
+	 * @param srcPathKey
+	 *            The srcPathKey to set.
+	 */
+	public void setSrcPathKey(String srcPathKey)
+	{
+		this.srcPathKey = srcPathKey;
+	}
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/Refresh.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/Refresh.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/Refresh.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/Refresh.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,105 @@
+/*
+ * 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.command.core;
+
+import javax.jcr.Item;
+import javax.jcr.Session;
+
+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.command.CommandHelper;
+
+/**
+ * Refresh the session to reflect the current saved state. <br>
+ * If the path is set then only that Item is refreshed.
+ */
+public class Refresh implements Command
+{
+	/** logger */
+	private static Log log = LogFactory.getLog(Refresh.class);
+
+	// ---------------------------- < keys >
+	/** keep changes key */
+	private String keepChangesKey = "keepChanges";
+
+	/** path to the node to refresh key */
+	private String pathKey = "path";
+
+	/**
+	 * @return Returns the keepChangesKey.
+	 */
+	public String getKeepChangesKey()
+	{
+		return keepChangesKey;
+	}
+
+	/**
+	 * @param keepChangesKey
+	 *            The keepChangesKey to set.
+	 */
+	public void setKeepChangesKey(String keepChangesKey)
+	{
+		this.keepChangesKey = keepChangesKey;
+	}
+
+	/**
+	 * @inheritDoc
+	 */
+	public boolean execute(Context ctx) throws Exception
+	{
+		boolean keepChanges = Boolean.valueOf(
+				(String) ctx.get(this.keepChangesKey)).booleanValue();
+
+		String path = (String) ctx.get(this.pathKey);
+
+		if (log.isDebugEnabled())
+		{
+			log.debug("refreshing. from node " + path);
+		}
+
+		if (path == null)
+		{
+			Session s = CommandHelper.getSession(ctx);
+			s.refresh(keepChanges);
+		} else
+		{
+			Item i = CommandHelper.getItem(ctx, path);
+			i.refresh(keepChanges);
+		}
+
+		return false;
+	}
+
+	/**
+	 * @return Returns the pathKey.
+	 */
+	public String getPathKey()
+	{
+		return pathKey;
+	}
+
+	/**
+	 * @param pathKey
+	 *            The pathKey to set.
+	 */
+	public void setPathKey(String pathKey)
+	{
+		this.pathKey = pathKey;
+	}
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/RemoveItem.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/RemoveItem.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/RemoveItem.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/RemoveItem.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,76 @@
+/*
+ * 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.command.core;
+
+import javax.jcr.Item;
+
+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.command.CommandHelper;
+
+/**
+ * Removes the item at the given path.
+ */
+public class RemoveItem implements Command
+{
+	/** logger */
+	private static Log log = LogFactory.getLog(RemoveItem.class);
+
+	// ---------------------------- < keys >
+
+	/** context attribute key for the path attribute */
+	private String pathKey = "path";
+
+	/**
+	 * @inheritDoc
+	 */
+	public boolean execute(Context ctx) throws Exception
+	{
+		String path = (String) ctx.get(this.pathKey);
+		if (log.isDebugEnabled())
+		{
+			log.debug("removing item from " + path);
+		}
+		Item item = CommandHelper.getItem(ctx, path);
+		if (item.isSame(CommandHelper.getCurrentNode(ctx))
+				&& item.getDepth() > 0)
+		{
+			CommandHelper.setCurrentNode(ctx, item.getParent());
+		}
+		item.remove();
+		return false;
+	}
+
+	/**
+	 * @return Returns the pathKey.
+	 */
+	public String getPathKey()
+	{
+		return pathKey;
+	}
+
+	/**
+	 * @param pathKey
+	 *            The pathKey to set.
+	 */
+	public void setPathKey(String pathKey)
+	{
+		this.pathKey = pathKey;
+	}
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/RemoveItems.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/RemoveItems.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/RemoveItems.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/RemoveItems.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,118 @@
+/*
+ * 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.command.core;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.jcr.Item;
+import javax.jcr.Node;
+
+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.command.CommandHelper;
+import org.apache.jackrabbit.util.ChildrenCollectorFilter;
+
+/**
+ * Removes any item under the given node that match the given name pattern.
+ */
+public class RemoveItems implements Command
+{
+	/** logger */
+	private static Log log = LogFactory.getLog(RemoveItems.class);
+
+	// ---------------------------- < keys >
+	/** path key */
+	private String pathKey = "path";
+
+	/** item pattern key */
+	private String patternKey = "pattern";
+
+	/**
+	 * @inheritDoc
+	 */
+	public boolean execute(Context ctx) throws Exception
+	{
+		String pattern = (String) ctx.get(this.patternKey);
+		String path = (String) ctx.get(this.pathKey);
+
+		Node n = CommandHelper.getNode(ctx, path);
+
+		if (log.isDebugEnabled())
+		{
+			log.debug("removing nodes from " + n.getPath()
+					+ " that match pattern " + pattern);
+		}
+
+		List children = new ArrayList();
+		ChildrenCollectorFilter collector = new ChildrenCollectorFilter(
+				pattern, children, true, true, 1);
+		collector.visit(n);
+
+		Iterator items = children.iterator();
+
+		while (items.hasNext())
+		{
+			Item item = (Item) items.next();
+			if (item.isSame(CommandHelper.getCurrentNode(ctx))
+					&& item.getDepth() > 0)
+			{
+				CommandHelper.setCurrentNode(ctx, item.getParent());
+			}
+			item.remove();
+		}
+
+		return false;
+	}
+
+	/**
+	 * @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;
+	}
+
+	/**
+	 * @return Returns the pathKey.
+	 */
+	public String getPathKey()
+	{
+		return pathKey;
+	}
+
+	/**
+	 * @param pathKey
+	 *            The pathKey to set.
+	 */
+	public void setPathKey(String pathKey)
+	{
+		this.pathKey = pathKey;
+	}
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/Rename.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/Rename.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/Rename.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/Rename.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,89 @@
+/*
+ * 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.command.core;
+
+import javax.jcr.Node;
+import javax.jcr.Session;
+
+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.command.CommandHelper;
+
+/**
+ * Rename a node
+ */
+public class Rename implements Command
+{
+    /** logger */
+    private static Log log = LogFactory.getLog(Rename.class);
+
+    // ---------------------------- < keys >
+    /** source path */
+    private String srcPathKey = "srcPath";
+
+    /** destination path */
+    private String destPathKey = "destPath";
+
+    /**
+     * @inheritDoc
+     */
+    public boolean execute(Context ctx) throws Exception
+    {
+        String from = (String) ctx.get(this.srcPathKey);
+        String to = (String) ctx.get(this.destPathKey);
+
+        if (log.isDebugEnabled())
+        {
+            log.debug("renaming node from " + from + " to " + to);
+        }
+
+        Session s = CommandHelper.getSession(ctx);
+        Node nodeFrom = CommandHelper.getNode(ctx, from);
+        if (nodeFrom.getDepth() == 1)
+        {
+            s.move(nodeFrom.getPath(), "/" + to);
+        } else
+        {
+            s.move(nodeFrom.getPath(), nodeFrom.getParent().getPath() + "/"
+                    + to);
+        }
+
+        return false;
+    }
+
+    public String getDestPathKey()
+    {
+        return destPathKey;
+    }
+
+    public void setDestPathKey(String destPathKey)
+    {
+        this.destPathKey = destPathKey;
+    }
+
+    public String getSrcPathKey()
+    {
+        return srcPathKey;
+    }
+
+    public void setSrcPathKey(String srcPathKey)
+    {
+        this.srcPathKey = srcPathKey;
+    }
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/Save.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/Save.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/Save.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/Save.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,77 @@
+/*
+ * 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.command.core;
+
+import javax.jcr.Node;
+
+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.command.CommandHelper;
+
+/**
+ * Saves the current working node. <br>
+ * 
+ */
+public class Save implements Command
+{
+	/** logger */
+	private static Log log = LogFactory.getLog(Save.class);
+
+	// ---------------------------- < keys >
+	/** path key */
+	private String pathKey = "path";
+
+	/**
+	 * @inheritDoc
+	 */
+	public boolean execute(Context ctx) throws Exception
+	{
+		String path = (String) ctx.get(this.pathKey);
+
+		if (path == null)
+		{
+			log.debug("saving session");
+			CommandHelper.getSession(ctx).save();
+		} else
+		{
+			log.debug("saving node at " + path);
+			Node n = CommandHelper.getNode(ctx, path);
+			n.save();
+		}
+
+		return false;
+	}
+
+	/**
+	 * @return Returns the pathKey.
+	 */
+	public String getPathKey()
+	{
+		return pathKey;
+	}
+
+	/**
+	 * @param pathKey
+	 *            The pathKey to set.
+	 */
+	public void setPathKey(String pathKey)
+	{
+		this.pathKey = pathKey;
+	}
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/SetMultivalueProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/SetMultivalueProperty.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/SetMultivalueProperty.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/SetMultivalueProperty.java Tue Oct  4 13:51:32 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.command.core;
+
+import javax.jcr.Node;
+import javax.jcr.PropertyType;
+
+import org.apache.commons.chain.Context;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jackrabbit.command.CommandHelper;
+
+/**
+ * Set a multivalue property to the current working node. <br>
+ * The default regular expression is ",".
+ */
+public class SetMultivalueProperty extends AbstractSetProperty
+{
+	/** logger */
+	private static Log log = LogFactory.getLog(SetMultivalueProperty.class);
+
+	// ---------------------------- < keys >
+
+	/** regular expression key */
+	private String regExpKey = "regExp";
+
+	/**
+	 * @inheritDoc
+	 */
+	public boolean execute(Context ctx) throws Exception
+	{
+		String regExp = (String) ctx.get(this.regExpKey);
+		String value = (String) ctx.get(this.valueKey);
+		String name = (String) ctx.get(this.nameKey);
+		String type = (String) ctx.get(this.typeKey);
+		String parent = (String) ctx.get(this.parentPathKey);
+
+		Node node = CommandHelper.getNode(ctx, parent);
+
+		if (log.isDebugEnabled())
+		{
+			log.debug("setting multivalue property from node at "
+					+ node.getPath() + ". regexp=" + regExp + " value=" + value
+					+ " property=" + name);
+		}
+
+		String[] values = value.split(regExp);
+
+		if (type == null)
+		{
+			node.setProperty(name, values);
+		} else
+		{
+			node.setProperty(name, values, PropertyType.valueFromName(type));
+		}
+
+		return false;
+	}
+
+	/**
+	 * @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/command/core/SetMultivalueProperty.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/SetProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/SetProperty.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/SetProperty.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/SetProperty.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,62 @@
+/*
+ * 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.command.core;
+
+import javax.jcr.Node;
+import javax.jcr.PropertyType;
+
+import org.apache.commons.chain.Context;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jackrabbit.command.CommandHelper;
+
+/**
+ * Sets a property to the current working Node
+ */
+public class SetProperty extends AbstractSetProperty
+{
+	/** logger */
+	private static Log log = LogFactory.getLog(SetProperty.class);
+
+	/**
+	 * @inheritDoc
+	 */
+	public boolean execute(Context ctx) throws Exception
+	{
+		String value = (String) ctx.get(this.valueKey);
+		String name = (String) ctx.get(this.nameKey);
+		String propertyType = (String) ctx.get(this.typeKey);
+		String parent = (String) ctx.get(this.parentPathKey);
+
+		Node node = CommandHelper.getNode(ctx, parent);
+		if (log.isDebugEnabled())
+		{
+			log.debug("setting property to node at " + node.getPath()
+					+ ". property=" + name + " value=" + value);
+		}
+		if (propertyType == null)
+		{
+			node.setProperty(name, value);
+		} else
+		{
+			node.setProperty(name, value, PropertyType
+					.valueFromName(propertyType));
+		}
+		return false;
+	}
+
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/ConnectToRmiServer.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/ConnectToRmiServer.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/ConnectToRmiServer.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/ConnectToRmiServer.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,72 @@
+/*
+ * 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.command.ext;
+
+import javax.jcr.Repository;
+
+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.command.CommandHelper;
+import org.apache.jackrabbit.rmi.client.ClientRepositoryFactory;
+
+/**
+ * Connect to a JCR-RMI server
+ */
+public class ConnectToRmiServer implements Command
+{
+	/** logger */
+	private static Log log = LogFactory.getLog(ConnectToRmiServer.class);
+
+	// ---------------------------- < keys >
+	/** url key */
+	private String urlKey = "url";
+
+	/**
+	 * @inheritDoc
+	 */
+	public boolean execute(Context ctx) throws Exception
+	{
+		String url = (String) ctx.get(this.urlKey);
+		if (log.isDebugEnabled())
+		{
+			log.debug("connecting to jcr-rmi server at " + url);
+		}
+		ClientRepositoryFactory factory = new ClientRepositoryFactory();
+		Repository repository = factory.getRepository(url);
+		CommandHelper.setRepository(ctx, repository);
+		return false;
+	}
+
+	/**
+	 * @return Returns the urlKey.
+	 */
+	public String getUrlKey()
+	{
+		return urlKey;
+	}
+
+	/**
+	 * @param urlKey
+	 *            The urlKey to set.
+	 */
+	public void setUrlKey(String urlKey)
+	{
+		this.urlKey = urlKey;
+	}
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/CreateWorkspace.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/CreateWorkspace.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/CreateWorkspace.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/CreateWorkspace.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,75 @@
+/*
+ * 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.command.ext;
+
+import java.util.ResourceBundle;
+
+import javax.jcr.Workspace;
+
+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.command.CommandHelper;
+import org.apache.jackrabbit.core.WorkspaceImpl;
+
+/**
+ * Creates a Workspace.<br>
+ * Note that this Command uses Jackrabbit specific API.
+ */
+public class CreateWorkspace implements Command
+{
+	/** bundle */
+	ResourceBundle bundle = CommandHelper.getBundle();
+
+	/** logger */
+	private static Log log = LogFactory.getLog(CreateWorkspace.class);
+
+	// ---------------------------- < keys >
+	/** workspace name key */
+	private String nameKey = "name";
+
+	public boolean execute(Context ctx) throws Exception
+	{
+		String name = (String) ctx.get(this.nameKey);
+		if (log.isDebugEnabled())
+		{
+			log.debug("creating workspace for name " + name);
+		}
+		Workspace w = CommandHelper.getSession(ctx).getWorkspace();
+		if (w instanceof WorkspaceImpl == false)
+		{
+			throw new IllegalStateException(bundle
+					.getString("phrase.jackrabbit.command"));
+		}
+
+		WorkspaceImpl jrw = (WorkspaceImpl) w;
+		jrw.createWorkspace(name);
+		return false;
+	}
+
+	public String getNameKey()
+	{
+		return nameKey;
+	}
+
+	public void setNameKey(String nameKey)
+	{
+		this.nameKey = nameKey;
+	}
+
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/RegisterNodeType.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/RegisterNodeType.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/RegisterNodeType.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/RegisterNodeType.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,32 @@
+/*
+ * 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.command.ext;
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+
+/**
+ * Register a node type
+ */
+public class RegisterNodeType implements Command
+{
+	public boolean execute(Context arg0) throws Exception
+	{
+		throw new UnsupportedOperationException("not implemented yet");
+	}
+
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/StartJackrabbit.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/StartJackrabbit.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/StartJackrabbit.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/StartJackrabbit.java Tue Oct  4 13:51:32 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.command.ext;
+
+import javax.jcr.Repository;
+
+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.command.CommandHelper;
+import org.apache.jackrabbit.core.RepositoryImpl;
+import org.apache.jackrabbit.core.config.RepositoryConfig;
+
+/**
+ * <p>
+ * Starts a Jackrabbit instance and put it in the <code>Context</code>.
+ * </p>
+ */
+public class StartJackrabbit implements Command
+{
+    /** logger */
+    private static Log log = LogFactory.getLog(StartJackrabbit.class);
+
+    /** config file */
+    private String configKey = "config";
+
+    /** home folder */
+    private String homeKey = "home";
+
+    /**
+     * @inheritDoc
+     */
+    public boolean execute(Context ctx) throws Exception
+    {
+        String config = (String) ctx.get(this.configKey);
+        String home = (String) ctx.get(this.homeKey);
+        if (log.isDebugEnabled())
+        {
+            log
+                .debug("starting jackrabbit. config=" + config + " home="
+                        + home);
+        }
+        RepositoryConfig conf = RepositoryConfig.create(config, home);
+        Repository repo = RepositoryImpl.create(conf);
+        CommandHelper.setRepository(ctx, repo);
+        return false;
+    }
+
+    public String getConfigKey()
+    {
+        return configKey;
+    }
+
+    public void setConfigKey(String configKey)
+    {
+        this.configKey = configKey;
+    }
+
+    public String getHomeKey()
+    {
+        return homeKey;
+    }
+
+    public void setHomeKey(String homeKey)
+    {
+        this.homeKey = homeKey;
+    }
+
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/StartJackrabbitSingleton.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/StartJackrabbitSingleton.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/StartJackrabbitSingleton.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/StartJackrabbitSingleton.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,114 @@
+/*
+ * 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.command.ext;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jcr.Repository;
+
+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.command.CommandHelper;
+import org.apache.jackrabbit.core.RepositoryImpl;
+import org.apache.jackrabbit.core.config.RepositoryConfig;
+
+/**
+ * <p>
+ * Get a Jackrabbit instance and put it in the <code>Context</code>.<br>
+ * This commands maintains a cache with already created instances.<br>
+ * if there's no Repository for the given config and home settings a 
+ * new instance will be created and cached.
+ * </p>
+ */
+public class StartJackrabbitSingleton implements Command
+{
+	/** logger */
+	private static Log log = LogFactory.getLog(StartJackrabbitSingleton.class);
+
+	/** cache */
+	private static Map cache = new HashMap();
+
+	/** config file */
+	private String configKey = "config";
+
+	/** home folder */
+	private String homeKey = "home";
+
+	/**
+	 * @inheritDoc
+	 */
+	public boolean execute(Context ctx) throws Exception
+	{
+		String config = (String) ctx.get(this.configKey);
+		String home = (String) ctx.get(this.homeKey);
+
+		if (log.isDebugEnabled())
+		{
+			log
+					.debug("starting jackrabbit. config=" + config + " home="
+							+ home);
+		}
+
+		try
+		{
+			synchronized (cache)
+			{
+				String key = config + "@" + home;
+				Repository repo = (Repository) cache.get(key);
+				if (repo == null)
+				{
+					String msg = "Starting Jakrabbit instance";
+					log.info(msg);
+					RepositoryConfig conf = RepositoryConfig.create(config,
+							home);
+					repo = RepositoryImpl.create(conf);
+					cache.put(key, repo);
+				}
+				CommandHelper.setRepository(ctx, repo);
+			}
+		} catch (Exception e)
+		{
+			log.error("Unable to start jackrabbit", e) ;
+			throw e;
+		}
+		return false;
+	}
+
+	public String getConfigKey()
+	{
+		return configKey;
+	}
+
+	public void setConfigKey(String configKey)
+	{
+		this.configKey = configKey;
+	}
+
+	public String getHomeKey()
+	{
+		return homeKey;
+	}
+
+	public void setHomeKey(String homeKey)
+	{
+		this.homeKey = homeKey;
+	}
+
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/StopJackrabbit.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/StopJackrabbit.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/StopJackrabbit.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/StopJackrabbit.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,58 @@
+/*
+ * 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.command.ext;
+
+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.command.CommandHelper;
+import org.apache.jackrabbit.core.RepositoryImpl;
+
+/**
+ * Stop Jackrabbit
+ */
+public class StopJackrabbit implements Command
+{
+
+	/** logger */
+	private static Log log = LogFactory.getLog(StopJackrabbit.class);
+
+	/**
+	 * @inheritDoc
+	 */
+	public boolean execute(Context ctx) throws Exception
+	{
+		if (log.isDebugEnabled())
+		{
+			log.debug("stopping jackrabbit");
+		}
+		RepositoryImpl repo = (RepositoryImpl) CommandHelper.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();
+		CommandHelper.setRepository(ctx, null);
+		return false;
+	}
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/package.html
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/package.html?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/package.html (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/package.html Tue Oct  4 13:51:32 2005
@@ -0,0 +1,3 @@
+<body>
+	Commands in this package are Jackrabbit specific.
+</body>
\ No newline at end of file

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/ExportFileSystem.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/ExportFileSystem.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/ExportFileSystem.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/ExportFileSystem.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,211 @@
+/*
+ * 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.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.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jackrabbit.command.CommandException;
+import org.apache.jackrabbit.command.CommandHelper;
+
+/**
+ * Exports a node of type nt:file or nt:folder to the given file system path.
+ */
+public class ExportFileSystem implements Command
+{
+	/** logger */
+	private static Log log = LogFactory.getLog(ExportFileSystem.class);
+
+	// ---------------------------- < keys >
+
+	/** Node path key */
+	private String srcJcrPathKey = "srcJcrPath";
+
+	/** File system path key */
+	private String destFsPathKey = "destFsPath";
+
+	/** Overwrite flag key */
+	private String overwriteKey = "overwrite";
+
+	/**
+	 * @inheritDoc
+	 */
+	public boolean execute(Context ctx) throws Exception
+	{
+		String from = (String) ctx.get(this.srcJcrPathKey);
+		String to = (String) ctx.get(this.destFsPathKey);
+		boolean overwrite = Boolean
+				.valueOf((String) ctx.get(this.overwriteKey)).booleanValue();
+
+		if (log.isDebugEnabled())
+		{
+			log.debug("exporting node at " + from + " to the filesystem (" + to
+					+ ") overwrite=" + overwrite);
+		}
+
+		Node node = CommandHelper.getNode(ctx, from);
+
+		File f = new File(to);
+
+		// check if the file exists
+		if (f.exists() && !overwrite)
+		{
+			throw new CommandException("exception.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 CommandException("exception.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 CommandException
+	 * @throws ValueFormatException
+	 * @throws PathNotFoundException
+	 * @throws RepositoryException
+	 */
+	private void createFile(Node node, File file) throws IOException,
+			CommandException, ValueFormatException, PathNotFoundException,
+			RepositoryException
+	{
+
+		boolean created = file.createNewFile();
+		if (!created)
+		{
+			throw new CommandException("exception.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 CommandException
+	 * @throws RepositoryException
+	 * @throws IOException
+	 */
+	private void addFolder(Node node, File file) throws CommandException,
+			RepositoryException, IOException
+	{
+		boolean created = file.mkdir();
+
+		if (!created)
+		{
+			throw new CommandException("exception.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 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;
+	}
+
+	public String getSrcJcrPathKey()
+	{
+		return srcJcrPathKey;
+	}
+
+	public void setSrcJcrPathKey(String srcJcrPathKey)
+	{
+		this.srcJcrPathKey = srcJcrPathKey;
+	}
+
+	public String getDestFsPathKey()
+	{
+		return destFsPathKey;
+	}
+
+	public void setDestFsPathKey(String toFsPathKey)
+	{
+		this.destFsPathKey = toFsPathKey;
+	}
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/ExportPropertyToFile.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/ExportPropertyToFile.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/ExportPropertyToFile.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/ExportPropertyToFile.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,212 @@
+/*
+ * 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.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.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jackrabbit.command.CommandException;
+import org.apache.jackrabbit.command.CommandHelper;
+
+/**
+ * Exports a property value of the current working node to the file system.
+ */
+public class ExportPropertyToFile implements Command
+{
+	/** logger */
+	private static Log log = LogFactory.getLog(ExportPropertyToFile.class);
+
+	// ---------------------------- < keys >
+
+	/** property name */
+	private String nameKey = "name";
+
+	/** value index */
+	private String indexKey = "index";
+
+	/** target file */
+	private String destFsPathKey = "destFsPath";
+
+	/** overwrite the target file if necessary */
+	private String overwriteKey = "overwrite";
+
+	/**
+	 * @inheritDoc
+	 */
+	public boolean execute(Context ctx) throws Exception
+	{
+		String name = (String) ctx.get(this.nameKey);
+		Integer index = (Integer) ctx.get(this.indexKey);
+		String to = (String) ctx.get(this.destFsPathKey);
+
+		Node n = CommandHelper.getCurrentNode(ctx);
+
+		if (log.isDebugEnabled())
+		{
+			log.debug("exporting property value from " + n.getPath() + "/"
+					+ name + " to the filesystem: " + to);
+		}
+
+		Property p = n.getProperty(name);
+		if (p.getDefinition().isMultiple())
+		{
+			exportValue(ctx, p.getValues()[index.intValue()], to);
+		} else
+		{
+			exportValue(ctx, p.getValue(), to);
+		}
+		return false;
+	}
+
+	/**
+	 * Export th given value to a File
+	 * 
+	 * @param ctx
+	 * @param value
+	 * @throws CommandException
+	 * @throws IOException
+	 * @throws RepositoryException
+	 * @throws IllegalStateException
+	 */
+	private void exportValue(Context ctx, Value value, String to)
+			throws CommandException, IOException, IllegalStateException,
+			RepositoryException
+	{
+		boolean overwrite = Boolean
+				.valueOf((String) ctx.get(this.overwriteKey)).booleanValue();
+
+		File file = new File(to);
+
+		// Check if there's a file at the given target path
+		if (file.exists() && !overwrite)
+		{
+			throw new CommandException("exception.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 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 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 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;
+	}
+
+	public String getDestFsPathKey()
+	{
+		return destFsPathKey;
+	}
+
+	public void setDestFsPathKey(String destFsPathKey)
+	{
+		this.destFsPathKey = destFsPathKey;
+	}
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/ImportFileSystem.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/ImportFileSystem.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/ImportFileSystem.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/ImportFileSystem.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,195 @@
+/*
+ * 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.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.command.CommandHelper;
+import org.apache.jackrabbit.command.CommandException;
+
+/**
+ * This command imports data from the file system. <br>
+ * If the given path refers to a file it's imported 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
+ */
+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);
+		}
+	}
+
+	// ---------------------------- < keys >
+
+	/** File system path key */
+	private String srcFsPathKey = "srcFsPath";
+
+	public boolean execute(Context ctx) throws Exception
+	{
+		String file = (String) ctx.get(this.srcFsPathKey);
+		Node parent = CommandHelper.getCurrentNode(ctx);
+
+		if (log.isDebugEnabled())
+		{
+			log.debug("importing filesystem from " + file + " to node "
+					+ parent);
+		}
+
+		if (file == null)
+		{
+			throw new CommandException("exception.fspath.is.null");
+		}
+
+		File f = new File(file);
+
+		if (!f.exists())
+		{
+			throw new CommandException("exception.file.not.found", new String[]
+			{ file });
+		}
+
+		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 fromKey.
+	 */
+	public String getSrcFsPathKey()
+	{
+		return srcFsPathKey;
+	}
+
+	/**
+	 * @param fromKey
+	 *            Set the context attribute key for the from attribute.
+	 */
+	public void setSrcFsPathKey(String fromKey)
+	{
+		this.srcFsPathKey = fromKey;
+	}
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/SetPropertyFromFile.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/SetPropertyFromFile.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/SetPropertyFromFile.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/SetPropertyFromFile.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,88 @@
+/*
+ * 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.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.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jackrabbit.command.CommandException;
+import org.apache.jackrabbit.command.CommandHelper;
+import org.apache.jackrabbit.command.core.AbstractSetProperty;
+
+/**
+ * Set a property value with the content of the given files. The PropertyType
+ * may be specified.
+ */
+public class SetPropertyFromFile extends AbstractSetProperty
+{
+	/** logger */
+	private static Log log = LogFactory.getLog(SetPropertyFromFile.class);
+
+	/**
+	 * @inheritDoc
+	 */
+	public boolean execute(Context ctx) throws Exception
+	{
+		String value = (String) ctx.get(this.valueKey);
+		String name = (String) ctx.get(this.nameKey);
+		String propertyType = (String) ctx.get(this.typeKey);
+		String parent = (String) ctx.get(this.parentPathKey);
+
+		Node node = CommandHelper.getNode(ctx, parent);
+
+		if (log.isDebugEnabled())
+		{
+			log.debug("setting property " + node.getPath() + "/" + name
+					+ " with content of file " + value);
+		}
+
+		File f = new File(value);
+		if (!f.exists())
+		{
+			throw new CommandException("exception.file.not.found", new String[]
+			{ value });
+		}
+		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/command/fs/SetPropertyFromFile.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/mimetypes.properties
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/mimetypes.properties?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/mimetypes.properties (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/mimetypes.properties Tue Oct  4 13:51:32 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/command/fs/mimetypes.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLs.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLs.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLs.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLs.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,132 @@
+/*
+ * 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.command.info;
+
+import java.util.Iterator;
+import java.util.ResourceBundle;
+
+import javax.jcr.NodeIterator;
+import javax.jcr.PropertyIterator;
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.jackrabbit.command.CommandHelper;
+
+/**
+ * Ls superclass
+ */
+public abstract class AbstractLs implements Command
+{
+    /** bundle */
+    private static ResourceBundle bundle = CommandHelper.getBundle();
+
+    /** long width */
+    protected int longWidth = 10;
+
+    /** max items to list */
+    private int defaultMaxItems = 100;
+
+    /** max number of items */
+    private String maxItemsKey = "maxItems";
+
+    /** show path flag */
+    private boolean path;
+
+    protected void printFooter(Context ctx, Iterator iter)
+    {
+        CommandHelper.getOutput(ctx).println();
+        CommandHelper.getOutput(ctx).println(bundle.getString("word.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)
+    {
+        CommandHelper.getOutput(ctx).println(
+            iter.getSize() + " " + bundle.getString("word.nodes"));
+    }
+
+    private void printFooter(Context ctx, PropertyIterator iter)
+    {
+        CommandHelper.getOutput(ctx).println(
+            iter.getSize() + " " + bundle.getString("word.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;
+    }
+
+    /**
+     * @param ctx
+     * @return max number of items to show
+     */
+    protected int getMaxItems(Context ctx)
+    {
+        String maxItems = (String) ctx.get(this.maxItemsKey);
+        if (maxItems == null)
+        {
+            maxItems = new Integer(this.defaultMaxItems).toString();
+        }
+        return Integer.valueOf(maxItems).intValue();
+    }
+
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLsItems.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLsItems.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLsItems.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLsItems.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,137 @@
+/*
+ * 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.command.info;
+
+import java.util.Iterator;
+import java.util.ResourceBundle;
+
+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.command.CommandException;
+import org.apache.jackrabbit.command.CommandHelper;
+
+/**
+ * List items superclass
+ */
+public abstract class AbstractLsItems extends AbstractLs
+{
+	/** bundle */
+	private static ResourceBundle bundle = CommandHelper.getBundle() ; 
+	
+	/** name width */
+    private int nameWidth = 30;
+
+    /** node type width */
+    private int typeWidth = 15;
+
+    /**
+     * @param ctx
+     * @return Iterator containing the Items to list
+     * @throws CommandException
+     * @throws RepositoryException
+     */
+    protected abstract Iterator getItems(Context ctx)
+            throws CommandException, 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("word.name"), bundle.getString("word.type"),
+                bundle.getString("word.node"), bundle.getString("word.new"),
+                bundle.getString("word.modified")
+        };
+
+        // 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/command/info/AbstractLsItems.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message