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;
52 * Convenience method to get the repository id.
56 * Equivalent to calling <code>.getRepository().getId()</code>
59 * @return the repository id.
65 * Gather up the list of related artifacts to the ArtifactReference provided.
66 * This typically inclues the pom files, and those things with
67 * classifiers (such as doc, source code, test libs, etc...)
71 * <strong>NOTE:</strong> Some layouts (such as maven 1 "legacy") are not compatible with this query.
74 * @param reference the reference to work off of.
75 * @return the set of ArtifactReferences for related artifacts.
76 * @throws ContentNotFoundException if the initial artifact reference does not exist within the repository.
77 * @throws LayoutException
79 Set<ArtifactReference> getRelatedArtifacts( ArtifactReference reference )
80 throws ContentNotFoundException;
84 * Convenience method to get the repository (on disk) root directory.
88 * Equivalent to calling <code>.getRepository().getLocation()</code>
91 * @return the repository (on disk) root directory.
96 * Get the repository configuration associated with this
99 * @return the repository that is associated with this repository content.
101 ManagedRepository getRepository();
104 * Given a specific {@link ProjectReference}, return the list of available versions for
105 * that project reference.
107 * @param reference the project reference to work off of.
108 * @return the list of versions found for that project reference.
109 * @throws ContentNotFoundException if the project reference does nto exist within the repository.
110 * @throws LayoutException
112 Set<String> getVersions( ProjectReference reference )
113 throws ContentNotFoundException, LayoutException;
117 * Given a specific {@link VersionedReference}, return the list of available versions for that
118 * versioned reference.
122 * <strong>NOTE:</strong> This is really only useful when working with SNAPSHOTs.
125 * @param reference the versioned reference to work off of.
126 * @return the set of versions found.
127 * @throws ContentNotFoundException if the versioned reference does not exist within the repository.
128 * @throws LayoutException
130 Set<String> getVersions( VersionedReference reference )
131 throws ContentNotFoundException;
134 * Determines if the artifact referenced exists in the repository.
136 * @param reference the artifact reference to check for.
137 * @return true if the artifact referenced exists.
139 boolean hasContent( ArtifactReference reference );
142 * Determines if the project referenced exists in the repository.
144 * @param reference the project reference to check for.
145 * @return true it the project referenced exists.
147 boolean hasContent( ProjectReference reference );
150 * Determines if the version reference exists in the repository.
152 * @param reference the version reference to check for.
153 * @return true if the version referenced exists.
155 boolean hasContent( VersionedReference reference );
158 * Set the repository configuration to associate with this
159 * repository content.
161 * @param repo the repository to associate with this repository content.
163 void setRepository( ManagedRepository repo );
166 * Given a repository relative path to a filename, return the {@link VersionedReference} object suitable for the path.
168 * @param path the path relative to the repository base dir for the artifact.
169 * @return the {@link ArtifactReference} representing the path. (or null if path cannot be converted to
170 * a {@link ArtifactReference})
171 * @throws LayoutException if there was a problem converting the path to an artifact.
173 ArtifactReference toArtifactReference( String path )
174 throws LayoutException;
177 * Given an {@link ArtifactReference}, return the file reference to the artifact.
179 * @param reference the artifact reference to use.
180 * @return the relative path to the artifact.
182 File toFile( ArtifactReference reference );
185 * Given an {@link ArchivaArtifact}, return the file reference to the artifact.
187 * @param reference the archiva artifact to use.
188 * @return the relative path to the artifact.
190 File toFile( ArchivaArtifact reference );
193 * Given a {@link ProjectReference}, return the path to the metadata for
196 * @param reference the reference to use.
197 * @return the path to the metadata file, or null if no metadata is appropriate.
199 String toMetadataPath( ProjectReference reference );
202 * Given a {@link VersionedReference}, return the path to the metadata for
203 * the specific version of the project.
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( VersionedReference reference );
211 * Given an {@link ArtifactReference}, return the relative path to the artifact.
213 * @param reference the artifact reference to use.
214 * @return the relative path to the artifact.
216 String toPath( ArtifactReference reference );
219 * Given an {@link ArchivaArtifact}, return the relative path to the artifact.
221 * @param reference the archiva artifact to use.
222 * @return the relative path to the artifact.
224 String toPath( ArchivaArtifact reference );