This project has retired. For details please refer to its Attic page.
SnapshotArtifactRepositoryMetadata xref
View Javadoc
1   package org.apache.archiva.converter.artifact;
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 org.apache.maven.artifact.Artifact;
23  import org.apache.maven.artifact.repository.ArtifactRepository;
24  import org.apache.maven.artifact.repository.metadata.AbstractRepositoryMetadata;
25  import org.apache.maven.artifact.repository.metadata.Snapshot;
26  
27  /**
28   *
29   * This is a copy of org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata
30   * from the maven-compat module, because this is the only class that we use from the compat module and
31   * we can get rid of the dependency.
32   *
33   * Metadata for the artifact version directory of the repository.
34   *
35   *
36   * @author <a href="mailto:brett@apache.org">Brett Porter</a>
37   *
38   */
39  public class SnapshotArtifactRepositoryMetadata
40          extends AbstractRepositoryMetadata
41  {
42      private Artifact artifact;
43  
44      public SnapshotArtifactRepositoryMetadata( Artifact artifact )
45      {
46          super( createMetadata( artifact, null ) );
47          this.artifact = artifact;
48      }
49  
50      public SnapshotArtifactRepositoryMetadata( Artifact artifact,
51                                                 Snapshot snapshot )
52      {
53          super( createMetadata( artifact, createVersioning( snapshot ) ) );
54          this.artifact = artifact;
55      }
56  
57      public boolean storedInGroupDirectory()
58      {
59          return false;
60      }
61  
62      public boolean storedInArtifactVersionDirectory()
63      {
64          return true;
65      }
66  
67      public String getGroupId()
68      {
69          return artifact.getGroupId();
70      }
71  
72      public String getArtifactId()
73      {
74          return artifact.getArtifactId();
75      }
76  
77      public String getBaseVersion()
78      {
79          return artifact.getBaseVersion();
80      }
81  
82      public Object getKey()
83      {
84          return "snapshot " + artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getBaseVersion();
85      }
86  
87      public boolean isSnapshot()
88      {
89          return artifact.isSnapshot();
90      }
91  
92      public int getNature()
93      {
94          return isSnapshot() ? SNAPSHOT : RELEASE;
95      }
96  
97      public ArtifactRepository getRepository()
98      {
99          return artifact.getRepository();
100     }
101 
102     public void setRepository( ArtifactRepository remoteRepository )
103     {
104         artifact.setRepository( remoteRepository );
105     }
106 }