1 package org.apache.archiva.metadata.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.metadata.model.ArtifactMetadata;
23 import org.apache.archiva.metadata.model.MetadataFacet;
24 import org.apache.archiva.metadata.model.ProjectMetadata;
25 import org.apache.archiva.metadata.model.ProjectVersionMetadata;
26 import org.apache.archiva.metadata.model.ProjectVersionReference;
28 import java.util.Collection;
29 import java.util.Date;
30 import java.util.List;
32 public interface MetadataRepository
35 * Update metadata for a particular project in the metadata repository, or create it if it does not already exist.
38 * @param repositoryId the repository the project is in
39 * @param project the project metadata to create or update
41 void updateProject( RepositorySession session, String repositoryId, ProjectMetadata project )
42 throws MetadataRepositoryException;
44 void updateArtifact( RepositorySession session, String repositoryId, String namespace, String projectId, String projectVersion,
45 ArtifactMetadata artifactMeta )
46 throws MetadataRepositoryException;
48 void updateProjectVersion( RepositorySession session, String repositoryId, String namespace, String projectId,
49 ProjectVersionMetadata versionMetadata )
50 throws MetadataRepositoryException;
53 * create the namespace in the repository. (if not exist)
59 * @throws MetadataRepositoryException
61 void updateNamespace( RepositorySession session, String repositoryId, String namespace )
62 throws MetadataRepositoryException;
64 List<String> getMetadataFacets( RepositorySession session, String repositoryId, String facetId )
65 throws MetadataRepositoryException;
72 * @return true if the repository datas for this facetId
73 * @throws MetadataRepositoryException
76 boolean hasMetadataFacet( RepositorySession session, String repositoryId, String facetId )
77 throws MetadataRepositoryException;
79 MetadataFacet getMetadataFacet( RepositorySession session, String repositoryId, String facetId, String name )
80 throws MetadataRepositoryException;
82 void addMetadataFacet( RepositorySession session, String repositoryId, MetadataFacet metadataFacet )
83 throws MetadataRepositoryException;
85 void removeMetadataFacets( RepositorySession session, String repositoryId, String facetId )
86 throws MetadataRepositoryException;
88 void removeMetadataFacet( RepositorySession session, String repositoryId, String facetId, String name )
89 throws MetadataRepositoryException;
92 * if startTime or endTime are <code>null</code> they are not used for search
97 * @param startTime can be <code>null</code>
98 * @param endTime can be <code>null</code>
100 * @throws MetadataRepositoryException
102 List<ArtifactMetadata> getArtifactsByDateRange( RepositorySession session, String repositoryId, Date startTime, Date endTime )
103 throws MetadataRepositoryException;
105 Collection<ArtifactMetadata> getArtifactsByChecksum( RepositorySession session, String repositoryId, String checksum )
106 throws MetadataRepositoryException;
109 * Get artifacts with a project version metadata key that matches the passed value.
115 * @param repositoryId can be null, meaning search in all repositories
116 * @return a list of artifacts
117 * @throws MetadataRepositoryException
119 List<ArtifactMetadata> getArtifactsByProjectVersionMetadata( RepositorySession session, String key, String value, String repositoryId )
120 throws MetadataRepositoryException;
123 * Get artifacts with an artifact metadata key that matches the passed value.
129 * @param repositoryId can be null, meaning search in all repositories
130 * @return a list of artifacts
131 * @throws MetadataRepositoryException
133 List<ArtifactMetadata> getArtifactsByMetadata( RepositorySession session, String key, String value, String repositoryId )
134 throws MetadataRepositoryException;
137 * Get artifacts with a property key that matches the passed value.
138 * Possible keys are 'scm.url', 'org.name', 'url', 'mailingList.0.name', 'license.0.name',...
144 * @param repositoryId can be null, meaning search in all repositories
145 * @return a list of artifacts
146 * @throws MetadataRepositoryException
148 List<ArtifactMetadata> getArtifactsByProperty( RepositorySession session, String key, String value, String repositoryId )
149 throws MetadataRepositoryException;
151 void removeArtifact( RepositorySession session, String repositoryId, String namespace, String project, String version, String id )
152 throws MetadataRepositoryException;
155 * used for deleting timestamped version of SNAPSHOT artifacts
159 * @param artifactMetadata the artifactMetadata with the timestamped version (2.0-20120618.214135-2)
160 * @param baseVersion the base version of the snapshot (2.0-SNAPSHOT)
161 * @throws MetadataRepositoryException
164 void removeArtifact( RepositorySession session, ArtifactMetadata artifactMetadata, String baseVersion )
165 throws MetadataRepositoryException;
168 * FIXME need a unit test!!!
169 * Only remove {@link MetadataFacet} for the artifact
173 * @param repositoryId
177 * @param metadataFacet
178 * @throws MetadataRepositoryException
181 void removeArtifact( RepositorySession session, String repositoryId, String namespace, String project, String version,
182 MetadataFacet metadataFacet )
183 throws MetadataRepositoryException;
186 * Delete a repository's metadata. This includes all associated metadata facets.
189 * @param repositoryId the repository to delete
191 void removeRepository( RepositorySession session, String repositoryId )
192 throws MetadataRepositoryException;
197 * @param repositoryId
198 * @param namespace (groupId for maven )
199 * @throws MetadataRepositoryException
202 void removeNamespace( RepositorySession session, String repositoryId, String namespace )
203 throws MetadataRepositoryException;
205 List<ArtifactMetadata> getArtifacts( RepositorySession session, String repositoryId )
206 throws MetadataRepositoryException;
209 * basically just checking it exists not complete data returned
217 * @throws MetadataResolutionException
219 ProjectMetadata getProject( RepositorySession session, String repoId, String namespace, String projectId )
220 throws MetadataResolutionException;
222 ProjectVersionMetadata getProjectVersion( RepositorySession session, String repoId, String namespace, String projectId, String projectVersion )
223 throws MetadataResolutionException;
225 Collection<String> getArtifactVersions( RepositorySession session, String repoId, String namespace, String projectId, String projectVersion )
226 throws MetadataResolutionException;
229 * Retrieve project references from the metadata repository. Note that this is not built into the content model for
230 * a project version as a reference may be present (due to reverse-lookup of dependencies) before the actual
231 * project is, and we want to avoid adding a stub model to the content repository.
235 * @param repoId the repository ID to look within
236 * @param namespace the namespace of the project to get references to
237 * @param projectId the identifier of the project to get references to
238 * @param projectVersion the version of the project to get references to
239 * @return a list of project references
241 Collection<ProjectVersionReference> getProjectReferences( RepositorySession session, String repoId, String namespace, String projectId,
242 String projectVersion )
243 throws MetadataResolutionException;
245 Collection<String> getRootNamespaces( RepositorySession session, String repoId )
246 throws MetadataResolutionException;
253 * @return {@link Collection} of child namespaces of the namespace argument
254 * @throws MetadataResolutionException
256 Collection<String> getNamespaces( RepositorySession session, String repoId, String namespace )
257 throws MetadataResolutionException;
265 * @throws MetadataResolutionException
267 Collection<String> getProjects( RepositorySession session, String repoId, String namespace )
268 throws MetadataResolutionException;
277 * @throws MetadataResolutionException
279 Collection<String> getProjectVersions( RepositorySession session, String repoId, String namespace, String projectId )
280 throws MetadataResolutionException;
288 * @param projectVersion
289 * @throws MetadataRepositoryException
292 void removeProjectVersion( RepositorySession session, String repoId, String namespace, String projectId, String projectVersion )
293 throws MetadataRepositoryException;
301 * @param projectVersion
303 * @throws MetadataResolutionException
305 Collection<ArtifactMetadata> getArtifacts( RepositorySession session, String repoId, String namespace, String projectId,
306 String projectVersion )
307 throws MetadataResolutionException;
314 * @param repositoryId
317 * @throws MetadataRepositoryException
320 void removeProject( RepositorySession session, String repositoryId, String namespace, String projectId )
321 throws MetadataRepositoryException;
325 throws MetadataRepositoryException;
328 boolean canObtainAccess( Class<?> aClass );
330 <T> T obtainAccess( RepositorySession session, Class<T> aClass )
331 throws MetadataRepositoryException;
334 * Full text artifacts search.
338 * @param repositoryId can be null to search in all repositories
340 * @param exact running an exact search, the value must exactly match the text.
341 * @return a list of artifacts
342 * @throws MetadataRepositoryException
344 List<ArtifactMetadata> searchArtifacts( RepositorySession session, String repositoryId, String text, boolean exact )
345 throws MetadataRepositoryException;
348 * Full text artifacts search inside the specified key.
352 * @param repositoryId can be null to search in all repositories
353 * @param key search only inside this key
355 * @param exact running an exact search, the value must exactly match the text.
356 * @return a list of artifacts
357 * @throws MetadataRepositoryException
359 List<ArtifactMetadata> searchArtifacts( RepositorySession session, String repositoryId, String key, String text, boolean exact )
360 throws MetadataRepositoryException;