From: Brett Porter Date: Tue, 17 Mar 2009 16:24:16 +0000 (+0000) Subject: warnings in transaction module X-Git-Tag: archiva-1.2~39 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9e46c25ca2ffab24e7fa902af987200741e20d4c;p=archiva.git warnings in transaction module git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@755305 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/AbstractTransactionEvent.java b/archiva-modules/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/AbstractTransactionEvent.java index 7f1bbcf57..602d5b479 100644 --- a/archiva-modules/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/AbstractTransactionEvent.java +++ b/archiva-modules/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/AbstractTransactionEvent.java @@ -40,28 +40,28 @@ import java.util.Map; public abstract class AbstractTransactionEvent implements TransactionEvent { - private Map backups = new HashMap(); + private Map backups = new HashMap(); - private List createdDirs = new ArrayList(); + private List createdDirs = new ArrayList(); - private List createdFiles = new ArrayList(); + private List createdFiles = new ArrayList(); /** * {@link List}<{@link Digester}> */ - private List digesters; + private List digesters; protected AbstractTransactionEvent() { - this( new ArrayList( 0 ) ); + this( new ArrayList( 0 ) ); } - protected AbstractTransactionEvent( List digesters ) + protected AbstractTransactionEvent( List digesters ) { this.digesters = digesters; } - protected List getDigesters() + protected List getDigesters() { return digesters; } @@ -75,7 +75,7 @@ public abstract class AbstractTransactionEvent protected void mkDirs( File dir ) throws IOException { - List createDirs = new ArrayList(); + List createDirs = new ArrayList(); File parent = dir; while ( !parent.exists() || !parent.isDirectory() ) @@ -127,7 +127,7 @@ public abstract class AbstractTransactionEvent protected void revertFilesCreated() throws IOException { - Iterator it = createdFiles.iterator(); + Iterator it = createdFiles.iterator(); while ( it.hasNext() ) { File file = (File) it.next(); @@ -154,11 +154,9 @@ public abstract class AbstractTransactionEvent protected void restoreBackups() throws IOException { - Iterator it = backups.entrySet().iterator(); - while ( it.hasNext() ) + for ( Map.Entry entry : backups.entrySet() ) { - Map.Entry entry = (Map.Entry) it.next(); - FileUtils.copyFile( (File) entry.getValue(), (File) entry.getKey() ); + FileUtils.copyFile( entry.getValue(), entry.getKey() ); } } @@ -182,10 +180,8 @@ public abstract class AbstractTransactionEvent protected void createChecksums( File file, boolean force ) throws IOException { - Iterator it = getDigesters().iterator(); - while ( it.hasNext() ) + for ( Digester digester : getDigesters() ) { - Digester digester = (Digester) it.next(); File checksumFile = new File( file.getAbsolutePath() + "." + getDigesterFileExtension( digester ) ); if ( checksumFile.exists() ) { diff --git a/archiva-modules/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/CopyFileEvent.java b/archiva-modules/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/CopyFileEvent.java index 585c9cc28..094743ec5 100644 --- a/archiva-modules/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/CopyFileEvent.java +++ b/archiva-modules/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/CopyFileEvent.java @@ -19,14 +19,13 @@ package org.apache.maven.archiva.transaction; * under the License. */ -import org.apache.commons.io.FileUtils; -import org.codehaus.plexus.digest.Digester; - import java.io.File; import java.io.IOException; -import java.util.Iterator; import java.util.List; +import org.apache.commons.io.FileUtils; +import org.codehaus.plexus.digest.Digester; + /** * Event to copy a file. * @@ -45,7 +44,7 @@ public class CopyFileEvent * @param destination * @param digesters {@link List}<{@link Digester}> digesters to use for checksumming */ - public CopyFileEvent( File source, File destination, List digesters ) + public CopyFileEvent( File source, File destination, List digesters ) { super( digesters ); this.source = source; @@ -75,10 +74,8 @@ public class CopyFileEvent private void copyChecksums() throws IOException { - Iterator it = getDigesters().iterator(); - while ( it.hasNext() ) + for ( Digester digester : getDigesters() ) { - Digester digester = (Digester) it.next(); copyChecksum( getDigesterFileExtension( digester ) ); } } diff --git a/archiva-modules/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/CreateFileEvent.java b/archiva-modules/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/CreateFileEvent.java index e284ab179..ea8f51014 100644 --- a/archiva-modules/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/CreateFileEvent.java +++ b/archiva-modules/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/CreateFileEvent.java @@ -23,6 +23,8 @@ import java.io.File; import java.io.IOException; import java.util.List; +import org.codehaus.plexus.digest.Digester; + /** * Event for creating a file from a string content. * @@ -41,7 +43,7 @@ public class CreateFileEvent * @param destination * @param digesters {@link List}<{@link Digester}> digesters to use for checksumming */ - public CreateFileEvent( String content, File destination, List digesters ) + public CreateFileEvent( String content, File destination, List digesters ) { super( digesters ); this.content = content; diff --git a/archiva-modules/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/FileTransaction.java b/archiva-modules/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/FileTransaction.java index d890e66d2..ca2d168ce 100644 --- a/archiva-modules/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/FileTransaction.java +++ b/archiva-modules/archiva-base/archiva-transaction/src/main/java/org/apache/maven/archiva/transaction/FileTransaction.java @@ -22,26 +22,25 @@ package org.apache.maven.archiva.transaction; import java.io.File; import java.io.IOException; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; +import org.codehaus.plexus.digest.Digester; + /** * Implement commit/rollback semantics for a set of files. * */ public class FileTransaction { - private List events = new ArrayList(); + private List events = new ArrayList(); public void commit() throws TransactionException { - List toRollback = new ArrayList( events.size() ); + List toRollback = new ArrayList( events.size() ); - for ( Iterator i = events.iterator(); i.hasNext(); ) + for ( TransactionEvent event : events ) { - TransactionEvent event = (TransactionEvent) i.next(); - try { event.commit(); @@ -66,13 +65,11 @@ public class FileTransaction } } - private void rollback( List toRollback ) + private void rollback( List toRollback ) throws IOException { - for ( Iterator i = toRollback.iterator(); i.hasNext(); ) + for ( TransactionEvent event : toRollback ) { - TransactionEvent event = (TransactionEvent) i.next(); - event.rollback(); } } @@ -82,7 +79,7 @@ public class FileTransaction * @param destination * @param digesters {@link List}<{@link org.codehaus.plexus.digest.Digester}> digesters to use for checksumming */ - public void copyFile( File source, File destination, List digesters ) + public void copyFile( File source, File destination, List digesters ) { events.add( new CopyFileEvent( source, destination, digesters ) ); } @@ -92,7 +89,7 @@ public class FileTransaction * @param destination * @param digesters {@link List}<{@link org.codehaus.plexus.digest.Digester}> digesters to use for checksumming */ - public void createFile( String content, File destination, List digesters ) + public void createFile( String content, File destination, List digesters ) { events.add( new CreateFileEvent( content, destination, digesters ) ); } diff --git a/archiva-modules/archiva-base/archiva-transaction/src/test/java/org/apache/maven/archiva/transaction/AbstractFileEventTest.java b/archiva-modules/archiva-base/archiva-transaction/src/test/java/org/apache/maven/archiva/transaction/AbstractFileEventTest.java index 9bec73209..bcaed98e4 100644 --- a/archiva-modules/archiva-base/archiva-transaction/src/test/java/org/apache/maven/archiva/transaction/AbstractFileEventTest.java +++ b/archiva-modules/archiva-base/archiva-transaction/src/test/java/org/apache/maven/archiva/transaction/AbstractFileEventTest.java @@ -35,8 +35,9 @@ import java.util.List; public abstract class AbstractFileEventTest extends PlexusInSpringTestCase { - protected List digesters; + protected List digesters; + @SuppressWarnings("unchecked") public void setUp() throws Exception {