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.

MavenArtifactFacet.java 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. package org.apache.archiva.metadata.model.maven2;
  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 org.apache.archiva.metadata.model.MetadataFacet;
  21. import org.apache.commons.lang.StringUtils;
  22. import java.util.HashMap;
  23. import java.util.Map;
  24. public class MavenArtifactFacet
  25. implements MetadataFacet
  26. {
  27. private String classifier;
  28. private String type;
  29. private String timestamp;
  30. private int buildNumber;
  31. public static final String FACET_ID = "org.apache.archiva.metadata.repository.storage.maven2.artifact";
  32. public String getClassifier()
  33. {
  34. return classifier;
  35. }
  36. public void setClassifier( String classifier )
  37. {
  38. this.classifier = classifier;
  39. }
  40. public String getType()
  41. {
  42. return type;
  43. }
  44. public void setType( String type )
  45. {
  46. this.type = type;
  47. }
  48. public String getTimestamp()
  49. {
  50. return timestamp;
  51. }
  52. public void setTimestamp( String timestamp )
  53. {
  54. this.timestamp = timestamp;
  55. }
  56. public int getBuildNumber()
  57. {
  58. return buildNumber;
  59. }
  60. public void setBuildNumber( int buildNumber )
  61. {
  62. this.buildNumber = buildNumber;
  63. }
  64. @Override
  65. public String getFacetId()
  66. {
  67. return FACET_ID;
  68. }
  69. @Override
  70. public String getName()
  71. {
  72. // TODO: not needed, perhaps artifact/version metadata facet should be separate interface?
  73. return null;
  74. }
  75. @Override
  76. public Map<String, String> toProperties()
  77. {
  78. Map<String, String> properties = new HashMap<>();
  79. properties.put( "type", type );
  80. if ( classifier != null )
  81. {
  82. properties.put( "classifier", classifier );
  83. }
  84. if ( timestamp != null )
  85. {
  86. properties.put( "timestamp", timestamp );
  87. }
  88. if ( buildNumber > 0 )
  89. {
  90. properties.put( "buildNumber", Integer.toString( buildNumber ) );
  91. }
  92. return properties;
  93. }
  94. @Override
  95. public void fromProperties( Map<String, String> properties )
  96. {
  97. type = properties.get( "type" );
  98. classifier = properties.get( "classifier" );
  99. timestamp = properties.get( "timestamp" );
  100. String buildNumber = properties.get( "buildNumber" );
  101. if ( buildNumber != null )
  102. {
  103. this.buildNumber = Integer.parseInt( buildNumber );
  104. }
  105. }
  106. @Override
  107. public boolean equals( Object o )
  108. {
  109. if ( this == o )
  110. {
  111. return true;
  112. }
  113. if ( !( o instanceof MavenArtifactFacet ) )
  114. {
  115. return false;
  116. }
  117. MavenArtifactFacet that = (MavenArtifactFacet) o;
  118. return StringUtils.equals( that.getClassifier(), this.classifier );
  119. }
  120. }