diff options
author | Joakim Erdfelt <joakime@apache.org> | 2007-06-17 21:44:25 +0000 |
---|---|---|
committer | Joakim Erdfelt <joakime@apache.org> | 2007-06-17 21:44:25 +0000 |
commit | e6fc266d61e3ff72401408bbd91125b097415d19 (patch) | |
tree | 9f0f0ddaabf33521ac1b66222970050b42f536b2 /archiva-base/archiva-consumers | |
parent | ffa63bbba56dcb014a32ecf1a1e94f5d3cb783db (diff) | |
download | archiva-e6fc266d61e3ff72401408bbd91125b097415d19.tar.gz archiva-e6fc266d61e3ff72401408bbd91125b097415d19.zip |
[MRM-369]: [Repository Scanning] Exception on update to pre-existing artifact.
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@548120 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-base/archiva-consumers')
-rw-r--r-- | archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/ArtifactUpdateDatabaseConsumer.java | 46 |
1 files changed, 39 insertions, 7 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 a8d5a09f8..85ac7405e 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 @@ -83,7 +83,7 @@ public class ArtifactUpdateDatabaseConsumer * @plexus.requirement */ private ArchivaConfiguration configuration; - + /** * @plexus.requirement */ @@ -161,10 +161,15 @@ public class ArtifactUpdateDatabaseConsumer public void processFile( String path ) throws ConsumerException { - try + ArchivaArtifact artifact = getLiveArtifact( path ); + + if ( artifact == null ) { - ArchivaArtifact artifact = layout.toArtifact( path ); + return; + } + try + { artifact.getModel().setRepositoryId( this.repository.getId() ); // Calculate the hashcodes. @@ -194,14 +199,41 @@ public class ArtifactUpdateDatabaseConsumer dao.getArtifactDAO().saveArtifact( artifact ); } + catch ( ArchivaDatabaseException e ) + { + triggerConsumerError( DB_ERROR, "Unable to save artifact to database: " + e.getMessage() ); + } + } + + /** + * Get a Live Artifact from a Path. + * + * Will resolve the artifact details from the path, and then return a database live version + * of that artifact. Suitable for modification and saving (without the need to check for + * existance in database prior to save.) + * + * @param path the path to work from. + * @return the artifact that is suitable for database saving. + */ + public ArchivaArtifact getLiveArtifact( String path ) + { + try + { + ArchivaArtifact artifact = layout.toArtifact( path ); + + ArchivaArtifact liveArtifact = dao.getArtifactDAO().createArtifact( artifact.getGroupId(), + artifact.getArtifactId(), + artifact.getVersion(), + artifact.getClassifier(), + artifact.getType() ); + + return liveArtifact; + } catch ( LayoutException e ) { triggerConsumerError( TYPE_NOT_ARTIFACT, "Path " + path + " cannot be converted to artifact: " + e.getMessage() ); - } - catch ( ArchivaDatabaseException e ) - { - triggerConsumerError( DB_ERROR, "Unable to save artifact to database: " + e.getMessage() ); + return null; } } |