1package org.apache.archiva.metadata.repository;
23/*4 * Licensed to the Apache Software Foundation (ASF) under one5 * or more contributor license agreements. See the NOTICE file6 * distributed with this work for additional information7 * regarding copyright ownership. The ASF licenses this file8 * to you under the Apache License, Version 2.0 (the9 * "License"); you may not use this file except in compliance10 * with the License. You may obtain a copy of the License at11 *12 * http://www.apache.org/licenses/LICENSE-2.013 *14 * Unless required by applicable law or agreed to in writing,15 * software distributed under the License is distributed on an16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY17 * KIND, either express or implied. See the License for the18 * specific language governing permissions and limitations19 * under the License.20 */2122import org.apache.archiva.metadata.model.ArtifactMetadata;
23import org.apache.archiva.metadata.model.MetadataFacet;
24import org.apache.archiva.metadata.model.ProjectMetadata;
25import org.apache.archiva.metadata.model.ProjectVersionMetadata;
26import org.apache.archiva.metadata.model.ProjectVersionReference;
2728import java.util.Collection;
29import java.util.Date;
30import java.util.List;
3132publicinterfaceMetadataRepository33 {
34/**35 * Update metadata for a particular project in the metadata repository, or create it if it does not already exist.36 *37 * @param repositoryId the repository the project is in38 * @param project the project metadata to create or update39 */40void updateProject( String repositoryId, ProjectMetadata project )
41throws MetadataRepositoryException;
4243void updateArtifact( String repositoryId, String namespace, String projectId, String projectVersion,
44ArtifactMetadata artifactMeta )
45throws MetadataRepositoryException;
4647void updateProjectVersion( String repositoryId, String namespace, String projectId,
48ProjectVersionMetadata versionMetadata )
49throws MetadataRepositoryException;
5051/**52 * create the namespace in the repository. (if not exist)53 *54 * @param repositoryId55 * @param namespace56 * @throws MetadataRepositoryException57 */58void updateNamespace( String repositoryId, String namespace )
59throws MetadataRepositoryException;
6061 List<String> getMetadataFacets( String repositoryId, String facetId )
62throws MetadataRepositoryException;
6364/**65 * @param repositoryId66 * @param facetId67 * @return true if the repository datas for this facetId68 * @throws MetadataRepositoryException69 * @since 1.4-M470 */71boolean hasMetadataFacet( String repositoryId, String facetId )
72throws MetadataRepositoryException;
7374MetadataFacet getMetadataFacet( String repositoryId, String facetId, String name )
75throws MetadataRepositoryException;
7677void addMetadataFacet( String repositoryId, MetadataFacet metadataFacet )
78throws MetadataRepositoryException;
7980void removeMetadataFacets( String repositoryId, String facetId )
81throws MetadataRepositoryException;
8283void removeMetadataFacet( String repositoryId, String facetId, String name )
84throws MetadataRepositoryException;
8586/**87 * if startTime or endTime are <code>null</code> they are not used for search88 *89 * @param repositoryId90 * @param startTime can be <code>null</code>91 * @param endTime can be <code>null</code>92 * @return93 * @throws MetadataRepositoryException94 */95 List<ArtifactMetadata> getArtifactsByDateRange( String repositoryId, Date startTime, Date endTime )
96throws MetadataRepositoryException;
9798// TODO: remove from API, just use configuration99 Collection<String> getRepositories()
100throws MetadataRepositoryException;
101102 Collection<ArtifactMetadata> getArtifactsByChecksum( String repositoryId, String checksum )
103throws MetadataRepositoryException;
104105/**106 * Get artifacts with a project version metadata key that matches the passed value.107 * 108 * @param key109 * @param value110 * @param repositoryId can be null, meaning search in all repositories111 * @return a list of artifacts112 * @throws MetadataRepositoryException113 */114 List<ArtifactMetadata> getArtifactsByProjectVersionMetadata( String key, String value, String repositoryId )
115throws MetadataRepositoryException;
116117/**118 * Get artifacts with an artifact metadata key that matches the passed value.119 * 120 * @param key121 * @param value122 * @param repositoryId can be null, meaning search in all repositories123 * @return a list of artifacts124 * @throws MetadataRepositoryException125 */126 List<ArtifactMetadata> getArtifactsByMetadata( String key, String value, String repositoryId )
127throws MetadataRepositoryException;
128129/**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 key134 * @param value135 * @param repositoryId can be null, meaning search in all repositories136 * @return a list of artifacts137 * @throws MetadataRepositoryException138 */139 List<ArtifactMetadata> getArtifactsByProperty( String key, String value, String repositoryId )
140throws MetadataRepositoryException;
141142void removeArtifact( String repositoryId, String namespace, String project, String version, String id )
143throws MetadataRepositoryException;
144145/**146 * used for deleting timestamped version of SNAPSHOT artifacts147 *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 MetadataRepositoryException151 * @since 1.4-M3152 */153void removeArtifact( ArtifactMetadata artifactMetadata, String baseVersion )
154throws MetadataRepositoryException;
155156/**157 * FIXME need a unit test!!!158 * Only remove {@link MetadataFacet} for the artifact159 *160 * @param repositoryId161 * @param namespace162 * @param project163 * @param version164 * @param metadataFacet165 * @throws MetadataRepositoryException166 * @since 1.4-M3167 */168void removeArtifact( String repositoryId, String namespace, String project, String version,
169MetadataFacet metadataFacet )
170throws MetadataRepositoryException;
171172/**173 * Delete a repository's metadata. This includes all associated metadata facets.174 *175 * @param repositoryId the repository to delete176 */177void removeRepository( String repositoryId )
178throws MetadataRepositoryException;
179180/**181 * @param repositoryId182 * @param namespace (groupId for maven )183 * @throws MetadataRepositoryException184 * @since 1.4-M3185 */186void removeNamespace( String repositoryId, String namespace )
187throws MetadataRepositoryException;
188189 List<ArtifactMetadata> getArtifacts( String repositoryId )
190throws MetadataRepositoryException;
191192/**193 * basically just checking it exists not complete data returned194 *195 * @param repoId196 * @param namespace197 * @param projectId198 * @return199 * @throws MetadataResolutionException200 */201ProjectMetadata getProject( String repoId, String namespace, String projectId )
202throws MetadataResolutionException;
203204ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId, String projectVersion )
205throws MetadataResolutionException;
206207 Collection<String> getArtifactVersions( String repoId, String namespace, String projectId, String projectVersion )
208throws MetadataResolutionException;
209210/**211 * Retrieve project references from the metadata repository. Note that this is not built into the content model for212 * a project version as a reference may be present (due to reverse-lookup of dependencies) before the actual213 * project is, and we want to avoid adding a stub model to the content repository.214 *215 * @param repoId the repository ID to look within216 * @param namespace the namespace of the project to get references to217 * @param projectId the identifier of the project to get references to218 * @param projectVersion the version of the project to get references to219 * @return a list of project references220 */221 Collection<ProjectVersionReference> getProjectReferences( String repoId, String namespace, String projectId,
222 String projectVersion )
223throws MetadataResolutionException;
224225 Collection<String> getRootNamespaces( String repoId )
226throws MetadataResolutionException;
227228/**229 * @param repoId230 * @param namespace231 * @return {@link Collection} of child namespaces of the namespace argument232 * @throws MetadataResolutionException233 */234 Collection<String> getNamespaces( String repoId, String namespace )
235throws MetadataResolutionException;
236237/**238 * @param repoId239 * @param namespace240 * @return241 * @throws MetadataResolutionException242 */243 Collection<String> getProjects( String repoId, String namespace )
244throws MetadataResolutionException;
245246/**247 * @param repoId248 * @param namespace249 * @param projectId250 * @return251 * @throws MetadataResolutionException252 */253 Collection<String> getProjectVersions( String repoId, String namespace, String projectId )
254throws MetadataResolutionException;
255256/**257 * @param repoId258 * @param namespace259 * @param projectId260 * @param projectVersion261 * @throws MetadataRepositoryException262 * @since 1.4-M4263 */264void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion )
265throws MetadataRepositoryException;
266267/**268 * @param repoId269 * @param namespace270 * @param projectId271 * @param projectVersion272 * @return273 * @throws MetadataResolutionException274 */275 Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId,
276 String projectVersion )
277throws MetadataResolutionException;
278279/**280 * remove a project281 *282 * @param repositoryId283 * @param namespace284 * @param projectId285 * @throws MetadataRepositoryException286 * @since 1.4-M4287 */288void removeProject( String repositoryId, String namespace, String projectId )
289throws MetadataRepositoryException;
290291292/**293 * <b>implementations can throw RuntimeException</b>294 */295void save();
296297298void close()
299throws MetadataRepositoryException;
300301/**302 * <b>implementations can throw RuntimeException</b>303 */304void revert();
305306boolean canObtainAccess( Class<?> aClass );
307308 <T> T obtainAccess( Class<T> aClass )
309throws MetadataRepositoryException;
310311/**312 * Full text artifacts search.313 * 314 * @param text315 * @param repositoryId can be null to search in all repositories316 * @param exact running an exact search, the value must exactly match the text. 317 * @return a list of artifacts318 * @throws MetadataRepositoryException319 */320 List<ArtifactMetadata> searchArtifacts( String text, String repositoryId, boolean exact )
321throws MetadataRepositoryException;
322323/**324 * Full text artifacts search inside the specified key.325 * 326 * @param key search only inside this key327 * @param text328 * @param repositoryId can be null to search in all repositories329 * @param exact running an exact search, the value must exactly match the text. 330 * @return a list of artifacts331 * @throws MetadataRepositoryException332 */333 List<ArtifactMetadata> searchArtifacts( String key, String text, String repositoryId, boolean exact )
334throws MetadataRepositoryException;
335336 }