diff options
author | Martin Stockhammer <martin_s@apache.org> | 2017-08-12 14:49:45 +0200 |
---|---|---|
committer | Martin Stockhammer <martin_s@apache.org> | 2017-08-12 14:49:45 +0200 |
commit | f93a787e74f048fd4fe393819c09d898da63b4f4 (patch) | |
tree | 50bf7dbae71c5a8f650a6cab04d97d1e643dba3c /archiva-modules | |
parent | e5e11721b14786153a9d9156b4dde4ba8b8ad2b3 (diff) | |
download | archiva-f93a787e74f048fd4fe393819c09d898da63b4f4.tar.gz archiva-f93a787e74f048fd4fe393819c09d898da63b4f4.zip |
Adding custom properties to project metadata.
Extending the project metadata to add custom properties. This may be used by
storage implementations later.
Diffstat (limited to 'archiva-modules')
-rw-r--r-- | archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectMetadata.java | 80 |
1 files changed, 79 insertions, 1 deletions
diff --git a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectMetadata.java b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectMetadata.java index c795bb5db..61326e5ef 100644 --- a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectMetadata.java +++ b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectMetadata.java @@ -19,39 +19,117 @@ package org.apache.archiva.metadata.model; * under the License. */ +import java.util.Properties; + +/** + * Metadata on project level. + * Namely the namespace and the project id. But different repository types may + * add additional metadata information. + * + */ public class ProjectMetadata { + private Properties customProperties; + private String namespace; private String id; + /** + * Sets the project id. + * @param id + */ public void setId( String id ) { this.id = id; } - + + /** + * Returns the project id. + * @return + */ public String getId() { return id; } + /** + * Returns the namespace where the project resides. + * @return The namespace. + */ public String getNamespace() { return namespace; } + /** + * Sets the namespace. Namespaces are strings that may contain '.' characters to separate + * the hierarchy levels. + * @return + */ public void setNamespace( String namespace ) { this.namespace = namespace; } + /** + * Adds a custom property. Repository storage implementations may add custom properties + * on the project level. + * @param key + * @param value + */ + public void addProperty(String key, String value) { + Properties props = getProperties(); + props.setProperty( key, value ); + } + + /** + * Replaces all custom properties with the given properties object. + * The given object is stored by reference and not copied. + * @param properties + */ + public void setProperties(Properties properties) { + this.customProperties = properties; + } + + + /** + * Returns the object with all custom properties. + * If there are no custom properties set, a empty object will be returned. + * + * @return The custom properties. + */ + public Properties getProperties() { + if (customProperties==null) + { + Properties props = new Properties( ); + this.customProperties = props; + return props; + } else { + return this.customProperties; + } + } + + /** + * Returns true, if there are custom properties set. + * @return True, if there exist custom properties. + */ + public boolean hasProperties() { + return this.customProperties != null && this.customProperties.size()>0; + } + @Override public String toString() { final StringBuilder sb = new StringBuilder( "ProjectMetadata{" ); sb.append( "namespace='" ).append( namespace ).append( '\'' ); sb.append( ", id='" ).append( id ).append( '\'' ); + if (customProperties!=null) { + sb.append(", custom: '").append(customProperties.toString()).append('\''); + } sb.append( '}' ); return sb.toString(); } + + } |