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 extends RepositoryContent
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;
61 * @throws ContentNotFoundException
64 void deleteGroupId( String groupId )
65 throws ContentNotFoundException;
69 * @param namespace groupId for maven
70 * @param projectId artifactId for maven
71 * @throws ContentNotFoundException
73 void deleteProject( String namespace, String projectId )
74 throws RepositoryException;
78 * Convenience method to get the repository id.
81 * Equivalent to calling <code>.getRepository().getId()</code>
84 * @return the repository id.
90 * Gather up the list of related artifacts to the ArtifactReference provided.
91 * This typically inclues the pom files, and those things with
92 * classifiers (such as doc, source code, test libs, etc...)
95 * <strong>NOTE:</strong> Some layouts (such as maven 1 "legacy") are not compatible with this query.
98 * @param reference the reference to work off of.
99 * @return the set of ArtifactReferences for related artifacts.
100 * @throws ContentNotFoundException if the initial artifact reference does not exist within the repository.
102 Set<ArtifactReference> getRelatedArtifacts( ArtifactReference reference )
103 throws ContentNotFoundException;
107 * Convenience method to get the repository (on disk) root directory.
110 * Equivalent to calling <code>.getRepository().getLocation()</code>
113 * @return the repository (on disk) root directory.
115 String getRepoRoot();
118 * Get the repository configuration associated with this
119 * repository content.
121 * @return the repository that is associated with this repository content.
123 ManagedRepository getRepository();
126 * Given a specific {@link ProjectReference}, return the list of available versions for
127 * that project reference.
129 * @param reference the project reference to work off of.
130 * @return the list of versions found for that project reference.
131 * @throws ContentNotFoundException if the project reference does nto exist within the repository.
132 * @throws LayoutException
134 Set<String> getVersions( ProjectReference reference )
135 throws ContentNotFoundException, LayoutException;
139 * Given a specific {@link VersionedReference}, return the list of available versions for that
140 * versioned reference.
143 * <strong>NOTE:</strong> This is really only useful when working with SNAPSHOTs.
146 * @param reference the versioned reference to work off of.
147 * @return the set of versions found.
148 * @throws ContentNotFoundException if the versioned reference does not exist within the repository.
150 Set<String> getVersions( VersionedReference reference )
151 throws ContentNotFoundException;
154 * Determines if the artifact referenced exists in the repository.
156 * @param reference the artifact reference to check for.
157 * @return true if the artifact referenced exists.
159 boolean hasContent( ArtifactReference reference );
162 * Determines if the project referenced exists in the repository.
164 * @param reference the project reference to check for.
165 * @return true it the project referenced exists.
167 boolean hasContent( ProjectReference reference );
170 * Determines if the version reference exists in the repository.
172 * @param reference the version reference to check for.
173 * @return true if the version referenced exists.
175 boolean hasContent( VersionedReference reference );
178 * Set the repository configuration to associate with this
179 * repository content.
181 * @param repo the repository to associate with this repository content.
183 void setRepository( org.apache.archiva.repository.ManagedRepository repo );
186 * Given an {@link ArtifactReference}, return the file reference to the artifact.
188 * @param reference the artifact reference to use.
189 * @return the relative path to the artifact.
191 Path toFile( ArtifactReference reference );
194 * Given an {@link ArchivaArtifact}, return the file reference to the artifact.
196 * @param reference the archiva artifact to use.
197 * @return the relative path to the artifact.
199 Path toFile( ArchivaArtifact reference );
202 * Given a {@link ProjectReference}, return the path to the metadata for
205 * @param reference the reference to use.
206 * @return the path to the metadata file, or null if no metadata is appropriate.
208 String toMetadataPath( ProjectReference reference );
211 * Given a {@link VersionedReference}, return the path to the metadata for
212 * the specific version of the project.
214 * @param reference the reference to use.
215 * @return the path to the metadata file, or null if no metadata is appropriate.
217 String toMetadataPath( VersionedReference reference );
220 * Given an {@link ArchivaArtifact}, return the relative path to the artifact.
222 * @param reference the archiva artifact to use.
223 * @return the relative path to the artifact.
225 String toPath( ArchivaArtifact reference );