View Javadoc

1   package org.apache.continuum.purge.repository.content;
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.continuum.model.repository.LocalRepository;
23  import org.apache.maven.archiva.model.ArtifactReference;
24  import org.apache.maven.archiva.model.ProjectReference;
25  import org.apache.maven.archiva.model.VersionedReference;
26  import org.apache.maven.archiva.repository.ContentNotFoundException;
27  import org.apache.maven.archiva.repository.layout.LayoutException;
28  
29  import java.io.File;
30  import java.util.Set;
31  
32  /**
33   * Taken from Archiva's ManagedRepositoryContent interface and made some few changes.
34   *
35   * @author Maria Catherine Tan
36   * @version $Id: RepositoryManagedContent.java 1372260 2012-08-13 04:29:09Z brett $
37   * @since 25 jul 07
38   */
39  public interface RepositoryManagedContent
40  {
41      /**
42       * Delete from the local repository all files / directories associated with the
43       * provided version reference.
44       *
45       * @param reference the version reference to delete.
46       * @throws ContentNotFoundException
47       */
48      public void deleteVersion( VersionedReference reference )
49          throws ContentNotFoundException;
50  
51      /**
52       * <p>
53       * Convenience method to get the repository id.
54       * </p>
55       *
56       * <p>
57       * Equivalent to calling <code>.getRepository().getId()</code>
58       * </p>
59       *
60       * @return the repository id.
61       */
62      public int getId();
63  
64      /**
65       * <p>
66       * Gather up the list of related artifacts to the ArtifactReference provided.
67       * This typically inclues the pom files, and those things with
68       * classifiers (such as doc, source code, test libs, etc...)
69       * </p>
70       *
71       * <p>
72       * <strong>NOTE:</strong> Some layouts (such as maven 1 "legacy") are not compatible with this query.
73       * </p>
74       *
75       * @param reference the reference to work off of.
76       * @return the set of ArtifactReferences for related artifacts.
77       * @throws ContentNotFoundException if the initial artifact reference does not exist within the repository.
78       * @throws LayoutException
79       */
80      public Set<ArtifactReference> getRelatedArtifacts( ArtifactReference reference )
81          throws ContentNotFoundException, LayoutException;
82  
83      /**
84       * <p>
85       * Convenience method to get the repository (on disk) root directory.
86       * </p>
87       *
88       * <p>
89       * Equivalent to calling <code>.getLocalRepository().getDirectory()</code>
90       * </p>
91       *
92       * @return the repository (on disk) root directory.
93       */
94      public String getRepoRoot();
95  
96      /**
97       * Get the local repository associated with this
98       * repository content.
99       *
100      * @return the local repository that is associated with this repository content.
101      */
102     public LocalRepository getRepository();
103 
104     /**
105      * Given a specific {@link ProjectReference}, return the list of available versions for
106      * that project reference.
107      *
108      * @param reference the project reference to work off of.
109      * @return the list of versions found for that project reference.
110      * @throws ContentNotFoundException if the project reference does not exist within the repository.
111      * @throws LayoutException
112      */
113     public Set<String> getVersions( ProjectReference reference )
114         throws ContentNotFoundException, LayoutException;
115 
116     /**
117      * <p>
118      * Given a specific {@link VersionedReference}, return the list of available versions for that
119      * versioned reference.
120      * </p>
121      *
122      * <p>
123      * <strong>NOTE:</strong> This is really only useful when working with SNAPSHOTs.
124      * </p>
125      *
126      * @param reference the versioned reference to work off of.
127      * @return the set of versions found.
128      * @throws ContentNotFoundException if the versioned reference does not exist within the repository.
129      * @throws LayoutException
130      */
131     public Set<String> getVersions( VersionedReference reference )
132         throws ContentNotFoundException, LayoutException;
133 
134     /**
135      * Set the local repository to associate with this
136      * repository content.
137      *
138      * @param repo the repository to associate with this repository content.
139      */
140     public void setRepository( LocalRepository repo );
141 
142     /**
143      * Given a repository relative path to a filename, return the {@link VersionedReference} object suitable for the path.
144      *
145      * @param path the path relative to the repository base dir for the artifact.
146      * @return the {@link ArtifactReference} representing the path.  (or null if path cannot be converted to
147      *         a {@link ArtifactReference})
148      * @throws LayoutException if there was a problem converting the path to an artifact.
149      */
150     public ArtifactReference toArtifactReference( String path )
151         throws LayoutException;
152 
153     /**
154      * Given an {@link ArtifactReference}, return the file reference to the artifact.
155      *
156      * @param reference the artifact reference to use.
157      * @return the relative path to the artifact.
158      */
159     public File toFile( ArtifactReference reference );
160 
161     /**
162      * Given a {@link ProjectReference}, return the path to the metadata for
163      * the project.
164      *
165      * @param reference the reference to use.
166      * @return the path to the metadata file, or null if no metadata is appropriate.
167      */
168     public String toMetadataPath( ProjectReference reference );
169 
170     /**
171      * Given a {@link VersionedReference}, return the path to the metadata for
172      * the specific version of the project.
173      *
174      * @param reference the reference to use.
175      * @return the path to the metadata file, or null if no metadata is appropriate.
176      */
177     public String toMetadataPath( VersionedReference reference );
178 
179     /**
180      * Given an {@link ArtifactReference}, return the relative path to the artifact.
181      *
182      * @param reference the artifact reference to use.
183      * @return the relative path to the artifact.
184      */
185     public String toPath( ArtifactReference reference );
186 }