1 package org.apache.archiva.metadata.model;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import java.util.Date;
25 * Metadata stored in the content repository for a particular artifact. Information that is shared between different
26 * artifacts of a given project version can be found in the
27 * {@link org.apache.archiva.metadata.model.ProjectVersionMetadata} class. The metadata is faceted to store information
28 * about particular types of artifacts, for example Maven 2.x artifact specific information.
29 * For more information, see the
30 * <a href="{@docRoot}/../metadata-content-model.html" target="_top">Metadata Content Model</a>.
32 public class ArtifactMetadata
33 extends FacetedMetadata
36 * The artifact ID uniquely identifies an artifact within a given namespace, project and project version. For
37 * example, <tt>archiva-1.4-20100201.345612-2.jar</tt>
42 * The repository that the artifact is stored in within the content repository.
44 private String repositoryId;
47 * The namespace of the project within the repository.
49 * @see org.apache.archiva.metadata.model.ProjectMetadata#namespace
51 private String namespace;
54 * The identifier of the project within the repository and namespace.
56 * @see org.apache.archiva.metadata.model.ProjectMetadata#id
58 private String project;
61 * The version of the project. This may be more generalised than @{link #version}.
63 * @see org.apache.archiva.metadata.model.ProjectVersionMetadata#id
65 private String projectVersion;
68 * The artifact version, if different from the project version. Note that the metadata does not do any calculation
69 * of this based on the project version - the calling code must be sure to set and check it appropriately if
72 private String version;
75 * The last modified date of the artifact file, if known.
77 private Date fileLastModified;
80 * The file size of the artifact, if known.
85 * The MD5 checksum of the artifact, if calculated.
90 * The SHA-1 checksum of the artifact, if calculated.
95 * When the artifact was found in the repository storage and added to the metadata content repository.
97 private Date whenGathered;
104 public void setId( String id )
109 public long getSize()
114 public void setSize( long size )
119 public String getVersion()
124 public void setVersion( String version )
126 this.version = version;
129 public String getProjectVersion()
131 return projectVersion;
134 public void setProjectVersion( String projectVersion )
136 this.projectVersion = projectVersion;
139 public void setFileLastModified( long fileLastModified )
141 this.fileLastModified = new Date( fileLastModified );
144 public void setWhenGathered( Date whenGathered )
146 this.whenGathered = whenGathered;
149 public void setMd5( String md5 )
154 public void setSha1( String sha1 )
159 public Date getWhenGathered()
164 public String getMd5()
169 public String getSha1()
174 public Date getFileLastModified()
177 return fileLastModified;
180 public String getNamespace()
185 public void setNamespace( String namespace )
187 this.namespace = namespace;
190 public void setProject( String project )
192 this.project = project;
195 public String getProject()
200 public String getRepositoryId()
205 public void setRepositoryId( String repositoryId )
207 this.repositoryId = repositoryId;
211 public boolean equals( Object o )
217 if ( o == null || getClass() != o.getClass() )
222 ArtifactMetadata that = (ArtifactMetadata) o;
224 if ( size != that.size )
228 if ( fileLastModified != null
229 ? !fileLastModified.equals( that.fileLastModified )
230 : that.fileLastModified != null )
234 if ( !id.equals( that.id ) )
238 if ( md5 != null ? !md5.equals( that.md5 ) : that.md5 != null )
242 if ( namespace != null ? !namespace.equals( that.namespace ) : that.namespace != null )
246 if ( project != null ? !project.equals( that.project ) : that.project != null )
250 if ( projectVersion != null ? !projectVersion.equals( that.projectVersion ) : that.projectVersion != null )
254 if ( !repositoryId.equals( that.repositoryId ) )
258 if ( sha1 != null ? !sha1.equals( that.sha1 ) : that.sha1 != null )
262 if ( version != null ? !version.equals( that.version ) : that.version != null )
266 if ( whenGathered != null ? !whenGathered.equals( that.whenGathered ) : that.whenGathered != null )
275 public String toString()
277 return "ArtifactMetadata{" + "id='" + id + '\'' + ", size=" + size + ", version='" + version + '\'' +
278 ", fileLastModified=" + fileLastModified + ", whenGathered=" + whenGathered + ", md5='" + md5 + '\'' +
279 ", sha1='" + sha1 + '\'' + ", namespace='" + namespace + '\'' + ", project='" + project + '\'' +
280 ", projectVersion='" + projectVersion + '\'' + ", repositoryId='" + repositoryId + '\'' + '}';