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