jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edgarp...@apache.org
Subject svn commit: r294914 [1/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
Author: edgarpoce
Date: Tue Oct  4 13:51:32 2005
New Revision: 294914

URL: http://svn.apache.org/viewcvs?rev=294914&view=rev
Log:
jcr-commands 
 - naming and packaging reviewed
 - now commands only read parameters from the context because commands shouldn't have a state of their own but use only the context.
 - i18n reorganized in one single resources file
 - batch mode added
 - cover most of jcr operations (versioning, locking, etc.)
 - commands simplified. Most commands don't have default values.
 - logging added

Added:
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/cli/
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/cli/connect.jcr
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/cli/embedded.jcr
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/META-INF/
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/META-INF/MANIFEST
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/CommandException.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/CommandHelper.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/AbstractParameter.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/Argument.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/CommandLine.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/CommandLineFactory.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/ConfigurationException.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/Flag.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/JcrClient.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/JcrParser.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/JcrParserException.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/Option.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/SourceCommand.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/command-line-rules.xml   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/command-line.xml   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/command.xml   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/digester-rules.dtd   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/package.html   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/collect/
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/collect/AbstractCollect.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/collect/CollectItems.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/collect/CollectNodes.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/collect/CollectProperties.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/AbstractSetProperty.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/AddNode.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/ClearWorkspace.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/Clone.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/Copy.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/CurrentNode.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/Login.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/Logout.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/Move.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/OrderBefore.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/ReadValue.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/Refresh.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/RemoveItem.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/RemoveItems.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/Rename.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/Save.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/SetMultivalueProperty.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/SetProperty.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/ConnectToRmiServer.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/CreateWorkspace.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/RegisterNodeType.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/StartJackrabbit.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/StartJackrabbitSingleton.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/StopJackrabbit.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/package.html   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/ExportFileSystem.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/ExportPropertyToFile.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/ImportFileSystem.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/SetPropertyFromFile.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/fs/mimetypes.properties   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLs.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLsItems.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLsNodes.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/AbstractLsProperties.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Cat.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Describe.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Dump.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Help.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/JcrInfoCommandException.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsCollectedItems.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsCollectedNodes.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsCollectedProperties.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsItems.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsNamespaces.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsNodes.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsProperties.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsReferences.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/LsVersions.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/PrintHelper.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/lock/
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/lock/AddLockToken.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/lock/Lock.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/lock/RefreshLock.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/lock/RemoveLockToken.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/lock/Unlock.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/mixin/
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/mixin/AddMixin.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/mixin/RemoveMixin.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/namespace/
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/namespace/RegisterNamespace.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/namespace/UnregisterNamespace.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/query/
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/query/AbstractQuery.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/query/SQLQuery.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/query/XPathQuery.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/resources.properties   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/version/
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/version/AddVersionLabel.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/version/Checkin.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/version/Checkout.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/version/Merge.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/version/RemoveVersion.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/version/RemoveVersionByLabel.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/version/RemoveVersionLabel.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/version/Restore.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/version/RestoreByLabel.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/xml/
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/xml/AbstractExportViewToFile.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/xml/ExportDocViewToFile.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/xml/ExportSysViewToFile.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/xml/ImportXmlFromFile.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/test/log4j.properties   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/test/org/apache/jackrabbit/command/
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/test/org/apache/jackrabbit/command/cli/
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/test/org/apache/jackrabbit/command/cli/CliTest.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/test/org/apache/jackrabbit/command/cli/CommandsTest.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/test/org/apache/jackrabbit/command/cli/I18nTest.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/test/org/apache/jackrabbit/command/cli/JcrRmiServer.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/test/org/apache/jackrabbit/command/cli/TestAll.java   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/xdocs/
    incubator/jackrabbit/trunk/contrib/jcr-commands/xdocs/benchmarking.jmx
    incubator/jackrabbit/trunk/contrib/jcr-commands/xdocs/devguide.xml   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/xdocs/index.xml   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/xdocs/navigation.xml   (with props)
    incubator/jackrabbit/trunk/contrib/jcr-commands/xdocs/userguide.xml   (with props)
Removed:
    incubator/jackrabbit/trunk/contrib/jcr-commands/NOTICE.txt
    incubator/jackrabbit/trunk/contrib/jcr-commands/applications/test/fs/
    incubator/jackrabbit/trunk/contrib/jcr-commands/applications/test/log4j.properties
    incubator/jackrabbit/trunk/contrib/jcr-commands/applications/test/testSetPropertyFromFile.txt
    incubator/jackrabbit/trunk/contrib/jcr-commands/benchmarking/
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/MANIFEST
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/log4j.properties
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/chain/
    incubator/jackrabbit/trunk/contrib/jcr-commands/src/test/org/apache/jackrabbit/chain/
Modified:
    incubator/jackrabbit/trunk/contrib/jcr-commands/CHANGES.txt
    incubator/jackrabbit/trunk/contrib/jcr-commands/TODO.txt
    incubator/jackrabbit/trunk/contrib/jcr-commands/maven.xml
    incubator/jackrabbit/trunk/contrib/jcr-commands/project.properties

Modified: incubator/jackrabbit/trunk/contrib/jcr-commands/CHANGES.txt
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/CHANGES.txt?rev=294914&r1=294913&r2=294914&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/CHANGES.txt (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/CHANGES.txt Tue Oct  4 13:51:32 2005
@@ -1,3 +1,14 @@
+2005-10-01
+ - naming and packaging reviewed
+ - now commands only read parameters from the context 
+   because commands shouldn't have a state of their own
+   but use only the context.
+ - i18n reorganized in one single resources file
+ - batch mode added
+ - cover most of jcr operations (versioning, locking, etc.)
+ - commands simplified. Most commands don't have default values.
+ - logging added
+
 2005-08-11
  - removed jmeter dependencies
  - added command line interface (o.a.j.chain.cli)

Modified: incubator/jackrabbit/trunk/contrib/jcr-commands/TODO.txt
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/TODO.txt?rev=294914&r1=294913&r2=294914&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/TODO.txt (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/TODO.txt Tue Oct  4 13:51:32 2005
@@ -1,2 +1,4 @@
-- Add more commands
-- Add logging
\ No newline at end of file
+- xdocs
+- javadocs
+- testing
+- review i18n resource file
\ No newline at end of file

Modified: incubator/jackrabbit/trunk/contrib/jcr-commands/maven.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/maven.xml?rev=294914&r1=294913&r2=294914&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/maven.xml (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/maven.xml Tue Oct  4 13:51:32 2005
@@ -14,7 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 -->
-
 <project
     default="jar:jar"
     xmlns:deploy="deploy"
@@ -23,19 +22,13 @@
     xmlns:maven="jelly:maven">
 
     <!-- Additionally cleans the test data created -->
-    <postGoal name="clean">
-        <attainGoal name="test:clean"/>
-    </postGoal>
+    <preGoal name="test">
+        <attainGoal name="removerepo"/>
+    </preGoal>
 
     <!-- deletes the test data -->
-    <goal name="test:clean">
-        <ant:delete includeEmptyDirs="true">
-            <ant:fileset dir="applications/test">
-                <ant:include name="**/*"/>
-                <ant:exclude name="repository.xml"/>
-                <ant:exclude name="log4j.properties"/>
-            </ant:fileset>
-        </ant:delete>
+    <goal name="removerepo">
+        <ant:delete dir="applications/test/repository"/>
     </goal>
 
-</project>
+</project>
\ No newline at end of file

Modified: incubator/jackrabbit/trunk/contrib/jcr-commands/project.properties
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/project.properties?rev=294914&r1=294913&r2=294914&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/project.properties (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/project.properties Tue Oct  4 13:51:32 2005
@@ -103,4 +103,4 @@
 ######################################################################
 # Javaapp plugin
 ######################################################################
-maven.javaapp.mainclass=org.apache.jackrabbit.chain.cli.JcrClient
\ No newline at end of file
+maven.javaapp.mainclass=org.apache.jackrabbit.command.cli.JcrClient
\ No newline at end of file

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/cli/connect.jcr
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/cli/connect.jcr?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/cli/connect.jcr (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/cli/connect.jcr Tue Oct  4 13:51:32 2005
@@ -0,0 +1,2 @@
+connect rmi://localhost/jcr/repository
+login user password
\ No newline at end of file

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/cli/embedded.jcr
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/cli/embedded.jcr?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/cli/embedded.jcr (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/cli/embedded.jcr Tue Oct  4 13:51:32 2005
@@ -0,0 +1,2 @@
+start ../../applications/test/repository.xml ../../applications/test/repository
+login user password
\ No newline at end of file

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/META-INF/MANIFEST
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/META-INF/MANIFEST?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/META-INF/MANIFEST (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/META-INF/MANIFEST Tue Oct  4 13:51:32 2005
@@ -0,0 +1,2 @@
+Manifest-Version: 1.0
+Main-Class: org.apache.jackrabbit.command.cli.JcrClient

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/CommandException.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/CommandException.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/CommandException.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/CommandException.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.command;
+
+import java.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * JCR command Exception
+ */
+public class CommandException extends Exception
+{
+    /** Resource bundle */
+    private static ResourceBundle bundle = CommandHelper.getBundle() ;
+
+    /**
+     * Exception arguments
+     */
+    private Object[] arguments;
+
+    /**
+     * Comment for <code>serialVersionUID</code>
+     */
+    private static final long serialVersionUID = 3978426922931860275L;
+
+    /**
+     * @param message
+     */
+    public CommandException(String message)
+    {
+        super(message);
+    }
+
+    /**
+     * @param message
+     * @param arguments
+     */
+    public CommandException(String message, Object[] arguments)
+    {
+        super(message);
+        this.arguments = arguments;
+    }
+
+    /**
+     * @param message
+     * @param cause
+     */
+    public CommandException(String message, Throwable cause)
+    {
+        super(message, cause);
+    }
+
+    /**
+     * @param message
+     * @param cause
+     * @param arguments
+     */
+    public CommandException(String message, Throwable cause,
+        Object[] arguments)
+    {
+        super(message, cause);
+        this.arguments = arguments;
+    }
+
+    /**
+     * @return the localized message
+     */
+    public String getLocalizedMessage()
+    {
+        try
+        {
+            if (this.arguments == null)
+            {
+                return bundle.getString(this.getMessage());
+            } else
+            {
+                MessageFormat f = new MessageFormat("");
+                f.applyPattern(bundle.getString(this.getMessage()));
+                return f.format(this.arguments);
+            }
+        } catch (MissingResourceException e)
+        {
+            return this.getMessage();
+        }
+    }
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/CommandHelper.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/CommandHelper.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/CommandHelper.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/CommandHelper.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,343 @@
+/*
+ * 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;
+
+import java.io.PrintWriter;
+import java.util.Iterator;
+import java.util.ResourceBundle;
+
+import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.PropertyIterator;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.commons.chain.Context;
+import org.apache.commons.collections.IteratorUtils;
+
+/**
+ * Helper class for getting and setting context attributes.
+ */
+public class CommandHelper
+{
+	/** bundle */
+	private static ResourceBundle bundle = ResourceBundle
+			.getBundle(CommandHelper.class.getPackage().getName()
+					+ ".resources");
+
+	/** Current node key */
+	private static String CURRENT_NODE_KEY = "jcr.current";
+
+	/** repository key */
+	private static String REPOSITORY_KEY = "jcr.repository";
+
+	/** session key */
+	private static String SESSION_KEY = "jcr.session";
+
+	/** session key */
+	private static String OUTPUT_KEY = "jcr.output";
+
+	/**
+	 * Sets the current output
+	 * 
+	 * @param ctx
+	 * @param output
+	 */
+	public static void setOutput(Context ctx, PrintWriter out)
+	{
+		if (out == null)
+		{
+			ctx.remove(OUTPUT_KEY);
+		} else
+		{
+			ctx.put(OUTPUT_KEY, out);
+		}
+	}
+
+	/**
+	 * Sets the current working Node
+	 * 
+	 * @param ctx
+	 * @param node
+	 * @throws CommandException
+	 */
+	public static void setCurrentNode(Context ctx, Node node)
+			throws CommandException
+	{
+		if (node == null)
+		{
+			ctx.remove(CURRENT_NODE_KEY);
+		} else
+		{
+			ctx.put(CURRENT_NODE_KEY, node);
+		}
+	}
+
+	/**
+	 * Sets the current working Repository
+	 * 
+	 * @param ctx
+	 * @param repository
+	 */
+	public static void setRepository(Context ctx, Repository repository)
+	{
+		if (repository == null)
+		{
+			ctx.remove(REPOSITORY_KEY);
+		} else
+		{
+			ctx.put(REPOSITORY_KEY, repository);
+		}
+
+	}
+
+	/**
+	 * Sets the current working Session
+	 * 
+	 * @param ctx
+	 * @param session
+	 */
+	public static void setSession(Context ctx, Session session)
+	{
+		if (session == null)
+		{
+			ctx.remove(SESSION_KEY);
+		} else
+		{
+			ctx.put(SESSION_KEY, session);
+		}
+	}
+
+	/**
+	 * Gets the current working Node
+	 * 
+	 * @param ctx
+	 * @return
+	 */
+	public static PrintWriter getOutput(Context ctx)
+	{
+		PrintWriter out = (PrintWriter) ctx.get(OUTPUT_KEY);
+		if (out == null)
+		{
+			out = new PrintWriter(System.out, true);
+		}
+		return out;
+	}
+
+	/**
+	 * Gets the current working Node
+	 * 
+	 * @param ctx
+	 * @return
+	 * @throws CommandException
+	 */
+	public static Node getCurrentNode(Context ctx) throws CommandException
+	{
+		Node n = (Node) ctx.get(CURRENT_NODE_KEY);
+		if (n == null)
+		{
+			throw new CommandException("exception.no.current.node");
+		}
+		return n;
+	}
+
+	/**
+	 * Gets the current working Repository
+	 * 
+	 * @param ctx
+	 * @return
+	 * @throws CommandException
+	 */
+	public static Repository getRepository(Context ctx) throws CommandException
+	{
+		return (Repository) ctx.get(REPOSITORY_KEY);
+	}
+
+	/**
+	 * Gets the current working Session
+	 * 
+	 * @param ctx
+	 * @return
+	 * @throws CommandException
+	 */
+	public static Session getSession(Context ctx) throws CommandException
+	{
+		return (Session) ctx.get(SESSION_KEY);
+	}
+
+	/**
+	 * Gets node at the given path.
+	 * 
+	 * @param ctx
+	 * @param path
+	 * @return
+	 * @throws CommandException
+	 * @throws PathNotFoundException
+	 * @throws RepositoryException
+	 */
+	public static Node getNode(Context ctx, String path)
+			throws CommandException, PathNotFoundException, RepositoryException
+	{
+		Item i = getItem(ctx, path);
+		if (!i.isNode())
+		{
+			throw new PathNotFoundException("the path " + i.getPath()
+					+ "refers to a Property");
+		}
+		return (Node) i;
+	}
+
+	/**
+	 * Gets the Item at the given path. <br>
+	 * If the path is null it returns the current working node.
+	 * 
+	 * @param ctx
+	 * @param path
+	 * @return the Item for the given path
+	 * @throws CommandException
+	 * @throws PathNotFoundException
+	 * @throws RepositoryException
+	 */
+	public static Item getItem(Context ctx, String path)
+			throws CommandException, PathNotFoundException, RepositoryException
+	{
+		Node current = (Node) ctx.get(CURRENT_NODE_KEY);
+		Item i = null;
+
+		if (path == null)
+		{
+			i = current;
+		} else if (path.equals("/"))
+		{
+			i = current.getSession().getRootNode();
+		} else if (path.startsWith("/"))
+		{
+			i = current.getSession().getItem(path);
+		} else
+		{
+			String newPath = current.getPath();
+			// handle the root node
+			if (!newPath.endsWith("/"))
+			{
+				newPath += "/";
+			}
+			newPath += path;
+			i = current.getSession().getItem(newPath);
+		}
+
+		return i;
+	}
+
+	/**
+	 * Returns true if the node exists at the given path
+	 * 
+	 * @param ctx
+	 * @param path
+	 * @return
+	 * @throws CommandException
+	 * @throws RepositoryException
+	 */
+	public static boolean hasNode(Context ctx, String path)
+			throws CommandException, RepositoryException
+	{
+		if (path.equals("/"))
+		{
+			return true;
+		} else if (path.startsWith("/"))
+		{
+			return getSession(ctx).getRootNode().hasNode(path.substring(1));
+		} else
+		{
+			Node current = (Node) ctx.get(CURRENT_NODE_KEY);
+			return current.hasNode(path);
+		}
+	}
+
+	/**
+	 * Get the nodes under the given node that match the given pattern.
+	 * 
+	 * @param ctx
+	 *            Command Context
+	 * @param node
+	 *            Parent node
+	 * @param pattern
+	 * @return an Iterator that contains the matching nodes
+	 * @throws CommandException
+	 * @throws RepositoryException
+	 */
+	public static NodeIterator getNodes(Context ctx, Node node, String pattern)
+			throws CommandException, RepositoryException
+	{
+		if (pattern != null)
+		{
+			return node.getNodes(pattern);
+		} else
+		{
+			return node.getNodes();
+		}
+	}
+
+	/**
+	 * Get the properties under the current working node for the given pattern
+	 * 
+	 * @param ctx
+	 * @param node
+	 *            Parent node
+	 * @param pattern
+	 * @return
+	 * @throws CommandException
+	 * @throws RepositoryException
+	 */
+	public static PropertyIterator getProperties(Context ctx, Node node,
+			String pattern) throws CommandException, RepositoryException
+	{
+		if (pattern != null)
+		{
+			return node.getProperties(pattern);
+		} else
+		{
+			return node.getProperties();
+		}
+	}
+
+	/**
+	 * @return default resource bundle
+	 */
+	public static ResourceBundle getBundle()
+	{
+		return bundle;
+	}
+
+	/**
+	 * Get the items under the given node that match the pattern
+	 * 
+	 * @param ctx
+	 * @return
+	 * @throws CommandException
+	 * @throws RepositoryException
+	 */
+	public static Iterator getItems(Context ctx, Node node, String pattern)
+			throws CommandException, RepositoryException
+	{
+		return IteratorUtils.chainedIterator(getNodes(ctx, node, pattern),
+				getProperties(ctx, node, pattern));
+	}
+
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/AbstractParameter.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/AbstractParameter.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/AbstractParameter.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/AbstractParameter.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,161 @@
+/*
+ * 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.cli;
+
+import java.util.ResourceBundle;
+
+import org.apache.jackrabbit.command.CommandHelper;
+
+/**
+ * Command Line parameter superclass
+ */
+public abstract class AbstractParameter implements Cloneable
+{
+
+	/** Resource bundle */
+	protected ResourceBundle bundle = CommandHelper.getBundle();
+
+	/** name */
+	private String name;
+
+	/** long name */
+	private String longName;
+
+	/** description */
+	private String description;
+
+	/** command or a context attribute */
+	private String contextKey;
+
+	/** value */
+	private String value;
+
+	/**
+	 * @return Returns the description.
+	 */
+	public String getDescription()
+	{
+		return description;
+	}
+
+	/**
+	 * @return localized description
+	 */
+	public abstract String getLocalizedDescription();
+
+	/**
+	 * @return Returns the name.
+	 */
+	public String getName()
+	{
+		return name;
+	}
+
+	/**
+	 * @param description
+	 *            The description to set.
+	 */
+	public void setDescription(String description)
+	{
+		this.description = description;
+	}
+
+	/**
+	 * @param name
+	 *            The name to set.
+	 */
+	public void setName(String name)
+	{
+		this.name = name;
+	}
+
+	/**
+	 * @return Returns the value.
+	 */
+	public String getValue()
+	{
+		return value;
+	}
+
+	/**
+	 * @param value
+	 *            The value to set.
+	 */
+	public void setValue(String value)
+	{
+		this.value = value;
+	}
+
+	/**
+	 * @return Returns the longName.
+	 */
+	public String getLongName()
+	{
+		return longName;
+	}
+
+	/**
+	 * @param longName
+	 *            The longName to set.
+	 */
+	public void setLongName(String longName)
+	{
+		this.longName = longName;
+	}
+
+	protected void clone(AbstractParameter param)
+	{
+		param.contextKey = this.contextKey;
+		param.description = this.description;
+		param.longName = this.longName;
+		param.name = this.name;
+		param.value = this.value;
+	}
+
+	/**
+	 * @return Returns the commandAttribute.
+	 * if the context key is unset it returns the parameter name
+	 */
+	public String getContextKey()
+	{
+		if (contextKey == null)
+		{
+			return this.name;
+		}
+		return contextKey;
+	}
+
+	/**
+	 * @param commandAttribute
+	 *            The commandAttribute to set.
+	 */
+	public void setContextKey(String commandAttribute)
+	{
+		this.contextKey = commandAttribute;
+	}
+
+	/**
+	 * @return true if this parameter is mandatory
+	 */
+	public abstract boolean isRequired();
+
+	/**
+	 * @return argumentlocalized name
+	 */
+	public abstract String getLocalizedArgName();
+
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/Argument.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/Argument.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/Argument.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/Argument.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,50 @@
+/*
+ * 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.cli;
+
+/**
+ * Command line argument.
+ */
+public class Argument extends Option
+{
+    /** position of the argument */
+    private int position;
+
+    /**
+     * @return
+     */
+    public int getPosition()
+    {
+        return position;
+    }
+
+    public void setPosition(int position)
+    {
+        this.position = position;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public Object clone()
+    {
+        Argument arg = new Argument();
+        arg.position = this.position;
+        this.clone(arg);
+        return arg;
+    }
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/CommandLine.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/CommandLine.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/CommandLine.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/CommandLine.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,377 @@
+/*
+ * 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.cli;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.ResourceBundle;
+import java.util.TreeMap;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.Predicate;
+import org.apache.commons.collections.iterators.IteratorChain;
+import org.apache.jackrabbit.command.CommandHelper;
+
+/**
+ * Command Line.
+ */
+public class CommandLine implements Comparable, Cloneable
+{
+    /** Resource bundle */
+    protected static ResourceBundle bundle = CommandHelper.getBundle();
+
+    /** Name */
+    private String name;
+
+    /** Description */
+    private String description;
+
+    /** Commons chain command implementation */
+    private String impl;
+
+    /** alias */
+    private Collection alias = new ArrayList();
+
+    /** Options */
+    private Map options = new TreeMap();
+
+    /** Options */
+    private Map flags = new TreeMap();
+
+    /** arguments */
+    private Map arguments = new TreeMap();
+
+    /**
+     * constructor
+     */
+    public CommandLine()
+    {
+        super();
+    }
+
+    /**
+     * @return required arguments
+     */
+    public Collection getRequiredArguments()
+    {
+        Predicate p = new Predicate()
+        {
+            public boolean evaluate(Object o)
+            {
+                Argument arg = (Argument) o;
+                return arg.isRequired();
+            }
+        };
+        return CollectionUtils.select(this.arguments.values(), p);
+    }
+
+    /**
+     * @return required options
+     */
+    public Collection getRequiredOptions()
+    {
+        Predicate p = new Predicate()
+        {
+            public boolean evaluate(Object o)
+            {
+                Option opt = (Option) o;
+                return opt.isRequired();
+            }
+        };
+        return CollectionUtils.select(this.options.values(), p);
+    }
+
+    /**
+     * @return Returns the description.
+     */
+    public String getDescription()
+    {
+        return description;
+    }
+
+    /**
+     * @return Returns the localized description. 
+     */
+    public String getLocalizedDescription()
+    {
+        if (description == null)
+        {
+            return bundle.getString("cmd." + this.name);
+        } else
+        {
+            return bundle.getString(this.description);
+        }
+    }
+
+    /**
+     * @param description
+     *            The description to set.
+     */
+    public void setDescription(String description)
+    {
+        this.description = description;
+    }
+
+    /**
+     * @return Returns the flags.
+     */
+    public Map getFlags()
+    {
+        return flags;
+    }
+
+    /**
+     * @param flags
+     *            The flags to set.
+     */
+    public void setFlags(Map flags)
+    {
+        this.flags = flags;
+    }
+
+    /**
+     * @return Returns the impl.
+     */
+    public String getImpl()
+    {
+        return impl;
+    }
+
+    /**
+     * @param impl
+     *            The impl to set.
+     */
+    public void setImpl(String impl)
+    {
+        this.impl = impl;
+    }
+
+    /**
+     * @return Returns the name.
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+    /**
+     * @param name
+     *            The name to set.
+     */
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+
+    /**
+     * @return Returns the options.
+     */
+    public Map getOptions()
+    {
+        return options;
+    }
+
+    /**
+     * @param options
+     *            The options to set.
+     */
+    public void setOptions(Map options)
+    {
+        this.options = options;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public int compareTo(Object o)
+    {
+        CommandLine cl = (CommandLine) o;
+        return name.compareTo(cl.name);
+    }
+
+    /**
+     * @return all the parameters. i.e. args, options and flags.
+     */
+    public Iterator getAllParameters()
+    {
+        IteratorChain chain = new IteratorChain();
+        chain.addIterator(getArguments().values().iterator());
+        chain.addIterator(getOptions().values().iterator());
+        chain.addIterator(getFlags().values().iterator());
+        return chain;
+    }
+
+    /**
+     * @return the required parameters. i.e. args, options and flags.
+     */
+    public Iterator getRequiredParameters()
+    {
+        IteratorChain chain = new IteratorChain();
+        chain.addIterator(getRequiredArguments().iterator());
+        chain.addIterator(getRequiredOptions().iterator());
+        return chain;
+    }
+
+    /**
+     * Adds an argument.
+     * 
+     * @param arg
+     */
+    public void addArgument(Argument arg)
+    {
+        if (arguments.containsKey(new Integer(arg.getPosition())))
+        {
+            throw new IllegalArgumentException(
+                "there's an argument in the position in command " + this.name);
+        }
+        // Put default values description and arg name i18n keys
+        if (arg.getArgName() == null)
+        {
+            arg.setArgName("cmd." + this.getName() + "." + arg.getName());
+        }
+        if (arg.getDescription() == null)
+        {
+            arg.setDescription("cmd." + this.getName() + "." + arg.getName()
+                    + ".desc");
+        }
+        this.arguments.put(new Integer(arg.getPosition()), arg);
+    }
+
+    /**
+     * Add an Option
+     * 
+     * @param opt
+     */
+    public void addOption(Option opt)
+    {
+        // Put default values description and arg name i18n keys
+        if (opt.getArgName() == null)
+        {
+            opt.setArgName("cmd." + this.getName() + "." + opt.getName());
+        }
+        if (opt.getDescription() == null)
+        {
+            opt.setDescription("cmd." + this.getName() + "." + opt.getName()
+                    + ".desc");
+        }
+        this.options.put(opt.getName(), opt);
+    }
+
+    /**
+     * Flag
+     * 
+     * @param flag
+     */
+    public void addFlag(Flag flag)
+    {
+        // Put default values description and arg name i18n keys
+        if (flag.getDescription() == null)
+        {
+            flag.setDescription("cmd." + this.getName() + "." + flag.getName()
+                    + ".desc");
+        }
+        this.flags.put(flag.getName(), flag);
+    }
+
+    /**
+     * @return Returns the arguments.
+     */
+    public Map getArguments()
+    {
+        return arguments;
+    }
+
+    /**
+     * @param arguments
+     *            The arguments to set.
+     */
+    public void setArguments(Map arguments)
+    {
+        this.arguments = arguments;
+    }
+
+    /**
+     * @return Returns the alias.
+     */
+    public Collection getAlias()
+    {
+        return alias;
+    }
+
+    /**
+     * @param alias
+     *            The alias to set.
+     */
+    public void setAlias(Collection alias)
+    {
+        this.alias = alias;
+    }
+
+    /**
+     * Add alias
+     * 
+     * @param alias
+     */
+    public void addAlias(String alias)
+    {
+        this.alias.add(alias);
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public Object clone()
+    {
+        CommandLine cl = new CommandLine();
+        cl.alias = this.alias;
+        // Arguments
+        Iterator iter = this.arguments.values().iterator();
+        while (iter.hasNext())
+        {
+            Argument arg = (Argument) iter.next();
+            cl.addArgument((Argument) arg.clone());
+        }
+        cl.description = this.description;
+        // Flags
+        iter = this.flags.values().iterator();
+        while (iter.hasNext())
+        {
+            Flag f = (Flag) iter.next();
+            cl.addFlag((Flag) f.clone());
+        }
+        cl.impl = this.impl;
+        cl.name = this.name;
+        // Flags
+        iter = this.options.values().iterator();
+        while (iter.hasNext())
+        {
+            Option o = (Option) iter.next();
+            cl.addOption((Option) o.clone());
+        }
+        return cl;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public String toString()
+    {
+        return "CommandLine-" + this.getName() + "(" + impl + ")";
+    }
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/CommandLineFactory.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/CommandLineFactory.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/CommandLineFactory.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/CommandLineFactory.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,186 @@
+/*
+ * 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.cli;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.ResourceBundle;
+import java.util.TreeMap;
+
+import org.apache.commons.digester.Digester;
+import org.apache.commons.digester.xmlrules.DigesterLoader;
+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.xml.sax.SAXException;
+
+/**
+ * Command line factory.
+ */
+public class CommandLineFactory
+{
+	/** logger */
+	private static Log log = LogFactory.getLog(CommandLineFactory.class);
+
+	private static ResourceBundle bundle = CommandHelper.getBundle();
+
+	/** file name */
+	private static String COMMAND_LINE_FILE = "command-line.xml";
+
+	/** rules file name */
+	private static String COMMAND_LINE_RULES_FILE = "command-line-rules.xml";
+
+	/** singleton */
+	private static CommandLineFactory singleton;
+
+	/** command cache */
+	private Map cache = new TreeMap();
+
+	/** alias cache */
+	private Map alias = new HashMap();
+
+	/**
+	 * private Constructor
+	 */
+	private CommandLineFactory()
+	{
+		super();
+	}
+
+	/**
+	 * @return CliCommandFactory singleton
+	 */
+	public static CommandLineFactory getInstance()
+	{
+		if (singleton == null)
+		{
+			try
+			{
+				CommandLineFactory factory = new CommandLineFactory();
+				factory.init();
+				singleton = factory;
+			} catch (Exception e)
+			{
+				log.error(bundle.getString("exception.unabletoinit"), e);
+				e.printStackTrace();
+			}
+		}
+		return singleton;
+	}
+
+	/**
+	 * @return all registered commands
+	 * @throws CommandException
+	 */
+	public Collection getCommandLines() throws CommandException
+	{
+		List cls = new ArrayList();
+		Iterator iter = cache.values().iterator();
+		while (iter.hasNext())
+		{
+			CommandLine cl = (CommandLine) iter.next();
+			cls.add(cl.clone());
+		}
+		return cls;
+	}
+
+	/**
+	 * @param name
+	 * @return a new Command Line Instance for the given command name
+	 * @throws JcrParserException
+	 */
+	public CommandLine getCommandLine(String name) throws JcrParserException
+	{
+		log.debug("lookup command " + name);
+		// get Command line
+		CommandLine original = (CommandLine) cache.get(name);
+
+		if (original == null)
+		{
+			log.debug("lookup alias " + name);
+			original = (CommandLine) alias.get(name);
+		}
+
+		if (original == null)
+		{
+			log.warn("command not found " + name);
+			throw new JcrParserException("exception.no.command.for.name",
+					new String[]
+					{ name });
+		}
+
+		// Return a clone
+		return (CommandLine) original.clone();
+	}
+
+	/**
+	 * Parse configuration file
+	 * 
+	 * @throws IOException
+	 * @throws SAXException
+	 * @throws ConfigurationException
+	 */
+	private void init() throws IOException, SAXException,
+			ConfigurationException
+	{
+		// Configure Digester from XML ruleset
+		URL rulesFile = getClass().getResource(COMMAND_LINE_RULES_FILE);
+		URL clFile = getClass().getResource(COMMAND_LINE_FILE);
+
+		// init digester
+		Digester digester = DigesterLoader.createDigester(rulesFile);
+
+		// Push empty List onto Digester's Stack
+		List cls = new ArrayList();
+		digester.push(cls);
+
+		// Parse the XML document
+		InputStream input = clFile.openStream();
+		digester.parse(input);
+		input.close();
+
+		// Add to cache
+		Iterator iter = cls.iterator();
+		while (iter.hasNext())
+		{
+			CommandLine cl = (CommandLine) iter.next();
+			cache.put(cl.getName(), cl);
+			// Add to alias cache
+			Iterator aliasIt = cl.getAlias().iterator();
+			while (aliasIt.hasNext())
+			{
+				String aliasName = (String) aliasIt.next();
+				if (alias.containsKey(aliasName))
+				{
+					throw new ConfigurationException(
+							"exception.alias.already.in.use", new String[]
+							{ aliasName, cl.getName() });
+				}
+				alias.put(aliasName, cl);
+			}
+		}
+	}
+
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/ConfigurationException.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/ConfigurationException.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/ConfigurationException.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/ConfigurationException.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,68 @@
+/*
+ * 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.cli;
+
+import org.apache.jackrabbit.command.CommandException;
+
+/**
+ * This Exception is thrown when there's an error in the command config file.
+ */
+public class ConfigurationException extends CommandException
+{
+
+    /**
+     * <code>serialVersionUID</code>
+     */
+    private static final long serialVersionUID = 3257848770644621622L;
+
+    /**
+     * @param message
+     */
+    public ConfigurationException(String message)
+    {
+        super(message);
+    }
+
+    /**
+     * @param message
+     * @param arguments
+     */
+    public ConfigurationException(String message, Object[] arguments)
+    {
+        super(message, arguments);
+    }
+
+    /**
+     * @param message
+     * @param cause
+     */
+    public ConfigurationException(String message, Throwable cause)
+    {
+        super(message, cause);
+    }
+
+    /**
+     * @param message
+     * @param cause
+     * @param arguments
+     */
+    public ConfigurationException(String message, Throwable cause,
+        Object[] arguments)
+    {
+        super(message, cause, arguments);
+    }
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/Flag.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/Flag.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/Flag.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/Flag.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,100 @@
+/*
+ * 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.cli;
+
+/**
+ * Command line flag. A flag is a parameter that has no other value that the
+ * option name. e.g. -[flag name].
+ */
+public class Flag extends AbstractParameter
+{
+    private boolean present = false;
+
+    /**
+     * @return Returns the present.
+     */
+    public boolean isPresent()
+    {
+        return present;
+    }
+
+    /**
+     * @param present
+     *            The present to set.
+     */
+    public void setPresent(boolean present)
+    {
+        this.present = present;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public String getValue()
+    {
+        return Boolean.toString(present);
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public void setValue(String value)
+    {
+        present = Boolean.getBoolean(value);
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public Object clone()
+    {
+        Flag f = new Flag();
+        f.present = this.present;
+        this.clone(f);
+        return f;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public boolean isRequired()
+    {
+        return false;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public String getLocalizedArgName()
+    {
+        return "";
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public String getLocalizedDescription()
+    {
+        if (this.getDescription() == null)
+        {
+            return bundle.getString("param.flag." + this.getName() + ".desc");
+        } else
+        {
+            return bundle.getString(this.getDescription());
+        }
+    }
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/JcrClient.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/JcrClient.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/JcrClient.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/JcrClient.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,326 @@
+/*
+ * 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.cli;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.Session;
+
+import org.apache.commons.chain.Context;
+import org.apache.commons.chain.impl.ContextBase;
+import org.apache.commons.cli.BasicParser;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.commons.cli.Parser;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jackrabbit.command.CommandHelper;
+
+/**
+ * Command line interface client
+ */
+public class JcrClient
+{
+	/** logger */
+	private static Log log = LogFactory.getLog(JcrClient.class);
+
+	/** Resource bundle */
+	private ResourceBundle bundle = CommandHelper.getBundle();
+
+	/** exit control variable */
+	private boolean exit = false;
+
+	/** Execution context */
+	private Context ctx;
+
+	/** run options */
+	private Options options;
+
+	/**
+	 * Constructor
+	 */
+	JcrClient()
+	{
+		super();
+		ctx = new ContextBase();
+		initOptions();
+		initContext();
+	}
+
+	/**
+	 * Constructor
+	 */
+	JcrClient(Context ctx)
+	{
+		super();
+		this.ctx = ctx;
+	}
+
+	/**
+	 * @param args
+	 */
+	public static void main(String[] args)
+	{
+		JcrClient client = new JcrClient();
+		client.run(args);
+	}
+
+	/**
+	 * Run client
+	 * 
+	 * @param args
+	 */
+	private void run(String[] args)
+	{
+		try
+		{
+			// parse arguments
+			Parser parser = new BasicParser();
+			CommandLine cl = parser.parse(options, args);
+
+			// Set locale
+			this.setLocale(cl);
+
+			// Welcome message
+			System.out.println(bundle.getString("word.welcome"));
+
+			// check interactive mode
+			if (cl.hasOption("source"))
+			{
+				this.runNonInteractive(cl);
+			} else
+			{
+				this.runInteractive(cl);
+			}
+		} catch (Exception e)
+		{
+			HelpFormatter hf = new HelpFormatter();
+			hf.printHelp("jcrclient", options);
+			e.printStackTrace();
+			return;
+		}
+	}
+
+	/**
+	 * Run in interactive mode
+	 * 
+	 * @param command
+	 *            line
+	 * @throws Exception
+	 */
+	private void runInteractive(CommandLine cl) throws Exception
+	{
+		// Prompt command
+		while (!exit)
+		{
+			try
+			{
+				System.out.print(this.getPrompt() + ">");
+				// Read input
+				BufferedReader br = new BufferedReader(new InputStreamReader(
+						System.in));
+				String input = br.readLine();
+				log.debug("running: " + input);
+				if (input.trim().equals("exit") || input.trim().equals("quit"))
+				{ // exit?
+					exit = true;
+					System.out.println("Good bye..");
+				} else if (input.trim().length() == 0)
+				{
+					// Do nothing
+				} else
+				{
+					this.runCommand(input);
+				}
+			} catch (JcrParserException e)
+			{
+				System.out.println(e.getLocalizedMessage());
+				System.out.println();
+			} catch (Exception e)
+			{
+				handleException(e);
+			}
+		}
+	}
+
+	/**
+	 * Run in non interactive mode
+	 * 
+	 * @param command
+	 *            line
+	 * @throws Exception
+	 */
+	private void runNonInteractive(CommandLine cl) throws Exception
+	{
+		this.runCommand("source " + cl.getOptionValue("source"));
+	}
+
+	/**
+	 * Parses the input and runs the specified command
+	 * 
+	 * @param input
+	 * @throws Exception
+	 */
+	void runCommand(String input) throws Exception
+	{
+		if (input.startsWith("#") || input.length() == 0)
+		{
+			return;
+		}
+
+		// Process user input
+		JcrParser parser = new JcrParser();
+		parser.parse(input);
+
+		// populate ctx
+		parser.populateContext(ctx);
+
+		// Execute command
+		long start = System.currentTimeMillis();
+		parser.getCommand().execute(ctx);
+		long elapsed = System.currentTimeMillis() - start;
+
+		// depopulate ctx
+		parser.depopulateContext(ctx);
+
+		// Display elapsed timed
+		System.out.println();
+		System.out.println(bundle.getString("phrase.elapsedtime") + ": "
+				+ elapsed + " ms.");
+		System.out.println();
+	}
+
+	/**
+	 * Handle the Exception. <br>
+	 * Shows a short message and prompt the user to show the entire stacktrace.
+	 * 
+	 * @param e
+	 */
+	private void handleException(Exception ex)
+	{
+		System.out.println();
+		System.out.println(bundle.getString("exception.occurred"));
+		System.out.println();
+		System.out.println(bundle.getString("exception") + ": "
+				+ ex.getClass().getName());
+		System.out.println(bundle.getString("word.message") + ": "
+				+ ex.getLocalizedMessage());
+		System.out.println();
+		String prompt = bundle.getString("phrase.display.stacktrace")
+				+ "? [y/n]";
+		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
+		String str = "";
+		int tries = 0;
+		while (!str.equals("y") && !str.equals("n") && tries < 3)
+		{
+			tries++;
+			System.out.print(prompt);
+			try
+			{
+				str = in.readLine();
+			} catch (IOException e)
+			{
+				e.printStackTrace();
+			}
+		}
+		if (str.equals("y"))
+		{
+			ex.printStackTrace();
+		}
+	}
+
+	/**
+	 * Prompt message
+	 * 
+	 * @return prompt
+	 * @throws Exception
+	 */
+	private String getPrompt() throws Exception
+	{
+
+		Repository r = CommandHelper.getRepository(ctx);
+		if (r == null)
+		{
+			return bundle.getString("phrase.not.connected");
+		}
+
+		Session s = CommandHelper.getSession(ctx);
+		if (s == null)
+		{
+			return bundle.getString("phrase.not.logged.in");
+		}
+
+		Node n = CommandHelper.getCurrentNode(ctx);
+
+		return n.getPath();
+	}
+
+	/**
+	 * Init allowed CommandLine options
+	 */
+	private void initOptions()
+	{
+		options = new Options();
+		options.addOption("lang", "code", true, "Language code");
+		options.addOption("country", "code", true, "Country code");
+		options.addOption("source", "path", true,
+				"Script for noninteractive mode");
+	}
+
+	/**
+	 * Sets the default Locale for the given CommandLine
+	 * 
+	 * @param cl
+	 * @throws ParseException
+	 */
+	private void setLocale(CommandLine cl) throws ParseException
+	{
+		Locale locale = null;
+		if (cl.hasOption("lang") && cl.hasOption("country"))
+		{
+			locale = new Locale(cl.getOptionValue("lang"), cl
+					.getOptionValue("country"));
+		}
+		if (cl.hasOption("lang") && !cl.hasOption("country"))
+		{
+			locale = new Locale(cl.getOptionValue("lang"));
+		}
+		if (locale != null)
+		{
+			Locale.setDefault(locale);
+		}
+	}
+
+	/**
+	 * Init context. <br>
+	 * Sets the Context Output to the console
+	 */
+	private void initContext()
+	{
+		CommandHelper.setOutput(ctx, new PrintWriter(System.out, true));
+	}
+
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/JcrParser.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/JcrParser.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/JcrParser.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/JcrParser.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,324 @@
+/*
+ * 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.cli;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.chain.Catalog;
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.commons.chain.config.ConfigParser;
+import org.apache.commons.chain.impl.CatalogFactoryBase;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Input Parser
+ */
+public class JcrParser
+{
+    /** parser */
+    private static Log log = LogFactory.getLog(JcrParser.class);
+
+    static
+    {
+        try
+        {
+            ConfigParser parser = new ConfigParser();
+            parser.parse(JcrParser.class.getResource("command.xml"));
+        } catch (Exception e)
+        {
+            e.printStackTrace();
+            log.error(e);
+        }
+    }
+
+    /** catalog */
+    private Catalog catalog = CatalogFactoryBase.getInstance().getCatalog();
+
+    /** Command */
+    private Command cmd;
+
+    /** Command Line */
+    private CommandLine cl;
+
+    /**
+     * Constructor
+     */
+    public JcrParser()
+    {
+        super();
+    }
+
+    /**
+     * Parse the user's input.
+     * 
+     * @param input
+     * @return a Command
+     * @throws JcrParserException
+     *             if the input is illegal
+     * @throws ConfigurationException
+     *             if the mapped command can't be mapped to a Commons Chain
+     *             Command
+     */
+    public void parse(String input) throws JcrParserException,
+            ConfigurationException
+    {
+        this.cl = null;
+        this.cmd = null;
+
+        // Validate input
+        if (input == null || input.length() == 0)
+        {
+            throw new JcrParserException("exception.parse.input.empty");
+        }
+
+        // Extract arguments
+        LinkedList args = this.getArguments(input);
+
+        // The first arg is the command name
+        String cmdName = (String) args.getFirst();
+        args.removeFirst();
+
+        // Get the command line descriptor
+        cl = CommandLineFactory.getInstance().getCommandLine(cmdName);
+
+        // populate with the given params
+        populate(cl, args);
+
+        // validate the command line
+        validate(cl);
+
+        // Create Chain Command
+        String impl = cl.getImpl();
+        if (impl == null)
+        {
+            impl = cl.getName();
+        }
+        cmd = catalog.getCommand(impl);
+
+        if (cmd == null)
+        {
+            throw new JcrParserException("no chain command for name " + impl);
+        }
+
+    }
+
+    /**
+     * Tokenize user's input
+     * 
+     * @param input
+     * @return
+     */
+    private LinkedList getArguments(String input)
+    {
+        LinkedList args = new LinkedList();
+        int length = input.length();
+
+        boolean insideSingleQuote = false;
+        boolean insideDoubleQuote = false;
+        int escape = -1;
+
+        StringBuffer arg = new StringBuffer();
+
+        for (int i = 0; i < length; ++i)
+        {
+            char c = input.charAt(i);
+
+            // end of argument?
+            if ((!insideSingleQuote & !insideDoubleQuote & Character
+                .isWhitespace(c)))
+            {
+                if (arg.toString().trim().length() > 0)
+                {
+                    args.add(arg.toString().trim());
+                    arg = new StringBuffer();
+                }
+                continue;
+            }
+
+            if (i == escape)
+            { // escaped char
+                arg.append(c);
+            } else
+            { // unescaped char
+                switch (c)
+                {
+                case '\\':
+                    escape = i + 1;
+                    break;
+                case '"':
+                    insideDoubleQuote = !insideDoubleQuote;
+                    break;
+                case '\'':
+                    insideSingleQuote = !insideSingleQuote;
+                    break;
+                default:
+                    arg.append(c);
+                    break;
+                }
+            }
+        }
+
+        if (arg.toString().trim().length() > 0)
+        {
+            args.add(arg.toString());
+        }
+
+        return args;
+    }
+
+    /**
+     * Populate the context with the attributes needed by the Command
+     */
+    public void populateContext(Context ctx)
+    {
+        Iterator iter = cl.getAllParameters();
+        while (iter.hasNext())
+        {
+            AbstractParameter param = (AbstractParameter) iter.next();
+            log.debug("add ctx attr: " + param.getContextKey() + "=" + param.getValue());
+            ctx.put(param.getContextKey(), param.getValue());
+        }
+    }
+
+    /**
+     * Remove context attribute specific to the parsed command
+     */
+    public void depopulateContext(Context ctx)
+    {
+        Iterator iter = cl.getAllParameters();
+        while (iter.hasNext())
+        {
+            AbstractParameter param = (AbstractParameter) iter.next();
+            String ctxKey = param.getContextKey() ;
+            log.debug("remove ctx attr: " + ctxKey + "=" + param.getValue());
+            ctx.remove(ctxKey);
+        }
+    }
+
+    /**
+     * @return the Command
+     */
+    public Command getCommand()
+    {
+        return cmd;
+    }
+
+    /**
+     * Populate the CommandLine with the given parameters
+     * 
+     * @param cl
+     * @param values
+     * @throws JcrParserException
+     */
+    private void populate(CommandLine cl, List valList)
+            throws JcrParserException
+    {
+        String[] values = (String[]) valList
+            .toArray(new String[valList.size()]);
+
+        // Command Line parameters
+        Map options = cl.getOptions();
+        Map flags = cl.getFlags();
+        Map clArgs = cl.getArguments();
+
+        // Input arguments
+        List args = new ArrayList();
+
+        for (int i = 0; i < values.length; i++)
+        {
+            String value = values[i];
+
+            if (value.startsWith("-"))
+            {
+                // option
+                if (i + 1 < values.length && !values[i + 1].startsWith("-"))
+                {
+                    Option opt = (Option) options.get(value.substring(1));
+                    if (opt == null)
+                    {
+                        throw new JcrParserException("no.opt.for.name",
+                            new String[]
+                            {
+                                value.substring(1)
+                            });
+                    }
+                    opt.setValue(values[i + 1]);
+                    i++;
+                } else
+                {
+                    // flag
+                    Flag flag = (Flag) flags.get(value.substring(1));
+                    if (flag == null)
+                    {
+                        throw new JcrParserException("no.flag.for.name",
+                            new String[]
+                            {
+                                value
+                            });
+                    }
+                    flag.setPresent(true);
+                }
+            } else
+            {
+                // collect arguments
+                args.add(value);
+            }
+        }
+
+        // set arguments
+        String[] argValues = (String[]) args.toArray(new String[args.size()]);
+        for (int j = 0; j < argValues.length; j++)
+        {
+            Argument arg = (Argument) clArgs.get(new Integer(j));
+            if (arg == null)
+            {
+                throw new JcrParserException("more.arguments.than.expected");
+            }
+            arg.setValue(argValues[j]);
+        }
+
+    }
+
+    /**
+     * Validate the CommandLine.
+     * 
+     * @param cl
+     * @throws JcrParserException
+     */
+    private void validate(CommandLine cl) throws JcrParserException
+    {
+        Iterator iter = cl.getRequiredParameters();
+        while (iter.hasNext())
+        {
+            AbstractParameter param = (AbstractParameter) iter.next();
+            if (param.getValue() == null)
+            {
+                throw new JcrParserException("missing.paramater", new String[]
+                {
+                    param.getName()
+                });
+            }
+        }
+    }
+
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/JcrParserException.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/JcrParserException.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/JcrParserException.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/JcrParserException.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,68 @@
+/*
+ * 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.cli;
+
+import org.apache.jackrabbit.command.CommandException;
+
+/**
+ * Exception thrown if any error occurs while parsing the user's input.
+ */
+public class JcrParserException extends CommandException
+{
+
+    /**
+     * <code>serialVersionUID</code>
+     */
+    private static final long serialVersionUID = 3761694498056713525L;
+
+    /**
+     * @param message
+     * @param arguments
+     */
+    public JcrParserException(String message, Object[] arguments)
+    {
+        super(message, arguments);
+    }
+
+    /**
+     * @param message
+     * @param cause
+     * @param arguments
+     */
+    public JcrParserException(String message, Throwable cause,
+        Object[] arguments)
+    {
+        super(message, cause, arguments);
+    }
+
+    /**
+     * @param message
+     */
+    public JcrParserException(String message)
+    {
+        super(message);
+    }
+
+    /**
+     * @param message
+     * @param cause
+     */
+    public JcrParserException(String message, Throwable cause)
+    {
+        super(message, cause);
+    }
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/Option.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/Option.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/Option.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/Option.java Tue Oct  4 13:51:32 2005
@@ -0,0 +1,99 @@
+/*
+ * 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.cli;
+
+/**
+ * Command Line option. An option is a pair of parameters with the following
+ * pattern -[option name] [option value]
+ */
+public class Option extends AbstractParameter
+{
+
+    /** argument name */
+    private String argName;
+
+    /** required */
+    private boolean required = false;
+
+    /**
+     * @return Returns the required.
+     */
+    public boolean isRequired()
+    {
+        return required;
+    }
+
+    /**
+     * @param required
+     *            The required to set.
+     */
+    public void setRequired(boolean required)
+    {
+        this.required = required;
+    }
+
+    /**
+     * @return Returns the argName.
+     */
+    public String getArgName()
+    {
+        return argName;
+    }
+
+    /**
+     * @return localized argument name
+     */
+    public String getLocalizedArgName()
+    {
+        return bundle.getString(this.getArgName());
+    }
+
+    /**
+     * @param argName
+     *            The argName to set.
+     */
+    public void setArgName(String argName)
+    {
+        this.argName = argName;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public Object clone()
+    {
+        Option o = new Option();
+        this.clone(o);
+        return o;
+    }
+
+    protected void clone(Option opt)
+    {
+        super.clone(opt);
+        opt.argName = this.argName;
+        opt.required = this.required;
+
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public String getLocalizedDescription()
+    {
+        return bundle.getString(this.getDescription());
+    }
+}

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

Added: incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/SourceCommand.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/SourceCommand.java?rev=294914&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/SourceCommand.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/SourceCommand.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.cli;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.PrintWriter;
+import java.util.ResourceBundle;
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.jackrabbit.command.CommandHelper;
+import org.apache.jackrabbit.command.CommandException;
+
+/**
+ * Executes a CLI script from the given file.
+ */
+public class SourceCommand implements Command
+{
+    /** Resource bundle */
+    private ResourceBundle bundle = CommandHelper.getBundle() ;
+
+    /** file */
+    private String fileKey = "file";
+
+    /** cli parser */
+    JcrParser parser = new JcrParser();
+
+    /**
+     * @return Returns the file.
+     */
+    public String getFileKey()
+    {
+        return fileKey;
+    }
+
+    /**
+     * @param file
+     *            The file to set.
+     */
+    public void setFileKey(String file)
+    {
+        this.fileKey = file;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public boolean execute(Context ctx) throws Exception
+    {
+        File f = new File((String) ctx.get(this.fileKey));
+        if (!f.exists())
+        {
+            throw new CommandException("exception.file.not.found", new String[]
+            {
+                f.getAbsolutePath()
+            });
+        }
+        // client
+        JcrClient client = new JcrClient(ctx) ;
+        
+        BufferedReader in = new BufferedReader(new FileReader(f));
+        PrintWriter out = CommandHelper.getOutput(ctx);
+        String line = null;
+        while ((line = in.readLine()) != null)
+        {
+            out.println(bundle.getString("word.running") + ": " + line);
+            client.runCommand(line);
+        }
+        in.close();
+        return false;
+    }
+}

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



Mime
View raw message