diff options
author | Brett Porter <brett@apache.org> | 2009-03-17 16:24:16 +0000 |
---|---|---|
committer | Brett Porter <brett@apache.org> | 2009-03-17 16:24:16 +0000 |
commit | 9e46c25ca2ffab24e7fa902af987200741e20d4c (patch) | |
tree | 25c93b45437e955c349465b6ca1e0144e6ece4a6 /archiva-modules/archiva-base/archiva-transaction/src | |
parent | 76a1d2429fd6a08b93e0b3f14644dee44b24b3e5 (diff) | |
download | archiva-9e46c25ca2ffab24e7fa902af987200741e20d4c.tar.gz archiva-9e46c25ca2ffab24e7fa902af987200741e20d4c.zip |
warnings in transaction module
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@755305 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-base/archiva-transaction/src')
5 files changed, 31 insertions, 38 deletions
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<File, File> backups = new HashMap<File, File>(); - private List createdDirs = new ArrayList(); + private List<File> createdDirs = new ArrayList<File>(); - private List createdFiles = new ArrayList(); + private List<File> createdFiles = new ArrayList<File>(); /** * {@link List}<{@link Digester}> */ - private List digesters; + private List<Digester> digesters; protected AbstractTransactionEvent() { - this( new ArrayList( 0 ) ); + this( new ArrayList<Digester>( 0 ) ); } - protected AbstractTransactionEvent( List digesters ) + protected AbstractTransactionEvent( List<Digester> digesters ) { this.digesters = digesters; } - protected List getDigesters() + protected List<Digester> getDigesters() { return digesters; } @@ -75,7 +75,7 @@ public abstract class AbstractTransactionEvent protected void mkDirs( File dir ) throws IOException { - List createDirs = new ArrayList(); + List<File> createDirs = new ArrayList<File>(); 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<File> 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<File, File> 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<Digester> 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<Digester> 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<AbstractTransactionEvent> events = new ArrayList<AbstractTransactionEvent>(); public void commit() throws TransactionException { - List toRollback = new ArrayList( events.size() ); + List<TransactionEvent> toRollback = new ArrayList<TransactionEvent>( 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<TransactionEvent> 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<Digester> 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<Digester> 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<Digester> digesters; + @SuppressWarnings("unchecked") public void setUp() throws Exception { |