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.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.layout.LayoutException;
28 import java.nio.file.Path;
32 * ManagedRepositoryContent interface for interacting with a managed repository in an abstract way,
33 * without the need for processing based on filesystem paths, or working with the database.
35 public interface ManagedRepositoryContent
38 * Delete from the managed repository all files / directories associated with the
39 * provided version reference.
41 * @param reference the version reference to delete.
42 * @throws ContentNotFoundException
44 void deleteVersion( VersionedReference reference )
45 throws ContentNotFoundException;
48 * delete a specified artifact from the repository
50 * @param artifactReference
51 * @throws ContentNotFoundException
53 void deleteArtifact( ArtifactReference artifactReference )
54 throws ContentNotFoundException;
58 * @throws ContentNotFoundException
61 void deleteGroupId( String groupId )
62 throws ContentNotFoundException;
66 * @param namespace groupId for maven
67 * @param projectId artifactId for maven
68 * @throws ContentNotFoundException
70 void deleteProject( String namespace, String projectId )
71 throws RepositoryException;
75 * Convenience method to get the repository id.
78 * Equivalent to calling <code>.getRepository().getId()</code>
81 * @return the repository id.
87 * Gather up the list of related artifacts to the ArtifactReference provided.
88 * This typically inclues the pom files, and those things with
89 * classifiers (such as doc, source code, test libs, etc...)
92 * <strong>NOTE:</strong> Some layouts (such as maven 1 "legacy") are not compatible with this query.
95 * @param reference the reference to work off of.
96 * @return the set of ArtifactReferences for related artifacts.
97 * @throws ContentNotFoundException if the initial artifact reference does not exist within the repository.
99 Set<ArtifactReference> getRelatedArtifacts( ArtifactReference reference )
100 throws ContentNotFoundException;
104 * Convenience method to get the repository (on disk) root directory.
107 * Equivalent to calling <code>.getRepository().getLocation()</code>
110 * @return the repository (on disk) root directory.
112 String getRepoRoot();
115 * Get the repository configuration associated with this
116 * repository content.
118 * @return the repository that is associated with this repository content.
120 org.apache.archiva.repository.ManagedRepository getRepository();
123 * Given a specific {@link ProjectReference}, return the list of available versions for
124 * that project reference.
126 * @param reference the project reference to work off of.
127 * @return the list of versions found for that project reference.
128 * @throws ContentNotFoundException if the project reference does nto exist within the repository.
129 * @throws LayoutException
131 Set<String> getVersions( ProjectReference reference )
132 throws ContentNotFoundException, LayoutException;
136 * Given a specific {@link VersionedReference}, return the list of available versions for that
137 * versioned reference.
140 * <strong>NOTE:</strong> This is really only useful when working with SNAPSHOTs.
143 * @param reference the versioned reference to work off of.
144 * @return the set of versions found.
145 * @throws ContentNotFoundException if the versioned reference does not exist within the repository.
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( org.apache.archiva.repository.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 Path 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 Path 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 );