You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2006/06/05 01:24:10 UTC

svn commit: r411622 - in /geronimo/sandbox/gshell/trunk: gshell-api/src/main/java/org/apache/geronimo/gshell/command/ gshell-assemblies/gshell-complete-assembly/ gshell-commands/ gshell-commands/gshell-vfs-commands/ gshell-commands/gshell-vfs-commands/...

Author: jdillon
Date: Sun Jun  4 16:24:09 2006
New Revision: 411622

URL: http://svn.apache.org/viewvc?rev=411622&view=rev
Log:
This is the start of VFS commands to provide rich file operations

Added:
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/pom.xml   (with props)
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/java/
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/java/org/
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/java/org/apache/
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/java/org/apache/geronimo/
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/java/org/apache/geronimo/gshell/
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/java/org/apache/geronimo/gshell/commands/
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/java/org/apache/geronimo/gshell/commands/vfs/
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyCommand.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/java/org/apache/geronimo/gshell/commands/vfs/VFSCommandSupport.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/resources/
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/resources/META-INF/
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/resources/META-INF/org.apache.geronimo.gshell.command/
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/resources/META-INF/org.apache.geronimo.gshell.command/copy.properties   (with props)
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/resources/org/
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/resources/org/apache/
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/resources/org/apache/geronimo/
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/resources/org/apache/geronimo/gshell/
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/resources/org/apache/geronimo/gshell/commands/
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/resources/org/apache/geronimo/gshell/commands/vfs/
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/resources/org/apache/geronimo/gshell/commands/vfs/CopyCommandMessages.properties   (with props)
Modified:
    geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java
    geronimo/sandbox/gshell/trunk/gshell-assemblies/gshell-complete-assembly/pom.xml
    geronimo/sandbox/gshell/trunk/gshell-commands/pom.xml

Modified: geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java?rev=411622&r1=411621&r2=411622&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java Sun Jun  4 16:24:09 2006
@@ -99,12 +99,23 @@
             dump(context.getVariables());
         }
 
-        doInit();
+        try {
+            doInit();
+        }
+        catch (Exception e) {
+            log.error("Initialization failed", e);
+
+            //
+            // HACK:
+            //
+
+            throw new RuntimeException("Command initialization failed", e);
+        }
 
         log.debug("Initialized");
     }
 
-    protected void doInit() {
+    protected void doInit() throws Exception {
         // Sub-class should override to provide custom initialization
     }
 
@@ -125,14 +136,25 @@
             dump(context.getVariables());
         }
 
-        doDestroy();
+        try {
+            doDestroy();
+        }
+        catch (Exception e) {
+            log.error("Destruction failed", e);
+
+            //
+            // HACK:
+            //
+
+            throw new RuntimeException("Command destruction failed", e);
+        }
 
         this.context = null;
 
         log.debug("Destroyed");
     }
 
