1 package org.apache.archiva.repository;
2
3 /*
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
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
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
19 * under the License.
20 */
21
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
27 import java.io.IOException;
28 import java.util.Set;
29
30 /**
31 *
32 * This interface must be implemented by the repository implementations. The repository provider knows all
33 * about the repositories and should be the only part that uses the repository specific classes and libraries
34 * (e.g. the maven libraries).
35 *
36 * Newly created instances should always be filled with default values that make sense. null values should
37 * be avoided.
38 *
39 * References like staging repositories must not be set.
40 *
41 *
42 */
43 public interface RepositoryProvider extends EventHandler
44 {
45
46 /**
47 * Returns the types of repositories this provider can handle.
48 *
49 * @return the set of supported repository types
50 */
51 Set<RepositoryType> provides();
52
53 /**
54 * Creates a editable managed repository instance. The provider must not check the uniqueness of the
55 * id parameter and must not track the already created instances. Each call to this method will create
56 * a new instance.
57 *
58 * @param id the repository identifier
59 * @param name the repository name
60 * @return a new created managed repository instance
61 */
62 EditableManagedRepository createManagedInstance(String id, String name) throws IOException;
63
64 /**
65 * Creates a editable remote repository instance. The provider must not check the uniqueness of the
66 * id parameter and must not track the already created instances. Each call to this method will create
67 * a new instance.
68 *
69 * @param id the repository identifier
70 * @param name the repository name
71 * @return a new created remote repository instance
72 */
73 EditableRemoteRepository createRemoteInstance(String id, String name);
74
75 /**
76 * Creates a editable repository group. . The provider must not check the uniqueness of the
77 * id parameter and must not track the already created instances. Each call to this method will create
78 * a new instance.
79 *
80 * @param id the repository identifier
81 * @param name the repository name
82 * @return A new instance of the repository group implementation
83 */
84 EditableRepositoryGroup createRepositoryGroup(String id, String name);
85
86 /**
87 * Creates a new managed repository instance from the given configuration. All attributes are filled from the
88 * provided configuration object.
89 *
90 * @param configuration the repository configuration that contains the repository data
91 * @return a new created managed repository instance
92 * @throws RepositoryException if some of the configuration values are not valid
93 */
94 ManagedRepository createManagedInstance( ManagedRepositoryConfiguration configuration) throws RepositoryException;
95
96 /**
97 * Updates the given managed repository instance from the given configuration. All attributes are filled from the
98 * provided configuration object.
99 *
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 }