This project has retired. For details please refer to its Attic page.
Source code
001package org.apache.archiva.repository;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *  http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import org.apache.archiva.admin.model.beans.ManagedRepository;
023import org.apache.archiva.model.ArchivaArtifact;
024import org.apache.archiva.model.ArtifactReference;
025import org.apache.archiva.model.ProjectReference;
026import org.apache.archiva.model.VersionedReference;
027import org.apache.archiva.repository.layout.LayoutException;
028
029import java.io.File;
030import java.util.Set;
031
032/**
033 * ManagedRepositoryContent interface for interacting with a managed repository in an abstract way,
034 * without the need for processing based on filesystem paths, or working with the database.
035 */
036public interface ManagedRepositoryContent
037{
038    /**
039     * Delete from the managed repository all files / directories associated with the
040     * provided version reference.
041     *
042     * @param reference the version reference to delete.
043     * @throws ContentNotFoundException
044     */
045    void deleteVersion( VersionedReference reference )
046        throws ContentNotFoundException;
047
048    /**
049     * delete a specified artifact from the repository
050     *
051     * @param artifactReference
052     * @throws ContentNotFoundException
053     */
054    void deleteArtifact( ArtifactReference artifactReference )
055        throws ContentNotFoundException;
056
057    /**
058     * @param groupId
059     * @throws ContentNotFoundException
060     * @since 1.4-M3
061     */
062    void deleteGroupId( String groupId )
063        throws ContentNotFoundException;
064
065    /**
066     *
067     * @param namespace groupId for maven
068     * @param projectId artifactId for maven
069     * @throws ContentNotFoundException
070     */
071    void deleteProject( String namespace, String projectId )
072        throws RepositoryException;
073
074    /**
075     * <p>
076     * Convenience method to get the repository id.
077     * </p>
078     * <p>
079     * Equivalent to calling <code>.getRepository().getId()</code>
080     * </p>
081     *
082     * @return the repository id.
083     */
084    String getId();
085
086    /**
087     * <p>
088     * Gather up the list of related artifacts to the ArtifactReference provided.
089     * This typically inclues the pom files, and those things with
090     * classifiers (such as doc, source code, test libs, etc...)
091     * </p>
092     * <p>
093     * <strong>NOTE:</strong> Some layouts (such as maven 1 "legacy") are not compatible with this query.
094     * </p>
095     *
096     * @param reference the reference to work off of.
097     * @return the set of ArtifactReferences for related artifacts.
098     * @throws ContentNotFoundException if the initial artifact reference does not exist within the repository.
099     */
100    Set<ArtifactReference> getRelatedArtifacts( ArtifactReference reference )
101        throws ContentNotFoundException;
102
103    /**
104     * <p>
105     * Convenience method to get the repository (on disk) root directory.
106     * </p>
107     * <p>
108     * Equivalent to calling <code>.getRepository().getLocation()</code>
109     * </p>
110     *
111     * @return the repository (on disk) root directory.
112     */
113    String getRepoRoot();
114
115    /**
116     * Get the repository configuration associated with this
117     * repository content.
118     *
119     * @return the repository that is associated with this repository content.
120     */
121    ManagedRepository getRepository();
122
123    /**
124     * Given a specific {@link ProjectReference}, return the list of available versions for
125     * that project reference.
126     *
127     * @param reference the project reference to work off of.
128     * @return the list of versions found for that project reference.
129     * @throws ContentNotFoundException if the project reference does nto exist within the repository.
130     * @throws LayoutException
131     */
132    Set<String> getVersions( ProjectReference reference )
133        throws ContentNotFoundException, LayoutException;
134
135    /**
136     * <p>
137     * Given a specific {@link VersionedReference}, return the list of available versions for that
138     * versioned reference.
139     * </p>
140     * <p>
141     * <strong>NOTE:</strong> This is really only useful when working with SNAPSHOTs.
142     * </p>
143     *
144     * @param reference the versioned reference to work off of.
145     * @return the set of versions found.
146     * @throws ContentNotFoundException if the versioned reference does not exist within the repository.
147     */
148    Set<String> getVersions( VersionedReference reference )
149        throws ContentNotFoundException;
150
151    /**
152     * Determines if the artifact referenced exists in the repository.
153     *
154     * @param reference the artifact reference to check for.
155     * @return true if the artifact referenced exists.
156     */
157    boolean hasContent( ArtifactReference reference );
158
159    /**
160     * Determines if the project referenced exists in the repository.
161     *
162     * @param reference the project reference to check for.
163     * @return true it the project referenced exists.
164     */
165    boolean hasContent( ProjectReference reference );
166
167    /**
168     * Determines if the version reference exists in the repository.
169     *
170     * @param reference the version reference to check for.
171     * @return true if the version referenced exists.
172     */
173    boolean hasContent( VersionedReference reference );
174
175    /**
176     * Set the repository configuration to associate with this
177     * repository content.
178     *
179     * @param repo the repository to associate with this repository content.
180     */
181    void setRepository( ManagedRepository repo );
182
183    /**
184     * Given a repository relative path to a filename, return the {@link VersionedReference} object suitable for the path.
185     *
186     * @param path the path relative to the repository base dir for the artifact.
187     * @return the {@link ArtifactReference} representing the path.  (or null if path cannot be converted to
188     *         a {@link ArtifactReference})
189     * @throws LayoutException if there was a problem converting the path to an artifact.
190     */
191    ArtifactReference toArtifactReference( String path )
192        throws LayoutException;
193
194    /**
195     * Given an {@link ArtifactReference}, return the file reference to the artifact.
196     *
197     * @param reference the artifact reference to use.
198     * @return the relative path to the artifact.
199     */
200    File toFile( ArtifactReference reference );
201
202    /**
203     * Given an {@link ArchivaArtifact}, return the file reference to the artifact.
204     *
205     * @param reference the archiva artifact to use.
206     * @return the relative path to the artifact.
207     */
208    File toFile( ArchivaArtifact reference );
209
210    /**
211     * Given a {@link ProjectReference}, return the path to the metadata for
212     * the project.
213     *
214     * @param reference the reference to use.
215     * @return the path to the metadata file, or null if no metadata is appropriate.
216     */
217    String toMetadataPath( ProjectReference reference );
218
219    /**
220     * Given a {@link VersionedReference}, return the path to the metadata for
221     * the specific version of the project.
222     *
223     * @param reference the reference to use.
224     * @return the path to the metadata file, or null if no metadata is appropriate.
225     */
226    String toMetadataPath( VersionedReference reference );
227
228    /**
229     * Given an {@link ArtifactReference}, return the relative path to the artifact.
230     *
231     * @param reference the artifact reference to use.
232     * @return the relative path to the artifact.
233     */
234    String toPath( ArtifactReference reference );
235
236    /**
237     * Given an {@link ArchivaArtifact}, return the relative path to the artifact.
238     *
239     * @param reference the archiva artifact to use.
240     * @return the relative path to the artifact.
241     */
242    String toPath( ArchivaArtifact reference );
243}