You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ArtifactMetadata.java 8.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. package org.apache.archiva.metadata.model;
  2. /*
  3. * Licensed to the Apache Software Foundation (ASF) under one
  4. * or more contributor license agreements. See the NOTICE file
  5. * distributed with this work for additional information
  6. * regarding copyright ownership. The ASF licenses this file
  7. * to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance
  9. * with the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing,
  14. * software distributed under the License is distributed on an
  15. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16. * KIND, either express or implied. See the License for the
  17. * specific language governing permissions and limitations
  18. * under the License.
  19. */
  20. import javax.xml.bind.annotation.XmlRootElement;
  21. import java.util.Date;
  22. /**
  23. * Metadata stored in the content repository for a particular artifact. Information that is shared between different
  24. * artifacts of a given project version can be found in the
  25. * {@link org.apache.archiva.metadata.model.ProjectVersionMetadata} class. The metadata is faceted to store information
  26. * about particular types of artifacts, for example Maven 2.x artifact specific information.
  27. * For more information, see the
  28. * <a href="{@docRoot}/../metadata-content-model.html" target="_top">Metadata Content Model</a>.
  29. */
  30. @XmlRootElement ( name = "artifactMetadata" )
  31. public class ArtifactMetadata
  32. extends FacetedMetadata
  33. {
  34. /**
  35. * The artifact ID uniquely identifies an artifact within a given namespace, project and project version. For
  36. * example, <tt>archiva-1.4-20100201.345612-2.jar</tt>
  37. */
  38. private String id;
  39. /**
  40. * The repository that the artifact is stored in within the content repository.
  41. */
  42. private String repositoryId;
  43. /**
  44. * The namespace of the project within the repository.
  45. *
  46. * @see org.apache.archiva.metadata.model.ProjectMetadata#namespace
  47. */
  48. private String namespace;
  49. /**
  50. * The identifier of the project within the repository and namespace.
  51. *
  52. * @see org.apache.archiva.metadata.model.ProjectMetadata#id
  53. */
  54. private String project;
  55. /**
  56. * The version of the project. This may be more generalised than @{link #version}.
  57. *
  58. * @see org.apache.archiva.metadata.model.ProjectVersionMetadata#id
  59. */
  60. private String projectVersion;
  61. /**
  62. * The artifact version, if different from the project version. Note that the metadata does not do any calculation
  63. * of this based on the project version - the calling code must be sure to set and check it appropriately if
  64. * <tt>null</tt>.
  65. */
  66. private String version;
  67. /**
  68. * The last modified date of the artifact file, if known.
  69. */
  70. private Date fileLastModified;
  71. /**
  72. * The file size of the artifact, if known.
  73. */
  74. private long size;
  75. /**
  76. * The MD5 checksum of the artifact, if calculated.
  77. */
  78. private String md5;
  79. /**
  80. * The SHA-1 checksum of the artifact, if calculated.
  81. */
  82. private String sha1;
  83. /**
  84. * When the artifact was found in the repository storage and added to the metadata content repository.
  85. */
  86. private Date whenGathered;
  87. public String getId()
  88. {
  89. return id;
  90. }
  91. public void setId( String id )
  92. {
  93. this.id = id;
  94. }
  95. public long getSize()
  96. {
  97. return size;
  98. }
  99. public void setSize( long size )
  100. {
  101. this.size = size;
  102. }
  103. public String getVersion()
  104. {
  105. return version;
  106. }
  107. public void setVersion( String version )
  108. {
  109. this.version = version;
  110. }
  111. public String getProjectVersion()
  112. {
  113. return projectVersion;
  114. }
  115. public void setProjectVersion( String projectVersion )
  116. {
  117. this.projectVersion = projectVersion;
  118. }
  119. public void setFileLastModified( long fileLastModified )
  120. {
  121. this.fileLastModified = new Date( fileLastModified );
  122. }
  123. public void setWhenGathered( Date whenGathered )
  124. {
  125. this.whenGathered = whenGathered;
  126. }
  127. public void setMd5( String md5 )
  128. {
  129. this.md5 = md5;
  130. }
  131. public void setSha1( String sha1 )
  132. {
  133. this.sha1 = sha1;
  134. }
  135. public Date getWhenGathered()
  136. {
  137. return whenGathered;
  138. }
  139. public String getMd5()
  140. {
  141. return md5;
  142. }
  143. public String getSha1()
  144. {
  145. return sha1;
  146. }
  147. public Date getFileLastModified()
  148. {
  149. return fileLastModified;
  150. }
  151. public String getNamespace()
  152. {
  153. return namespace;
  154. }
  155. public void setNamespace( String namespace )
  156. {
  157. this.namespace = namespace;
  158. }
  159. public void setProject( String project )
  160. {
  161. this.project = project;
  162. }
  163. public String getProject()
  164. {
  165. return project;
  166. }
  167. public String getRepositoryId()
  168. {
  169. return repositoryId;
  170. }
  171. public void setRepositoryId( String repositoryId )
  172. {
  173. this.repositoryId = repositoryId;
  174. }
  175. @Override
  176. public boolean equals( Object o )
  177. {
  178. if ( this == o )
  179. {
  180. return true;
  181. }
  182. if ( o == null || getClass() != o.getClass() )
  183. {
  184. return false;
  185. }
  186. ArtifactMetadata that = (ArtifactMetadata) o;
  187. if ( size != that.size )
  188. {
  189. return false;
  190. }
  191. if ( fileLastModified != null
  192. ? !fileLastModified.equals( that.fileLastModified )
  193. : that.fileLastModified != null )
  194. {
  195. return false;
  196. }
  197. if ( !id.equals( that.id ) )
  198. {
  199. return false;
  200. }
  201. if ( md5 != null ? !md5.equals( that.md5 ) : that.md5 != null )
  202. {
  203. return false;
  204. }
  205. if ( namespace != null ? !namespace.equals( that.namespace ) : that.namespace != null )
  206. {
  207. return false;
  208. }
  209. if ( project != null ? !project.equals( that.project ) : that.project != null )
  210. {
  211. return false;
  212. }
  213. if ( projectVersion != null ? !projectVersion.equals( that.projectVersion ) : that.projectVersion != null )
  214. {
  215. return false;
  216. }
  217. /**
  218. * We cannot compare in different repositories, if this is in here
  219. if ( !repositoryId.equals( that.repositoryId ) )
  220. {
  221. return false;
  222. }
  223. **/
  224. if ( sha1 != null ? !sha1.equals( that.sha1 ) : that.sha1 != null )
  225. {
  226. return false;
  227. }
  228. if ( version != null ? !version.equals( that.version ) : that.version != null )
  229. {
  230. return false;
  231. }
  232. if ( whenGathered != null ? !whenGathered.equals( that.whenGathered ) : that.whenGathered != null )
  233. {
  234. return false;
  235. }
  236. return true;
  237. }
  238. @Override
  239. public int hashCode()
  240. {
  241. int result = id != null ? id.hashCode() : 0;
  242. result = 31 * result + ( repositoryId != null ? repositoryId.hashCode() : 0 );
  243. result = 31 * result + ( namespace != null ? namespace.hashCode() : 0 );
  244. result = 31 * result + ( project != null ? project.hashCode() : 0 );
  245. result = 31 * result + ( projectVersion != null ? projectVersion.hashCode() : 0 );
  246. result = 31 * result + ( version != null ? version.hashCode() : 0 );
  247. result = 31 * result + ( fileLastModified != null ? fileLastModified.hashCode() : 0 );
  248. result = 31 * result + (int) ( size ^ ( size >>> 32 ) );
  249. result = 31 * result + ( md5 != null ? md5.hashCode() : 0 );
  250. result = 31 * result + ( sha1 != null ? sha1.hashCode() : 0 );
  251. result = 31 * result + ( whenGathered != null ? whenGathered.hashCode() : 0 );
  252. return result;
  253. }
  254. @Override
  255. public String toString()
  256. {
  257. return "ArtifactMetadata{" + "id='" + id + '\'' + ", size=" + size + ", version='" + version + '\'' +
  258. ", fileLastModified=" + fileLastModified + ", whenGathered=" + whenGathered + ", md5='" + md5 + '\'' +
  259. ", sha1='" + sha1 + '\'' + ", namespace='" + namespace + '\'' + ", project='" + project + '\'' +
  260. ", projectVersion='" + projectVersion + '\'' + ", repositoryId='" + repositoryId + '\'' + '}';
  261. }
  262. }