This project has retired. For details please refer to its Attic page.
ManagedRepositoryContent xref
View Javadoc
1   package org.apache.archiva.repository;
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.archiva.admin.model.beans.ManagedRepository;
23  import org.apache.archiva.model.ArchivaArtifact;
24  import org.apache.archiva.model.ArtifactReference;
25  import org.apache.archiva.model.ProjectReference;
26  import org.apache.archiva.model.VersionedReference;
27  import org.apache.archiva.repository.layout.LayoutException;
28  
29  import java.io.File;
30  import java.util.Set;
31  
32  /**
33   * ManagedRepositoryContent interface for interacting with a managed repository in an abstract way,
34   * without the need for processing based on filesystem paths, or working with the database.
35   */
36  public interface ManagedRepositoryContent
37  {
38      /**
39       * Delete from the managed repository all files / directories associated with the
40       * provided version reference.
41       *
42       * @param reference the version reference to delete.
43       * @throws ContentNotFoundException
44       */
45      void deleteVersion( VersionedReference reference )
46          throws ContentNotFoundException;
47  
48      /**
49       * delete a specified artifact from the repository
50       *
51       * @param artifactReference
52       * @throws ContentNotFoundException
53       */
54      void deleteArtifact( ArtifactReference artifactReference )
55          throws ContentNotFoundException;
56  
57      /**
58       * @param groupId
59       * @throws ContentNotFoundException
60       * @since 1.4-M3
61       */
62      void deleteGroupId( String groupId )
63          throws ContentNotFoundException;
64  
65      /**
66       *
67       * @param namespace groupId for maven
68       * @param projectId artifactId for maven
69       * @throws ContentNotFoundException
70       */
71      void deleteProject( String namespace, String projectId )
72          throws RepositoryException;
73  
74      /**
75       * <p>
76       * Convenience method to get the repository id.
77       * </p>
78       * <p>
79       * Equivalent to calling <code>.getRepository().getId()</code>
80       * </p>
81       *
82       * @return the repository id.
83       */
84      String getId();
85  
86      /**
87       * <p>
88       * Gather up the list of related artifacts to the ArtifactReference provided.
89       * This typically inclues the pom files, and those things with
90       * classifiers (such as doc, source code, test libs, etc...)
91       * </p>
92       * <p>
93       * <strong>NOTE:</strong> Some layouts (such as maven 1 "legacy") are not compatible with this query.
94       * </p>
95       *
96       * @param reference the reference to work off of.
97       * @return the set of ArtifactReferences for related artifacts.
98       * @throws ContentNotFoundException if the initial artifact reference does not exist within the repository.
99       */
100     Set<ArtifactReference> getRelatedArtifacts( ArtifactReference reference )
101         throws ContentNotFoundException;
102 
103     /**
104      * <p>
105      * Convenience method to get the repository (on disk) root directory.
106      * </p>
107      * <p>
108      * Equivalent to calling <code>.getRepository().getLocation()</code>
109      * </p>
110      *
111      * @return the repository (on disk) root directory.
112      */
113     String getRepoRoot();
114 
115     /**
116      * Get the repository configuration associated with this
117      * repository content.
118      *
119      * @return the repository that is associated with this repository content.
120      */
121     ManagedRepository getRepository();
122 
123     /**
124      * Given a specific {@link ProjectReference}, return the list of available versions for
125      * that project reference.
126      *
127      * @param reference the project reference to work off of.
128      * @return the list of versions found for that project reference.
129      * @throws ContentNotFoundException if the project reference does nto exist within the repository.
130      * @throws LayoutException
131      */
132     Set<String> getVersions( ProjectReference reference )
133         throws ContentNotFoundException, LayoutException;
134 
135     /**
136      * <p>
137      * Given a specific {@link VersionedReference}, return the list of available versions for that
138      * versioned reference.
139      * </p>
140      * <p>
141      * <strong>NOTE:</strong> This is really only useful when working with SNAPSHOTs.
142      * </p>
143      *
144      * @param reference the versioned reference to work off of.
145      * @return the set of versions found.
146      * @throws ContentNotFoundException if the versioned reference does not exist within the repository.
147      */
148     Set<String> getVersions( VersionedReference reference )
149         throws ContentNotFoundException;
150 
151     /**
152      * Determines if the artifact referenced exists in the repository.
153      *
154      * @param reference the artifact reference to check for.
155      * @return true if the artifact referenced exists.
156      */
157     boolean hasContent( ArtifactReference reference );
158 
159     /**
160      * Determines if the project referenced exists in the repository.
161      *
162      * @param reference the project reference to check for.
163      * @return true it the project referenced exists.
164      */
165     boolean hasContent( ProjectReference reference );
166 
167     /**
168      * Determines if the version reference exists in the repository.
169      *
170      * @param reference the version reference to check for.
171      * @return true if the version referenced exists.
172      */
173     boolean hasContent( VersionedReference reference );
174 
175     /**
176      * Set the repository configuration to associate with this
177      * repository content.
178      *
179      * @param repo the repository to associate with this repository content.
180      */
181     void setRepository( ManagedRepository repo );
182 
183     /**
184      * Given a repository relative path to a filename, return the {@link VersionedReference} object suitable for the path.
185      *
186      * @param path the path relative to the repository base dir for the artifact.
187      * @return the {@link ArtifactReference} representing the path.  (or null if path cannot be converted to
188      *         a {@link ArtifactReference})
189      * @throws LayoutException if there was a problem converting the path to an artifact.
190      */
191     ArtifactReference toArtifactReference( String path )
192         throws LayoutException;
193 
194     /**
195      * Given an {@link ArtifactReference}, return the file reference to the artifact.
196      *
197      * @param reference the artifact reference to use.
198      * @return the relative path to the artifact.
199      */
200     File toFile( ArtifactReference reference );
201 
202     /**
203      * Given an {@link ArchivaArtifact}, return the file reference to the artifact.
204      *
205      * @param reference the archiva artifact to use.
206      * @return the relative path to the artifact.
207      */
208     File toFile( ArchivaArtifact reference );
209 
210     /**
211      * Given a {@link ProjectReference}, return the path to the metadata for
212      * the project.
213      *
214      * @param reference the reference to use.
215      * @return the path to the metadata file, or null if no metadata is appropriate.
216      */
217     String toMetadataPath( ProjectReference reference );
218 
219     /**
220      * Given a {@link VersionedReference}, return the path to the metadata for
221      * the specific version of the project.
222      *
223      * @param reference the reference to use.
224      * @return the path to the metadata file, or null if no metadata is appropriate.
225      */
226     String toMetadataPath( VersionedReference reference );
227 
228     /**
229      * Given an {@link ArtifactReference}, return the relative path to the artifact.
230      *
231      * @param reference the artifact reference to use.
232      * @return the relative path to the artifact.
233      */
234     String toPath( ArtifactReference reference );
235 
236     /**
237      * Given an {@link ArchivaArtifact}, return the relative path to the artifact.
238      *
239      * @param reference the archiva artifact to use.
240      * @return the relative path to the artifact.
241      */
242     String toPath( ArchivaArtifact reference );
243 }