geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r700003 - in /geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs: CatAction.java ChangeDirectoryAction.java CopyAction.java ListDirectoryAction.java RemoveAction.java TouchAction.java
Date Mon, 29 Sep 2008 07:23:25 GMT
Author: jdillon
Date: Mon Sep 29 00:23:24 2008
New Revision: 700003

URL: http://svn.apache.org/viewvc?rev=700003&view=rev
Log:
Add more validation

Modified:
    geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CatAction.java
    geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/ChangeDirectoryAction.java
    geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyAction.java
    geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/ListDirectoryAction.java
    geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/RemoveAction.java
    geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/TouchAction.java

Modified: geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CatAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CatAction.java?rev=700003&r1=700002&r2=700003&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CatAction.java
(original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CatAction.java
Mon Sep 29 00:23:24 2008
@@ -21,6 +21,7 @@
 
 import org.apache.commons.vfs.FileObject;
 import org.apache.commons.vfs.FileUtil;
+import org.apache.commons.vfs.FileType;
 import org.apache.geronimo.gshell.clp.Argument;
 import org.apache.geronimo.gshell.command.CommandContext;
 import org.apache.geronimo.gshell.io.IO;
@@ -42,8 +43,15 @@
 
         FileObject file = resolveFile(context, path);
 
-        // TODO: Validate more
-
+        if (!file.exists()) {
+            io.error("File not found: {}", file.getName());
+            return Result.FAILURE;
+        }
+        else if (file.getType() == FileType.FOLDER) {
+            io.error("File is a directory: {}", file.getName());
+            return Result.FAILURE;
+        }
+        
         FileUtil.writeContent(file, io.outputStream);
         io.out.println();
 

Modified: geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/ChangeDirectoryAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/ChangeDirectoryAction.java?rev=700003&r1=700002&r2=700003&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/ChangeDirectoryAction.java
(original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/ChangeDirectoryAction.java
Mon Sep 29 00:23:24 2008
@@ -47,7 +47,6 @@
 
         FileObject file = resolveFile(context, path);
 
-        // Complain if the file is missing or is not a directory
         if (!file.exists()) {
             io.error("Directory not found: {}", file.getName());
             return Result.FAILURE;

Modified: geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyAction.java?rev=700003&r1=700002&r2=700003&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyAction.java
(original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyAction.java
Mon Sep 29 00:23:24 2008
@@ -24,6 +24,7 @@
 import org.apache.commons.vfs.Selectors;
 import org.apache.geronimo.gshell.clp.Argument;
 import org.apache.geronimo.gshell.command.CommandContext;
+import org.apache.geronimo.gshell.io.IO;
 
 /**
  * Copies a file or directory.
@@ -39,12 +40,20 @@
     @Argument(index=1, required=true)
     private String targetPath;
 
+    // TODO: Add --recursive suport
+    
     public Object execute(final CommandContext context) throws Exception {
         assert context != null;
+        IO io = context.getIo();
 
         FileObject source = resolveFile(context, sourcePath);
         FileObject target = resolveFile(context, targetPath);
 
+        if (!source.exists()) {
+            io.error("Source file not found: {}", source.getName());
+            return Result.FAILURE;
+        }
+
         // TODO: Validate more
 
         if (target.exists() && target.getType() == FileType.FOLDER) {

Modified: geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/ListDirectoryAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/ListDirectoryAction.java?rev=700003&r1=700002&r2=700003&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/ListDirectoryAction.java
(original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/ListDirectoryAction.java
Mon Sep 29 00:23:24 2008
@@ -70,11 +70,11 @@
             io.info("{}", file.getName());
 
             FileContent content = file.getContent();
-            io.info("Size: {} bytes", content.getSize());
+            io.verbose("Size: {} bytes", content.getSize());
 
             DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
             String lastMod = dateFormat.format(new Date(content.getLastModifiedTime()));
-            io.info("Last modified: {}", lastMod);
+            io.verbose("Last modified: {}", lastMod);
         }
 
         return Result.SUCCESS;

Modified: geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/RemoveAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/RemoveAction.java?rev=700003&r1=700002&r2=700003&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/RemoveAction.java
(original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/RemoveAction.java
Mon Sep 29 00:23:24 2008
@@ -21,8 +21,10 @@
 
 import org.apache.commons.vfs.FileObject;
 import org.apache.commons.vfs.Selectors;
+import org.apache.commons.vfs.FileType;
 import org.apache.geronimo.gshell.clp.Argument;
 import org.apache.geronimo.gshell.command.CommandContext;
+import org.apache.geronimo.gshell.io.IO;
 
 /**
  * Remove a file or directory.
@@ -35,12 +37,18 @@
     @Argument(required=true)
     private String path;
 
+    // TODO: Add --recursive support
+
     public Object execute(final CommandContext context) throws Exception {
         assert context != null;
+        IO io = context.getIo();
 
         FileObject file = resolveFile(context, path);
 
-        // TODO: Validate more
+        if (!file.exists()) {
+            io.error("File not found: {}", file.getName());
+            return Result.FAILURE;
+        }
 
         file.delete(Selectors.SELECT_SELF);
 

Modified: geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/TouchAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/TouchAction.java?rev=700003&r1=700002&r2=700003&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/TouchAction.java
(original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/TouchAction.java
Mon Sep 29 00:23:24 2008
@@ -39,8 +39,6 @@
 
         FileObject file = resolveFile(context, path);
 
-        // TODO: Validate more
-
         if (!file.exists()) {
             file.createFile();
         }



Mime
View raw message