From 1e7c8f6da44eaba619664487d32abddf5cd3bb5e Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Fri, 14 Mar 2008 05:01:56 +0000 Subject: [PATCH] [MRM-709] Use commons-io instead of Plexus Utils * Some more IOUtil and FileUtil conversions. git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@636993 13f79535-47bb-0310-9956-ffa450edef68 --- .../indexer/bytecode/BytecodeRecordLoader.java | 9 +++++---- .../hashcodes/HashcodesRecordLoader.java | 6 +++--- archiva-base/archiva-transaction/pom.xml | 4 ++++ .../transaction/AbstractTransactionEvent.java | 18 ++++++------------ .../transaction/AbstractFileEventTest.java | 4 ++-- 5 files changed, 20 insertions(+), 21 deletions(-) diff --git a/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/bytecode/BytecodeRecordLoader.java b/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/bytecode/BytecodeRecordLoader.java index 4b9ed12f0..9795215e1 100644 --- a/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/bytecode/BytecodeRecordLoader.java +++ b/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/bytecode/BytecodeRecordLoader.java @@ -9,7 +9,7 @@ package org.apache.maven.archiva.indexer.bytecode; * "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 + * 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 @@ -20,10 +20,11 @@ package org.apache.maven.archiva.indexer.bytecode; */ import junit.framework.AssertionFailedError; + +import org.apache.commons.io.IOUtils; import org.apache.maven.archiva.model.ArchivaArtifact; import org.apache.maven.archiva.model.ArchivaArtifactJavaDetails; import org.apache.maven.archiva.model.platform.JavaArtifactHelper; -import org.codehaus.plexus.util.IOUtil; import java.io.BufferedReader; import java.io.File; @@ -125,8 +126,8 @@ public class BytecodeRecordLoader } finally { - IOUtil.close( reader ); - IOUtil.close( freader ); + IOUtils.closeQuietly( reader ); + IOUtils.closeQuietly( freader ); } // cache.put( artifact, record ); diff --git a/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/hashcodes/HashcodesRecordLoader.java b/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/hashcodes/HashcodesRecordLoader.java index b03356904..4d9e0f74d 100644 --- a/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/hashcodes/HashcodesRecordLoader.java +++ b/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/hashcodes/HashcodesRecordLoader.java @@ -19,10 +19,10 @@ package org.apache.maven.archiva.indexer.hashcodes; * under the License. */ +import org.apache.commons.io.IOUtils; import org.apache.maven.archiva.model.ArchivaArtifact; import org.apache.maven.archiva.model.ArchivaArtifactJavaDetails; import org.apache.maven.archiva.model.platform.JavaArtifactHelper; -import org.codehaus.plexus.util.IOUtil; import java.io.BufferedReader; import java.io.File; @@ -97,8 +97,8 @@ public class HashcodesRecordLoader } finally { - IOUtil.close( reader ); - IOUtil.close( freader ); + IOUtils.closeQuietly( reader ); + IOUtils.closeQuietly( freader ); } return record; diff --git a/archiva-base/archiva-transaction/pom.xml b/archiva-base/archiva-transaction/pom.xml index 754eb5726..88a3e2af7 100644 --- a/archiva-base/archiva-transaction/pom.xml +++ b/archiva-base/archiva-transaction/pom.xml @@ -28,6 +28,10 @@ Archiva Transactions API for managing transaction. + + commons-io + commons-io + org.codehaus.plexus plexus-digest diff --git a/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/AbstractTransactionEvent.java b/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/AbstractTransactionEvent.java index b8e08f0eb..7323f7cfd 100644 --- a/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/AbstractTransactionEvent.java +++ b/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/AbstractTransactionEvent.java @@ -19,10 +19,10 @@ package org.apache.maven.archiva.transaction; * under the License. */ +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; 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 java.io.File; import java.io.FileOutputStream; @@ -215,19 +215,13 @@ public abstract class AbstractTransactionEvent } } + /** + * TODO: Remove in favor of using FileUtils directly. + */ protected void writeStringToFile( 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 ); } /** diff --git a/archiva-base/archiva-transaction/src/test/java/org/apache/maven/archiva/transaction/AbstractFileEventTest.java b/archiva-base/archiva-transaction/src/test/java/org/apache/maven/archiva/transaction/AbstractFileEventTest.java index d30d83917..05652f554 100644 --- a/archiva-base/archiva-transaction/src/test/java/org/apache/maven/archiva/transaction/AbstractFileEventTest.java +++ b/archiva-base/archiva-transaction/src/test/java/org/apache/maven/archiva/transaction/AbstractFileEventTest.java @@ -19,9 +19,9 @@ package org.apache.maven.archiva.transaction; * under the License. */ +import org.apache.commons.io.IOUtils; import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.digest.Digester; -import org.codehaus.plexus.util.IOUtil; import java.io.File; import java.io.FileInputStream; @@ -85,7 +85,7 @@ public abstract class AbstractFileEventTest try { in = new FileInputStream( file ); - return IOUtil.toString( in ); + return IOUtils.toString( in ); } finally { -- 2.39.5