From 657b328e5d5c4e9b05b1fe36a0584cc0ed938d8c Mon Sep 17 00:00:00 2001 From: "Maria Odea B. Ching" Date: Tue, 16 Oct 2007 07:45:27 +0000 Subject: [PATCH] removed usage of BidirectionalRepositoryLayout in database cleanup consumers, made use of the ManagedRepositoryContent instead git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@585068 13f79535-47bb-0310-9956-ffa450edef68 --- ...DatabaseCleanupRemoveArtifactConsumer.java | 37 ++----------------- .../DatabaseCleanupRemoveProjectConsumer.java | 35 ++---------------- .../database/AbstractDatabaseCleanupTest.java | 6 --- ...baseCleanupRemoveArtifactConsumerTest.java | 2 - ...abaseCleanupRemoveProjectConsumerTest.java | 2 - ...abaseCleanupRemoveArtifactConsumerTest.xml | 37 ------------------- ...tabaseCleanupRemoveProjectConsumerTest.xml | 19 ---------- 7 files changed, 7 insertions(+), 131 deletions(-) diff --git a/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveArtifactConsumer.java b/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveArtifactConsumer.java index 6d462c2fb..efdff1765 100644 --- a/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveArtifactConsumer.java +++ b/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveArtifactConsumer.java @@ -28,9 +28,6 @@ import org.apache.maven.archiva.database.ArchivaDatabaseException; import org.apache.maven.archiva.repository.ManagedRepositoryContent; import org.apache.maven.archiva.repository.RepositoryContentFactory; import org.apache.maven.archiva.repository.RepositoryException; -import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout; -import org.apache.maven.archiva.repository.layout.LayoutException; -import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory; import java.util.List; import java.io.File; @@ -64,11 +61,6 @@ public class DatabaseCleanupRemoveArtifactConsumer * @plexus.requirement role-hint="jdo" */ private ArtifactDAO artifactDAO; - - /** - * @plexus.requirement - */ - private BidirectionalRepositoryLayoutFactory layoutFactory; /** * @plexus.requirement @@ -98,9 +90,9 @@ public class DatabaseCleanupRemoveArtifactConsumer { ManagedRepositoryContent repositoryContent = repositoryFactory.getManagedRepositoryContent( artifact.getModel().getRepositoryId() ); - - File file = new File( repositoryContent.getRepoRoot(), toPath( artifact ) ); - + + File file = new File( repositoryContent.getRepoRoot(), repositoryContent.toPath( artifact ) ); + if( !file.exists() ) { artifactDAO.deleteArtifact( artifact ); @@ -136,30 +128,9 @@ public class DatabaseCleanupRemoveArtifactConsumer { this.artifactDAO = artifactDAO; } - - public void setBidirectionalRepositoryLayoutFactory( BidirectionalRepositoryLayoutFactory layoutFactory ) - { - this.layoutFactory = layoutFactory; - } public void setRepositoryFactory( RepositoryContentFactory repositoryFactory ) { this.repositoryFactory = repositoryFactory; - } - - private String toPath( ArchivaArtifact artifact ) - { - try - { - BidirectionalRepositoryLayout layout = layoutFactory.getLayout( artifact ); - - return layout.toPath( artifact ); - } - catch ( LayoutException e ) - { - getLogger().warn( "Unable to calculate path for artifact: " + artifact ); - return null; - } - } - + } } diff --git a/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveProjectConsumer.java b/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveProjectConsumer.java index feb0ec672..343439774 100644 --- a/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveProjectConsumer.java +++ b/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveProjectConsumer.java @@ -28,14 +28,10 @@ import org.apache.maven.archiva.model.ArchivaProjectModel; import org.apache.maven.archiva.repository.ManagedRepositoryContent; import org.apache.maven.archiva.repository.RepositoryContentFactory; import org.apache.maven.archiva.repository.RepositoryException; -import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout; -import org.apache.maven.archiva.repository.layout.LayoutException; -import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory; import org.apache.maven.archiva.database.ProjectModelDAO; import org.apache.maven.archiva.database.ArchivaDatabaseException; import java.util.List; -import java.util.ArrayList; import java.io.File; /** @@ -68,11 +64,6 @@ public class DatabaseCleanupRemoveProjectConsumer * @plexus.requirement role-hint="jdo" */ private ProjectModelDAO projectModelDAO; - - /** - * @plexus.requirement - */ - private BidirectionalRepositoryLayoutFactory layoutFactory; /** * @plexus.requirement @@ -108,8 +99,8 @@ public class DatabaseCleanupRemoveProjectConsumer ManagedRepositoryContent repositoryContent = repositoryFactory.getManagedRepositoryContent( artifact.getModel().getRepositoryId() ); - File file = new File( repositoryContent.getRepoRoot(), toPath( artifact ) ); - + File file = new File( repositoryContent.getRepoRoot(), repositoryContent.toPath( artifact ) ); + if( !file.exists() ) { ArchivaProjectModel projectModel = projectModelDAO.getProjectModel( @@ -144,31 +135,11 @@ public class DatabaseCleanupRemoveProjectConsumer { return false; } - - private String toPath( ArchivaArtifact artifact ) - { - try - { - BidirectionalRepositoryLayout layout = layoutFactory.getLayout( artifact ); - - return layout.toPath( artifact ); - } - catch ( LayoutException e ) - { - getLogger().warn( "Unable to calculate path for artifact: " + artifact ); - return null; - } - } - + public void setProjectModelDAO( ProjectModelDAO projectModelDAO ) { this.projectModelDAO = projectModelDAO; } - - public void setBidirectionalRepositoryLayoutFactory( BidirectionalRepositoryLayoutFactory layoutFactory ) - { - this.layoutFactory = layoutFactory; - } public void setRepositoryFactory( RepositoryContentFactory repositoryFactory ) { diff --git a/archiva-base/archiva-consumers/archiva-database-consumers/src/test/java/org/apache/maven/archiva/consumers/database/AbstractDatabaseCleanupTest.java b/archiva-base/archiva-consumers/archiva-database-consumers/src/test/java/org/apache/maven/archiva/consumers/database/AbstractDatabaseCleanupTest.java index e49ff497b..f4bb42990 100644 --- a/archiva-base/archiva-consumers/archiva-database-consumers/src/test/java/org/apache/maven/archiva/consumers/database/AbstractDatabaseCleanupTest.java +++ b/archiva-base/archiva-consumers/archiva-database-consumers/src/test/java/org/apache/maven/archiva/consumers/database/AbstractDatabaseCleanupTest.java @@ -25,7 +25,6 @@ import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.maven.archiva.repository.RepositoryContentFactory; -import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory; import org.apache.maven.archiva.model.ArchivaArtifact; import org.apache.maven.archiva.model.ArchivaArtifactModel; import org.apache.maven.archiva.model.ArchivaProjectModel; @@ -39,8 +38,6 @@ public class AbstractDatabaseCleanupTest extends PlexusTestCase { ArchivaConfiguration archivaConfig; - - BidirectionalRepositoryLayoutFactory layoutFactory; RepositoryContentFactory repositoryFactory; @@ -73,9 +70,6 @@ public class AbstractDatabaseCleanupTest repo.setLocation( new File( getBasedir(), "src/test/resources/test-repo" ).toString() ); archivaConfig.save( configuration ); - - // set bidirectional repository layout factory - layoutFactory = (BidirectionalRepositoryLayoutFactory) lookup( BidirectionalRepositoryLayoutFactory.class ); repositoryFactory = (RepositoryContentFactory) lookup( RepositoryContentFactory.class ); } diff --git a/archiva-base/archiva-consumers/archiva-database-consumers/src/test/java/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveArtifactConsumerTest.java b/archiva-base/archiva-consumers/archiva-database-consumers/src/test/java/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveArtifactConsumerTest.java index 1e4932129..08747a8d4 100644 --- a/archiva-base/archiva-consumers/archiva-database-consumers/src/test/java/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveArtifactConsumerTest.java +++ b/archiva-base/archiva-consumers/archiva-database-consumers/src/test/java/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveArtifactConsumerTest.java @@ -50,8 +50,6 @@ public class DatabaseCleanupRemoveArtifactConsumerTest dbCleanupRemoveArtifactConsumer.setArtifactDAO( artifactDAOMock ); - dbCleanupRemoveArtifactConsumer.setBidirectionalRepositoryLayoutFactory( layoutFactory ); - dbCleanupRemoveArtifactConsumer.setRepositoryFactory( repositoryFactory ); } diff --git a/archiva-base/archiva-consumers/archiva-database-consumers/src/test/java/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveProjectConsumerTest.java b/archiva-base/archiva-consumers/archiva-database-consumers/src/test/java/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveProjectConsumerTest.java index 646d3b0c8..0e454e08e 100644 --- a/archiva-base/archiva-consumers/archiva-database-consumers/src/test/java/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveProjectConsumerTest.java +++ b/archiva-base/archiva-consumers/archiva-database-consumers/src/test/java/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveProjectConsumerTest.java @@ -51,8 +51,6 @@ public class DatabaseCleanupRemoveProjectConsumerTest dbCleanupRemoveProjectConsumer.setProjectModelDAO( projectModelDAOMock ); - dbCleanupRemoveProjectConsumer.setBidirectionalRepositoryLayoutFactory( layoutFactory ); - dbCleanupRemoveProjectConsumer.setRepositoryFactory( repositoryFactory ); } diff --git a/archiva-base/archiva-consumers/archiva-database-consumers/src/test/resources/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveArtifactConsumerTest.xml b/archiva-base/archiva-consumers/archiva-database-consumers/src/test/resources/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveArtifactConsumerTest.xml index 1a2bc2093..712381c1c 100644 --- a/archiva-base/archiva-consumers/archiva-database-consumers/src/test/resources/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveArtifactConsumerTest.xml +++ b/archiva-base/archiva-consumers/archiva-database-consumers/src/test/resources/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveArtifactConsumerTest.xml @@ -20,24 +20,6 @@ - - org.apache.maven.archiva.consumers.DatabaseCleanupConsumer - not-present-remove-db-artifact - org.apache.maven.archiva.consumers.database.DatabaseCleanupRemoveArtifactConsumer - - - org.apache.maven.archiva.configuration.ArchivaConfiguration - database-cleanup - - - org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory - - - org.apache.maven.archiva.database.ArtifactDAO - jdo - - - org.apache.maven.archiva.configuration.ArchivaConfiguration database-cleanup @@ -60,25 +42,6 @@ - - org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory - org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory - - - org.apache.maven.archiva.configuration.ArchivaConfiguration - database-cleanup - - - org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout - layouts - - - - - org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout - default - org.apache.maven.archiva.repository.layout.DefaultBidirectionalRepositoryLayout - org.apache.maven.archiva.repository.RepositoryContentFactory diff --git a/archiva-base/archiva-consumers/archiva-database-consumers/src/test/resources/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveProjectConsumerTest.xml b/archiva-base/archiva-consumers/archiva-database-consumers/src/test/resources/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveProjectConsumerTest.xml index ded662447..712381c1c 100644 --- a/archiva-base/archiva-consumers/archiva-database-consumers/src/test/resources/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveProjectConsumerTest.xml +++ b/archiva-base/archiva-consumers/archiva-database-consumers/src/test/resources/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveProjectConsumerTest.xml @@ -42,25 +42,6 @@ - - org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory - org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory - - - org.apache.maven.archiva.configuration.ArchivaConfiguration - database-cleanup - - - org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout - layouts - - - - - org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout - default - org.apache.maven.archiva.repository.layout.DefaultBidirectionalRepositoryLayout - org.apache.maven.archiva.repository.RepositoryContentFactory -- 2.39.5