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