This project has retired. For details please refer to its Attic page.
Source code
001package org.apache.archiva.metadata.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.metadata.model.ArtifactMetadata;
023import org.apache.archiva.metadata.model.MetadataFacet;
024import org.apache.archiva.metadata.model.ProjectMetadata;
025import org.apache.archiva.metadata.model.ProjectVersionMetadata;
026import org.apache.archiva.metadata.model.ProjectVersionReference;
027
028import java.util.Collection;
029import java.util.Date;
030import java.util.List;
031
032public interface MetadataRepository
033{
034    /**
035     * Update metadata for a particular project in the metadata repository, or create it if it does not already exist.
036     *
037     * @param repositoryId the repository the project is in
038     * @param project      the project metadata to create or update
039     */
040    void updateProject( String repositoryId, ProjectMetadata project )
041        throws MetadataRepositoryException;
042
043    void updateArtifact( String repositoryId, String namespace, String projectId, String projectVersion,
044                         ArtifactMetadata artifactMeta )
045        throws MetadataRepositoryException;
046
047    void updateProjectVersion( String repositoryId, String namespace, String projectId,
048                               ProjectVersionMetadata versionMetadata )
049        throws MetadataRepositoryException;
050
051    /**
052     * create the namespace in the repository. (if not exist)
053     *
054     * @param repositoryId
055     * @param namespace
056     * @throws MetadataRepositoryException
057     */
058    void updateNamespace( String repositoryId, String namespace )
059        throws MetadataRepositoryException;
060
061    List<String> getMetadataFacets( String repositoryId, String facetId )
062        throws MetadataRepositoryException;
063
064    /**
065     * @param repositoryId
066     * @param facetId
067     * @return true if the repository datas for this facetId
068     * @throws MetadataRepositoryException
069     * @since 1.4-M4
070     */
071    boolean hasMetadataFacet( String repositoryId, String facetId )
072        throws MetadataRepositoryException;
073
074    MetadataFacet getMetadataFacet( String repositoryId, String facetId, String name )
075        throws MetadataRepositoryException;
076
077    void addMetadataFacet( String repositoryId, MetadataFacet metadataFacet )
078        throws MetadataRepositoryException;
079
080    void removeMetadataFacets( String repositoryId, String facetId )
081        throws MetadataRepositoryException;
082
083    void removeMetadataFacet( String repositoryId, String facetId, String name )
084        throws MetadataRepositoryException;
085
086    /**
087     * if startTime or endTime are <code>null</code> they are not used for search
088     *
089     * @param repositoryId
090     * @param startTime    can be <code>null</code>
091     * @param endTime      can be <code>null</code>
092     * @return
093     * @throws MetadataRepositoryException
094     */
095    List<ArtifactMetadata> getArtifactsByDateRange( String repositoryId, Date startTime, Date endTime )
096        throws MetadataRepositoryException;
097
098    // TODO: remove from API, just use configuration
099    Collection<String> getRepositories()
100        throws MetadataRepositoryException;
101
102    Collection<ArtifactMetadata> getArtifactsByChecksum( String repositoryId, String checksum )
103        throws MetadataRepositoryException;
104
105    /**
106     * Get artifacts with a project version metadata key that matches the passed value.
107     *  
108     * @param key
109     * @param value
110     * @param repositoryId can be null, meaning search in all repositories
111     * @return a list of artifacts
112     * @throws MetadataRepositoryException
113     */
114    List<ArtifactMetadata> getArtifactsByProjectVersionMetadata( String key, String value, String repositoryId )
115        throws MetadataRepositoryException;
116
117    /**
118     * Get artifacts with an artifact metadata key that matches the passed value.
119     *  
120     * @param key
121     * @param value
122     * @param repositoryId can be null, meaning search in all repositories
123     * @return a list of artifacts
124     * @throws MetadataRepositoryException
125     */
126    List<ArtifactMetadata> getArtifactsByMetadata( String key, String value, String repositoryId )
127        throws MetadataRepositoryException;
128
129    /**
130     * Get artifacts with a property key that matches the passed value.
131     * Possible keys are 'scm.url', 'org.name', 'url', 'mailingList.0.name', 'license.0.name',...
132     *  
133     * @param key
134     * @param value
135     * @param repositoryId can be null, meaning search in all repositories
136     * @return a list of artifacts
137     * @throws MetadataRepositoryException
138     */
139    List<ArtifactMetadata> getArtifactsByProperty( String key, String value, String repositoryId )
140        throws MetadataRepositoryException;
141
142    void removeArtifact( String repositoryId, String namespace, String project, String version, String id )
143        throws MetadataRepositoryException;
144
145    /**
146     * used for deleting timestamped version of SNAPSHOT artifacts
147     *
148     * @param artifactMetadata the artifactMetadata with the timestamped version (2.0-20120618.214135-2)
149     * @param baseVersion      the base version of the snapshot (2.0-SNAPSHOT)
150     * @throws MetadataRepositoryException
151     * @since 1.4-M3
152     */
153    void removeArtifact( ArtifactMetadata artifactMetadata, String baseVersion )
154        throws MetadataRepositoryException;
155
156    /**
157     * FIXME need a unit test!!!
158     * Only remove {@link MetadataFacet} for the artifact
159     *
160     * @param repositoryId
161     * @param namespace
162     * @param project
163     * @param version
164     * @param metadataFacet
165     * @throws MetadataRepositoryException
166     * @since 1.4-M3
167     */
168    void removeArtifact( String repositoryId, String namespace, String project, String version,
169                         MetadataFacet metadataFacet )
170        throws MetadataRepositoryException;
171
172    /**
173     * Delete a repository's metadata. This includes all associated metadata facets.
174     *
175     * @param repositoryId the repository to delete
176     */
177    void removeRepository( String repositoryId )
178        throws MetadataRepositoryException;
179
180    /**
181     * @param repositoryId
182     * @param namespace    (groupId for maven )
183     * @throws MetadataRepositoryException
184     * @since 1.4-M3
185     */
186    void removeNamespace( String repositoryId, String namespace )
187        throws MetadataRepositoryException;
188
189    List<ArtifactMetadata> getArtifacts( String repositoryId )
190        throws MetadataRepositoryException;
191
192    /**
193     * basically just checking it exists not complete data returned
194     *
195     * @param repoId
196     * @param namespace
197     * @param projectId
198     * @return
199     * @throws MetadataResolutionException
200     */
201    ProjectMetadata getProject( String repoId, String namespace, String projectId )
202        throws MetadataResolutionException;
203
204    ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId, String projectVersion )
205        throws MetadataResolutionException;
206
207    Collection<String> getArtifactVersions( String repoId, String namespace, String projectId, String projectVersion )
208        throws MetadataResolutionException;
209
210    /**
211     * Retrieve project references from the metadata repository. Note that this is not built into the content model for
212     * a project version as a reference may be present (due to reverse-lookup of dependencies) before the actual
213     * project is, and we want to avoid adding a stub model to the content repository.
214     *
215     * @param repoId         the repository ID to look within
216     * @param namespace      the namespace of the project to get references to
217     * @param projectId      the identifier of the project to get references to
218     * @param projectVersion the version of the project to get references to
219     * @return a list of project references
220     */
221    Collection<ProjectVersionReference> getProjectReferences( String repoId, String namespace, String projectId,
222                                                              String projectVersion )
223        throws MetadataResolutionException;
224
225    Collection<String> getRootNamespaces( String repoId )
226        throws MetadataResolutionException;
227
228    /**
229     * @param repoId
230     * @param namespace
231     * @return {@link Collection} of child namespaces of the namespace argument
232     * @throws MetadataResolutionException
233     */
234    Collection<String> getNamespaces( String repoId, String namespace )
235        throws MetadataResolutionException;
236
237    /**
238     * @param repoId
239     * @param namespace
240     * @return
241     * @throws MetadataResolutionException
242     */
243    Collection<String> getProjects( String repoId, String namespace )
244        throws MetadataResolutionException;
245
246    /**
247     * @param repoId
248     * @param namespace
249     * @param projectId
250     * @return
251     * @throws MetadataResolutionException
252     */
253    Collection<String> getProjectVersions( String repoId, String namespace, String projectId )
254        throws MetadataResolutionException;
255
256    /**
257     * @param repoId
258     * @param namespace
259     * @param projectId
260     * @param projectVersion
261     * @throws MetadataRepositoryException
262     * @since 1.4-M4
263     */
264    void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion )
265        throws MetadataRepositoryException;
266
267    /**
268     * @param repoId
269     * @param namespace
270     * @param projectId
271     * @param projectVersion
272     * @return
273     * @throws MetadataResolutionException
274     */
275    Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId,
276                                               String projectVersion )
277        throws MetadataResolutionException;
278
279    /**
280     * remove a project
281     *
282     * @param repositoryId
283     * @param namespace
284     * @param projectId
285     * @throws MetadataRepositoryException
286     * @since 1.4-M4
287     */
288    void removeProject( String repositoryId, String namespace, String projectId )
289        throws MetadataRepositoryException;
290
291
292    /**
293     * <b>implementations can throw RuntimeException</b>
294     */
295    void save();
296
297
298    void close()
299        throws MetadataRepositoryException;
300
301    /**
302     * <b>implementations can throw RuntimeException</b>
303     */
304    void revert();
305
306    boolean canObtainAccess( Class<?> aClass );
307
308    <T> T obtainAccess( Class<T> aClass )
309        throws MetadataRepositoryException;
310
311    /**
312     * Full text artifacts search.
313     *  
314     * @param text
315     * @param repositoryId can be null to search in all repositories
316     * @param exact running an exact search, the value must exactly match the text.  
317     * @return a list of artifacts
318     * @throws MetadataRepositoryException
319     */
320    List<ArtifactMetadata> searchArtifacts( String text, String repositoryId, boolean exact )
321        throws MetadataRepositoryException;
322
323    /**
324     * Full text artifacts search inside the specified key.
325     *  
326     * @param key search only inside this key
327     * @param text
328     * @param repositoryId can be null to search in all repositories
329     * @param exact running an exact search, the value must exactly match the text.  
330     * @return a list of artifacts
331     * @throws MetadataRepositoryException
332     */
333    List<ArtifactMetadata> searchArtifacts( String key, String text, String repositoryId, boolean exact )
334        throws MetadataRepositoryException;
335
336}