001 package 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 022 import org.apache.archiva.metadata.model.ArtifactMetadata; 023 import org.apache.archiva.metadata.model.MetadataFacet; 024 import org.apache.archiva.metadata.model.ProjectMetadata; 025 import org.apache.archiva.metadata.model.ProjectVersionMetadata; 026 import org.apache.archiva.metadata.model.ProjectVersionReference; 027 028 import java.util.Collection; 029 import java.util.Date; 030 import java.util.List; 031 032 public 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 * @param repositoryId 054 * @param namespace 055 * @throws MetadataRepositoryException 056 */ 057 void updateNamespace( String repositoryId, String namespace ) 058 throws MetadataRepositoryException; 059 060 List<String> getMetadataFacets( String repositoryId, String facetId ) 061 throws MetadataRepositoryException; 062 063 /** 064 * 065 * @param repositoryId 066 * @param facetId 067 * @return true if the repository datas for this facetId 068 * @since 1.4-M4 069 * @throws MetadataRepositoryException 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 * @param repositoryId 089 * @param startTime can be <code>null</code> 090 * @param endTime can be <code>null</code> 091 * @return 092 * @throws MetadataRepositoryException 093 */ 094 List<ArtifactMetadata> getArtifactsByDateRange( String repositoryId, Date startTime, Date endTime ) 095 throws MetadataRepositoryException; 096 097 // TODO: remove from API, just use configuration 098 Collection<String> getRepositories() 099 throws MetadataRepositoryException; 100 101 List<ArtifactMetadata> getArtifactsByChecksum( String repositoryId, String checksum ) 102 throws MetadataRepositoryException; 103 104 void removeArtifact( String repositoryId, String namespace, String project, String version, String id ) 105 throws MetadataRepositoryException; 106 107 /** 108 * used for deleting timestamped version of SNAPSHOT artifacts 109 * 110 * @param artifactMetadata the artifactMetadata with the timestamped version (2.0-20120618.214135-2) 111 * @param baseVersion the base version of the snapshot (2.0-SNAPSHOT) 112 * @throws MetadataRepositoryException 113 * @since 1.4-M3 114 */ 115 void removeArtifact( ArtifactMetadata artifactMetadata, String baseVersion ) 116 throws MetadataRepositoryException; 117 118 /** 119 * Only remove {@link MetadataFacet} for the artifact 120 * @param repositoryId 121 * @param namespace 122 * @param project 123 * @param version 124 * @param metadataFacet 125 * @throws MetadataRepositoryException 126 * @since 1.4-M3 127 */ 128 void removeArtifact( String repositoryId, String namespace, String project, String version, 129 MetadataFacet metadataFacet ) 130 throws MetadataRepositoryException; 131 132 /** 133 * Delete a repository's metadata. This includes all associated metadata facets. 134 * 135 * @param repositoryId the repository to delete 136 */ 137 void removeRepository( String repositoryId ) 138 throws MetadataRepositoryException; 139 140 /** 141 * @param repositoryId 142 * @param namespace (groupId for maven ) 143 * @throws MetadataRepositoryException 144 * @since 1.4-M3 145 */ 146 void removeNamespace( String repositoryId, String namespace ) 147 throws MetadataRepositoryException; 148 149 List<ArtifactMetadata> getArtifacts( String repositoryId ) 150 throws MetadataRepositoryException; 151 152 /** 153 * basically just checking it exists not complete data returned 154 * @param repoId 155 * @param namespace 156 * @param projectId 157 * @return 158 * @throws MetadataResolutionException 159 */ 160 ProjectMetadata getProject( String repoId, String namespace, String projectId ) 161 throws MetadataResolutionException; 162 163 ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId, String projectVersion ) 164 throws MetadataResolutionException; 165 166 Collection<String> getArtifactVersions( String repoId, String namespace, String projectId, String projectVersion ) 167 throws MetadataResolutionException; 168 169 /** 170 * Retrieve project references from the metadata repository. Note that this is not built into the content model for 171 * a project version as a reference may be present (due to reverse-lookup of dependencies) before the actual 172 * project is, and we want to avoid adding a stub model to the content repository. 173 * 174 * @param repoId the repository ID to look within 175 * @param namespace the namespace of the project to get references to 176 * @param projectId the identifier of the project to get references to 177 * @param projectVersion the version of the project to get references to 178 * @return a list of project references 179 */ 180 Collection<ProjectVersionReference> getProjectReferences( String repoId, String namespace, String projectId, 181 String projectVersion ) 182 throws MetadataResolutionException; 183 184 Collection<String> getRootNamespaces( String repoId ) 185 throws MetadataResolutionException; 186 187 Collection<String> getNamespaces( String repoId, String namespace ) 188 throws MetadataResolutionException; 189 190 Collection<String> getProjects( String repoId, String namespace ) 191 throws MetadataResolutionException; 192 193 Collection<String> getProjectVersions( String repoId, String namespace, String projectId ) 194 throws MetadataResolutionException; 195 196 /** 197 * @param repoId 198 * @param namespace 199 * @param projectId 200 * @param projectVersion 201 * @throws MetadataResolutionException 202 * @since 1.4-M4 203 */ 204 void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion ) 205 throws MetadataRepositoryException; 206 207 Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId, 208 String projectVersion ) 209 throws MetadataResolutionException; 210 211 /** 212 * remove a project 213 * @param repositoryId 214 * @param namespace 215 * @param projectId 216 * @throws MetadataRepositoryException 217 * @since 1.4-M4 218 */ 219 void removeProject( String repositoryId, String namespace, String projectId ) 220 throws MetadataRepositoryException; 221 222 223 /** 224 * <b>implementations can throw RuntimeException</b> 225 */ 226 void save(); 227 228 229 void close() 230 throws MetadataRepositoryException; 231 232 /** 233 * <b>implementations can throw RuntimeException</b> 234 */ 235 void revert(); 236 237 boolean canObtainAccess( Class<?> aClass ); 238 239 <T>T obtainAccess( Class<T> aClass ) 240 throws MetadataRepositoryException; 241 }