mirror of https://github.com/apache/archiva.git
warnings in transaction module
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@755305 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
76a1d2429f
commit
9e46c25ca2
|
@ -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() )
|
||||
{
|
||||
|
|
|
@ -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 ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 ) );
|
||||
}
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue