diff options
author | James William Dumay <jdumay@apache.org> | 2009-02-10 05:35:05 +0000 |
---|---|---|
committer | James William Dumay <jdumay@apache.org> | 2009-02-10 05:35:05 +0000 |
commit | 6267a21d29f46ab7a7d17bdfcbc78aa9c87ff502 (patch) | |
tree | 21bbd877c1bb941a1fc9aca342bd2113509ee7a7 /archiva-modules/archiva-base/archiva-model | |
parent | dc5aee4038796d2f79279806576e68acc08b9fb8 (diff) | |
download | archiva-6267a21d29f46ab7a7d17bdfcbc78aa9c87ff502.tar.gz archiva-6267a21d29f46ab7a7d17bdfcbc78aa9c87ff502.zip |
MRM-1081 - Archiva model should be updated so that the ARTIFACT table includes repositoryId as a primary key
* Updated so that repositoryId is part of the primary key for an artifact
* removed old search API classes as they needed to be brought over to the new API and doing so would be a waste of time
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@742859 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-base/archiva-model')
3 files changed, 66 insertions, 7 deletions
diff --git a/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/AbstractArtifactKey.java b/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/AbstractArtifactKey.java index bb96d6f54..bf9d95ac4 100644 --- a/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/AbstractArtifactKey.java +++ b/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/AbstractArtifactKey.java @@ -106,6 +106,11 @@ public class AbstractArtifactKey public String type = ""; /** + * The Repository Id (JPOX Requires this remain public) + */ + public String repositoryId = ""; + + /** * Default Constructor. Required by JPOX. */ public AbstractArtifactKey() @@ -126,19 +131,22 @@ public class AbstractArtifactKey version = parts[2]; classifier = parts[3]; type = parts[4]; + repositoryId = parts[5]; } /** * Get the String representation of this object. - Required by JPOX. */ + @Override public String toString() { - return StringUtils.join( new String[] { groupId, artifactId, version, classifier, type }, ':' ); + return StringUtils.join( new String[] { groupId, artifactId, version, classifier, type, repositoryId }, ':' ); } /** * Get the hashcode for this object's values - Required by JPOX. */ + @Override public int hashCode() { final int PRIME = 31; @@ -148,12 +156,14 @@ public class AbstractArtifactKey result = PRIME * result + ( ( version == null ) ? 0 : version.hashCode() ); result = PRIME * result + ( ( classifier == null ) ? 0 : classifier.hashCode() ); result = PRIME * result + ( ( type == null ) ? 0 : type.hashCode() ); + result = PRIME * result + ( ( repositoryId == null ) ? 0 : repositoryId.hashCode() ); return result; } /** * Get the equals for this object's values - Required by JPOX. */ + @Override public boolean equals( Object obj ) { if ( this == obj ) @@ -233,6 +243,18 @@ public class AbstractArtifactKey return false; } + if ( repositoryId == null ) + { + if ( other.repositoryId != null ) + { + return false; + } + } + else if ( !repositoryId.equals( other.repositoryId ) ) + { + return false; + } + return true; } @@ -286,4 +308,13 @@ public class AbstractArtifactKey } } + public void setRepositoryId( String repositoryId ) + { + this.repositoryId = ""; + + if ( StringUtils.isNotBlank(repositoryId) ) + { + this.repositoryId = repositoryId; + } + } } diff --git a/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/ArchivaArtifact.java b/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/ArchivaArtifact.java index 9da58c4ec..baf086296 100644 --- a/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/ArchivaArtifact.java +++ b/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/ArchivaArtifact.java @@ -36,7 +36,7 @@ public class ArchivaArtifact private String baseVersion; public ArchivaArtifact( String groupId, String artifactId, String version, - String classifier, String type ) + String classifier, String type, String repositoryId ) { if ( empty( groupId ) ) { @@ -62,6 +62,12 @@ public class ArchivaArtifact + Keys.toKey( groupId, artifactId, version, classifier, type ) + "]" ); } + if ( empty( repositoryId ) ) + { + throw new IllegalArgumentException( "Unable to create ArchivaArtifact with empty repositoryId [" + + Keys.toKey( groupId, artifactId, version, classifier, type ) + "]" ); + } + model = new ArchivaArtifactModel(); model.setGroupId( groupId ); @@ -70,6 +76,7 @@ public class ArchivaArtifact model.setClassifier( StringUtils.defaultString( classifier ) ); model.setType( type ); model.setSnapshot( VersionUtil.isSnapshot( version ) ); + model.setRepositoryId(repositoryId); this.baseVersion = VersionUtil.getBaseVersion( version ); } @@ -81,9 +88,9 @@ public class ArchivaArtifact this.baseVersion = VersionUtil.getBaseVersion( model.getVersion() ); } - public ArchivaArtifact( ArtifactReference ref ) + public ArchivaArtifact( ArtifactReference ref, String repositoryId ) { - this( ref.getGroupId(), ref.getArtifactId(), ref.getVersion(), ref.getClassifier(), ref.getType() ); + this( ref.getGroupId(), ref.getArtifactId(), ref.getVersion(), ref.getClassifier(), ref.getType(), repositoryId ); } public ArchivaArtifactModel getModel() @@ -131,6 +138,11 @@ public class ArchivaArtifact return StringUtils.isNotEmpty( model.getClassifier() ); } + public String getRepositoryId() + { + return model.getRepositoryId(); + } + @Override public int hashCode() { diff --git a/archiva-modules/archiva-base/archiva-model/src/main/mdo/archiva-base.xml b/archiva-modules/archiva-base/archiva-model/src/main/mdo/archiva-base.xml index 93912f688..19884d5ec 100644 --- a/archiva-modules/archiva-base/archiva-model/src/main/mdo/archiva-base.xml +++ b/archiva-modules/archiva-base/archiva-model/src/main/mdo/archiva-base.xml @@ -299,11 +299,14 @@ The type of artifact. </description> </field> - <field stash.maxSize="50"> + <field stash.maxSize="50" + jpox.primary-key="true" + jpox.value-strategy="off" + jpox.persistence-modifier="persistent"> <name>repositoryId</name> - <identifier>false</identifier> + <identifier>true</identifier> <version>1.0.0+</version> - <required>false</required> + <required>true</required> <type>String</type> <description> The repository associated with this content. @@ -513,6 +516,19 @@ The type of artifact. </description> </field> + <field stash.maxSize="50" + jpox.primary-key="true" + jpox.value-strategy="off" + jpox.persistence-modifier="persistent"> + <name>repositoryId</name> + <identifier>true</identifier> + <version>1.0.0+</version> + <required>true</required> + <type>String</type> + <description> + The repository associated with this content. + </description> + </field> <field> <name>checksumBytecode</name> <identifier>false</identifier> |