1 package org.apache.archiva.repository;
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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
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;
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.
38 public interface ManagedRepositoryContent
41 * Delete from the managed repository all files / directories associated with the
42 * provided version reference.
44 * @param reference the version reference to delete.
45 * @throws ContentNotFoundException
47 void deleteVersion( VersionedReference reference )
48 throws ContentNotFoundException;
51 * delete a specified artifact from the repository
53 * @param artifactReference
54 * @throws ContentNotFoundException
56 void deleteArtifact( ArtifactReference artifactReference )
57 throws ContentNotFoundException;
62 * @throws ContentNotFoundException
64 void deleteGroupId( String groupId )
65 throws ContentNotFoundException;
69 * Convenience method to get the repository id.
73 * Equivalent to calling <code>.getRepository().getId()</code>
76 * @return the repository id.
82 * Gather up the list of related artifacts to the ArtifactReference provided.
83 * This typically inclues the pom files, and those things with
84 * classifiers (such as doc, source code, test libs, etc...)
88 * <strong>NOTE:</strong> Some layouts (such as maven 1 "legacy") are not compatible with this query.
91 * @param reference the reference to work off of.
92 * @return the set of ArtifactReferences for related artifacts.
93 * @throws ContentNotFoundException if the initial artifact reference does not exist within the repository.
94 * @throws LayoutException
96 Set<ArtifactReference> getRelatedArtifacts( ArtifactReference reference )
97 throws ContentNotFoundException;
101 * Convenience method to get the repository (on disk) root directory.
105 * Equivalent to calling <code>.getRepository().getLocation()</code>
108 * @return the repository (on disk) root directory.
110 String getRepoRoot();
113 * Get the repository configuration associated with this
114 * repository content.
116 * @return the repository that is associated with this repository content.
118 ManagedRepository getRepository();
121 * Given a specific {@link ProjectReference}, return the list of available versions for
122 * that project reference.
124 * @param reference the project reference to work off of.
125 * @return the list of versions found for that project reference.
126 * @throws ContentNotFoundException if the project reference does nto exist within the repository.
127 * @throws LayoutException
129 Set<String> getVersions( ProjectReference reference )
130 throws ContentNotFoundException, LayoutException;
134 * Given a specific {@link VersionedReference}, return the list of available versions for that
135 * versioned reference.
139 * <strong>NOTE:</strong> This is really only useful when working with SNAPSHOTs.
142 * @param reference the versioned reference to work off of.
143 * @return the set of versions found.
144 * @throws ContentNotFoundException if the versioned reference does not exist within the repository.
145 * @throws LayoutException
147 Set<String> getVersions( VersionedReference reference )
148 throws ContentNotFoundException;
151 * Determines if the artifact referenced exists in the repository.
153 * @param reference the artifact reference to check for.
154 * @return true if the artifact referenced exists.
156 boolean hasContent( ArtifactReference reference );
159 * Determines if the project referenced exists in the repository.
161 * @param reference the project reference to check for.
162 * @return true it the project referenced exists.
164 boolean hasContent( ProjectReference reference );
167 * Determines if the version reference exists in the repository.
169 * @param reference the version reference to check for.
170 * @return true if the version referenced exists.
172 boolean hasContent( VersionedReference reference );
175 * Set the repository configuration to associate with this
176 * repository content.
178 * @param repo the repository to associate with this repository content.
180 void setRepository( ManagedRepository repo );
183 * Given a repository relative path to a filename, return the {@link VersionedReference} object suitable for the path.
185 * @param path the path relative to the repository base dir for the artifact.
186 * @return the {@link ArtifactReference} representing the path. (or null if path cannot be converted to
187 * a {@link ArtifactReference})
188 * @throws LayoutException if there was a problem converting the path to an artifact.
190 ArtifactReference toArtifactReference( String path )
191 throws LayoutException;
194 * Given an {@link ArtifactReference}, return the file reference to the artifact.
196 * @param reference the artifact reference to use.
197 * @return the relative path to the artifact.
199 File toFile( ArtifactReference reference );
202 * Given an {@link ArchivaArtifact}, return the file reference to the artifact.
204 * @param reference the archiva artifact to use.
205 * @return the relative path to the artifact.
207 File toFile( ArchivaArtifact reference );
210 * Given a {@link ProjectReference}, return the path to the metadata for
213 * @param reference the reference to use.
214 * @return the path to the metadata file, or null if no metadata is appropriate.
216 String toMetadataPath( ProjectReference reference );
219 * Given a {@link VersionedReference}, return the path to the metadata for
220 * the specific version of the project.
222 * @param reference the reference to use.
223 * @return the path to the metadata file, or null if no metadata is appropriate.
225 String toMetadataPath( VersionedReference reference );
228 * Given an {@link ArtifactReference}, return the relative path to the artifact.
230 * @param reference the artifact reference to use.
231 * @return the relative path to the artifact.
233 String toPath( ArtifactReference reference );
236 * Given an {@link ArchivaArtifact}, return the relative path to the artifact.
238 * @param reference the archiva artifact to use.
239 * @return the relative path to the artifact.
241 String toPath( ArchivaArtifact reference );