1 package org.apache.archiva.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.configuration.ManagedRepositoryConfiguration;
23 import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
24 import org.apache.archiva.configuration.RepositoryGroupConfiguration;
25 import org.apache.archiva.event.EventHandler;
26 import org.apache.archiva.repository.event.RepositoryEvent;
28 import java.io.IOException;
33 * This interface must be implemented by the repository implementations. The repository provider knows all
34 * about the repositories and should be the only part that uses the repository specific classes and libraries
35 * (e.g. the maven libraries).
37 * Newly created instances should always be filled with default values that make sense. null values should
40 * References like staging repositories must not be set.
44 public interface RepositoryProvider extends EventHandler
48 * Returns the types of repositories this provider can handle.
50 * @return the set of supported repository types
52 Set<RepositoryType> provides();
55 * Creates a editable managed repository instance. The provider must not check the uniqueness of the
56 * id parameter and must not track the already created instances. Each call to this method will create
59 * @param id the repository identifier
60 * @param name the repository name
61 * @return a new created managed repository instance
63 EditableManagedRepository createManagedInstance(String id, String name) throws IOException;
66 * Creates a editable remote repository instance. The provider must not check the uniqueness of the
67 * id parameter and must not track the already created instances. Each call to this method will create
70 * @param id the repository identifier
71 * @param name the repository name
72 * @return a new created remote repository instance
74 EditableRemoteRepository createRemoteInstance(String id, String name);
77 * Creates a editable repository group. . The provider must not check the uniqueness of the
78 * id parameter and must not track the already created instances. Each call to this method will create
81 * @param id the repository identifier
82 * @param name the repository name
83 * @return A new instance of the repository group implementation
85 EditableRepositoryGroup createRepositoryGroup(String id, String name);
88 * Creates a new managed repository instance from the given configuration. All attributes are filled from the
89 * provided configuration object.
91 * @param configuration the repository configuration that contains the repository data
92 * @return a new created managed repository instance
93 * @throws RepositoryException if some of the configuration values are not valid
95 ManagedRepository createManagedInstance( ManagedRepositoryConfiguration configuration) throws RepositoryException;
98 * Updates the given managed repository instance from the given configuration. All attributes are filled from the
99 * provided configuration object.
101 * @param repo the repository instance that should be updated
102 * @param configuration the repository configuration that contains the repository data
103 * @throws RepositoryException if some of the configuration values are not valid
105 void updateManagedInstance( EditableManagedRepository repo, ManagedRepositoryConfiguration configuration) throws RepositoryException;
108 * Creates a new managed staging repository instance from the given configuration. All attributes are filled from the
109 * provided configuration object.
111 * @param baseConfiguration the repository configuration of the base repository that references the staging repository
112 * @return a new created managed staging repository instance
113 * @throws RepositoryException if some of the configuration values are not valid
115 ManagedRepository createStagingInstance(ManagedRepositoryConfiguration baseConfiguration) throws RepositoryException;
118 * Creates a new remote repository instance from the given configuration. All attributes are filled from the
119 * provided configuration object.
121 * @param configuration the repository configuration that contains the repository data
122 * @return a new created remote repository instance
123 * @throws RepositoryException if some of the configuration values are not valid
125 RemoteRepository createRemoteInstance( RemoteRepositoryConfiguration configuration) throws RepositoryException;
128 * Updates the given remote repository instance from the given configuration. All attributes are filled from the
129 * provided configuration object.
131 * @param repo the repository instance that should be updated
132 * @param configuration the repository configuration that contains the repository data
133 * @throws RepositoryException if some of the configuration values are not valid
135 void updateRemoteInstance(EditableRemoteRepository repo, RemoteRepositoryConfiguration configuration) throws RepositoryException;
139 * Creates a new repository group instance from the given configuration. All attributes are filled from the
140 * provided configuration object.
142 * @param configuration the repository group configuration
143 * @return a new created repository group instance
144 * @throws RepositoryException if some of the configuration values are not valid
146 RepositoryGroup createRepositoryGroup(RepositoryGroupConfiguration configuration) throws RepositoryException;
149 * Updates the given remote repository instance from the given configuration. All attributes are filled from the
150 * provided configuration object.
152 * @param repositoryGroup the repository group instance that should be updated
153 * @param configuration the repository group configuration that contains the group data
154 * @throws RepositoryException if some of the configuration values are not valid
156 void updateRepositoryGroupInstance(EditableRepositoryGroup repositoryGroup, RepositoryGroupConfiguration configuration) throws RepositoryException;
159 * Returns a configuration object from the given remote repository instance.
161 * @param remoteRepository the remote repository instance
162 * @return the repository configuration with all the data that is stored in the repository instance
163 * @throws RepositoryException if the data cannot be converted
165 RemoteRepositoryConfiguration getRemoteConfiguration(RemoteRepository remoteRepository) throws RepositoryException;
168 * Returns a configuration object from the given managed repository instance.
170 * @param managedRepository the managed repository instance
171 * @return the repository configuration with all the data that is stored in the repository instance
172 * @throws RepositoryException if the data cannot be converted
174 ManagedRepositoryConfiguration getManagedConfiguration(ManagedRepository managedRepository) throws RepositoryException;
177 * Returns a configuration object from the given repository group instance.
179 * @param repositoryGroup the repository group
180 * @return the repository group configuration with all the data that is stored in the repository instance
181 * @throws RepositoryException if the data cannot be converted
183 RepositoryGroupConfiguration getRepositoryGroupConfiguration(RepositoryGroup repositoryGroup) throws RepositoryException;
186 * This event handler is registered to all newly created repositories immediately after creation. This may be needed by
187 * some components to get events right after creation of the instance.
189 * @param eventHandler the event handler instance
191 void addRepositoryEventHandler( EventHandler<? super RepositoryEvent> eventHandler);