From: Joakim Erdfelt Date: Sun, 24 Feb 2008 05:12:20 +0000 (+0000) Subject: MRM-709: Use commons-io instead of Plexus Utils X-Git-Tag: archiva-r676265~350 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7b7497e19e5b452d00a12f8141f2766c1cc08611;p=archiva.git MRM-709: Use commons-io instead of Plexus Utils * Eliminating AsciiFileUtil as it is now redundant. git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@630590 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-base/archiva-artifact-converter/src/main/java/org/apache/maven/archiva/converter/artifact/AsciiFileUtil.java b/archiva-base/archiva-artifact-converter/src/main/java/org/apache/maven/archiva/converter/artifact/AsciiFileUtil.java deleted file mode 100644 index a69f2134a..000000000 --- a/archiva-base/archiva-artifact-converter/src/main/java/org/apache/maven/archiva/converter/artifact/AsciiFileUtil.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.apache.maven.archiva.converter.artifact; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -import java.io.File; -import java.io.IOException; - -import org.apache.commons.io.FileUtils; - -/** - * AsciiFileUtil - conveinence utility for reading / writing ascii files. - * - * @author Joakim Erdfelt - * @version $Id$ - * @todo switch to commons-lang and use their high-performance versions of these utility methods. - */ -public class AsciiFileUtil -{ - /** - * Read a file into a {@link String} and return it. - * - * @param file the file to read - * @return the {@link String} contents of the file. - * @throws IOException if there was a problem performing this operation. - */ - public static String readFile( File file ) - throws IOException - { - return FileUtils.readFileToString( file, null ); - } - - /** - * Write the contents of a {@link String} to a file. - * - * @param file the file to write to - * @param content the {@link String} contents to write. - * @throws IOException if there was a problem performing this operation. - */ - public static void writeFile( File file, String content ) - throws IOException - { - FileUtils.writeStringToFile( file, content, null ); - } -} diff --git a/archiva-base/archiva-artifact-converter/src/main/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverter.java b/archiva-base/archiva-artifact-converter/src/main/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverter.java index 43b8d20d3..876e91edb 100644 --- a/archiva-base/archiva-artifact-converter/src/main/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverter.java +++ b/archiva-base/archiva-artifact-converter/src/main/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverter.java @@ -193,7 +193,7 @@ public class LegacyToDefaultConverter } // Even if the checksums for the POM are invalid we should still convert the POM - contents = AsciiFileUtil.readFile( file ); + contents = FileUtils.readFileToString( file, null ); } catch ( IOException e ) { @@ -209,7 +209,7 @@ public class LegacyToDefaultConverter boolean matching = false; if ( !force && targetFile.exists() ) { - String targetContents = AsciiFileUtil.readFile( targetFile ); + String targetContents = FileUtils.readFileToString( targetFile, null ); matching = targetContents.equals( contents ); } if ( force || !matching ) @@ -308,7 +308,7 @@ public class LegacyToDefaultConverter File checksumFile = new File( file.getParentFile(), fileName ); if ( checksumFile.exists() ) { - String checksum = AsciiFileUtil.readFile( checksumFile ); + String checksum = FileUtils.readFileToString( checksumFile, null ); try { digester.verify( file, checksum ); diff --git a/archiva-base/archiva-artifact-converter/src/test/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverterTest.java b/archiva-base/archiva-artifact-converter/src/test/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverterTest.java index b46d7583d..4a47c78e4 100644 --- a/archiva-base/archiva-artifact-converter/src/test/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverterTest.java +++ b/archiva-base/archiva-artifact-converter/src/test/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverterTest.java @@ -21,7 +21,6 @@ package org.apache.maven.archiva.converter.artifact; import org.apache.maven.archiva.converter.artifact.ArtifactConversionException; import org.apache.maven.archiva.converter.artifact.ArtifactConverter; -import org.apache.maven.archiva.converter.artifact.AsciiFileUtil; import org.apache.maven.archiva.converter.artifact.Messages; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; @@ -934,8 +933,8 @@ public class LegacyToDefaultConverterTest private static void compareFiles( File expectedPomFile, File pomFile ) throws IOException { - String expectedContent = normalizeString( AsciiFileUtil.readFile( expectedPomFile ) ); - String targetContent = normalizeString( AsciiFileUtil.readFile( pomFile ) ); + String expectedContent = normalizeString( org.apache.commons.io.FileUtils.readFileToString( expectedPomFile, null ) ); + String targetContent = normalizeString( org.apache.commons.io.FileUtils.readFileToString( pomFile, null ) ); assertEquals( "Check file match between " + expectedPomFile + " and " + pomFile, expectedContent, targetContent ); }