diff options
author | Martin Stockhammer <martin_s@apache.org> | 2019-08-06 22:06:57 +0200 |
---|---|---|
committer | Martin Stockhammer <martin_s@apache.org> | 2019-08-06 22:06:57 +0200 |
commit | 21d5cf53fe45111fdb030b307715780703032de7 (patch) | |
tree | 8331f135e7349cad9996a9cd222d7fc401877fd2 /archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer | |
parent | eca0097d857aa4739a6387c67d22a9a355a46fa1 (diff) | |
download | archiva-21d5cf53fe45111fdb030b307715780703032de7.tar.gz archiva-21d5cf53fe45111fdb030b307715780703032de7.zip |
Refactoring repository metadata session handling
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 | 36 |
1 files changed, 17 insertions, 19 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 e93b032ac..f50cbbd81 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 @@ -29,10 +29,7 @@ import org.apache.archiva.consumers.KnownRepositoryContentConsumer; import org.apache.archiva.metadata.model.ArtifactMetadata; import org.apache.archiva.metadata.model.ProjectMetadata; import org.apache.archiva.metadata.model.ProjectVersionMetadata; -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.*; import org.apache.archiva.metadata.repository.storage.ReadMetadataRequest; import org.apache.archiva.metadata.repository.storage.RepositoryStorage; import org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataInvalidException; @@ -193,14 +190,14 @@ public class ArchivaMetadataCreationConsumer // read the metadata and update it if it is newer or doesn't exist artifact.setWhenGathered( whenGathered ); - metadataRepository.updateArtifact( , repoId, project.getNamespace(), project.getId(), + metadataRepository.updateArtifact(repositorySession , repoId, project.getNamespace(), project.getId(), projectVersion, artifact ); if ( createVersionMetadata ) { - metadataRepository.updateProjectVersion( , repoId, project.getNamespace(), + metadataRepository.updateProjectVersion(repositorySession , repoId, project.getNamespace(), project.getId(), versionMetadata ); } - metadataRepository.updateProject( , repoId, project ); + metadataRepository.updateProject(repositorySession , repoId, project ); repositorySession.save(); } catch ( MetadataRepositoryException e ) @@ -208,27 +205,28 @@ public class ArchivaMetadataCreationConsumer log.warn( "Error occurred persisting metadata for artifact:{} (repository:{}); message: {}" , path, repoId, e.getMessage(), e ); - repositorySession.revert(); + try { + repositorySession.revert(); + } catch (MetadataSessionException ex) { + log.error("Reverting failed {}", ex.getMessage()); + } } catch ( RepositoryStorageRuntimeException e ) { log.warn( "Error occurred persisting metadata for artifact:{} (repository:{}); message: {}", path, repoId, e.getMessage(), e ); - repositorySession.revert(); - } - finally + try { + repositorySession.revert(); + } catch (MetadataSessionException ex) { + log.error("Reverting failed {}", ex.getMessage()); + } + } catch (MetadataSessionException e) { + throw new ConsumerException(e.getMessage(), e); + } finally { repositorySession.close(); } - catch ( org.apache.archiva.metadata.repository.MetadataSessionException e ) - { - e.printStackTrace( ); - } - catch ( org.apache.archiva.metadata.repository.MetadataSessionException e ) - { - e.printStackTrace( ); - } } @Override |