This project has retired. For details please refer to its Attic page.
ArtifactMetadata xref
View Javadoc
1   package org.apache.archiva.metadata.model;
2   
3   /*
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
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
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
19   * under the License.
20   */
21  
22  import javax.xml.bind.annotation.XmlRootElement;
23  import java.util.Date;
24  
25  /**
26   * Metadata stored in the content repository for a particular artifact. Information that is shared between different
27   * artifacts of a given project version can be found in the
28   * {@link org.apache.archiva.metadata.model.ProjectVersionMetadata} class. The metadata is faceted to store information
29   * about particular types of artifacts, for example Maven 2.x artifact specific information.
30   * For more information, see the
31   * <a href="{@docRoot}/../metadata-content-model.html" target="_top">Metadata Content Model</a>.
32   */
33  @XmlRootElement ( name = "artifactMetadata" )
34  public class ArtifactMetadata
35      extends FacetedMetadata
36  {
37      /**
38       * The artifact ID uniquely identifies an artifact within a given namespace, project and project version. For
39       * example, <tt>archiva-1.4-20100201.345612-2.jar</tt>
40       */
41      private String id;
42  
43      /**
44       * The repository that the artifact is stored in within the content repository.
45       */
46      private String repositoryId;
47  
48      /**
49       * The namespace of the project within the repository.
50       *
51       * @see org.apache.archiva.metadata.model.ProjectMetadata#namespace
52       */
53      private String namespace;
54  
55      /**
56       * The identifier of the project within the repository and namespace.
57       *
58       * @see org.apache.archiva.metadata.model.ProjectMetadata#id
59       */
60      private String project;
61  
62      /**
63       * The version of the project. This may be more generalised than @{link #version}.
64       *
65       * @see org.apache.archiva.metadata.model.ProjectVersionMetadata#id
66       */
67      private String projectVersion;
68  
69      /**
70       * The artifact version, if different from the project version. Note that the metadata does not do any calculation
71       * of this based on the project version - the calling code must be sure to set and check it appropriately if
72       * <tt>null</tt>.
73       */
74      private String version;
75  
76      /**
77       * The last modified date of the artifact file, if known.
78       */
79      private Date fileLastModified;
80  
81      /**
82       * The file size of the artifact, if known.
83       */
84      private long size;
85  
86      /**
87       * The MD5 checksum of the artifact, if calculated.
88       */
89      private String md5;
90  
91      /**
92       * The SHA-1 checksum of the artifact, if calculated.
93       */
94      private String sha1;
95  
96      /**
97       * When the artifact was found in the repository storage and added to the metadata content repository.
98       */
99      private Date whenGathered;
100 
101     public String getId()
102     {
103         return id;
104     }
105 
106     public void setId( String id )
107     {
108         this.id = id;
109     }
110 
111     public long getSize()
112     {
113         return size;
114     }
115 
116     public void setSize( long size )
117     {
118         this.size = size;
119     }
120 
121     public String getVersion()
122     {
123         return version;
124     }
125 
126     public void setVersion( String version )
127     {
128         this.version = version;
129     }
130 
131     public String getProjectVersion()
132     {
133         return projectVersion;
134     }
135 
136     public void setProjectVersion( String projectVersion )
137     {
138         this.projectVersion = projectVersion;
139     }
140 
141     public void setFileLastModified( long fileLastModified )
142     {
143         this.fileLastModified = new Date( fileLastModified );
144     }
145 
146     public void setWhenGathered( Date whenGathered )
147     {
148         this.whenGathered = whenGathered;
149     }
150 
151     public void setMd5( String md5 )
152     {
153         this.md5 = md5;
154     }
155 
156     public void setSha1( String sha1 )
157     {
158         this.sha1 = sha1;
159     }
160 
161     public Date getWhenGathered()
162     {
163         return whenGathered;
164     }
165 
166     public String getMd5()
167     {
168         return md5;
169     }
170 
171     public String getSha1()
172     {
173         return sha1;
174     }
175 
176     public Date getFileLastModified()
177     {
178 
179         return fileLastModified;
180     }
181 
182     public String getNamespace()
183     {
184         return namespace;
185     }
186 
187     public void setNamespace( String namespace )
188     {
189         this.namespace = namespace;
190     }
191 
192     public void setProject( String project )
193     {
194         this.project = project;
195     }
196 
197     public String getProject()
198     {
199         return project;
200     }
201 
202     public String getRepositoryId()
203     {
204         return repositoryId;
205     }
206 
207     public void setRepositoryId( String repositoryId )
208     {
209         this.repositoryId = repositoryId;
210     }
211 
212     @Override
213     public boolean equals( Object o )
214     {
215         if ( this == o )
216         {
217             return true;
218         }
219         if ( o == null || getClass() != o.getClass() )
220         {
221             return false;
222         }
223 
224         ArtifactMetadata that = (ArtifactMetadata) o;
225 
226         if ( size != that.size )
227         {
228             return false;
229         }
230         if ( fileLastModified != null
231             ? !fileLastModified.equals( that.fileLastModified )
232             : that.fileLastModified != null )
233         {
234             return false;
235         }
236         if ( !id.equals( that.id ) )
237         {
238             return false;
239         }
240         if ( md5 != null ? !md5.equals( that.md5 ) : that.md5 != null )
241         {
242             return false;
243         }
244         if ( namespace != null ? !namespace.equals( that.namespace ) : that.namespace != null )
245         {
246             return false;
247         }
248         if ( project != null ? !project.equals( that.project ) : that.project != null )
249         {
250             return false;
251         }
252         if ( projectVersion != null ? !projectVersion.equals( that.projectVersion ) : that.projectVersion != null )
253         {
254             return false;
255         }
256         if ( !repositoryId.equals( that.repositoryId ) )
257         {
258             return false;
259         }
260         if ( sha1 != null ? !sha1.equals( that.sha1 ) : that.sha1 != null )
261         {
262             return false;
263         }
264         if ( version != null ? !version.equals( that.version ) : that.version != null )
265         {
266             return false;
267         }
268         if ( whenGathered != null ? !whenGathered.equals( that.whenGathered ) : that.whenGathered != null )
269         {
270             return false;
271         }
272 
273         return true;
274     }
275 
276     @Override
277     public int hashCode()
278     {
279         int result = id != null ? id.hashCode() : 0;
280         result = 31 * result + ( repositoryId != null ? repositoryId.hashCode() : 0 );
281         result = 31 * result + ( namespace != null ? namespace.hashCode() : 0 );
282         result = 31 * result + ( project != null ? project.hashCode() : 0 );
283         result = 31 * result + ( projectVersion != null ? projectVersion.hashCode() : 0 );
284         result = 31 * result + ( version != null ? version.hashCode() : 0 );
285         result = 31 * result + ( fileLastModified != null ? fileLastModified.hashCode() : 0 );
286         result = 31 * result + (int) ( size ^ ( size >>> 32 ) );
287         result = 31 * result + ( md5 != null ? md5.hashCode() : 0 );
288         result = 31 * result + ( sha1 != null ? sha1.hashCode() : 0 );
289         result = 31 * result + ( whenGathered != null ? whenGathered.hashCode() : 0 );
290         return result;
291     }
292 
293     @Override
294     public String toString()
295     {
296         return "ArtifactMetadata{" + "id='" + id + '\'' + ", size=" + size + ", version='" + version + '\'' +
297             ", fileLastModified=" + fileLastModified + ", whenGathered=" + whenGathered + ", md5='" + md5 + '\'' +
298             ", sha1='" + sha1 + '\'' + ", namespace='" + namespace + '\'' + ", project='" + project + '\'' +
299             ", projectVersion='" + projectVersion + '\'' + ", repositoryId='" + repositoryId + '\'' + '}';
300     }
301 }