You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by ev...@apache.org on 2008/08/08 22:48:17 UTC
svn commit: r684085 [4/6] - in /continuum/trunk: ./
continuum-api/src/main/java/org/apache/continuum/dao/
continuum-api/src/main/java/org/apache/maven/continuum/store/
continuum-base/continuum-configuration/ continuum-commons/
continuum-commons/src/mai...
Modified: continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/executor/CleanAllPurgeExecutor.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/executor/CleanAllPurgeExecutor.java?rev=684085&r1=684084&r2=684085&view=diff
==============================================================================
--- continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/executor/CleanAllPurgeExecutor.java (original)
+++ continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/executor/CleanAllPurgeExecutor.java Fri Aug 8 13:48:14 2008
@@ -19,16 +19,16 @@
* under the License.
*/
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FilenameFilter;
-import java.io.IOException;
-
import org.apache.commons.io.filefilter.DirectoryFileFilter;
import org.apache.continuum.purge.ContinuumPurgeConstants;
import org.apache.maven.archiva.consumers.core.repository.ArtifactFilenameFilter;
import org.codehaus.plexus.util.FileUtils;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FilenameFilter;
+import java.io.IOException;
+
/**
* @author Maria Catherine Tan
*/
@@ -36,12 +36,12 @@
extends AbstractContinuumPurgeExecutor
{
private String purgeType;
-
+
public CleanAllPurgeExecutor( String purgeType )
{
this.purgeType = purgeType;
}
-
+
public void purge( String path )
throws ContinuumPurgeExecutorException
{
@@ -58,7 +58,7 @@
purgeBuildOutput( path );
}
}
-
+
private void purgeRepository( String path )
throws ContinuumPurgeExecutorException
{
@@ -68,19 +68,20 @@
}
catch ( IOException e )
{
- throw new ContinuumPurgeExecutorException( "Error while purging all artifacts or directories in " + path, e );
+ throw new ContinuumPurgeExecutorException( "Error while purging all artifacts or directories in " + path,
+ e );
}
}
-
+
private void purgeReleases( String path )
throws ContinuumPurgeExecutorException
{
File workingDir = new File( path );
-
+
FilenameFilter filter = new ArtifactFilenameFilter( "releases-" );
-
+
File[] releasesDir = workingDir.listFiles( filter );
-
+
try
{
for ( File releaseDir : releasesDir )
@@ -93,16 +94,16 @@
throw new ContinuumPurgeExecutorException( "Error while purging all releases directories", e );
}
}
-
+
private void purgeBuildOutput( String path )
throws ContinuumPurgeExecutorException
{
File buildOutputDir = new File( path );
-
+
FileFilter filter = DirectoryFileFilter.DIRECTORY;
-
+
File[] projectsDir = buildOutputDir.listFiles( filter );
-
+
try
{
for ( File projectDir : projectsDir )
Modified: continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/executor/DaysOldDirectoryPurgeExecutor.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/executor/DaysOldDirectoryPurgeExecutor.java?rev=684085&r1=684084&r2=684085&view=diff
==============================================================================
--- continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/executor/DaysOldDirectoryPurgeExecutor.java (original)
+++ continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/executor/DaysOldDirectoryPurgeExecutor.java Fri Aug 8 13:48:14 2008
@@ -19,13 +19,6 @@
* under the License.
*/
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Calendar;
-
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.comparator.LastModifiedFileComparator;
import org.apache.commons.io.filefilter.DirectoryFileFilter;
@@ -33,6 +26,13 @@
import org.apache.continuum.purge.ContinuumPurgeConstants;
import org.apache.maven.archiva.consumers.core.repository.ArtifactFilenameFilter;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Calendar;
+
/**
* @author Maria Catherine Tan
*/
@@ -41,17 +41,17 @@
implements ContinuumPurgeExecutor
{
private int daysOlder;
-
+
private int retentionCount;
-
+
private String directoryType;
-
+
public DaysOldDirectoryPurgeExecutor( int daysOlder, int retentionCount, String directoryType )
{
this.daysOlder = daysOlder;
-
+
this.retentionCount = retentionCount;
-
+
this.directoryType = directoryType;
}
@@ -67,34 +67,34 @@
purgeBuildOutputDirectory( path );
}
}
-
+
private void purgeReleaseDirectory( String path )
{
File releaseDir = new File( path );
-
+
FilenameFilter filter = new ArtifactFilenameFilter( "releases-" );
-
+
File[] releasesDir = releaseDir.listFiles( filter );
-
+
if ( retentionCount > releasesDir.length )
{
return;
}
-
+
Arrays.sort( releasesDir, LastModifiedFileComparator.LASTMODIFIED_COMPARATOR );
-
+
Calendar olderThanThisDate = Calendar.getInstance( DateUtils.UTC_TIME_ZONE );
olderThanThisDate.add( Calendar.DATE, -daysOlder );
-
+
int countToPurge = releasesDir.length - retentionCount;
-
+
for ( File dir : releasesDir )
{
if ( countToPurge <= 0 )
{
break;
}
-
+
if ( dir.lastModified() < olderThanThisDate.getTimeInMillis() )
{
try
@@ -109,50 +109,50 @@
}
}
}
-
+
private void purgeBuildOutputDirectory( String path )
{
File buildOutputDir = new File( path );
-
+
FileFilter filter = DirectoryFileFilter.DIRECTORY;
-
+
File[] projectsDir = buildOutputDir.listFiles( filter );
-
+
for ( File projectDir : projectsDir )
{
File[] buildsDir = projectDir.listFiles( filter );
-
+
if ( retentionCount > buildsDir.length )
{
continue;
}
-
+
int countToPurge = buildsDir.length - retentionCount;
-
+
Calendar olderThanThisDate = Calendar.getInstance( DateUtils.UTC_TIME_ZONE );
olderThanThisDate.add( Calendar.DATE, -daysOlder );
-
+
Arrays.sort( buildsDir, LastModifiedFileComparator.LASTMODIFIED_COMPARATOR );
-
+
for ( File buildDir : buildsDir )
{
if ( countToPurge <= 0 )
{
break;
}
-
+
if ( buildDir.lastModified() < olderThanThisDate.getTimeInMillis() )
{
try
{
FileUtils.deleteDirectory( buildDir );
- File logFile = new File ( buildDir.getAbsoluteFile() + ".log.txt" );
-
+ File logFile = new File( buildDir.getAbsoluteFile() + ".log.txt" );
+
if ( logFile.exists() )
{
- logFile.delete();
+ logFile.delete();
}
-
+
countToPurge--;
}
catch ( IOException e )
Modified: continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/executor/DaysOldRepositoryPurgeExecutor.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/executor/DaysOldRepositoryPurgeExecutor.java?rev=684085&r1=684084&r2=684085&view=diff
==============================================================================
--- continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/executor/DaysOldRepositoryPurgeExecutor.java (original)
+++ continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/executor/DaysOldRepositoryPurgeExecutor.java Fri Aug 8 13:48:14 2008
@@ -19,6 +19,15 @@
* under the License.
*/
+import org.apache.commons.lang.time.DateUtils;
+import org.apache.continuum.purge.repository.content.RepositoryManagedContent;
+import org.apache.maven.archiva.common.utils.VersionComparator;
+import org.apache.maven.archiva.common.utils.VersionUtil;
+import org.apache.maven.archiva.model.ArtifactReference;
+import org.apache.maven.archiva.model.VersionedReference;
+import org.apache.maven.archiva.repository.ContentNotFoundException;
+import org.apache.maven.archiva.repository.layout.LayoutException;
+
import java.io.File;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -30,18 +39,9 @@
import java.util.Set;
import java.util.regex.Matcher;
-import org.apache.commons.lang.time.DateUtils;
-import org.apache.continuum.purge.repository.content.RepositoryManagedContent;
-import org.apache.maven.archiva.common.utils.VersionComparator;
-import org.apache.maven.archiva.common.utils.VersionUtil;
-import org.apache.maven.archiva.model.ArtifactReference;
-import org.apache.maven.archiva.model.VersionedReference;
-import org.apache.maven.archiva.repository.ContentNotFoundException;
-import org.apache.maven.archiva.repository.layout.LayoutException;
-
/**
* Codes were taken from Archiva's DaysOldRepositoryPurge and made some few changes.
- *
+ *
* @author Maria Catherine Tan
*/
public class DaysOldRepositoryPurgeExecutor
@@ -49,13 +49,13 @@
implements ContinuumPurgeExecutor
{
private int daysOlder;
-
+
private int retentionCount;
-
+
private RepositoryManagedContent repository;
-
+
private SimpleDateFormat timestampParser;
-
+
public DaysOldRepositoryPurgeExecutor( RepositoryManagedContent repository, int daysOlder, int retentionCount )
{
this.repository = repository;
@@ -64,55 +64,55 @@
timestampParser = new SimpleDateFormat( "yyyyMMdd.HHmmss" );
timestampParser.setTimeZone( DateUtils.UTC_TIME_ZONE );
}
-
+
public void purge( String path )
throws ContinuumPurgeExecutorException
{
try
{
File artifactFile = new File( repository.getRepoRoot(), path );
-
+
if ( !artifactFile.exists() )
{
return;
}
-
+
ArtifactReference artifact = repository.toArtifactReference( path );
-
+
Calendar olderThanThisDate = Calendar.getInstance( DateUtils.UTC_TIME_ZONE );
olderThanThisDate.add( Calendar.DATE, -daysOlder );
-
+
// respect retention count
VersionedReference reference = new VersionedReference();
reference.setGroupId( artifact.getGroupId() );
reference.setArtifactId( artifact.getArtifactId() );
reference.setVersion( artifact.getVersion() );
-
+
List<String> versions = new ArrayList<String>( repository.getVersions( reference ) );
-
+
Collections.sort( versions, VersionComparator.getInstance() );
-
+
if ( retentionCount > versions.size() )
{
// Done. nothing to do here. skip it.
return;
}
-
+
int countToPurge = versions.size() - retentionCount;
-
+
for ( String version : versions )
{
if ( countToPurge <= 0 )
{
break;
}
-
+
ArtifactReference newArtifactReference =
repository.toArtifactReference( artifactFile.getAbsolutePath() );
newArtifactReference.setVersion( version );
-
+
File newArtifactFile = repository.toFile( newArtifactReference );
-
+
// Is this a generic snapshot "1.0-SNAPSHOT" ?
if ( VersionUtil.isGenericSnapshot( newArtifactReference.getVersion() ) )
{
@@ -126,7 +126,7 @@
else if ( VersionUtil.isUniqueSnapshot( newArtifactReference.getVersion() ) )
{
Calendar timestampCal = uniqueSnapshotToCalendar( newArtifactReference.getVersion() );
-
+
if ( timestampCal.getTimeInMillis() < olderThanThisDate.getTimeInMillis() )
{
doPurgeAllRelated( newArtifactReference );
@@ -149,12 +149,12 @@
throw new ContinuumPurgeExecutorException( e.getMessage(), e );
}
}
-
+
private Calendar uniqueSnapshotToCalendar( String version )
{
// The latestVersion will contain the full version string "1.0-alpha-5-20070821.213044-8"
// This needs to be broken down into ${base}-${timestamp}-${build_number}
-
+
Matcher m = VersionUtil.UNIQUE_SNAPSHOT_PATTERN.matcher( version );
if ( m.matches() )
{
@@ -163,14 +163,14 @@
{
String tsDate = mtimestamp.group( 1 );
String tsTime = mtimestamp.group( 2 );
-
+
Date versionDate;
try
{
versionDate = timestampParser.parse( tsDate + "." + tsTime );
Calendar cal = Calendar.getInstance( DateUtils.UTC_TIME_ZONE );
cal.setTime( versionDate );
-
+
return cal;
}
catch ( ParseException e )
@@ -182,7 +182,7 @@
}
return null;
}
-
+
private void doPurgeAllRelated( ArtifactReference reference )
throws LayoutException
{
Modified: continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/executor/ReleasedSnapshotsRepositoryPurgeExecutor.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/executor/ReleasedSnapshotsRepositoryPurgeExecutor.java?rev=684085&r1=684084&r2=684085&view=diff
==============================================================================
--- continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/executor/ReleasedSnapshotsRepositoryPurgeExecutor.java (original)
+++ continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/executor/ReleasedSnapshotsRepositoryPurgeExecutor.java Fri Aug 8 13:48:14 2008
@@ -19,11 +19,6 @@
* under the License.
*/
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
import org.apache.continuum.purge.repository.content.RepositoryManagedContent;
import org.apache.maven.archiva.common.utils.VersionComparator;
import org.apache.maven.archiva.common.utils.VersionUtil;
@@ -33,55 +28,60 @@
import org.apache.maven.archiva.repository.ContentNotFoundException;
import org.apache.maven.archiva.repository.layout.LayoutException;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
/**
* Codes were taken from Archiva's CleanupReleasedSnapshotsRepositoryPurge and just made some few changes
- *
+ *
* @author Maria Catherine Tan
*/
public class ReleasedSnapshotsRepositoryPurgeExecutor
extends AbstractContinuumPurgeExecutor
{
private RepositoryManagedContent repository;
-
+
public ReleasedSnapshotsRepositoryPurgeExecutor( RepositoryManagedContent repository )
{
this.repository = repository;
}
-
+
public void purge( String path )
throws ContinuumPurgeExecutorException
{
try
{
File artifactFile = new File( repository.getRepoRoot(), path );
-
+
if ( !artifactFile.exists() )
{
// Nothing to do here, file doesn't exist, skip it.
return;
}
-
+
ArtifactReference artifact = repository.toArtifactReference( path );
-
+
if ( !VersionUtil.isSnapshot( artifact.getVersion() ) )
{
// Nothing to do here, not a snapshot, skip it.
return;
}
-
+
ProjectReference reference = new ProjectReference();
reference.setGroupId( artifact.getGroupId() );
reference.setArtifactId( artifact.getArtifactId() );
-
+
// Gather up all of the versions.
List<String> allVersions = new ArrayList<String>( repository.getVersions( reference ) );
-
+
// Split the versions into released and snapshots.
List<String> releasedVersions = new ArrayList<String>();
List<String> snapshotVersions = new ArrayList<String>();
-
+
for ( String version : allVersions )
- {
+ {
if ( VersionUtil.isSnapshot( version ) )
{
snapshotVersions.add( version );
@@ -91,22 +91,22 @@
releasedVersions.add( version );
}
}
-
+
Collections.sort( allVersions, VersionComparator.getInstance() );
Collections.sort( releasedVersions, VersionComparator.getInstance() );
Collections.sort( snapshotVersions, VersionComparator.getInstance() );
-
+
VersionedReference versionRef = new VersionedReference();
versionRef.setGroupId( artifact.getGroupId() );
versionRef.setArtifactId( artifact.getArtifactId() );
-
+
for ( String version : snapshotVersions )
- {
- if( releasedVersions.contains( VersionUtil.getReleaseVersion( version ) ) )
- {
+ {
+ if ( releasedVersions.contains( VersionUtil.getReleaseVersion( version ) ) )
+ {
versionRef.setVersion( version );
repository.deleteVersion( versionRef );
-
+
removeMetadata( versionRef );
}
}
@@ -120,15 +120,15 @@
throw new ContinuumPurgeExecutorException( e.getMessage(), e );
}
}
-
+
private void removeMetadata( VersionedReference versionRef )
throws ContinuumPurgeExecutorException
{
String path = repository.toMetadataPath( versionRef );
File projectPath = new File( repository.getRepoRoot(), path );
-
+
File projectDir = projectPath.getParentFile();
-
+
purgeSupportFiles( projectDir, "maven-metadata" );
}
}
\ No newline at end of file
Modified: continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/executor/RetentionCountDirectoryPurgeExecutor.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/executor/RetentionCountDirectoryPurgeExecutor.java?rev=684085&r1=684084&r2=684085&view=diff
==============================================================================
--- continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/executor/RetentionCountDirectoryPurgeExecutor.java (original)
+++ continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/executor/RetentionCountDirectoryPurgeExecutor.java Fri Aug 8 13:48:14 2008
@@ -19,36 +19,36 @@
* under the License.
*/
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.util.Arrays;
-
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.comparator.LastModifiedFileComparator;
import org.apache.commons.io.filefilter.DirectoryFileFilter;
import org.apache.continuum.purge.ContinuumPurgeConstants;
import org.apache.maven.archiva.consumers.core.repository.ArtifactFilenameFilter;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.util.Arrays;
+
/**
* @author Maria Catherine Tan
*/
public class RetentionCountDirectoryPurgeExecutor
extends AbstractContinuumPurgeExecutor
implements ContinuumPurgeExecutor
-{
+{
private int retentionCount;
-
+
private String directoryType;
-
+
public RetentionCountDirectoryPurgeExecutor( int retentionCount, String directoryType )
{
this.retentionCount = retentionCount;
-
+
this.directoryType = directoryType;
}
-
+
public void purge( String path )
throws ContinuumPurgeExecutorException
{
@@ -59,33 +59,33 @@
else if ( directoryType.equals( ContinuumPurgeConstants.PURGE_DIRECTORY_BUILDOUTPUT ) )
{
purgeBuildOutputDirectory( path );
- }
+ }
}
-
+
private void purgeReleaseDirectory( String path )
{
File releaseDir = new File( path );
-
+
FilenameFilter filter = new ArtifactFilenameFilter( "releases-" );
-
+
File[] files = releaseDir.listFiles( filter );
-
+
if ( retentionCount > files.length )
{
return;
}
-
+
Arrays.sort( files, LastModifiedFileComparator.LASTMODIFIED_COMPARATOR );
-
+
int countToPurge = files.length - retentionCount;
-
+
for ( File file : files )
{
if ( countToPurge-- <= 0 )
{
break;
}
-
+
try
{
FileUtils.deleteDirectory( file );
@@ -97,43 +97,43 @@
}
}
}
-
+
private void purgeBuildOutputDirectory( String path )
{
File buildOutputDir = new File( path );
-
+
FileFilter filter = DirectoryFileFilter.DIRECTORY;
-
+
File[] projectsDir = buildOutputDir.listFiles( filter );
-
+
for ( File projectDir : projectsDir )
{
File[] buildsDir = projectDir.listFiles( filter );
-
+
if ( retentionCount > buildsDir.length )
{
continue;
}
-
+
Arrays.sort( buildsDir, LastModifiedFileComparator.LASTMODIFIED_COMPARATOR );
-
+
int countToPurge = buildsDir.length - retentionCount;
-
+
for ( File buildDir : buildsDir )
{
if ( countToPurge-- <= 0 )
{
break;
}
-
+
try
{
FileUtils.deleteDirectory( buildDir );
- File logFile = new File ( buildDir.getAbsoluteFile() + ".log.txt" );
-
+ File logFile = new File( buildDir.getAbsoluteFile() + ".log.txt" );
+
if ( logFile.exists() )
{
- logFile.delete();
+ logFile.delete();
}
}
catch ( IOException e )
Modified: continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/executor/RetentionCountRepositoryPurgeExecutor.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/executor/RetentionCountRepositoryPurgeExecutor.java?rev=684085&r1=684084&r2=684085&view=diff
==============================================================================
--- continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/executor/RetentionCountRepositoryPurgeExecutor.java (original)
+++ continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/executor/RetentionCountRepositoryPurgeExecutor.java Fri Aug 8 13:48:14 2008
@@ -19,12 +19,6 @@
* under the License.
*/
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
import org.apache.continuum.purge.repository.content.RepositoryManagedContent;
import org.apache.maven.archiva.common.utils.VersionComparator;
import org.apache.maven.archiva.common.utils.VersionUtil;
@@ -33,9 +27,15 @@
import org.apache.maven.archiva.repository.ContentNotFoundException;
import org.apache.maven.archiva.repository.layout.LayoutException;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
/**
* Codes were taken from Archiva's RetentionCountRepository Purge and made some few changes.
- *
+ *
* @author Maria Catherine Tan
*/
public class RetentionCountRepositoryPurgeExecutor
@@ -43,7 +43,7 @@
implements ContinuumPurgeExecutor
{
private int retentionCount;
-
+
private RepositoryManagedContent repository;
public RetentionCountRepositoryPurgeExecutor( RepositoryManagedContent repository, int retentionCount )
@@ -51,7 +51,7 @@
this.repository = repository;
this.retentionCount = retentionCount;
}
-
+
public void purge( String path )
throws ContinuumPurgeExecutorException
{
@@ -63,7 +63,7 @@
{
return;
}
-
+
ArtifactReference artifact = repository.toArtifactReference( path );
if ( VersionUtil.isSnapshot( artifact.getVersion() ) )
@@ -116,7 +116,7 @@
artifact.setVersion( version );
artifact.setClassifier( reference.getClassifier() );
artifact.setType( reference.getType() );
-
+
try
{
Set<ArtifactReference> related = repository.getRelatedArtifacts( artifact );
Modified: continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/repository/content/ManagedDefaultRepositoryContent.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/repository/content/ManagedDefaultRepositoryContent.java?rev=684085&r1=684084&r2=684085&view=diff
==============================================================================
--- continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/repository/content/ManagedDefaultRepositoryContent.java (original)
+++ continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/repository/content/ManagedDefaultRepositoryContent.java Fri Aug 8 13:48:14 2008
@@ -19,11 +19,6 @@
* under the License.
*/
-import java.io.File;
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
-
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.continuum.model.repository.LocalRepository;
@@ -33,19 +28,23 @@
import org.apache.maven.archiva.model.ArtifactReference;
import org.apache.maven.archiva.model.ProjectReference;
import org.apache.maven.archiva.model.VersionedReference;
+import org.apache.maven.archiva.repository.ContentNotFoundException;
import org.apache.maven.archiva.repository.content.ArtifactExtensionMapping;
import org.apache.maven.archiva.repository.content.DefaultPathParser;
import org.apache.maven.archiva.repository.content.PathParser;
-import org.apache.maven.archiva.repository.ContentNotFoundException;
import org.apache.maven.archiva.repository.layout.LayoutException;
+import java.io.File;
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+
/**
* Taken from Archiva's ManagedDefaultRepositoryContent and made some few changes.
- *
- * @plexus.component
- * role="org.apache.continuum.purge.repository.content.RepositoryManagedContent"
- * role-hint="default"
- * instantiation-strategy="per-lookup"
+ *
+ * @plexus.component role="org.apache.continuum.purge.repository.content.RepositoryManagedContent"
+ * role-hint="default"
+ * instantiation-strategy="per-lookup"
*/
public class ManagedDefaultRepositoryContent
implements RepositoryManagedContent
@@ -57,24 +56,24 @@
protected static final char GROUP_SEPARATOR = '.';
protected static final char ARTIFACT_SEPARATOR = '-';
-
+
private PathParser defaultPathParser = new DefaultPathParser();
/**
* @plexus.requirement role-hint="file-types"
*/
private FileTypes filetypes;
-
+
private LocalRepository repository;
-
+
public void deleteVersion( VersionedReference reference )
throws ContentNotFoundException
{
String path = toMetadataPath( reference );
File projectPath = new File( getRepoRoot(), path );
-
+
File projectDir = projectPath.getParentFile();
- if( projectDir.exists() && projectDir.isDirectory() )
+ if ( projectDir.exists() && projectDir.isDirectory() )
{
try
{
@@ -86,7 +85,7 @@
}
}
}
-
+
public int getId()
{
return repository.getId();
@@ -97,21 +96,21 @@
{
File artifactFile = toFile( reference );
File repoDir = artifactFile.getParentFile();
-
+
if ( !repoDir.exists() )
{
- throw new ContentNotFoundException( "Unable to get related artifacts using a non-existant directory: "
- + repoDir.getAbsolutePath() );
+ throw new ContentNotFoundException(
+ "Unable to get related artifacts using a non-existant directory: " + repoDir.getAbsolutePath() );
}
-
+
if ( !repoDir.isDirectory() )
{
- throw new ContentNotFoundException( "Unable to get related artifacts using a non-directory: "
- + repoDir.getAbsolutePath() );
+ throw new ContentNotFoundException(
+ "Unable to get related artifacts using a non-directory: " + repoDir.getAbsolutePath() );
}
-
+
Set<ArtifactReference> foundArtifacts = new HashSet<ArtifactReference>();
-
+
// First gather up the versions found as artifacts in the managed repository.
File repoFiles[] = repoDir.listFiles();
for ( int i = 0; i < repoFiles.length; i++ )
@@ -121,42 +120,42 @@
// Skip it. it's a directory.
continue;
}
-
+
String relativePath = PathUtil.getRelative( repository.getLocation(), repoFiles[i] );
-
+
if ( filetypes.matchesArtifactPattern( relativePath ) )
{
ArtifactReference artifact = toArtifactReference( relativePath );
-
+
// Test for related, groupId / artifactId / version must match.
- if ( artifact.getGroupId().equals( reference.getGroupId() )
- && artifact.getArtifactId().equals( reference.getArtifactId() )
- && artifact.getVersion().equals( reference.getVersion() ) )
+ if ( artifact.getGroupId().equals( reference.getGroupId() ) &&
+ artifact.getArtifactId().equals( reference.getArtifactId() ) &&
+ artifact.getVersion().equals( reference.getVersion() ) )
{
foundArtifacts.add( artifact );
}
}
}
-
+
return foundArtifacts;
}
-
+
public String getRepoRoot()
{
return repository.getLocation();
}
-
+
public LocalRepository getRepository()
{
return repository;
}
-
+
/**
* Gather the Available Versions (on disk) for a specific Project Reference, based on filesystem
* information.
*
* @return the Set of available versions, based on the project reference.
- * @throws LayoutException
+ * @throws LayoutException
* @throws LayoutException
*/
public Set<String> getVersions( ProjectReference reference )
@@ -174,14 +173,14 @@
if ( !repoDir.exists() )
{
- throw new ContentNotFoundException( "Unable to get Versions on a non-existant directory: "
- + repoDir.getAbsolutePath() );
+ throw new ContentNotFoundException(
+ "Unable to get Versions on a non-existant directory: " + repoDir.getAbsolutePath() );
}
if ( !repoDir.isDirectory() )
{
- throw new ContentNotFoundException( "Unable to get Versions on a non-directory: "
- + repoDir.getAbsolutePath() );
+ throw new ContentNotFoundException(
+ "Unable to get Versions on a non-directory: " + repoDir.getAbsolutePath() );
}
Set<String> foundVersions = new HashSet<String>();
@@ -227,14 +226,14 @@
if ( !repoDir.exists() )
{
- throw new ContentNotFoundException( "Unable to get versions on a non-existant directory: "
- + repoDir.getAbsolutePath() );
+ throw new ContentNotFoundException(
+ "Unable to get versions on a non-existant directory: " + repoDir.getAbsolutePath() );
}
if ( !repoDir.isDirectory() )
{
- throw new ContentNotFoundException( "Unable to get versions on a non-directory: "
- + repoDir.getAbsolutePath() );
+ throw new ContentNotFoundException(
+ "Unable to get versions on a non-directory: " + repoDir.getAbsolutePath() );
}
Set<String> foundVersions = new HashSet<String>();
@@ -268,22 +267,22 @@
return foundVersions;
}
-
+
public String toMetadataPath( ProjectReference reference )
{
StringBuffer path = new StringBuffer();
-
+
path.append( formatAsDirectory( reference.getGroupId() ) ).append( PATH_SEPARATOR );
path.append( reference.getArtifactId() ).append( PATH_SEPARATOR );
path.append( MAVEN_METADATA );
-
+
return path.toString();
}
-
+
public String toMetadataPath( VersionedReference reference )
{
StringBuffer path = new StringBuffer();
-
+
path.append( formatAsDirectory( reference.getGroupId() ) ).append( PATH_SEPARATOR );
path.append( reference.getArtifactId() ).append( PATH_SEPARATOR );
if ( reference.getVersion() != null )
@@ -292,17 +291,17 @@
path.append( VersionUtil.getBaseVersion( reference.getVersion() ) ).append( PATH_SEPARATOR );
}
path.append( MAVEN_METADATA );
-
+
return path.toString();
}
-
+
public String toPath( ArtifactReference reference )
{
if ( reference == null )
{
throw new IllegalArgumentException( "Artifact reference cannot be null" );
}
-
+
String baseVersion = VersionUtil.getBaseVersion( reference.getVersion() );
return toPath( reference.getGroupId(), reference.getArtifactId(), baseVersion, reference.getVersion(),
reference.getClassifier(), reference.getType() );
@@ -315,7 +314,7 @@
/**
* Convert a path to an artifact reference.
- *
+ *
* @param path the path to convert. (relative or full location path)
* @throws LayoutException if the path cannot be converted to an artifact reference.
*/
@@ -360,14 +359,14 @@
if ( !repoDir.exists() )
{
- throw new IOException( "Unable to gather the list of snapshot versions on a non-existant directory: "
- + repoDir.getAbsolutePath() );
+ throw new IOException( "Unable to gather the list of snapshot versions on a non-existant directory: " +
+ repoDir.getAbsolutePath() );
}
if ( !repoDir.isDirectory() )
{
- throw new IOException( "Unable to gather the list of snapshot versions on a non-directory: "
- + repoDir.getAbsolutePath() );
+ throw new IOException(
+ "Unable to gather the list of snapshot versions on a non-directory: " + repoDir.getAbsolutePath() );
}
File repoFiles[] = repoDir.listFiles();
@@ -405,36 +404,36 @@
return false;
}
}
-
+
private String formatAsDirectory( String directory )
{
return directory.replace( GROUP_SEPARATOR, PATH_SEPARATOR );
}
-
+
private String toPath( String groupId, String artifactId, String baseVersion, String version, String classifier,
String type )
{
StringBuffer path = new StringBuffer();
-
+
path.append( formatAsDirectory( groupId ) ).append( PATH_SEPARATOR );
path.append( artifactId ).append( PATH_SEPARATOR );
-
+
if ( baseVersion != null )
{
path.append( baseVersion ).append( PATH_SEPARATOR );
if ( ( version != null ) && ( type != null ) )
{
path.append( artifactId ).append( ARTIFACT_SEPARATOR ).append( version );
-
+
if ( StringUtils.isNotBlank( classifier ) )
{
path.append( ARTIFACT_SEPARATOR ).append( classifier );
}
-
+
path.append( GROUP_SEPARATOR ).append( ArtifactExtensionMapping.getExtension( type ) );
}
}
-
+
return path.toString();
}
}
\ No newline at end of file
Modified: continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/repository/content/ManagedLegacyRepositoryContent.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/repository/content/ManagedLegacyRepositoryContent.java?rev=684085&r1=684084&r2=684085&view=diff
==============================================================================
--- continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/repository/content/ManagedLegacyRepositoryContent.java (original)
+++ continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/repository/content/ManagedLegacyRepositoryContent.java Fri Aug 8 13:48:14 2008
@@ -26,9 +26,9 @@
import org.apache.maven.archiva.model.ArtifactReference;
import org.apache.maven.archiva.model.ProjectReference;
import org.apache.maven.archiva.model.VersionedReference;
+import org.apache.maven.archiva.repository.ContentNotFoundException;
import org.apache.maven.archiva.repository.content.ArtifactExtensionMapping;
import org.apache.maven.archiva.repository.content.PathParser;
-import org.apache.maven.archiva.repository.ContentNotFoundException;
import org.apache.maven.archiva.repository.layout.LayoutException;
import java.io.File;
@@ -39,11 +39,10 @@
/**
* Taken from Archiva's ManagedLegacyRepositoryContent and made some few changes
- *
- * @plexus.component
- * role="org.apache.continuum.purge.repository.content.RepositoryManagedContent"
- * role-hint="legacy"
- * instantiation-strategy="per-lookup"
+ *
+ * @plexus.component role="org.apache.continuum.purge.repository.content.RepositoryManagedContent"
+ * role-hint="legacy"
+ * instantiation-strategy="per-lookup"
*/
public class ManagedLegacyRepositoryContent
implements RepositoryManagedContent
@@ -67,31 +66,31 @@
* @plexus.requirement role-hint="legacy-parser"
*/
private PathParser legacyPathParser;
-
+
/**
* @plexus.requirement role-hint="file-types"
*/
private FileTypes filetypes;
-
+
private LocalRepository repository;
-
+
public void deleteVersion( VersionedReference reference )
throws ContentNotFoundException
{
File groupDir = new File( repository.getLocation(), reference.getGroupId() );
-
+
if ( !groupDir.exists() )
{
- throw new ContentNotFoundException( "Unable to get versions using a non-existant groupId directory: "
- + groupDir.getAbsolutePath() );
+ throw new ContentNotFoundException(
+ "Unable to get versions using a non-existant groupId directory: " + groupDir.getAbsolutePath() );
}
-
+
if ( !groupDir.isDirectory() )
{
- throw new ContentNotFoundException( "Unable to get versions using a non-directory: "
- + groupDir.getAbsolutePath() );
+ throw new ContentNotFoundException(
+ "Unable to get versions using a non-directory: " + groupDir.getAbsolutePath() );
}
-
+
// First gather up the versions found as artifacts in the managed repository.
File typeDirs[] = groupDir.listFiles();
for ( File typeDir : typeDirs )
@@ -101,16 +100,16 @@
// Skip it, we only care about directories.
continue;
}
-
+
if ( !typeDir.getName().endsWith( "s" ) )
{
// Skip it, we only care about directories that end in "s".
}
-
+
deleteVersions( typeDir, reference );
}
}
-
+
private void deleteVersions( File typeDir, VersionedReference reference )
{
File repoFiles[] = typeDir.listFiles();
@@ -121,16 +120,16 @@
// Skip it. it's a directory.
continue;
}
-
+
String relativePath = PathUtil.getRelative( repository.getLocation(), repoFile );
-
+
if ( filetypes.matchesArtifactPattern( relativePath ) )
{
try
{
ArtifactReference artifact = toArtifactReference( relativePath );
- if ( StringUtils.equals( artifact.getArtifactId(), reference.getArtifactId() )
- && StringUtils.equals( artifact.getVersion(), reference.getVersion() ) )
+ if ( StringUtils.equals( artifact.getArtifactId(), reference.getArtifactId() ) &&
+ StringUtils.equals( artifact.getVersion(), reference.getVersion() ) )
{
repoFile.delete();
deleteSupportFiles( repoFile );
@@ -151,7 +150,7 @@
deleteSupportFile( repoFile, ".asc" );
deleteSupportFile( repoFile, ".gpg" );
}
-
+
private void deleteSupportFile( File repoFile, String supportExtension )
{
File supportFile = new File( repoFile.getAbsolutePath() + supportExtension );
@@ -160,32 +159,32 @@
supportFile.delete();
}
}
-
+
public int getId()
{
return repository.getId();
}
-
+
public Set<ArtifactReference> getRelatedArtifacts( ArtifactReference reference )
throws ContentNotFoundException, LayoutException
{
File artifactFile = toFile( reference );
File repoDir = artifactFile.getParentFile();
-
+
if ( !repoDir.exists() )
{
- throw new ContentNotFoundException( "Unable to get related artifacts using a non-existant directory: "
- + repoDir.getAbsolutePath() );
+ throw new ContentNotFoundException(
+ "Unable to get related artifacts using a non-existant directory: " + repoDir.getAbsolutePath() );
}
-
+
if ( !repoDir.isDirectory() )
{
- throw new ContentNotFoundException( "Unable to get related artifacts using a non-directory: "
- + repoDir.getAbsolutePath() );
+ throw new ContentNotFoundException(
+ "Unable to get related artifacts using a non-directory: " + repoDir.getAbsolutePath() );
}
-
+
Set<ArtifactReference> foundArtifacts = new HashSet<ArtifactReference>();
-
+
// First gather up the versions found as artifacts in the managed repository.
File projectParentDir = repoDir.getParentFile();
File typeDirs[] = projectParentDir.listFiles();
@@ -196,47 +195,47 @@
// Skip it, we only care about directories.
continue;
}
-
+
if ( !typeDir.getName().endsWith( "s" ) )
{
// Skip it, we only care about directories that end in "s".
}
-
+
getRelatedArtifacts( typeDir, reference, foundArtifacts );
}
-
+
return foundArtifacts;
}
-
+
public String getRepoRoot()
{
return repository.getLocation();
}
-
+
public LocalRepository getRepository()
{
return repository;
}
-
+
public Set<String> getVersions( ProjectReference reference )
throws ContentNotFoundException
{
File groupDir = new File( repository.getLocation(), reference.getGroupId() );
-
+
if ( !groupDir.exists() )
{
- throw new ContentNotFoundException( "Unable to get versions using a non-existant groupId directory: "
- + groupDir.getAbsolutePath() );
+ throw new ContentNotFoundException(
+ "Unable to get versions using a non-existant groupId directory: " + groupDir.getAbsolutePath() );
}
-
+
if ( !groupDir.isDirectory() )
{
- throw new ContentNotFoundException( "Unable to get versions using a non-directory: "
- + groupDir.getAbsolutePath() );
+ throw new ContentNotFoundException(
+ "Unable to get versions using a non-directory: " + groupDir.getAbsolutePath() );
}
-
+
Set<String> foundVersions = new HashSet<String>();
-
+
// First gather up the versions found as artifacts in the managed repository.
File typeDirs[] = groupDir.listFiles();
for ( File typeDir : typeDirs )
@@ -246,37 +245,37 @@
// Skip it, we only care about directories.
continue;
}
-
+
if ( !typeDir.getName().endsWith( "s" ) )
{
// Skip it, we only care about directories that end in "s".
}
-
+
getProjectVersions( typeDir, reference, foundVersions );
}
-
+
return foundVersions;
}
-
+
public Set<String> getVersions( VersionedReference reference )
throws ContentNotFoundException
{
File groupDir = new File( repository.getLocation(), reference.getGroupId() );
-
+
if ( !groupDir.exists() )
{
- throw new ContentNotFoundException( "Unable to get versions using a non-existant groupId directory: "
- + groupDir.getAbsolutePath() );
+ throw new ContentNotFoundException(
+ "Unable to get versions using a non-existant groupId directory: " + groupDir.getAbsolutePath() );
}
-
+
if ( !groupDir.isDirectory() )
{
- throw new ContentNotFoundException( "Unable to get versions using a non-directory: "
- + groupDir.getAbsolutePath() );
+ throw new ContentNotFoundException(
+ "Unable to get versions using a non-directory: " + groupDir.getAbsolutePath() );
}
-
+
Set<String> foundVersions = new HashSet<String>();
-
+
// First gather up the versions found as artifacts in the managed repository.
File typeDirs[] = groupDir.listFiles();
for ( File typeDir : typeDirs )
@@ -286,21 +285,21 @@
// Skip it, we only care about directories.
continue;
}
-
+
if ( !typeDir.getName().endsWith( "s" ) )
{
// Skip it, we only care about directories that end in "s".
}
-
+
getVersionedVersions( typeDir, reference, foundVersions );
}
-
+
return foundVersions;
}
/**
* Convert a path to an artifact reference.
- *
+ *
* @param path the path to convert. (relative or full location path)
* @throws LayoutException if the path cannot be converted to an artifact reference.
*/
@@ -311,27 +310,27 @@
{
return legacyPathParser.toArtifactReference( path.substring( repository.getLocation().length() ) );
}
-
+
return legacyPathParser.toArtifactReference( path );
}
-
+
public File toFile( ArtifactReference reference )
{
return new File( repository.getLocation(), toPath( reference ) );
}
-
+
public String toMetadataPath( ProjectReference reference )
{
// No metadata present in legacy repository.
return null;
}
-
+
public String toMetadataPath( VersionedReference reference )
{
// No metadata present in legacy repository.
return null;
}
-
+
public String toPath( ArtifactReference reference )
{
if ( reference == null )
@@ -342,12 +341,12 @@
return toPath( reference.getGroupId(), reference.getArtifactId(), reference.getVersion(), reference
.getClassifier(), reference.getType() );
}
-
+
public void setRepository( LocalRepository repo )
{
this.repository = repo;
}
-
+
private void getProjectVersions( File typeDir, ProjectReference reference, Set<String> foundVersions )
{
File repoFiles[] = typeDir.listFiles();
@@ -358,9 +357,9 @@
// Skip it. it's a directory.
continue;
}
-
+
String relativePath = PathUtil.getRelative( repository.getLocation(), repoFile );
-
+
if ( filetypes.matchesArtifactPattern( relativePath ) )
{
try
@@ -378,7 +377,7 @@
}
}
}
-
+
private void getRelatedArtifacts( File typeDir, ArtifactReference reference, Set<ArtifactReference> foundArtifacts )
{
File repoFiles[] = typeDir.listFiles();
@@ -389,16 +388,16 @@
// Skip it. it's a directory.
continue;
}
-
+
String relativePath = PathUtil.getRelative( repository.getLocation(), repoFiles[i] );
-
+
if ( filetypes.matchesArtifactPattern( relativePath ) )
{
try
{
ArtifactReference artifact = toArtifactReference( relativePath );
- if ( StringUtils.equals( artifact.getArtifactId(), reference.getArtifactId() )
- && artifact.getVersion().startsWith( reference.getVersion() ) )
+ if ( StringUtils.equals( artifact.getArtifactId(), reference.getArtifactId() ) &&
+ artifact.getVersion().startsWith( reference.getVersion() ) )
{
foundArtifacts.add( artifact );
}
@@ -410,7 +409,7 @@
}
}
}
-
+
private void getVersionedVersions( File typeDir, VersionedReference reference, Set<String> foundVersions )
{
File repoFiles[] = typeDir.listFiles();
@@ -421,16 +420,16 @@
// Skip it. it's a directory.
continue;
}
-
+
String relativePath = PathUtil.getRelative( repository.getLocation(), repoFiles[i] );
-
+
if ( filetypes.matchesArtifactPattern( relativePath ) )
{
try
{
ArtifactReference artifact = toArtifactReference( relativePath );
- if ( StringUtils.equals( artifact.getArtifactId(), reference.getArtifactId() )
- && artifact.getVersion().startsWith( reference.getVersion() ) )
+ if ( StringUtils.equals( artifact.getArtifactId(), reference.getArtifactId() ) &&
+ artifact.getVersion().startsWith( reference.getVersion() ) )
{
foundVersions.add( artifact.getVersion() );
}
Modified: continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/repository/scanner/DefaultRepositoryScanner.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/repository/scanner/DefaultRepositoryScanner.java?rev=684085&r1=684084&r2=684085&view=diff
==============================================================================
--- continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/repository/scanner/DefaultRepositoryScanner.java (original)
+++ continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/repository/scanner/DefaultRepositoryScanner.java Fri Aug 8 13:48:14 2008
@@ -19,21 +19,20 @@
* under the License.
*/
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
import org.apache.commons.collections.CollectionUtils;
import org.apache.continuum.model.repository.LocalRepository;
import org.apache.continuum.purge.controller.PurgeController;
import org.apache.continuum.purge.executor.ContinuumPurgeExecutorException;
-import org.apache.continuum.purge.repository.scanner.RepositoryScannerInstance;
import org.apache.continuum.purge.repository.utils.FileTypes;
import org.codehaus.plexus.util.DirectoryWalker;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* Codes were taken from Archiva and made some changes.
- *
+ *
* @plexus.component role="org.apache.continuum.purge.repository.scanner.RepositoryScanner" role-hint="repository-scanner"
*/
public class DefaultRepositoryScanner
@@ -43,32 +42,31 @@
* @plexus.requirement role-hint="file-types"
*/
private FileTypes filetypes;
-
+
public void scan( LocalRepository repository, PurgeController purgeController )
throws ContinuumPurgeExecutorException
{
List<String> ignoredPatterns = filetypes.getIgnoredFileTypePatterns();
scan( repository, purgeController, ignoredPatterns );
}
-
- public void scan( LocalRepository repository, PurgeController purgeController,
- List<String> ignoredContentPatterns )
+
+ public void scan( LocalRepository repository, PurgeController purgeController, List<String> ignoredContentPatterns )
throws ContinuumPurgeExecutorException
{
- File repositoryBase = new File ( repository.getLocation() );
-
+ File repositoryBase = new File( repository.getLocation() );
+
if ( !repositoryBase.exists() )
{
- throw new UnsupportedOperationException( "Unable to scan a repository, directory "
- + repositoryBase.getAbsolutePath() + " does not exist." );
+ throw new UnsupportedOperationException(
+ "Unable to scan a repository, directory " + repositoryBase.getAbsolutePath() + " does not exist." );
}
if ( !repositoryBase.isDirectory() )
{
- throw new UnsupportedOperationException( "Unable to scan a repository, path "
- + repositoryBase.getAbsolutePath() + " is not a directory." );
+ throw new UnsupportedOperationException(
+ "Unable to scan a repository, path " + repositoryBase.getAbsolutePath() + " is not a directory." );
}
-
+
// Setup Includes / Excludes.
List<String> allExcludes = new ArrayList<String>();
@@ -91,7 +89,7 @@
dirWalker.setExcludes( allExcludes );
RepositoryScannerInstance scannerInstance = new RepositoryScannerInstance( repository, purgeController );
-
+
dirWalker.addDirectoryWalkListener( scannerInstance );
// Execute scan.
Modified: continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/repository/scanner/RepositoryScannerInstance.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/repository/scanner/RepositoryScannerInstance.java?rev=684085&r1=684084&r2=684085&view=diff
==============================================================================
--- continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/repository/scanner/RepositoryScannerInstance.java (original)
+++ continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/repository/scanner/RepositoryScannerInstance.java Fri Aug 8 13:48:14 2008
@@ -19,8 +19,6 @@
* under the License.
*/
-import java.io.File;
-
import org.apache.continuum.model.repository.LocalRepository;
import org.apache.continuum.purge.controller.PurgeController;
import org.apache.maven.archiva.common.utils.BaseFile;
@@ -28,6 +26,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.File;
+
/**
* Codes were taken from Archiva and made some few changes
*/
@@ -35,17 +35,17 @@
implements DirectoryWalkListener
{
private Logger log = LoggerFactory.getLogger( RepositoryScannerInstance.class );
-
+
private LocalRepository repository;
-
+
private PurgeController purgeController;
-
+
public RepositoryScannerInstance( LocalRepository repository, PurgeController purgeController )
{
this.repository = repository;
this.purgeController = purgeController;
}
-
+
public void debug( String message )
{
log.debug( "Repository Scanner: " + message );
Modified: continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/repository/utils/FileTypes.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/repository/utils/FileTypes.java?rev=684085&r1=684084&r2=684085&view=diff
==============================================================================
--- continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/repository/utils/FileTypes.java (original)
+++ continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/repository/utils/FileTypes.java Fri Aug 8 13:48:14 2008
@@ -19,39 +19,39 @@
* under the License.
*/
+import org.codehaus.plexus.util.SelectorUtils;
+
import java.util.Arrays;
import java.util.List;
-import org.codehaus.plexus.util.SelectorUtils;
-
/**
* Codes were taken from Archiva and made some changes.
*/
public class FileTypes
{
private List<String> artifactFileTypePatterns;
-
+
private List<String> ignoredFileTypePatterns;
-
+
public static final List<String> DEFAULT_EXCLUSIONS = Arrays.asList( "**/maven-metadata.xml",
- "**/maven-metadata-*.xml", "**/*.sha1",
- "**/*.asc", "**/*.md5", "**/*.pgp" );
-
+ "**/maven-metadata-*.xml", "**/*.sha1",
+ "**/*.asc", "**/*.md5", "**/*.pgp" );
+
public List<String> getIgnoredFileTypePatterns()
{
if ( ignoredFileTypePatterns == null )
{
ignoredFileTypePatterns = DEFAULT_EXCLUSIONS;
}
-
+
return ignoredFileTypePatterns;
}
-
+
public List<String> getArtifactFileTypePatterns()
{
return artifactFileTypePatterns;
}
-
+
public synchronized boolean matchesArtifactPattern( String relativePath )
{
// Correct the slash pattern.
@@ -62,7 +62,7 @@
return false;
}
- for ( String pattern : (List<String>)artifactFileTypePatterns )
+ for ( String pattern : (List<String>) artifactFileTypePatterns )
{
if ( SelectorUtils.matchPath( pattern, relativePath, false ) )
{
@@ -91,5 +91,5 @@
// No match.
return false;
- }
+ }
}
Modified: continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/repository/utils/FilenameParser.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/repository/utils/FilenameParser.java?rev=684085&r1=684084&r2=684085&view=diff
==============================================================================
--- continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/repository/utils/FilenameParser.java (original)
+++ continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/repository/utils/FilenameParser.java Fri Aug 8 13:48:14 2008
@@ -19,22 +19,22 @@
* under the License.
*/
+import org.apache.maven.archiva.common.utils.VersionUtil;
+
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.maven.archiva.common.utils.VersionUtil;
-
/**
* Codes were taken from Archiva's FilenameParser
*/
public class FilenameParser
{
private String name;
-
+
private String extension;
-
+
private int offset;
-
+
private static final Pattern mavenPluginPattern = Pattern.compile( "(maven-.*-plugin)|(.*-maven-plugin)" );
private static final Pattern extensionPattern =
@@ -47,7 +47,7 @@
public FilenameParser( String filename )
{
this.name = filename;
-
+
Matcher mat = extensionPattern.matcher( name );
if ( mat.find() )
{
@@ -59,12 +59,12 @@
reset();
}
-
+
public void reset()
{
offset = 0;
}
-
+
public String next()
{
// Past the end of the string.
@@ -84,7 +84,7 @@
// Nothing to return.
return null;
}
-
+
protected String remaining()
{
if ( offset >= name.length() )
@@ -136,7 +136,7 @@
return ver.toString();
}
-
+
public String getExtension()
{
return extension;
Modified: continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/repository/utils/LegacyPathParser.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/repository/utils/LegacyPathParser.java?rev=684085&r1=684084&r2=684085&view=diff
==============================================================================
--- continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/repository/utils/LegacyPathParser.java (original)
+++ continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/repository/utils/LegacyPathParser.java Fri Aug 8 13:48:14 2008
@@ -28,19 +28,19 @@
/**
* Codes were taken from Archiva's LegacyPathParser and made some few changes.
- *
+ *
* @plexus.component role="org.apache.maven.archiva.repository.content.PathParser" role-hint="legacy-parser"
*/
public class LegacyPathParser
implements PathParser
{
private static final String INVALID_ARTIFACT_PATH = "Invalid path to Artifact: ";
-
+
public ArtifactReference toArtifactReference( String path )
throws LayoutException
{
ArtifactReference artifact = new ArtifactReference();
-
+
String normalizedPath = StringUtils.replace( path, "\\", "/" );
String pathParts[] = StringUtils.split( normalizedPath, '/' );
@@ -56,12 +56,11 @@
if ( pathParts.length != 3 )
{
// Illegal Path Parts Length.
- throw new LayoutException( INVALID_ARTIFACT_PATH
- + "legacy paths should only have 3 parts [groupId]/[type]s/[artifactId]-[version].[type], found "
- + pathParts.length + " instead." );
+ throw new LayoutException( INVALID_ARTIFACT_PATH +
+ "legacy paths should only have 3 parts [groupId]/[type]s/[artifactId]-[version].[type], found " +
+ pathParts.length + " instead." );
}
-
// The Group ID.
artifact.setGroupId( pathParts[0] );
@@ -71,8 +70,8 @@
// Sanity Check: expectedType should end in "s".
if ( !expectedType.endsWith( "s" ) )
{
- throw new LayoutException( INVALID_ARTIFACT_PATH
- + "legacy paths should have an expected type ending in [s] in the second part of the path." );
+ throw new LayoutException( INVALID_ARTIFACT_PATH +
+ "legacy paths should have an expected type ending in [s] in the second part of the path." );
}
// The Filename.
@@ -135,9 +134,10 @@
if ( classifier != null )
{
String version = artifact.getVersion();
- if ( ! version.endsWith( "-" + classifier ) )
+ if ( !version.endsWith( "-" + classifier ) )
{
- throw new LayoutException( INVALID_ARTIFACT_PATH + expectedType + " artifacts must use the classifier " + classifier );
+ throw new LayoutException(
+ INVALID_ARTIFACT_PATH + expectedType + " artifacts must use the classifier " + classifier );
}
version = version.substring( 0, version.length() - classifier.length() - 1 );
artifact.setVersion( version );
@@ -169,9 +169,9 @@
if ( !expectedExtension.equals( extension ) )
{
- throw new LayoutException( INVALID_ARTIFACT_PATH + "mismatch on extension [" + extension
- + "] and layout specified type [" + artifact.getType() + "] (which maps to extension: ["
- + expectedExtension + "]) on path [" + path + "]" );
+ throw new LayoutException( INVALID_ARTIFACT_PATH + "mismatch on extension [" + extension +
+ "] and layout specified type [" + artifact.getType() + "] (which maps to extension: [" +
+ expectedExtension + "]) on path [" + path + "]" );
}
}
Modified: continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/task/PurgeTask.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/task/PurgeTask.java?rev=684085&r1=684084&r2=684085&view=diff
==============================================================================
--- continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/task/PurgeTask.java (original)
+++ continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/task/PurgeTask.java Fri Aug 8 13:48:14 2008
@@ -28,38 +28,38 @@
implements Task
{
private int purgeConfigurationId;
-
+
private long timestamp;
-
+
private long maxExecutionTime;
public PurgeTask( int purgeConfigurationId )
{
this.purgeConfigurationId = purgeConfigurationId;
-
+
this.timestamp = System.currentTimeMillis();
}
-
+
public int getPurgeConfigurationId()
{
return purgeConfigurationId;
}
-
+
public void setPurgeConfigurationId( int purgeConfigurationId )
{
this.purgeConfigurationId = purgeConfigurationId;
}
-
+
public void setMaxExecutionTime( long maxExecutionTime )
{
this.maxExecutionTime = maxExecutionTime;
}
-
+
public long getMaxExecutionTime()
{
return maxExecutionTime;
}
-
+
public long getTimestamp()
{
return timestamp;
Modified: continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/task/PurgeTaskExecutor.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/task/PurgeTaskExecutor.java?rev=684085&r1=684084&r2=684085&view=diff
==============================================================================
--- continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/task/PurgeTaskExecutor.java (original)
+++ continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/task/PurgeTaskExecutor.java Fri Aug 8 13:48:14 2008
@@ -49,38 +49,40 @@
* @plexus.requirement
*/
private PurgeConfigurationService purgeConfigurationService;
-
+
/**
* @plexus.requirement
*/
private RepositoryScanner scanner;
-
+
private PlexusContainer container;
-
+
public void executeTask( Task task )
throws TaskExecutionException
{
PurgeTask purgeTask = (PurgeTask) task;
-
- AbstractPurgeConfiguration purgeConfig = purgeConfigurationService.getPurgeConfiguration( purgeTask.getPurgeConfigurationId() );
-
+
+ AbstractPurgeConfiguration purgeConfig =
+ purgeConfigurationService.getPurgeConfiguration( purgeTask.getPurgeConfigurationId() );
+
try
{
if ( purgeConfig != null && purgeConfig instanceof RepositoryPurgeConfiguration )
{
RepositoryPurgeConfiguration repoPurge = (RepositoryPurgeConfiguration) purgeConfig;
-
+
LocalRepository repository = repoPurge.getRepository();
-
+
if ( repository == null )
{
- throw new TaskExecutionException( "Error while executing purge repository task: no repository set" );
+ throw new TaskExecutionException(
+ "Error while executing purge repository task: no repository set" );
}
-
+
purgeController = (PurgeController) container.lookup( PurgeController.ROLE, "purge-repository" );
-
+
purgeController.initializeExecutors( repoPurge );
-
+
if ( repoPurge.isDeleteAll() )
{
purgeController.doPurge( repository.getLocation() );
@@ -93,14 +95,14 @@
else if ( purgeConfig != null && purgeConfig instanceof DirectoryPurgeConfiguration )
{
DirectoryPurgeConfiguration dirPurge = (DirectoryPurgeConfiguration) purgeConfig;
-
+
purgeController = (PurgeController) container.lookup( PurgeController.ROLE, "purge-directory" );
-
+
purgeController.initializeExecutors( dirPurge );
-
- purgeController.doPurge( dirPurge.getLocation() );
+
+ purgeController.doPurge( dirPurge.getLocation() );
}
-
+
}
catch ( ComponentLookupException e )
{
Modified: continuum/trunk/continuum-purge/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-purge/src/main/resources/META-INF/plexus/components.xml?rev=684085&r1=684084&r2=684085&view=diff
==============================================================================
--- continuum/trunk/continuum-purge/src/main/resources/META-INF/plexus/components.xml (original)
+++ continuum/trunk/continuum-purge/src/main/resources/META-INF/plexus/components.xml Fri Aug 8 13:48:14 2008
@@ -19,13 +19,13 @@
<component-set>
<components>
-
+
<!--
- |
- | Purge Task Queue
- |
- |-->
-
+ |
+ | Purge Task Queue
+ |
+ |-->
+
<component>
<role>org.codehaus.plexus.taskqueue.TaskQueue</role>
<role-hint>purge</role-hint>
@@ -40,7 +40,7 @@
</task-viability-evaluators>
</configuration>
</component>
-
+
<component>
<role>org.codehaus.plexus.taskqueue.execution.TaskExecutor</role>
<role-hint>purge</role-hint>
@@ -56,7 +56,7 @@
</requirement>
</requirements>
</component>
-
+
<component>
<role>org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor</role>
<role-hint>purge</role-hint>
@@ -76,7 +76,7 @@
<name>purge</name>
</configuration>
</component>
-
+
<component>
<role>org.apache.continuum.purge.repository.utils.FileTypes</role>
<role-hint>file-types</role-hint>
Modified: continuum/trunk/continuum-purge/src/test/java/org/apache/continuum/purge/AbstractPurgeTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-purge/src/test/java/org/apache/continuum/purge/AbstractPurgeTest.java?rev=684085&r1=684084&r2=684085&view=diff
==============================================================================
--- continuum/trunk/continuum-purge/src/test/java/org/apache/continuum/purge/AbstractPurgeTest.java (original)
+++ continuum/trunk/continuum-purge/src/test/java/org/apache/continuum/purge/AbstractPurgeTest.java Fri Aug 8 13:48:14 2008
@@ -19,239 +19,243 @@
* under the License.
*/
-import java.io.File;
-import java.net.URL;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.jdo.PersistenceManager;
-import javax.jdo.PersistenceManagerFactory;
-
+import org.apache.continuum.dao.DirectoryPurgeConfigurationDao;
+import org.apache.continuum.dao.LocalRepositoryDao;
+import org.apache.continuum.dao.RepositoryPurgeConfigurationDao;
import org.apache.continuum.model.repository.DirectoryPurgeConfiguration;
import org.apache.continuum.model.repository.LocalRepository;
import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
import org.apache.maven.continuum.jdo.MemoryJdoFactory;
-import org.apache.maven.continuum.store.ContinuumStore;
import org.codehaus.plexus.jdo.JdoFactory;
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
import org.jpox.SchemaTool;
+import javax.jdo.PersistenceManager;
+import javax.jdo.PersistenceManagerFactory;
+import java.io.File;
+import java.net.URL;
+import java.util.Map;
+import java.util.Properties;
+
/**
* @author Maria Catherine Tan
*/
public abstract class AbstractPurgeTest
extends PlexusInSpringTestCase
-{
+{
private static final String TEST_DEFAULT_REPO_DIR = "target/default-repository";
-
+
private static final String TEST_DEFAULT_REPO_NAME = "defaultRepo";
-
+
private static final String TEST_DEFAULT_RELEASES_DIR = "target/working-directory";
-
+
private static final String TEST_DEFAULT_BUILDOUTPUT_DIR = "target/build-output-directory";
-
+
protected static final int TEST_DAYS_OLDER = 30;
-
+
protected static final int TEST_RETENTION_COUNT = 2;
-
+
protected static final String TEST_RELEASES_DIRECTORY_TYPE = "releases";
-
+
protected static final String TEST_BUILDOUTPUT_DIRECTORY_TYPE = "buildOutput";
-
- private ContinuumStore store;
-
+
+ protected LocalRepositoryDao localRepositoryDao;
+
+ protected DirectoryPurgeConfigurationDao directoryPurgeConfigurationDao;
+
+ protected RepositoryPurgeConfigurationDao repositoryPurgeConfigurationDao;
+
protected RepositoryPurgeConfiguration defaultRepoPurge;
-
+
protected DirectoryPurgeConfiguration defaultReleasesDirPurge;
-
+
protected DirectoryPurgeConfiguration defaultBuildOutputDirPurge;
-
+
protected LocalRepository defaultRepository;
-
+
+ @Override
protected void setUp()
throws Exception
{
super.setUp();
-
- getStore();
+
+ init();
+
+ localRepositoryDao = (LocalRepositoryDao) lookup( LocalRepositoryDao.class.getName() );
+
+ repositoryPurgeConfigurationDao = (RepositoryPurgeConfigurationDao) lookup( RepositoryPurgeConfigurationDao.class );
+
+ directoryPurgeConfigurationDao = (DirectoryPurgeConfigurationDao) lookup( DirectoryPurgeConfigurationDao.class );
- if ( store.getAllLocalRepositories().size() == 0 )
+ if ( localRepositoryDao.getAllLocalRepositories().size() == 0 )
{
createDefaultRepository();
- assertEquals( "check # repository", 1, store.getAllLocalRepositories().size() );
+ assertEquals( "check # repository", 1, localRepositoryDao.getAllLocalRepositories().size() );
createDefaultRepoPurgeConfiguration();
}
else
{
- assertEquals( "check # repository", 1, store.getAllLocalRepositories().size() );
- defaultRepository = store.getLocalRepositoryByName( TEST_DEFAULT_REPO_NAME );
- defaultRepoPurge = store.getRepositoryPurgeConfigurationsByLocalRepository( defaultRepository.getId() ).get( 0 );
+ assertEquals( "check # repository", 1, localRepositoryDao.getAllLocalRepositories().size() );
+ defaultRepository = localRepositoryDao.getLocalRepositoryByName( TEST_DEFAULT_REPO_NAME );
+ defaultRepoPurge = repositoryPurgeConfigurationDao.getRepositoryPurgeConfigurationsByLocalRepository(
+ defaultRepository.getId() ).get( 0 );
}
-
- if ( store.getDirectoryPurgeConfigurationsByType( TEST_RELEASES_DIRECTORY_TYPE ).size() == 0 )
+
+ if ( directoryPurgeConfigurationDao.getDirectoryPurgeConfigurationsByType(
+ TEST_RELEASES_DIRECTORY_TYPE ).size() == 0 )
{
createDefaultReleasesDirPurgeConfiguration();
}
else
{
- defaultReleasesDirPurge = store.getDirectoryPurgeConfigurationsByType( TEST_RELEASES_DIRECTORY_TYPE ).get( 0 );
+ defaultReleasesDirPurge = directoryPurgeConfigurationDao.getDirectoryPurgeConfigurationsByType(
+ TEST_RELEASES_DIRECTORY_TYPE ).get( 0 );
}
-
- if ( store.getDirectoryPurgeConfigurationsByType( TEST_BUILDOUTPUT_DIRECTORY_TYPE ).size() == 0 )
+
+ if ( directoryPurgeConfigurationDao.getDirectoryPurgeConfigurationsByType(
+ TEST_BUILDOUTPUT_DIRECTORY_TYPE ).size() == 0 )
{
createDefaultBuildOutputDirPurgeConfiguration();
}
else
{
- defaultBuildOutputDirPurge = store.getDirectoryPurgeConfigurationsByType( TEST_BUILDOUTPUT_DIRECTORY_TYPE ).get( 0 );
+ defaultBuildOutputDirPurge = directoryPurgeConfigurationDao.getDirectoryPurgeConfigurationsByType(
+ TEST_BUILDOUTPUT_DIRECTORY_TYPE ).get( 0 );
}
}
-
- protected ContinuumStore getStore()
+
+ protected void init()
throws Exception
{
- if ( store != null )
- {
- return store;
- }
-
// ----------------------------------------------------------------------
// Set up the JDO factory
// ----------------------------------------------------------------------
-
+
Object o = lookup( JdoFactory.ROLE, "continuum" );
-
+
assertEquals( MemoryJdoFactory.class.getName(), o.getClass().getName() );
-
+
MemoryJdoFactory jdoFactory = (MemoryJdoFactory) o;
-
+
String url = "jdbc:hsqldb:mem:" + getClass().getName() + "." + getName();
-
+
jdoFactory.setUrl( url );
-
+
jdoFactory.reconfigure();
-
+
// ----------------------------------------------------------------------
// Check the configuration
// ----------------------------------------------------------------------
-
+
PersistenceManagerFactory pmf = jdoFactory.getPersistenceManagerFactory();
-
+
assertNotNull( pmf );
-
+
assertEquals( url, pmf.getConnectionURL() );
-
+
PersistenceManager pm = pmf.getPersistenceManager();
-
+
pm.close();
-
+
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
-
+
Properties properties = jdoFactory.getProperties();
-
+
for ( Map.Entry entry : properties.entrySet() )
{
System.setProperty( (String) entry.getKey(), (String) entry.getValue() );
}
-
+
SchemaTool.createSchemaTables( new URL[]{getClass().getResource( "/META-INF/package.jdo" )}, new URL[]{}, null,
false, null );
-
- // ----------------------------------------------------------------------
- //
- // ----------------------------------------------------------------------
-
- store = (ContinuumStore) lookup( ContinuumStore.ROLE, "jdo" );
-
- return store;
}
-
+
protected File getDefaultRepositoryLocation()
throws Exception
{
File repositoryLocation = getTestFile( TEST_DEFAULT_REPO_DIR );
-
+
if ( !repositoryLocation.exists() )
{
repositoryLocation.mkdirs();
}
-
+
return repositoryLocation;
}
-
+
protected File getReleasesDirectoryLocation()
{
File releasesDirectory = getTestFile( TEST_DEFAULT_RELEASES_DIR );
-
+
if ( !releasesDirectory.exists() )
{
releasesDirectory.mkdir();
}
-
+
return releasesDirectory;
}
-
+
protected File getBuildOutputDirectoryLocation()
{
File buildOutputDir = getTestFile( TEST_DEFAULT_BUILDOUTPUT_DIR );
-
+
if ( !buildOutputDir.exists() )
{
buildOutputDir.mkdir();
}
-
+
return buildOutputDir;
}
private void createDefaultRepository()
throws Exception
{
- defaultRepository = store.getLocalRepositoryByName( TEST_DEFAULT_REPO_NAME );
-
+ defaultRepository = localRepositoryDao.getLocalRepositoryByName( TEST_DEFAULT_REPO_NAME );
+
if ( defaultRepository == null )
{
LocalRepository repository = new LocalRepository();
-
+
repository.setName( TEST_DEFAULT_REPO_NAME );
repository.setLocation( getDefaultRepositoryLocation().getAbsolutePath() );
- defaultRepository = store.addLocalRepository( repository );
+ defaultRepository = localRepositoryDao.addLocalRepository( repository );
}
}
-
+
private void createDefaultRepoPurgeConfiguration()
throws Exception
{
RepositoryPurgeConfiguration repoPurge = new RepositoryPurgeConfiguration();
-
+
repoPurge.setRepository( defaultRepository );
repoPurge.setDeleteAll( true );
-
- defaultRepoPurge = store.addRepositoryPurgeConfiguration( repoPurge );
+
+ defaultRepoPurge = repositoryPurgeConfigurationDao.addRepositoryPurgeConfiguration( repoPurge );
}
-
+
private void createDefaultReleasesDirPurgeConfiguration()
throws Exception
{
DirectoryPurgeConfiguration dirPurge = new DirectoryPurgeConfiguration();
-
+
dirPurge.setLocation( getReleasesDirectoryLocation().getAbsolutePath() );
dirPurge.setDirectoryType( "releases" );
dirPurge.setDeleteAll( true );
-
- defaultReleasesDirPurge = store.addDirectoryPurgeConfiguration( dirPurge );
+
+ defaultReleasesDirPurge = directoryPurgeConfigurationDao.addDirectoryPurgeConfiguration( dirPurge );
}
-
+
private void createDefaultBuildOutputDirPurgeConfiguration()
throws Exception
{
DirectoryPurgeConfiguration dirPurge = new DirectoryPurgeConfiguration();
-
+
dirPurge.setLocation( getBuildOutputDirectoryLocation().getAbsolutePath() );
dirPurge.setDirectoryType( "buildOutput" );
dirPurge.setDeleteAll( true );
-
- defaultBuildOutputDirPurge = store.addDirectoryPurgeConfiguration( dirPurge );
+
+ defaultBuildOutputDirPurge = directoryPurgeConfigurationDao.addDirectoryPurgeConfiguration( dirPurge );
}
}
Modified: continuum/trunk/continuum-purge/src/test/java/org/apache/continuum/purge/DefaultPurgeConfigurationServiceTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-purge/src/test/java/org/apache/continuum/purge/DefaultPurgeConfigurationServiceTest.java?rev=684085&r1=684084&r2=684085&view=diff
==============================================================================
--- continuum/trunk/continuum-purge/src/test/java/org/apache/continuum/purge/DefaultPurgeConfigurationServiceTest.java (original)
+++ continuum/trunk/continuum-purge/src/test/java/org/apache/continuum/purge/DefaultPurgeConfigurationServiceTest.java Fri Aug 8 13:48:14 2008
@@ -19,13 +19,13 @@
* under the License.
*/
-import java.util.List;
-
import org.apache.continuum.model.repository.DirectoryPurgeConfiguration;
import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
import org.apache.continuum.purge.repository.content.ManagedDefaultRepositoryContent;
import org.apache.continuum.purge.repository.content.RepositoryManagedContent;
+import java.util.List;
+
/**
* @author Maria Catherine Tan
*/
@@ -33,72 +33,77 @@
extends AbstractPurgeTest
{
private PurgeConfigurationService purgeConfigurationService;
-
+
protected void setUp()
throws Exception
{
super.setUp();
-
+
purgeConfigurationService = (PurgeConfigurationService) lookup( PurgeConfigurationService.ROLE );
}
-
+
public void testRepositoryPurgeConfiguration()
throws Exception
{
RepositoryPurgeConfiguration repoConfig = new RepositoryPurgeConfiguration();
-
+
repoConfig.setRepository( defaultRepository );
repoConfig.setDaysOlder( TEST_DAYS_OLDER );
repoConfig.setRetentionCount( TEST_RETENTION_COUNT );
-
+
repoConfig = purgeConfigurationService.addRepositoryPurgeConfiguration( repoConfig );
-
+
assertNotNull( repoConfig );
-
- RepositoryPurgeConfiguration retrieved = getStore().getRepositoryPurgeConfiguration( repoConfig.getId() );
+
+ RepositoryPurgeConfiguration retrieved =
+ repositoryPurgeConfigurationDao.getRepositoryPurgeConfiguration( repoConfig.getId() );
assertEquals( repoConfig, retrieved );
-
+
purgeConfigurationService.removeRepositoryPurgeConfiguration( repoConfig );
-
- List<RepositoryPurgeConfiguration> repoConfigs = purgeConfigurationService.getAllRepositoryPurgeConfigurations();
-
+
+ List<RepositoryPurgeConfiguration> repoConfigs =
+ purgeConfigurationService.getAllRepositoryPurgeConfigurations();
+
assertFalse( "check if repo purge configuration was removed", repoConfigs.contains( repoConfig ) );
- assertNotNull( "check if repository still exists", getStore().getLocalRepository( defaultRepository.getId() ) );
+ assertNotNull( "check if repository still exists",
+ localRepositoryDao.getLocalRepository( defaultRepository.getId() ) );
}
-
+
public void testDirectoryPurgeConfiguration()
throws Exception
{
DirectoryPurgeConfiguration dirConfig = new DirectoryPurgeConfiguration();
-
+
dirConfig.setLocation( getReleasesDirectoryLocation().getAbsolutePath() );
dirConfig.setDirectoryType( TEST_RELEASES_DIRECTORY_TYPE );
dirConfig.setDaysOlder( TEST_DAYS_OLDER );
dirConfig.setRetentionCount( TEST_RETENTION_COUNT );
-
+
dirConfig = purgeConfigurationService.addDirectoryPurgeConfiguration( dirConfig );
-
+
assertNotNull( dirConfig );
-
- DirectoryPurgeConfiguration retrieved = getStore().getDirectoryPurgeConfiguration( dirConfig.getId() );
+
+ DirectoryPurgeConfiguration retrieved =
+ directoryPurgeConfigurationDao.getDirectoryPurgeConfiguration( dirConfig.getId() );
assertEquals( dirConfig, retrieved );
-
+
dirConfig.setDirectoryType( TEST_BUILDOUTPUT_DIRECTORY_TYPE );
purgeConfigurationService.updateDirectoryPurgeConfiguration( dirConfig );
- retrieved = getStore().getDirectoryPurgeConfiguration( dirConfig.getId() );
+ retrieved = directoryPurgeConfigurationDao.getDirectoryPurgeConfiguration( dirConfig.getId() );
assertEquals( dirConfig, retrieved );
-
+
purgeConfigurationService.removeDirectoryPurgeConfiguration( dirConfig );
-
+
List<DirectoryPurgeConfiguration> dirConfigs = purgeConfigurationService.getAllDirectoryPurgeConfigurations();
assertFalse( "check if dir purge configuration was removed", dirConfigs.contains( dirConfig ) );
}
-
+
public void testRepositoryManagedContent()
throws Exception
{
- RepositoryManagedContent repo = purgeConfigurationService.getManagedRepositoryContent( defaultRepository.getId() );
-
+ RepositoryManagedContent repo =
+ purgeConfigurationService.getManagedRepositoryContent( defaultRepository.getId() );
+
assertTrue( "check repository managed content", ( repo instanceof ManagedDefaultRepositoryContent ) );
assertEquals( "check repository of the managed content", defaultRepository, repo.getRepository() );
}