]> source.dussan.org Git - archiva.git/commitdiff
MRM-709: Use commons-io instead of Plexus Utils
authorJoakim Erdfelt <joakime@apache.org>
Sun, 24 Feb 2008 05:07:26 +0000 (05:07 +0000)
committerJoakim Erdfelt <joakime@apache.org>
Sun, 24 Feb 2008 05:07:26 +0000 (05:07 +0000)
* Using FileUtils from commons-io.

git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@630589 13f79535-47bb-0310-9956-ffa450edef68

archiva-base/archiva-artifact-converter/pom.xml
archiva-base/archiva-artifact-converter/src/main/java/org/apache/maven/archiva/converter/artifact/AsciiFileUtil.java
archiva-base/archiva-artifact-converter/src/main/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverter.java

index e5729ae8d3fa4b014b5e9d3bd124c8906aee05d9..24b45dcc0ade52467805dce2093c3e8e6cc74429 100644 (file)
   <name>Archiva Artifact Converter</name>
   <description>Converts between Legacy and Modern Layout Artifacts.</description>
   <dependencies>
+    <dependency>
+      <groupId>commons-io</groupId>
+      <artifactId>commons-io</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-repository-metadata</artifactId>
index f155e311ef42c0b0d716ceb313cb71646d864247..a69f2134a1d7bc946bd36000ab67fcc95b320a85 100644 (file)
@@ -19,13 +19,11 @@ package org.apache.maven.archiva.converter.artifact;
  * under the License.
  */
 
-import org.codehaus.plexus.util.IOUtil;
-
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
 import java.io.IOException;
 
+import org.apache.commons.io.FileUtils;
+
 /**
  * AsciiFileUtil - conveinence utility for reading / writing ascii files.
  * 
@@ -45,16 +43,7 @@ public class AsciiFileUtil
     public static String readFile( File file )
         throws IOException
     {
-        FileInputStream in = null;
-        try
-        {
-            in = new FileInputStream( file );
-            return IOUtil.toString( in );
-        }
-        finally
-        {
-            IOUtil.close( in );
-        }
+        return FileUtils.readFileToString( file, null );
     }
 
     /**
@@ -67,15 +56,6 @@ public class AsciiFileUtil
     public static void writeFile( File file, String content )
         throws IOException
     {
-        FileOutputStream out = null;
-        try
-        {
-            out = new FileOutputStream( file );
-            IOUtil.copy( content, out );
-        }
-        finally
-        {
-            IOUtil.close( out );
-        }
+        FileUtils.writeStringToFile( file, content, null );
     }
 }
index abe5c3635e26a042d0b5a0d28584fb12a0d82cbd..43b8d20d36263bd1950391570097201884e630e1 100644 (file)
@@ -19,6 +19,8 @@ package org.apache.maven.archiva.converter.artifact;
  * under the License.
  */
 
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
 import org.apache.maven.archiva.transaction.FileTransaction;
 import org.apache.maven.archiva.transaction.TransactionException;
 import org.apache.maven.artifact.Artifact;
@@ -41,8 +43,6 @@ import org.apache.maven.model.converter.PomTranslationException;
 import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
 import org.codehaus.plexus.digest.Digester;
 import org.codehaus.plexus.digest.DigesterException;
-import org.codehaus.plexus.util.FileUtils;
-import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
 import java.io.File;
@@ -275,7 +275,7 @@ public class LegacyToDefaultConverter
                 }
                 finally
                 {
-                    IOUtil.close( writer );
+                    IOUtils.closeQuietly( writer );
                 }
             }
         }
@@ -411,7 +411,7 @@ public class LegacyToDefaultConverter
         }
         finally
         {
-            IOUtil.close( fileReader );
+            IOUtils.closeQuietly( fileReader );
         }
         return metadata;
     }
@@ -583,7 +583,7 @@ public class LegacyToDefaultConverter
             }
             finally
             {
-                IOUtil.close( writer );
+                IOUtils.closeQuietly( writer );
             }
         }
     }