-    protected void doDestroy() {
+    protected void doDestroy() throws Exception {
         // Sub-class should override to provide custom cleanup
     }
 

Modified: geronimo/sandbox/gshell/trunk/gshell-assemblies/gshell-complete-assembly/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-assemblies/gshell-complete-assembly/pom.xml?rev=411622&r1=411621&r2=411622&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-assemblies/gshell-complete-assembly/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-assemblies/gshell-complete-assembly/pom.xml Sun Jun  4 16:24:09 2006
@@ -56,6 +56,12 @@
             <artifactId>gshell-scripting-commands</artifactId>
             <version>${pom.version}</version>
         </dependency>
+
+        <dependency>
+            <groupId>${pom.groupId}</groupId>
+            <artifactId>gshell-vfs-commands</artifactId>
+            <version>${pom.version}</version>
+        </dependency>
     </dependencies>
     
     <build>

Added: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/pom.xml?rev=411622&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/pom.xml (added)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/pom.xml Sun Jun  4 16:24:09 2006
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- $Id$ -->
+
+<project
+    xmlns="http://maven.apache.org/POM/4.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    
+    <modelVersion>4.0.0</modelVersion>
+    
+    <parent>
+        <groupId>org.apache.geronimo.gshell</groupId>
+        <artifactId>gshell-commands</artifactId>
+        <version>1.0.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    
+    <artifactId>gshell-vfs-commands</artifactId>
+    <name>GShell Commands :: VFS</name>
+    <packaging>jar</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>${pom.groupId}</groupId>
+            <artifactId>gshell-api</artifactId>
+            <version>${pom.version}</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>commons-vfs</groupId>
+            <artifactId>commons-vfs</artifactId>
+            <version>20050307052300</version>
+            <type>jar</type>
+            <scope>compile</scope>
+        </dependency>
+    </dependencies>
+    
+</project>

Propchange: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyCommand.java?rev=411622&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyCommand.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyCommand.java Sun Jun  4 16:24:09 2006
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * 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.geronimo.gshell.commands.vfs;
+
+import org.apache.geronimo.gshell.command.MessageSource;
+import org.apache.geronimo.gshell.command.Command;
+import org.apache.geronimo.gshell.console.IO;
+
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.PosixParser;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.FileSystemManager;
+import org.apache.commons.vfs.FileUtil;
+
+/**
+ * ???
+ *
+ * @version $Id$
+ */
+public class CopyCommand
+    extends VFSCommandSupport
+{
+    public CopyCommand() {
+        super("copy");
+    }
+
+    protected int doExecute(String[] args) throws Exception {
+        assert args != null;
+
+        MessageSource messages = getMessageSource();
+
+        //
+        // TODO: Optimize, move common code to CommandSupport
+        //
+
+        IO io = getIO();
+
+        Options options = new Options();
+
+        options.addOption(OptionBuilder.withLongOpt("help")
+            .withDescription(messages.getMessage("cli.option.help"))
+            .create('h'));
+
+        CommandLineParser parser = new PosixParser();
+        CommandLine line = parser.parse(options, args);
+
+        boolean usage = false;
+
+        String[] _args = line.getArgs();
+
+        // Need exactly 2 args
+        if (_args.length != 2) {
+            usage = true;
+        }
+
+        if (usage || line.hasOption('h')) {
+            io.out.print(getName());
+            io.out.print(" -- ");
+            io.out.println(messages.getMessage("cli.usage.description"));
+            io.out.println();
+
+            HelpFormatter formatter = new HelpFormatter();
+            formatter.printHelp(
+                io.out,
+                80, // width (FIXME: Should pull from gshell.columns variable)
+                getName() + " [options] <source> <target>",
+                "",
+                options,
+                4, // left pad
+                4, // desc pad
+                "",
+                false); // auto usage
+
+            // io.out.println();
+            // io.out.println(messages.getMessage("cli.usage.footer"));
+            io.out.println();
+
+            return Command.SUCCESS;
+        }
+
+        FileSystemManager fsm = getFileSystemManager();
+        FileObject source = fsm.resolveFile(_args[0]);
+        FileObject target = fsm.resolveFile(_args[1]);
+
+        log.info("Copying " + source + " -> " + target);
+
+        FileUtil.copyContent(source, target);
+
+        return Command.SUCCESS;
+    }
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyCommand.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyCommand.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/java/org/apache/geronimo/gshell/commands/vfs/VFSCommandSupport.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/java/org/apache/geronimo/gshell/commands/vfs/VFSCommandSupport.java?rev=411622&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/java/org/apache/geronimo/gshell/commands/vfs/VFSCommandSupport.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/java/org/apache/geronimo/gshell/commands/vfs/VFSCommandSupport.java Sun Jun  4 16:24:09 2006
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * 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.geronimo.gshell.commands.vfs;
+
+import org.apache.geronimo.gshell.command.CommandSupport;
+import org.apache.commons.vfs.FileSystemManager;
+import org.apache.commons.vfs.VFS;
+
+/**
+ * Support for VFS commands.
+ *
+ * @version $Id$
+ */
+public abstract class VFSCommandSupport
+    extends CommandSupport
+{
+    private FileSystemManager fsManager;
+
+    protected VFSCommandSupport(final String name) {
+        super(name);
+    }
+
+    protected void doInit() throws Exception {
+        fsManager = VFS.getManager();
+    }
+
+    protected FileSystemManager getFileSystemManager() {
+        if (fsManager == null) {
+            throw new IllegalStateException("Not initialized; Missing FileSystemManager");
+        }
+
+        return fsManager;
+    }
+}

Propchange: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/java/org/apache/geronimo/gshell/commands/vfs/VFSCommandSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/java/org/apache/geronimo/gshell/commands/vfs/VFSCommandSupport.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/java/org/apache/geronimo/gshell/commands/vfs/VFSCommandSupport.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/resources/META-INF/org.apache.geronimo.gshell.command/copy.properties
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/resources/META-INF/org.apache.geronimo.gshell.command/copy.properties?rev=411622&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/resources/META-INF/org.apache.geronimo.gshell.command/copy.properties (added)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/resources/META-INF/org.apache.geronimo.gshell.command/copy.properties Sun Jun  4 16:24:09 2006
@@ -0,0 +1,13 @@
+##
+## $Id:exit.properties 410870 2006-06-01 07:43:42 -0700 (Thu, 01 Jun 2006) jdillon $
+##
+
+class=org.apache.geronimo.gshell.commands.vfs.CopyCommand
+
+name=copy
+
+aliases=cp
+
+category=vfs
+
+enable=true
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/resources/META-INF/org.apache.geronimo.gshell.command/copy.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/resources/META-INF/org.apache.geronimo.gshell.command/copy.properties
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/resources/META-INF/org.apache.geronimo.gshell.command/copy.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/resources/org/apache/geronimo/gshell/commands/vfs/CopyCommandMessages.properties
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/resources/org/apache/geronimo/gshell/commands/vfs/CopyCommandMessages.properties?rev=411622&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/resources/org/apache/geronimo/gshell/commands/vfs/CopyCommandMessages.properties (added)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/resources/org/apache/geronimo/gshell/commands/vfs/CopyCommandMessages.properties Sun Jun  4 16:24:09 2006
@@ -0,0 +1,17 @@
+##
+## $Id$
+##
+
+##
+## Option descriptions
+##
+
+cli.option.help=Display this help message
+
+##
+## Option usage (help)
+##
+
+cli.usage.description=Copy files via. VFS
+
+cli.usage.footer=
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/resources/org/apache/geronimo/gshell/commands/vfs/CopyCommandMessages.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/resources/org/apache/geronimo/gshell/commands/vfs/CopyCommandMessages.properties
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/resources/org/apache/geronimo/gshell/commands/vfs/CopyCommandMessages.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/sandbox/gshell/trunk/gshell-commands/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/pom.xml?rev=411622&r1=411621&r2=411622&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/pom.xml Sun Jun  4 16:24:09 2006
@@ -31,6 +31,7 @@
     <modules>
         <module>gshell-standard-commands</module>
         <module>gshell-scripting-commands</module>
+        <module>gshell-vfs-commands</module>
     </modules>
     
 </project>