From 84731f48bc296bf202a61e91873634049fb38473 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Wed, 17 Oct 2007 17:01:25 +0000 Subject: [PATCH] Upgrading bidirlayout usage to RepoContent usage to eliminate bugs around missing content from bad layout routines. git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@585576 13f79535-47bb-0310-9956-ffa450edef68 --- .../ArtifactUpdateDatabaseConsumer.java | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/ArtifactUpdateDatabaseConsumer.java b/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/ArtifactUpdateDatabaseConsumer.java index bbba3dd84..de38ce0fa 100644 --- a/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/ArtifactUpdateDatabaseConsumer.java +++ b/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/ArtifactUpdateDatabaseConsumer.java @@ -29,8 +29,10 @@ import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer; import org.apache.maven.archiva.database.ArchivaDAO; import org.apache.maven.archiva.database.ArchivaDatabaseException; import org.apache.maven.archiva.model.ArchivaArtifact; -import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout; -import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory; +import org.apache.maven.archiva.model.ArtifactReference; +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.LayoutException; import org.codehaus.plexus.digest.Digester; import org.codehaus.plexus.digest.DigesterException; @@ -50,8 +52,8 @@ import java.util.List; * @author Joakim Erdfelt * @version $Id$ * @plexus.component role="org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer" - * role-hint="update-db-artifact" - * instantiation-strategy="per-lookup" + * role-hint="update-db-artifact" + * instantiation-strategy="per-lookup" */ public class ArtifactUpdateDatabaseConsumer extends AbstractMonitoredConsumer @@ -61,7 +63,7 @@ public class ArtifactUpdateDatabaseConsumer private static final String DB_ERROR = "db-error"; - private static final String CHECKSUM_CALCULATION = null; + private static final String CHECKSUM_CALCULATION = "checksum-calc"; /** * @plexus.configuration default-value="update-db-artifact" @@ -91,7 +93,7 @@ public class ArtifactUpdateDatabaseConsumer /** * @plexus.requirement */ - private BidirectionalRepositoryLayoutFactory layoutFactory; + private RepositoryContentFactory repositoryFactory; /** * @plexus.requirement role-hint="sha1" @@ -103,12 +105,10 @@ public class ArtifactUpdateDatabaseConsumer */ private Digester digestMd5; - private ManagedRepositoryConfiguration repository; + private ManagedRepositoryContent repository; private File repositoryDir; - private BidirectionalRepositoryLayout layout; - private List includes = new ArrayList(); public String getId() @@ -136,19 +136,17 @@ public class ArtifactUpdateDatabaseConsumer return this.includes; } - public void beginScan( ManagedRepositoryConfiguration repository ) + public void beginScan( ManagedRepositoryConfiguration repo ) throws ConsumerException { - this.repository = repository; - this.repositoryDir = new File( repository.getLocation() ); - try { - this.layout = layoutFactory.getLayout( repository.getLayout() ); + this.repository = repositoryFactory.getManagedRepositoryContent( repo.getId() ); + this.repositoryDir = new File( repository.getRepoRoot() ); } - catch ( LayoutException e ) + catch(RepositoryException e) { - throw new ConsumerException( e.getMessage(), e ); + throw new ConsumerException( "Unable to start ArtifactUpdateDatabaseConsumer: " + e.getMessage(), e ); } } @@ -214,7 +212,7 @@ public class ArtifactUpdateDatabaseConsumer { try { - ArchivaArtifact artifact = layout.toArtifact( path ); + ArtifactReference artifact = repository.toArtifactReference( path ); ArchivaArtifact liveArtifact = dao.getArtifactDAO().createArtifact( artifact.getGroupId(), artifact.getArtifactId(),