jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edgarp...@apache.org
Subject svn commit: r294914 [4/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/info/AbstractLsNodes.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLsNodes.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLsNodes.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLsNodes.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,856 @@
+/*
+ * 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.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.ResourceBundle;
+
+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.command.CommandHelper;
+import org.apache.jackrabbit.command.CommandException;
+
+/**
+ * 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
+{
+	/** bundle */
+	private static ResourceBundle bundle = CommandHelper.getBundle();
+
+	// show path
+	private String pathKey = "path";
+
+	// show uuid
+	private String uuidKey = "uuid";
+
+	// show mixin
+	private String mixinKey = "mixin";
+
+	// show node size
+	private String nodesSizeKey = "nodeSize";
+
+	// show properties size
+	private String propertiesSizeKey = "propertiesSize";
+
+	// show references size
+	private String referencesSizeKey = "referencesSize";
+
+	// show is versionable
+	private String versionableKey = "versionable";
+
+	// show is lockable
+	private String lockableKey = "lockable";
+
+	// show is referenceable
+	private String referenceableKey = "referenceable";
+
+	// show is locked
+	private String lockedKey = "locked";
+
+	// show has lock
+	private String hasLockKey = "hasLock";
+
+	// show is new
+	private String new_Key = "new";
+
+	// show is modified
+	private String modifiedKey = "modified";
+
+	// show lock tocken
+	private String lockTokenKey = "lockToken";
+
+	/** 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 CommandException
+	 */
+	protected abstract Iterator getNodes(Context ctx) throws CommandException,
+			RepositoryException;
+
+	/**
+	 * Write a node to the current output
+	 * 
+	 * @param ctx
+	 * @param n
+	 * @throws RepositoryException
+	 * @throws CommandException
+	 */
+	void writeItem(Context ctx, Node n, OptionHolder oh)
+			throws RepositoryException, CommandException
+	{
+		// 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());
+		}
+
+		// lock token
+		if (oh.isLockToken())
+		{
+			widths.add(new Integer(this.nameWidth));
+			if (n.isLocked())
+			{
+				texts.add(n.getLock().getLockToken());
+			} else
+			{
+				texts.add("");
+			}
+		}
+
+		PrintHelper.printRow(ctx, widths, texts);
+	}
+
+	/**
+	 * Prints the header
+	 * 
+	 * @param ctx
+	 * @throws CommandException
+	 */
+	void writeHeader(Context ctx, OptionHolder oh) throws CommandException
+	{
+		// 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("word.name"));
+		widths.add(new Integer(this.nodeTypeWidth));
+		texts.add(bundle.getString("word.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("word.new"));
+		}
+
+		// is new
+		if (oh.isModified())
+		{
+			widths.add(new Integer(this.longWidth));
+			texts.add(bundle.getString("word.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("word.nodes"));
+		}
+
+		// prop size
+		if (oh.isPropertiesSize())
+		{
+			widths.add(new Integer(this.longWidth));
+			texts.add(bundle.getString("word.properties"));
+		}
+
+		// ref size
+		if (oh.isReferencesSize())
+		{
+			widths.add(new Integer(this.longWidth));
+			texts.add(bundle.getString("word.references"));
+		}
+
+		// is versionable
+		if (oh.isVersionable())
+		{
+			widths.add(new Integer(this.longWidth));
+			texts.add(bundle.getString("word.versionable"));
+		}
+
+		// is lockable
+		if (oh.isLockable())
+		{
+			widths.add(new Integer(this.longWidth));
+			texts.add(bundle.getString("word.lockable"));
+		}
+
+		// is referenceable
+		if (oh.isReferenceable())
+		{
+			widths.add(new Integer(this.longWidth));
+			texts.add(bundle.getString("word.referenceable"));
+		}
+
+		// is locked
+		if (oh.isLocked())
+		{
+			widths.add(new Integer(this.longWidth));
+			texts.add(bundle.getString("word.locked"));
+		}
+
+		// has lock
+		if (oh.isHasLock())
+		{
+			widths.add(new Integer(this.longWidth));
+			texts.add(bundle.getString("phrase.haslock"));
+		}
+
+		// path
+		if (oh.isPath())
+		{
+			widths.add(new Integer(this.pathWidth));
+			texts.add(bundle.getString("word.path"));
+		}
+
+		if (oh.isLockToken())
+		{
+			widths.add(new Integer(this.nameWidth));
+			texts.add(bundle.getString("word.locktoken"));
+		}
+
+		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;
+
+		boolean lockToken = false;
+
+		private Context ctx;
+
+		/**
+		 * @param key
+		 * @return the boolean value for the given key
+		 */
+		private boolean getFlag(String key)
+		{
+			boolean flag = false;
+			if (ctx.containsKey(key))
+			{
+				flag = Boolean.valueOf((String) ctx.get(key)).booleanValue();
+			}
+			return flag;
+		}
+
+		/**
+		 * Constructor
+		 */
+		public OptionHolder(Context ctx)
+		{
+			super();
+			this.ctx = ctx;
+			path = getFlag(pathKey);
+			uuid = getFlag(uuidKey);
+			mixin = getFlag(mixinKey);
+			nodesSize = getFlag(nodesSizeKey);
+			propertiesSize = getFlag(propertiesSizeKey);
+			referencesSize = getFlag(referencesSizeKey);
+			versionable = getFlag(versionableKey);
+			lockable = getFlag(lockableKey);
+			referenceable = getFlag(referenceableKey);
+			locked = getFlag(lockedKey);
+			hasLock = getFlag(hasLockKey);
+			new_ = getFlag(new_Key);
+			modified = getFlag(modifiedKey);
+			lockToken = getFlag(lockTokenKey);
+		}
+
+		/**
+		 * @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;
+		}
+
+		public boolean isLockToken()
+		{
+			return lockToken;
+		}
+	}
+
+	/**
+	 * @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;
+	}
+
+	public String getLockTokenKey()
+	{
+		return lockTokenKey;
+	}
+
+	public void setLockTokenKey(String lockTokenKey)
+	{
+		this.lockTokenKey = lockTokenKey;
+	}
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLsProperties.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLsProperties.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLsProperties.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLsProperties.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,163 @@
+/*
+ * 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.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.ResourceBundle;
+
+import javax.jcr.Property;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.ValueFormatException;
+
+import org.apache.commons.chain.Context;
+import org.apache.jackrabbit.command.CommandHelper;
+
+/**
+ * List properties superclass
+ */
+public abstract class AbstractLsProperties extends AbstractLs
+{
+
+    /** bundle */
+    private static ResourceBundle bundle = CommandHelper.getBundle();
+
+    /**
+     * @inheritDoc
+     */
+    public final boolean execute(Context ctx) throws Exception
+    {
+        int[] width = new int[]
+        {
+                30, longWidth, longWidth, longWidth, 20
+        };
+
+        String header[] = new String[]
+        {
+                bundle.getString("word.name"), bundle.getString("word.multiple"),
+                bundle.getString("word.type"), bundle.getString("word.length"),
+                bundle.getString("word.preview")
+        };
+
+        PrintHelper.printRow(ctx, width, header);
+        PrintHelper.printSeparatorRow(ctx, width, '-');
+
+        int index = 0;
+        Iterator iter = getProperties(ctx);
+
+        int maxItems = getMaxItems(ctx);
+
+        while (iter.hasNext() && index < maxItems)
+        {
+            Property p = (Property) iter.next();
+
+            long length = 0;
+
+            if (p.getDefinition().isMultiple())
+            {
+                long[] lengths = p.getLengths();
+                for (int i = 0; i < lengths.length; i++)
+                {
+                    length += lengths[i];
+                }
+            } else
+            {
+                length = p.getLength();
+            }
+
+            String multiple = Boolean.toString(p.getDefinition().isMultiple());
+            if (p.getDefinition().isMultiple())
+            {
+                multiple += "[" + p.getValues().length + "]";
+            }
+
+            Collection row = new ArrayList();
+            row.add(p.getName());
+            row.add(multiple);
+            row.add(PropertyType.nameFromValue(p.getType()));
+            row.add(Long.toString(length));
+            // preview
+            if (p.getDefinition().isMultiple())
+            {
+                row.add(this.getMultiplePreview(p));
+            } else
+            {
+                row.add(this.getPreview(p));
+            }
+
+            PrintHelper.printRow(ctx, width, row);
+            index++;
+        }
+
+        CommandHelper.getOutput(ctx).println();
+
+        // Write footer
+        printFooter(ctx, iter);
+
+        return false;
+    }
+
+    /**
+     * Subclasses are responsible of collecting the properties to display
+     * 
+     * @param ctx
+     * @return
+     */
+    protected abstract Iterator getProperties(Context ctx) throws Exception;
+
+    /**
+     * @param property
+     * @return the first 50 characters of single value properties
+     * @throws RepositoryException
+     */
+    private String getPreview(Property p) throws RepositoryException
+    {
+        String value = p.getValue().getString();
+        return value.substring(0, Math.min(value.length(), 50));
+    }
+
+    /**
+     * 
+     * @param property
+     * @return a <code>Collection</code> in which element contains the first
+     *         50 characters of the <code>Value</code>'s string
+     *         representation
+     * @throws RepositoryException
+     * @throws ValueFormatException
+     */
+    private Collection getMultiplePreview(Property p)
+            throws ValueFormatException, RepositoryException
+    {
+        Collection c = new ArrayList();
+        Value[] values = p.getValues();
+        for (int i = 0; i < values.length; i++)
+        {
+            try
+            {
+                String value = values[i].getString();
+                c.add(value.substring(0, Math.min(value.length(), 50)));
+            } catch (ValueFormatException e)
+            {
+                c.add(bundle.getString("phrase.notavailable"));
+            }
+        }
+        return c;
+    }
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Cat.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Cat.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Cat.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Cat.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,176 @@
+/*
+ * 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.io.BufferedReader;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringReader;
+
+import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.ValueFormatException;
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.jackrabbit.command.CommandHelper;
+import org.apache.jackrabbit.command.CommandException;
+
+/**
+ * Displays the content of a <code>Property</code> or a <code>Node</code> of
+ * type nt:file or nt:resource.
+ */
+public class Cat implements Command
+{
+    /** property name */
+    private String pathKey = "path";
+
+    /** index. [optional] argument to display multivalue properties */
+    private String indexKey = "index";
+
+    /**
+     * @inheritDoc
+     */
+    public boolean execute(Context ctx) throws Exception
+    {
+        String path = (String) ctx.get(this.pathKey);
+        Item item = CommandHelper.getItem(ctx, path);
+        if (item.isNode())
+        {
+            printNode(ctx, (Node) item);
+        } else
+        {
+            printProperty(ctx, (Property) item);
+        }
+        return false;
+    }
+
+    public String getPathKey()
+    {
+        return pathKey;
+    }
+
+    public void setPathKey(String path)
+    {
+        this.pathKey = path;
+    }
+
+    /**
+     * 
+     * @param ctx
+     * @param n
+     * @throws PathNotFoundException
+     * @throws CommandException
+     * @throws RepositoryException
+     * @throws IllegalStateException
+     * @throws IOException
+     */
+    private void printNode(Context ctx, Node n) throws PathNotFoundException,
+            CommandException, RepositoryException, IllegalStateException,
+            IOException
+    {
+        if (n.isNodeType("nt:file"))
+        {
+            printValue(ctx, n.getNode("jcr:content").getProperty("jcr:data")
+                .getValue());
+        } else if (n.isNodeType("nt:resource"))
+        {
+            printValue(ctx, n.getProperty("jcr:data").getValue());
+        } else
+        {
+            throw new CommandException("exception.cat.unsupported.type", new String[]
+            {
+                n.getPrimaryNodeType().getName()
+            });
+        }
+    }
+
+    /**
+     * 
+     * @param ctx
+     * @param p
+     * @throws CommandException
+     * @throws ValueFormatException
+     * @throws IllegalStateException
+     * @throws RepositoryException
+     * @throws IOException
+     */
+    private void printProperty(Context ctx, Property p)
+            throws CommandException, ValueFormatException,
+            IllegalStateException, RepositoryException, IOException
+    {
+        String indexStr = (String) ctx.get(this.indexKey);
+        int index = 0;
+        if (indexStr != null)
+        {
+            index = Integer.parseInt(indexStr);
+        }
+        if (p.getDefinition().isMultiple())
+        {
+            printValue(ctx, p.getValues()[index]);
+        } else
+        {
+            printValue(ctx, p.getValue());
+        }
+    }
+
+    /**
+     * Read the value
+     * 
+     * @param ctx
+     * @param value
+     * @throws ValueFormatException
+     * @throws IllegalStateException
+     * @throws RepositoryException
+     * @throws IOException
+     */
+    private void printValue(Context ctx, Value value)
+            throws ValueFormatException, IllegalStateException,
+            RepositoryException, IOException
+    {
+        PrintWriter out = CommandHelper.getOutput(ctx);
+        out.println();
+        BufferedReader in = new BufferedReader(new StringReader(value
+            .getString()));
+        String str = null;
+        while ((str = in.readLine()) != null)
+        {
+            out.println(str);
+        }
+    }
+
+    /**
+     * @return Returns the indexKey.
+     */
+    public String getIndexKey()
+    {
+        return indexKey;
+    }
+
+    /**
+     * @param indexKey
+     *            The indexKey to set.
+     */
+    public void setIndexKey(String indexKey)
+    {
+        this.indexKey = indexKey;
+    }
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Describe.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Describe.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Describe.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Describe.java Tue Oct  4 13:51:32 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.command.info;
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+
+/**
+ * Describes the given <code>Node</code>.
+ */
+public class Describe implements Command
+{
+
+	public boolean execute(Context arg0) throws Exception
+	{
+        throw new UnsupportedOperationException() ;
+	}
+
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Dump.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Dump.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Dump.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Dump.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.info;
+
+import java.io.PrintWriter;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.PropertyIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.jackrabbit.command.CommandHelper;
+
+/**
+ * Dumps stored data from the current working node
+ */
+public class Dump implements Command
+{
+	/** root node to dump */
+	private String pathKey = "path";
+
+	public boolean execute(Context ctx) throws Exception
+	{
+		String path = (String) ctx.get(this.pathKey);
+		PrintWriter out = CommandHelper.getOutput(ctx);
+		dump(out, CommandHelper.getNode(ctx, path));
+		return false;
+	}
+
+	public void dump(PrintWriter out, Node n) throws RepositoryException
+	{
+		out.println(n.getPath());
+		PropertyIterator pit = n.getProperties();
+		while (pit.hasNext())
+		{
+			Property p = pit.nextProperty();
+			out.print(p.getPath() + "=");
+			if (p.getDefinition().isMultiple())
+			{
+				Value[] values = p.getValues();
+				for (int i = 0; i < values.length; i++)
+				{
+					if (i > 0)
+						out.println(",");
+					out.println(values[i].getString());
+				}
+			} else
+			{
+				out.print(p.getString());
+			}
+			out.println();
+		}
+		NodeIterator nit = n.getNodes();
+		while (nit.hasNext())
+		{
+			Node cn = nit.nextNode();
+			dump(out, cn);
+		}
+	}
+
+	public String getPathKey()
+	{
+		return pathKey;
+	}
+
+	public void setPathKey(String pathKey)
+	{
+		this.pathKey = pathKey;
+	}
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Help.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Help.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Help.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Help.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,240 @@
+/*
+ * 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.io.PrintWriter;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.ResourceBundle;
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.jackrabbit.command.CommandException;
+import org.apache.jackrabbit.command.CommandHelper;
+import org.apache.jackrabbit.command.cli.AbstractParameter;
+import org.apache.jackrabbit.command.cli.Argument;
+import org.apache.jackrabbit.command.cli.CommandLine;
+import org.apache.jackrabbit.command.cli.CommandLineFactory;
+import org.apache.jackrabbit.command.cli.Flag;
+import org.apache.jackrabbit.command.cli.Option;
+
+/**
+ * Help on available commands
+ */
+public class Help implements Command
+{
+    /** bundle */
+    private static ResourceBundle bundle = CommandHelper.getBundle();
+
+    /** Command factory */
+    private CommandLineFactory factory = CommandLineFactory.getInstance();
+
+    /** Help formatter */
+    private HelpFormatter hf = new HelpFormatter();
+
+    /** command key */
+    private String commandKey = "command";
+
+    public boolean execute(Context ctx) throws Exception
+    {
+        String command = (String) ctx.get(this.commandKey) ;
+        PrintWriter out = CommandHelper.getOutput(ctx);
+        out.println();
+        if (command == null)
+        {
+            helpAll(ctx);
+        } else
+        {
+            helpCommand(ctx);
+        }
+        return false;
+    }
+
+    /**
+     * Writes help for all the commands
+     * 
+     * @param ctx
+     * @throws CommandException
+     */
+    private void helpAll(Context ctx) throws CommandException
+    {
+        PrintWriter out = CommandHelper.getOutput(ctx);
+        Collection descriptors = factory.getCommandLines();
+        Iterator iter = descriptors.iterator();
+
+        // Tab position
+        int tabPos = 20;
+        while (iter.hasNext())
+        {
+            CommandLine desc = (CommandLine) iter.next();
+            if (desc.getName().length() > tabPos)
+            {
+                tabPos = desc.getName().length() + 1;
+            }
+        }
+
+        iter = descriptors.iterator();
+        while (iter.hasNext())
+        {
+            CommandLine desc = (CommandLine) iter.next();
+            StringBuffer buf = new StringBuffer(desc.getName());
+            buf.setLength(tabPos);
+            for (int i = desc.getName().length(); i < buf.length(); i++)
+            {
+                buf.setCharAt(i, ' ');
+            }
+            buf.append(desc.getLocalizedDescription());
+            hf.printWrapped(out, 74, tabPos, buf.toString());
+        }
+    }
+
+    /**
+     * Writes detailed help for the given command
+     * 
+     * @param ctx
+     * @throws CommandException
+     */
+    private void helpCommand(Context ctx) throws CommandException
+    {
+        PrintWriter out = CommandHelper.getOutput(ctx);
+        
+        String cmdName = (String) ctx.get(this.commandKey) ;
+
+        CommandLine desc = factory.getCommandLine(cmdName);
+
+        out.println(bundle.getString("word.description") + ": ");
+        out.println(desc.getLocalizedDescription());
+        out.println();
+
+        // Usage
+        out.print(bundle.getString("word.usage") + ":");
+        out.print(desc.getName() + " ");
+
+        // Arguments
+        Iterator iter = desc.getArguments().values().iterator();
+        while (iter.hasNext())
+        {
+            Argument arg = (Argument) iter.next();
+            out.print("<" + arg.getLocalizedArgName() + "> ");
+        }
+
+        // Options
+        iter = desc.getOptions().values().iterator();
+        while (iter.hasNext())
+        {
+            Option arg = (Option) iter.next();
+            out.print("-" + arg.getName() + " <" + arg.getLocalizedArgName()
+                    + "> ");
+        }
+
+        // flags
+        iter = desc.getFlags().values().iterator();
+        while (iter.hasNext())
+        {
+            Flag arg = (Flag) iter.next();
+            out.print("-" + arg.getName() + " ");
+        }
+        out.println();
+
+        // Alias
+        if (desc.getAlias().size() > 0)
+        {
+            out.print(bundle.getString("word.alias") + ":");
+            iter = desc.getAlias().iterator();
+            while (iter.hasNext())
+            {
+                out.print((String) iter.next() + " ");
+
+            }
+            out.println();
+        }
+        out.println();
+
+        // Arguments details
+        if (desc.getArguments().size() > 0)
+        {
+            out.println("<" + bundle.getString("word.arguments") + ">");
+            printParam(ctx, desc.getArguments().values());
+        }
+
+        // Options details
+        if (desc.getOptions().values().size() > 0)
+        {
+            out.println();
+            out.println("<" + bundle.getString("word.options") + ">");
+            printParam(ctx, desc.getOptions().values());
+        }
+
+        // flag details
+        if (desc.getFlags().values().size() > 0)
+        {
+            out.println();
+            out.println("<" + bundle.getString("word.flags") + ">");
+            printParam(ctx, desc.getFlags().values());
+        }
+
+    }
+
+    private void printParam(Context ctx, Collection params)
+    {
+        int[] width = new int[]
+        {
+                10, 10, 10, 40
+        };
+
+        String[] header = new String[]
+        {
+                bundle.getString("word.name"), bundle.getString("word.argument"),
+                bundle.getString("word.required"), bundle.getString("word.description")
+        };
+
+        PrintHelper.printRow(ctx, width, header);
+        PrintHelper.printSeparatorRow(ctx, width, '-');
+
+        Iterator iter = params.iterator();
+        while (iter.hasNext())
+        {
+            AbstractParameter p = (AbstractParameter) iter.next();
+            String[] item = new String[]
+            {
+                    p.getName(), p.getLocalizedArgName(),
+                    Boolean.toString(p.isRequired()),
+                    p.getLocalizedDescription()
+            };
+            PrintHelper.printRow(ctx, width, item);
+        }
+
+    }
+
+    /**
+     * @return Returns the commandKey.
+     */
+    public String getCommandKey()
+    {
+        return commandKey;
+    }
+
+    /**
+     * @param commandKey
+     *            The commandKey to set.
+     */
+    public void setCommandKey(String commandKey)
+    {
+        this.commandKey = commandKey;
+    }
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/JcrInfoCommandException.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/JcrInfoCommandException.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/JcrInfoCommandException.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/JcrInfoCommandException.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,67 @@
+/*
+ * 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 org.apache.jackrabbit.command.CommandException;
+
+/**
+ * Exception thrown by Info Commands
+ */
+public class JcrInfoCommandException extends CommandException
+{
+    /**
+     * Comment for <code>serialVersionUID</code>
+     */
+    private static final long serialVersionUID = 3257854259679866933L;
+
+    /**
+     * @param message
+     */
+    public JcrInfoCommandException(String message)
+    {
+        super(message);
+    }
+
+    /**
+     * @param message
+     * @param arguments
+     */
+    public JcrInfoCommandException(String message, Object[] arguments)
+    {
+        super(message, arguments);
+    }
+
+    /**
+     * @param message
+     * @param cause
+     */
+    public JcrInfoCommandException(String message, Throwable cause)
+    {
+        super(message, cause);
+    }
+
+    /**
+     * @param message
+     * @param cause
+     * @param arguments
+     */
+    public JcrInfoCommandException(String message, Throwable cause,
+        Object[] arguments)
+    {
+        super(message, cause, arguments);
+    }
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsCollectedItems.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsCollectedItems.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsCollectedItems.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsCollectedItems.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,71 @@
+/*
+ * 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 javax.jcr.RepositoryException;
+
+import org.apache.commons.chain.Context;
+import org.apache.jackrabbit.command.CommandException;
+
+/**
+ * Lists collected nodes. This Command looks for an Iterator under the given
+ * context variable and lists its items.
+ */
+public class LsCollectedItems extends AbstractLsItems
+{
+    /** Context variable that holds the Iterator */
+    private String fromKey = "collected";
+
+    /**
+     * @return the context variable
+     */
+    public String getFromKey()
+    {
+        return fromKey;
+    }
+
+    /**
+     * Sets the context variable
+     * @param context variable name
+     */
+    public void setFromKey(String contextVariable)
+    {
+        this.fromKey = contextVariable;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    protected Iterator getItems(Context ctx) throws CommandException,
+            RepositoryException
+    {
+        // Always show the path
+        this.setPath(true);
+        Object o = ctx.get(this.fromKey);
+        if (o == null || !(o instanceof Iterator))
+        {
+            throw new JcrInfoCommandException(
+                "illegalargument.no.iterator.under", new String[]
+                {
+                    fromKey
+                });
+        }
+        return (Iterator) o;
+    }
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsCollectedNodes.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsCollectedNodes.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsCollectedNodes.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsCollectedNodes.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,70 @@
+/*
+ * 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 javax.jcr.RepositoryException;
+
+import org.apache.commons.chain.Context;
+import org.apache.jackrabbit.command.CommandException;
+
+/**
+ * Lists collected nodes. This Command looks for an Iterator under the given
+ * context variable and lists its nodes.
+ */
+public class LsCollectedNodes extends AbstractLsNodes
+{
+    /** Context variable that holds the Iterator */
+    private String fromKey = "collected";
+
+    /**
+     * @return the context variable
+     */
+    public String getFromKey()
+    {
+        return fromKey;
+    }
+
+    /**
+     * Sets the context variable
+     * @param context variable name
+     */
+    public void setFromKey(String contextVariable)
+    {
+        this.fromKey = contextVariable;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    protected Iterator getNodes(Context ctx) throws CommandException,
+            RepositoryException
+    {
+        this.setPath(true);
+        Object o = ctx.get(this.fromKey);
+        if (o == null || !(o instanceof Iterator))
+        {
+            throw new JcrInfoCommandException(
+                "illegalargument.no.iterator.under", new String[]
+                {
+                    fromKey
+                });
+        }
+        return (Iterator) o;
+    }
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsCollectedProperties.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsCollectedProperties.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsCollectedProperties.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsCollectedProperties.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,73 @@
+/*
+ * 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 javax.jcr.RepositoryException;
+
+import org.apache.commons.chain.Context;
+import org.apache.jackrabbit.command.CommandException;
+
+/**
+ * Lists collected properties.<br> 
+ * This Command looks for an Iterator under the given
+ * context variable and lists its properties.
+ */
+public class LsCollectedProperties extends AbstractLsProperties
+{
+    /** Context variable that holds the Iterator */
+    private String fromKey = "collected";
+
+    /**
+     * @return the context variable
+     */
+    public String getFromKey()
+    {
+        return fromKey;
+    }
+
+    /**
+     * Sets the context variable
+     * @param context variable name
+     */
+    public void setFromKey(String contextVariable)
+    {
+        this.fromKey = contextVariable;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    protected Iterator getProperties(Context ctx) throws CommandException,
+            RepositoryException
+    {
+        // show the path
+        this.setPath(true);
+        Object o = ctx.get(fromKey);
+        if (o == null || !(o instanceof Iterator))
+        {
+            throw new JcrInfoCommandException(
+                "illegalargument.no.iterator.under", new String[]
+                {
+                    fromKey
+                });
+        }
+        return (Iterator) o;
+    }
+
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsItems.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsItems.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsItems.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsItems.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.info;
+
+import java.util.Iterator;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+import org.apache.commons.chain.Context;
+import org.apache.jackrabbit.command.CommandHelper;
+import org.apache.jackrabbit.command.CommandException;
+
+/**
+ * List items
+ * 
+ * <p>
+ * <ul>
+ * <li>name</li>
+ * <li>type</li>
+ * <li>isNode</li>
+ * <li>isNew</li>
+ * <li>isModified</li>
+ * </ul>
+ * </p>
+ */
+public class LsItems extends AbstractLsItems
+{
+
+	/** name pattern key */
+	private String patternKey = "pattern";
+
+	/**
+	 * @return the name pattern
+	 */
+	public String getPatternKey()
+	{
+		return patternKey;
+	}
+
+	/**
+	 * Sets the name pattern
+	 * 
+	 * @param name
+	 *            pattern
+	 */
+	public void setPatternKey(String pattern)
+	{
+		this.patternKey = pattern;
+	}
+
+	/**
+	 * @inheritDoc
+	 */
+	protected Iterator getItems(Context ctx) throws CommandException,
+			RepositoryException
+	{
+		String pattern = (String) ctx.get(this.patternKey);
+		Node n = CommandHelper.getCurrentNode(ctx) ;
+		return CommandHelper.getItems(ctx, n, pattern);
+	}
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsNamespaces.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsNamespaces.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsNamespaces.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsNamespaces.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,35 @@
+/*
+ * 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 org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+
+/**
+ * Lists the registered namespaces
+ */
+public class LsNamespaces implements Command
+{
+
+    /**
+     * @inheritDoc
+     */
+    public boolean execute(Context ctx) throws Exception
+    {
+        throw new UnsupportedOperationException() ;
+    }
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsNodes.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsNodes.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsNodes.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsNodes.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,64 @@
+/*
+ * 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 javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+import org.apache.commons.chain.Context;
+import org.apache.jackrabbit.command.CommandHelper;
+import org.apache.jackrabbit.command.CommandException;
+
+/**
+ * Lists the nodes under the current working node that match the given pattern.
+ */
+public class LsNodes extends AbstractLsNodes
+{
+
+    /** name pattern key */
+    private String patternKey = "pattern";
+
+    /**
+     * @inheritDoc
+     */
+    protected Iterator getNodes(Context ctx) throws CommandException,
+            RepositoryException
+    {
+        String pattern = (String) ctx.get(this.patternKey);
+        Node n = CommandHelper.getCurrentNode(ctx) ;
+        return CommandHelper.getNodes(ctx, n, pattern);
+    }
+
+    /**
+     * @return Returns the patternKey.
+     */
+    public String getPatternKey()
+    {
+        return patternKey;
+    }
+
+    /**
+     * @param patternKey
+     *            The patternKey to set.
+     */
+    public void setPatternKey(String patternKey)
+    {
+        this.patternKey = patternKey;
+    }
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsProperties.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsProperties.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsProperties.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsProperties.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,73 @@
+/*
+ * 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 javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+import org.apache.commons.chain.Context;
+import org.apache.jackrabbit.command.CommandHelper;
+import org.apache.jackrabbit.command.CommandException;
+
+/**
+ * <p>
+ * Property fields:
+ * <ul>
+ * <li>name</li>
+ * <li>multiple</li>
+ * <li>type</li>
+ * <li>length</li>
+ * </ul>
+ * </p>
+ */
+public class LsProperties extends AbstractLsProperties
+{
+
+    /** property name pattern key */
+    private String patternKey = "pattern";
+
+    /**
+     * @return name pattern
+     */
+    public String getPatternKey()
+    {
+        return patternKey;
+    }
+
+    /**
+     * Sets the name pattern
+     * 
+     * @param pattern
+     */
+    public void setPatternKey(String pattern)
+    {
+        this.patternKey = pattern;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    protected Iterator getProperties(Context ctx) throws CommandException,
+            RepositoryException
+    {
+        String pattern = (String) ctx.get(this.patternKey) ;
+        Node n = CommandHelper.getCurrentNode(ctx) ;
+        return CommandHelper.getProperties(ctx, n, pattern);
+    }
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsReferences.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsReferences.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsReferences.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsReferences.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,98 @@
+/*
+ * 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.ResourceBundle;
+
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.PropertyIterator;
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.jackrabbit.command.CommandHelper;
+
+/**
+ * Displays references to the given Node
+ */
+public class LsReferences implements Command
+{
+	/** bundle */
+	private static ResourceBundle bundle = CommandHelper.getBundle() ; 
+	
+    /** path to the node */
+    private String pathKey = "path";
+
+    /**
+     * @inheritDoc
+     */
+    public boolean execute(Context ctx) throws Exception
+    {
+    	String path = (String) ctx.get(this.pathKey) ;
+        Node n = CommandHelper.getNode(ctx, path);
+
+        // header
+        int[] width = new int[]
+        {
+            60
+        };
+        String[] header = new String[]
+        {
+            bundle.getString("word.path")
+        };
+
+        // print header
+        PrintHelper.printRow(ctx, width, header);
+
+        // print separator
+        PrintHelper.printSeparatorRow(ctx, width, '-');
+
+        PropertyIterator iter = n.getReferences();
+        while (iter.hasNext())
+        {
+            Property p = iter.nextProperty();
+            // print header
+            PrintHelper.printRow(ctx, width, new String[]
+            {
+                p.getPath()
+            });
+        }
+
+        CommandHelper.getOutput(ctx).println();
+        CommandHelper.getOutput(ctx).println(
+            iter.getSize() + " " + bundle.getString("word.references"));
+
+        return false;
+    }
+
+    /**
+     * @return Returns the path.
+     */
+    public String getPathKey()
+    {
+        return pathKey;
+    }
+
+    /**
+     * @param path
+     *            The path to set.
+     */
+    public void setPathKey(String path)
+    {
+        this.pathKey = path;
+    }
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsVersions.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsVersions.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsVersions.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsVersions.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,83 @@
+/*
+ * 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.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.ResourceBundle;
+
+import javax.jcr.Node;
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionIterator;
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.jackrabbit.command.CommandHelper;
+
+/**
+ * Lists the <code>Version</code> in the <code>VersionHistory</code>.
+ */
+public class LsVersions implements Command
+{
+	/** bundle */
+	private static ResourceBundle bundle = CommandHelper.getBundle();
+
+	/** path to the node */
+	private String pathKey = "path";
+
+	/**
+	 * @inheritDoc
+	 */
+	public boolean execute(Context ctx) throws Exception
+	{
+		String path = (String) ctx.get(this.pathKey);
+		Node n = CommandHelper.getNode(ctx, path);
+
+		// header
+		int[] width = new int[]
+		{ 20, 50};
+		String[] header = new String[]
+		{ bundle.getString("word.version"), bundle.getString("word.labels") };
+		// print header
+		PrintHelper.printRow(ctx, width, header);
+		// print separator
+		PrintHelper.printSeparatorRow(ctx, width, '-');
+		VersionIterator iter = n.getVersionHistory().getAllVersions();
+		while (iter.hasNext())
+		{
+			Version v = iter.nextVersion();
+			Collection row = new ArrayList();
+			row.add(v.getName());
+			row.add(Arrays.asList(n.getVersionHistory().getVersionLabels(v)));
+			PrintHelper.printRow(ctx, width, row);
+		}
+
+		return false;
+	}
+
+	public String getPathKey()
+	{
+		return pathKey;
+	}
+
+	public void setPathKey(String pathKey)
+	{
+		this.pathKey = pathKey;
+	}
+
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/PrintHelper.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/PrintHelper.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/PrintHelper.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/PrintHelper.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,214 @@
+/*
+ * 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.io.PrintWriter;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.apache.commons.chain.Context;
+import org.apache.jackrabbit.command.CommandHelper;
+import org.apache.jackrabbit.command.CommandException;
+
+/**
+ * Helper methods to print
+ */
+class PrintHelper
+{
+
+	/**
+	 * 
+	 * @param ctx
+	 * @param width
+	 * @param text
+	 */
+	public static void printRow(Context ctx, int[] width, String[] text)
+	{
+		if (width.length != text.length)
+		{
+			throw new IllegalArgumentException(
+					"width[] and text[] haven't the same length");
+		}
+
+		PrintWriter out = CommandHelper.getOutput(ctx);
+
+		int rows = 1;
+
+		// Calculate rows
+		for (int i = 0; i < text.length; i++)
+		{
+			int textLength = text[i].length();
+			if (textLength == 0)
+			{
+				textLength = 1;
+			}
+			int columnWidth = width[i];
+			int neededRows = (int) Math.ceil((double) textLength
+					/ (double) columnWidth);
+			if (neededRows > rows)
+			{
+				rows = neededRows;
+			}
+		}
+
+		// Write table
+		for (int row = 0; row < rows; row++)
+		{
+			for (int column = 0; column < width.length; column++)
+			{
+				for (int pointer = 0; pointer < width[column]; pointer++)
+				{
+					int pos = row * width[column] + pointer;
+					if (pos < text[column].length())
+					{
+						out.print(text[column].charAt(pos));
+					} else
+					{
+						out.print(' ');
+					}
+				}
+				out.print(' ');
+			}
+			out.println();
+		}
+	}
+
+	/**
+	 * @param ctx
+	 * @param width
+	 * @param separator
+	 */
+	public static void printSeparatorRow(Context ctx, int[] width,
+			char separator)
+	{
+		PrintWriter out = CommandHelper.getOutput(ctx);
+		for (int i = 0; i < width.length; i++)
+		{
+			for (int j = 0; j <= width[i]; j++)
+			{
+				if (j < width[i])
+				{
+					out.print(separator);
+				} else
+				{
+					out.print(' ');
+				}
+			}
+		}
+		out.println();
+	}
+
+	/**
+	 * 
+	 * @param ctx
+	 * @param width
+	 * @param texts
+	 * @throws CommandException
+	 */
+	public static void printRow(Context ctx, int[] width, Collection texts)
+			throws CommandException
+	{
+		String[] text = new String[width.length];
+		Iterator iter = texts.iterator();
+		int column = 0;
+		while (iter.hasNext())
+		{
+			Object o = iter.next();
+			if (o == null)
+			{
+				text[column] = "";
+			} else if (o instanceof String)
+			{
+				text[column] = (String) o;
+			} else if (o instanceof Collection)
+			{
+				StringBuffer sb = new StringBuffer();
+				Iterator i = ((Collection) o).iterator();
+				while (i.hasNext())
+				{
+					String str = (String) i.next();
+					int rows = (int) Math.ceil((double) str.length()
+							/ (double) width[column]);
+					if (rows == 0)
+					{
+						rows = 1;
+					}
+					sb.append(str);
+					for (int j = 0; j < rows * width[column] - str.length(); j++)
+					{
+						sb.append(' ');
+					}
+				}
+				text[column] = sb.toString();
+			} else
+			{
+				throw new CommandException("exception.illegalargument");
+			}
+			column++;
+		}
+		printRow(ctx, width, text);
+	}
+
+	/**
+	 * 
+	 * @param ctx
+	 * @param widths
+	 * @param texts
+	 * @throws CommandException
+	 */
+	public static void printRow(Context ctx, Collection widths, Collection texts)
+			throws CommandException
+	{
+		printRow(ctx, convertWidth(widths), texts);
+	}
+
+	/**
+	 * 
+	 * @param ctx
+	 * @param widths
+	 * @param texts
+	 * @throws CommandException
+	 */
+	private static int[] convertWidth(Collection widths)
+			throws CommandException
+	{
+		int[] width = new int[widths.size()];
+		int index = 0;
+		Iterator iter = widths.iterator();
+		while (iter.hasNext())
+		{
+			Integer i = (Integer) iter.next();
+			width[index] = i.intValue();
+			index++;
+		}
+		return width;
+	}
+
+	/**
+	 * 
+	 * @param ctx
+	 * @param widths
+	 * @param separator
+	 * @throws CommandException
+	 */
+	public static void printSeparatorRow(Context ctx, Collection widths,
+			char separator) throws CommandException
+	{
+		printSeparatorRow(ctx, convertWidth(widths), separator);
+	}
+
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/lock/AddLockToken.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/lock/AddLockToken.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/lock/AddLockToken.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/lock/AddLockToken.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,65 @@
+/*
+ * 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.lock;
+
+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;
+
+/**
+ * Adds the given lock token to the current session.
+ */
+public class AddLockToken implements Command
+{
+	/** logger */
+	private static Log log = LogFactory.getLog(AddLockToken.class);
+
+	// ---------------------------- < keys >
+	/**
+	 * token
+	 */
+	private String tokenKey = "token";
+
+	/**
+	 * @inheritDoc
+	 */
+	public boolean execute(Context ctx) throws Exception
+	{
+		String token = (String) ctx.get(this.tokenKey);
+		if (log.isDebugEnabled())
+		{
+			log.debug("Adding lock token " + token + " to the current session.");
+		}
+		Session s = CommandHelper.getSession(ctx);
+		s.addLockToken(token);
+		return false;
+	}
+
+	public String getTokenKey()
+	{
+		return tokenKey;
+	}
+
+	public void setTokenKey(String tokenKey)
+	{
+		this.tokenKey = tokenKey;
+	}
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/lock/Lock.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/lock/Lock.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/lock/Lock.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/lock/Lock.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,103 @@
+/*
+ * 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.lock;
+
+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;
+
+/**
+ * Locks the given node
+ */
+public class Lock implements Command
+{
+	/** logger */
+	private static Log log = LogFactory.getLog(Lock.class);
+
+	// ---------------------------- < keys >
+	/** Node path key */
+	private String pathKey = "path";
+
+	/**
+	 * depth lock
+	 */
+	private String deepKey = "deep";
+
+	/**
+	 * Session scoped lock <br>
+	 * Key that refers to a <code>Boolean</code> context variable
+	 */
+	private String sessionScopedKey = "sessionScoped";
+
+	/**
+	 * @inheritDoc
+	 */
+	public boolean execute(Context ctx) throws Exception
+	{
+		String path = (String) ctx.get(this.pathKey);
+		boolean deep = Boolean.valueOf((String) ctx.get(this.deepKey))
+				.booleanValue();
+		boolean sessionScoped = Boolean.valueOf(
+				(String) ctx.get(this.sessionScopedKey)).booleanValue();
+		if (log.isDebugEnabled())
+		{
+			log.debug("locking node at " + path + " deep=" + deep
+					+ " sessionScoped=" + sessionScoped);
+		}
+		CommandHelper.getNode(ctx, path).lock(deep, sessionScoped);
+		return false;
+	}
+
+	public String getDeepKey()
+	{
+		return deepKey;
+	}
+
+	public void setDeepKey(String deepKey)
+	{
+		this.deepKey = deepKey;
+	}
+
+	public String getSessionScopedKey()
+	{
+		return sessionScopedKey;
+	}
+
+	public void setSessionScopedKey(String sessionScopedKey)
+	{
+		this.sessionScopedKey = sessionScopedKey;
+	}
+
+	/**
+	 * @return Returns the srcPathKey.
+	 */
+	public String getPathKey()
+	{
+		return pathKey;
+	}
+
+	/**
+	 * @param srcPathKey
+	 *            The srcPathKey to set.
+	 */
+	public void setPathKey(String srcPathKey)
+	{
+		this.pathKey = srcPathKey;
+	}
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/lock/RefreshLock.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/lock/RefreshLock.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/lock/RefreshLock.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/lock/RefreshLock.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,70 @@
+/*
+ * 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.lock;
+
+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;
+
+/**
+ * Resets lock timer
+ */
+public class RefreshLock implements Command
+{
+    /** logger */
+    private static Log log = LogFactory.getLog(RefreshLock.class);
+
+    // ---------------------------- < keys >
+    /** Node path key */
+    private String pathKey = "path";
+
+    /**
+     * @inheritDoc
+     */
+    public boolean execute(Context ctx) throws Exception
+    {
+        String path = (String) ctx.get(this.pathKey);
+        if (log.isDebugEnabled())
+        {
+            log.debug("refreshing lock at " + path);
+        }
+        Node n = CommandHelper.getNode(ctx, path);
+        n.getLock().refresh();
+        return false;
+    }
+
+    /**
+     * @return Returns the srcPathKey.
+     */
+    public String getPathKey()
+    {
+        return pathKey;
+    }
+
+    /**
+     * @param srcPathKey
+     *            The srcPathKey to set.
+     */
+    public void setPathKey(String srcPathKey)
+    {
+        this.pathKey = srcPathKey;
+    }
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/lock/RemoveLockToken.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/lock/RemoveLockToken.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/lock/RemoveLockToken.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/lock/RemoveLockToken.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,65 @@
+/*
+ * 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.lock;
+
+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;
+
+/**
+ * Removes the given lock token to the current session.
+ */
+public class RemoveLockToken implements Command
+{
+	/** logger */
+	private static Log log = LogFactory.getLog(AddLockToken.class);
+
+	// ---------------------------- < keys >
+	/**
+	 * token key
+	 */
+	private String tokenKey = "token";
+
+	/**
+	 * @inheritDoc
+	 */
+	public boolean execute(Context ctx) throws Exception
+	{
+		String token = (String) ctx.get(this.tokenKey);
+		if (log.isDebugEnabled())
+		{
+			log.debug("Removing lock token " + token + " from the current session.");
+		}
+		Session s = CommandHelper.getSession(ctx);
+		s.removeLockToken(token);
+		return false;
+	}
+
+	public String getTokenKey()
+	{
+		return tokenKey;
+	}
+
+	public void setTokenKey(String tokenKey)
+	{
+		this.tokenKey = tokenKey;
+	}
+}

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



Mime
View raw message