You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by im...@apache.org on 2006/03/15 20:12:28 UTC

svn commit: r386137 - /jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/tasks/AbstractSyncTask.java

Author: imario
Date: Wed Mar 15 11:12:28 2006
New Revision: 386137

URL: http://svn.apache.org/viewcvs?rev=386137&view=rev
Log:
PR: 38491

Added a "failonerror" attribute.

Thanks to Steven Tyler for pointing it out.

Modified:
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/tasks/AbstractSyncTask.java

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/tasks/AbstractSyncTask.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/tasks/AbstractSyncTask.java?rev=386137&r1=386136&r2=386137&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/tasks/AbstractSyncTask.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/tasks/AbstractSyncTask.java Wed Mar 15 11:12:28 2006
@@ -58,6 +58,7 @@
     private String destDirUrl;
     private String srcDirUrl;
     private boolean srcDirIsBase;
+    private boolean failonerror = true;
     private String filesList;
 
     /**
@@ -103,6 +104,22 @@
     }
 
     /**
+     * Sets whether we should fail if there was an error or not
+     */
+    public void setFailonerror(final boolean failonerror)
+    {
+        this.failonerror = failonerror;
+    }
+    
+    /**
+     * Sets whether we should fail if there was an error or not
+     */
+    public boolean isFailonerror()
+    {
+        return failonerror;
+    }
+    
+    /**
      * Sets the files to includes
      */
     public void setIncludes(final String filesList)
@@ -134,14 +151,16 @@
         {
             final String message =
                 Messages.getString("vfs.tasks/sync.no-destination.error");
-            throw new BuildException(message);
+            logOrDie(message, Project.MSG_WARN);
+            return;
         }
 
         if (destFileUrl != null && destDirUrl != null)
         {
             final String message =
                 Messages.getString("vfs.tasks/sync.too-many-destinations.error");
-            throw new BuildException(message);
+            logOrDie(message, Project.MSG_WARN);
+            return;
         }
 
         // Add the files of the includes attribute to the list
@@ -171,7 +190,7 @@
         if (srcFiles.size() == 0)
         {
             final String message = Messages.getString("vfs.tasks/sync.no-source-files.warn");
-            log(message, Project.MSG_WARN);
+            logOrDie(message, Project.MSG_WARN);
             return;
         }
 
@@ -197,6 +216,16 @@
         }
     }
 
+	protected void logOrDie(final String message, int level)
+	{
+		if (!isFailonerror())
+		{
+			log(message, level);
+			return;
+		}
+		throw new BuildException(message);
+	}
+
     /**
      * Copies the source files to the destination.
      */
@@ -222,7 +251,8 @@
             {
                 final String message =
                     Messages.getString("vfs.tasks/sync.src-file-no-exist.warn", srcFile);
-                log(message, Project.MSG_WARN);
+                
+                logOrDie(message, Project.MSG_WARN);
             }
             else
             {
@@ -312,7 +342,7 @@
         if (destFiles.contains(destFile))
         {
             final String message = Messages.getString("vfs.tasks/sync.duplicate-source-files.warn", destFile);
-            log(message, Project.MSG_WARN);
+            logOrDie(message, Project.MSG_WARN);
         }
         else
         {
@@ -334,7 +364,8 @@
         {
             final String message =
                 Messages.getString("vfs.tasks/sync.too-many-source-files.error");
-            throw new BuildException(message);
+            logOrDie(message, Project.MSG_WARN);
+            return;
         }
         final SourceInfo src = (SourceInfo) srcFiles.get(0);
         final FileObject srcFile = resolveFile(src.file);
@@ -342,7 +373,8 @@
         {
             final String message =
                 Messages.getString("vfs.tasks/sync.source-not-file.error", srcFile);
-            throw new BuildException(message);
+            logOrDie(message, Project.MSG_WARN);
+            return;
         }
 
         // Locate the destination file



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org