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.
37 * @param repositoryId the repository the project is in
38 * @param project the project metadata to create or update
40 void updateProject( String repositoryId, ProjectMetadata project )
41 throws MetadataRepositoryException;
43 void updateArtifact( String repositoryId, String namespace, String projectId, String projectVersion,
44 ArtifactMetadata artifactMeta )
45 throws MetadataRepositoryException;
47 void updateProjectVersion( String repositoryId, String namespace, String projectId,
48 ProjectVersionMetadata versionMetadata )
49 throws MetadataRepositoryException;
52 * create the namespace in the repository. (if not exist)
56 * @throws MetadataRepositoryException
58 void updateNamespace( String repositoryId, String namespace )
59 throws MetadataRepositoryException;
61 List<String> getMetadataFacets( String repositoryId, String facetId )
62 throws MetadataRepositoryException;
67 * @return true if the repository datas for this facetId
68 * @throws MetadataRepositoryException
71 boolean hasMetadataFacet( String repositoryId, String facetId )
72 throws MetadataRepositoryException;
74 MetadataFacet getMetadataFacet( String repositoryId, String facetId, String name )
75 throws MetadataRepositoryException;
77 void addMetadataFacet( String repositoryId, MetadataFacet metadataFacet )
78 throws MetadataRepositoryException;
80 void removeMetadataFacets( String repositoryId, String facetId )
81 throws MetadataRepositoryException;
83 void removeMetadataFacet( String repositoryId, String facetId, String name )
84 throws MetadataRepositoryException;
87 * if startTime or endTime are <code>null</code> they are not used for search
90 * @param startTime can be <code>null</code>
91 * @param endTime can be <code>null</code>
93 * @throws MetadataRepositoryException
95 List<ArtifactMetadata> getArtifactsByDateRange( String repositoryId, Date startTime, Date endTime )
96 throws MetadataRepositoryException;
98 // TODO: remove from API, just use configuration
99 Collection<String> getRepositories()
100 throws MetadataRepositoryException;
102 Collection<ArtifactMetadata> getArtifactsByChecksum( String repositoryId, String checksum )
103 throws MetadataRepositoryException;
105 void removeArtifact( String repositoryId, String namespace, String project, String version, String id )
106 throws MetadataRepositoryException;
109 * used for deleting timestamped version of SNAPSHOT artifacts
111 * @param artifactMetadata the artifactMetadata with the timestamped version (2.0-20120618.214135-2)
112 * @param baseVersion the base version of the snapshot (2.0-SNAPSHOT)
113 * @throws MetadataRepositoryException
116 void removeArtifact( ArtifactMetadata artifactMetadata, String baseVersion )
117 throws MetadataRepositoryException;
120 * FIXME need a unit test!!!
121 * Only remove {@link MetadataFacet} for the artifact
123 * @param repositoryId
127 * @param metadataFacet
128 * @throws MetadataRepositoryException
131 void removeArtifact( String repositoryId, String namespace, String project, String version,
132 MetadataFacet metadataFacet )
133 throws MetadataRepositoryException;
136 * Delete a repository's metadata. This includes all associated metadata facets.
138 * @param repositoryId the repository to delete
140 void removeRepository( String repositoryId )
141 throws MetadataRepositoryException;
144 * @param repositoryId
145 * @param namespace (groupId for maven )
146 * @throws MetadataRepositoryException
149 void removeNamespace( String repositoryId, String namespace )
150 throws MetadataRepositoryException;
152 List<ArtifactMetadata> getArtifacts( String repositoryId )
153 throws MetadataRepositoryException;
156 * basically just checking it exists not complete data returned
162 * @throws MetadataResolutionException
164 ProjectMetadata getProject( String repoId, String namespace, String projectId )
165 throws MetadataResolutionException;
167 ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId, String projectVersion )
168 throws MetadataResolutionException;
170 Collection<String> getArtifactVersions( String repoId, String namespace, String projectId, String projectVersion )
171 throws MetadataResolutionException;
174 * Retrieve project references from the metadata repository. Note that this is not built into the content model for
175 * a project version as a reference may be present (due to reverse-lookup of dependencies) before the actual
176 * project is, and we want to avoid adding a stub model to the content repository.
178 * @param repoId the repository ID to look within
179 * @param namespace the namespace of the project to get references to
180 * @param projectId the identifier of the project to get references to
181 * @param projectVersion the version of the project to get references to
182 * @return a list of project references
184 Collection<ProjectVersionReference> getProjectReferences( String repoId, String namespace, String projectId,
185 String projectVersion )
186 throws MetadataResolutionException;
188 Collection<String> getRootNamespaces( String repoId )
189 throws MetadataResolutionException;
194 * @return {@link Collection} of child namespaces of the namespace argument
195 * @throws MetadataResolutionException
197 Collection<String> getNamespaces( String repoId, String namespace )
198 throws MetadataResolutionException;
204 * @throws MetadataResolutionException
206 Collection<String> getProjects( String repoId, String namespace )
207 throws MetadataResolutionException;
214 * @throws MetadataResolutionException
216 Collection<String> getProjectVersions( String repoId, String namespace, String projectId )
217 throws MetadataResolutionException;
223 * @param projectVersion
224 * @throws MetadataRepositoryException
227 void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion )
228 throws MetadataRepositoryException;
234 * @param projectVersion
236 * @throws MetadataResolutionException
238 Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId,
239 String projectVersion )
240 throws MetadataResolutionException;
245 * @param repositoryId
248 * @throws MetadataRepositoryException
251 void removeProject( String repositoryId, String namespace, String projectId )
252 throws MetadataRepositoryException;
256 * <b>implementations can throw RuntimeException</b>
262 throws MetadataRepositoryException;
265 * <b>implementations can throw RuntimeException</b>
269 boolean canObtainAccess( Class<?> aClass );
271 <T> T obtainAccess( Class<T> aClass )
272 throws MetadataRepositoryException;