diff options
author | Olivier Lamy <olamy@apache.org> | 2012-10-23 13:29:21 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2012-10-23 13:29:21 +0000 |
commit | ef66c2d19fdb5e17eb23a1bc2a669211c67f270e (patch) | |
tree | c5ce3e49aed7c265d0e6c26a89fd094b4a1d86c5 /archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer | |
parent | 38788585d73b698a6f1e932db711c37b5c45a48b (diff) | |
download | archiva-ef66c2d19fdb5e17eb23a1bc2a669211c67f270e.tar.gz archiva-ef66c2d19fdb5e17eb23a1bc2a669211c67f270e.zip |
use a new bean rather than a lot of params to ease futur enhancements
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1401289 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer')
-rw-r--r-- | archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata/ArchivaMetadataCreationConsumer.java | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata/ArchivaMetadataCreationConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata/ArchivaMetadataCreationConsumer.java index 546593123..23dee2f46 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata/ArchivaMetadataCreationConsumer.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata/ArchivaMetadataCreationConsumer.java @@ -34,6 +34,7 @@ import org.apache.archiva.metadata.repository.MetadataRepository; import org.apache.archiva.metadata.repository.MetadataRepositoryException; import org.apache.archiva.metadata.repository.RepositorySession; import org.apache.archiva.metadata.repository.RepositorySessionFactory; +import org.apache.archiva.metadata.repository.storage.ReadMetadataRequest; import org.apache.archiva.metadata.repository.storage.RepositoryStorage; import org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataInvalidException; import org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataNotFoundException; @@ -54,11 +55,9 @@ import java.util.List; /** * Take an artifact off of disk and put it into the metadata repository. - * - * */ -@Service( "knownRepositoryContentConsumer#create-archiva-metadata" ) -@Scope( "prototype" ) +@Service ("knownRepositoryContentConsumer#create-archiva-metadata") +@Scope ("prototype") public class ArchivaMetadataCreationConsumer extends AbstractMonitoredConsumer implements KnownRepositoryContentConsumer, RegistryListener @@ -98,7 +97,7 @@ public class ArchivaMetadataCreationConsumer * factory. */ @Inject - @Named( value = "repositoryStorage#maven2" ) + @Named (value = "repositoryStorage#maven2") private RepositoryStorage repositoryStorage; private static final Logger log = LoggerFactory.getLogger( ArchivaMetadataCreationConsumer.class ); @@ -170,13 +169,16 @@ public class ArchivaMetadataCreationConsumer ProjectVersionMetadata versionMetadata = null; try { - versionMetadata = repositoryStorage.readProjectVersionMetadata( repoId, artifact.getNamespace(), - artifact.getProject(), projectVersion ); + ReadMetadataRequest readMetadataRequest = + new ReadMetadataRequest().repoId( repoId ).namespace( artifact.getNamespace() ).projectId( + artifact.getProject() ).projectVersion( projectVersion ); + versionMetadata = repositoryStorage.readProjectVersionMetadata( readMetadataRequest ); createVersionMetadata = true; } catch ( RepositoryStorageMetadataNotFoundException e ) { - log.warn( "Missing or invalid POM for artifact:{} (repository:{}); creating empty metadata" , path, repoId ); + log.warn( "Missing or invalid POM for artifact:{} (repository:{}); creating empty metadata", path, + repoId ); versionMetadata = new ProjectVersionMetadata(); versionMetadata.setId( projectVersion ); @@ -185,7 +187,8 @@ public class ArchivaMetadataCreationConsumer } catch ( RepositoryStorageMetadataInvalidException e ) { - log.warn( "Error occurred resolving POM for artifact:{} (repository:{}); message: {}" , new Object[] { path, repoId, e.getMessage() } ); + log.warn( "Error occurred resolving POM for artifact:{} (repository:{}); message: {}", + new Object[]{ path, repoId, e.getMessage() } ); } // read the metadata and update it if it is newer or doesn't exist @@ -202,12 +205,16 @@ public class ArchivaMetadataCreationConsumer } catch ( MetadataRepositoryException e ) { - log.warn( "Error occurred persisting metadata for artifact:{} (repository:{}); message: {}" + e.getMessage(), new Object[] { path, repoId, e.getMessage() }, e ); + log.warn( + "Error occurred persisting metadata for artifact:{} (repository:{}); message: {}" + e.getMessage(), + new Object[]{ path, repoId, e.getMessage() }, e ); repositorySession.revert(); } catch ( RepositoryStorageRuntimeException e ) { - log.warn( "Error occurred persisting metadata for artifact:{} (repository:{}); message: {}" + e.getMessage(), new Object[] { path, repoId, e.getMessage() }, e ); + log.warn( + "Error occurred persisting metadata for artifact:{} (repository:{}); message: {}" + e.getMessage(), + new Object[]{ path, repoId, e.getMessage() }, e ); repositorySession.revert(); } finally |