001package org.apache.archiva.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.configuration.ManagedRepositoryConfiguration; 023import org.apache.archiva.configuration.RemoteRepositoryConfiguration; 024import org.apache.archiva.configuration.RepositoryGroupConfiguration; 025import org.apache.archiva.event.EventHandler; 026 027import java.io.IOException; 028import java.util.Set; 029 030/** 031 * 032 * This interface must be implemented by the repository implementations. The repository provider knows all 033 * about the repositories and should be the only part that uses the repository specific classes and libraries 034 * (e.g. the maven libraries). 035 * 036 * Newly created instances should always be filled with default values that make sense. null values should 037 * be avoided. 038 * 039 * References like staging repositories must not be set. 040 * 041 * 042 */ 043public interface RepositoryProvider extends EventHandler 044{ 045 046 /** 047 * Returns the types of repositories this provider can handle. 048 * 049 * @return the set of supported repository types 050 */ 051 Set<RepositoryType> provides(); 052 053 /** 054 * Creates a editable managed repository instance. The provider must not check the uniqueness of the 055 * id parameter and must not track the already created instances. Each call to this method will create 056 * a new instance. 057 * 058 * @param id the repository identifier 059 * @param name the repository name 060 * @return a new created managed repository instance 061 */ 062 EditableManagedRepository createManagedInstance(String id, String name) throws IOException; 063 064 /** 065 * Creates a editable remote repository instance. The provider must not check the uniqueness of the 066 * id parameter and must not track the already created instances. Each call to this method will create 067 * a new instance. 068 * 069 * @param id the repository identifier 070 * @param name the repository name 071 * @return a new created remote repository instance 072 */ 073 EditableRemoteRepository createRemoteInstance(String id, String name); 074 075 /** 076 * Creates a editable repository group. . The provider must not check the uniqueness of the 077 * id parameter and must not track the already created instances. Each call to this method will create 078 * a new instance. 079 * 080 * @param id the repository identifier 081 * @param name the repository name 082 * @return A new instance of the repository group implementation 083 */ 084 EditableRepositoryGroup createRepositoryGroup(String id, String name); 085 086 /** 087 * Creates a new managed repository instance from the given configuration. All attributes are filled from the 088 * provided configuration object. 089 * 090 * @param configuration the repository configuration that contains the repository data 091 * @return a new created managed repository instance 092 * @throws RepositoryException if some of the configuration values are not valid 093 */ 094 ManagedRepository createManagedInstance( ManagedRepositoryConfiguration configuration) throws RepositoryException; 095 096 /** 097 * Updates the given managed repository instance from the given configuration. All attributes are filled from the 098 * provided configuration object. 099 * 100 * @param repo the repository instance that should be updated 101 * @param configuration the repository configuration that contains the repository data 102 * @throws RepositoryException if some of the configuration values are not valid 103 */ 104 void updateManagedInstance( EditableManagedRepository repo, ManagedRepositoryConfiguration configuration) throws RepositoryException; 105 106 /** 107 * Creates a new managed staging repository instance from the given configuration. All attributes are filled from the 108 * provided configuration object. 109 * 110 * @param baseConfiguration the repository configuration of the base repository that references the staging repository 111 * @return a new created managed staging repository instance 112 * @throws RepositoryException if some of the configuration values are not valid 113 */ 114 ManagedRepository createStagingInstance(ManagedRepositoryConfiguration baseConfiguration) throws RepositoryException; 115 116 /** 117 * Creates a new remote repository instance from the given configuration. All attributes are filled from the 118 * provided configuration object. 119 * 120 * @param configuration the repository configuration that contains the repository data 121 * @return a new created remote repository instance 122 * @throws RepositoryException if some of the configuration values are not valid 123 */ 124 RemoteRepository createRemoteInstance( RemoteRepositoryConfiguration configuration) throws RepositoryException; 125 126 /** 127 * Updates the given remote repository instance from the given configuration. All attributes are filled from the 128 * provided configuration object. 129 * 130 * @param repo the repository instance that should be updated 131 * @param configuration the repository configuration that contains the repository data 132 * @throws RepositoryException if some of the configuration values are not valid 133 */ 134 void updateRemoteInstance(EditableRemoteRepository repo, RemoteRepositoryConfiguration configuration) throws RepositoryException; 135 136 137 /** 138 * Creates a new repository group instance from the given configuration. All attributes are filled from the 139 * provided configuration object. 140 * 141 * @param configuration the repository group configuration 142 * @return a new created repository group instance 143 * @throws RepositoryException if some of the configuration values are not valid 144 */ 145 RepositoryGroup createRepositoryGroup(RepositoryGroupConfiguration configuration) throws RepositoryException; 146 147 /** 148 * Updates the given remote repository instance from the given configuration. All attributes are filled from the 149 * provided configuration object. 150 * 151 * @param repositoryGroup the repository group instance that should be updated 152 * @param configuration the repository group configuration that contains the group data 153 * @throws RepositoryException if some of the configuration values are not valid 154 */ 155 void updateRepositoryGroupInstance(EditableRepositoryGroup repositoryGroup, RepositoryGroupConfiguration configuration) throws RepositoryException; 156 157 /** 158 * Returns a configuration object from the given remote repository instance. 159 * 160 * @param remoteRepository the remote repository instance 161 * @return the repository configuration with all the data that is stored in the repository instance 162 * @throws RepositoryException if the data cannot be converted 163 */ 164 RemoteRepositoryConfiguration getRemoteConfiguration(RemoteRepository remoteRepository) throws RepositoryException; 165 166 /** 167 * Returns a configuration object from the given managed repository instance. 168 * 169 * @param managedRepository the managed repository instance 170 * @return the repository configuration with all the data that is stored in the repository instance 171 * @throws RepositoryException if the data cannot be converted 172 */ 173 ManagedRepositoryConfiguration getManagedConfiguration(ManagedRepository managedRepository) throws RepositoryException; 174 175 /** 176 * Returns a configuration object from the given repository group instance. 177 * 178 * @param repositoryGroup the repository group 179 * @return the repository group configuration with all the data that is stored in the repository instance 180 * @throws RepositoryException if the data cannot be converted 181 */ 182 RepositoryGroupConfiguration getRepositoryGroupConfiguration(RepositoryGroup repositoryGroup) throws RepositoryException; 183}