1 package org.apache.archiva.rest.services;
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
21 import org.apache.archiva.admin.model.RepositoryAdminException;
22 import org.apache.archiva.admin.model.admin.ArchivaAdministration;
23 import org.apache.archiva.admin.model.beans.FileType;
24 import org.apache.archiva.admin.model.beans.LegacyArtifactPath;
25 import org.apache.archiva.admin.model.beans.NetworkConfiguration;
26 import org.apache.archiva.admin.model.beans.OrganisationInformation;
27 import org.apache.archiva.admin.model.beans.UiConfiguration;
28 import org.apache.archiva.rest.api.services.ArchivaAdministrationService;
29 import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
30 import org.springframework.stereotype.Service;
32 import javax.inject.Inject;
33 import java.util.ArrayList;
34 import java.util.Collections;
35 import java.util.List;
38 * @author Olivier Lamy
41 @Service( "archivaAdministrationService#default" )
42 public class DefaultArchivaAdministrationService
43 extends AbstractRestService
44 implements ArchivaAdministrationService
47 private ArchivaAdministration archivaAdministration;
49 public List<LegacyArtifactPath> getLegacyArtifactPaths()
50 throws ArchivaRestServiceException
54 return archivaAdministration.getLegacyArtifactPaths();
56 catch ( RepositoryAdminException e )
58 throw new ArchivaRestServiceException( e.getMessage() );
62 public void addLegacyArtifactPath( LegacyArtifactPath legacyArtifactPath )
63 throws ArchivaRestServiceException
67 archivaAdministration.addLegacyArtifactPath( legacyArtifactPath, getAuditInformation() );
69 catch ( RepositoryAdminException e )
71 throw new ArchivaRestServiceException( e.getMessage() );
75 public Boolean deleteLegacyArtifactPath( String path )
76 throws ArchivaRestServiceException
80 archivaAdministration.deleteLegacyArtifactPath( path, getAuditInformation() );
83 catch ( RepositoryAdminException e )
85 throw new ArchivaRestServiceException( e.getMessage() );
90 public Boolean addFileTypePattern( String fileTypeId, String pattern )
91 throws ArchivaRestServiceException
95 archivaAdministration.addFileTypePattern( fileTypeId, pattern, getAuditInformation() );
98 catch ( RepositoryAdminException e )
100 throw new ArchivaRestServiceException( e.getMessage() );
104 public Boolean removeFileTypePattern( String fileTypeId, String pattern )
105 throws ArchivaRestServiceException
109 archivaAdministration.removeFileTypePattern( fileTypeId, pattern, getAuditInformation() );
112 catch ( RepositoryAdminException e )
114 throw new ArchivaRestServiceException( e.getMessage() );
118 public FileType getFileType( String fileTypeId )
119 throws ArchivaRestServiceException
123 return archivaAdministration.getFileType( fileTypeId );
125 catch ( RepositoryAdminException e )
127 throw new ArchivaRestServiceException( e.getMessage() );
131 public void addFileType( FileType fileType )
132 throws ArchivaRestServiceException
136 archivaAdministration.addFileType( fileType, getAuditInformation() );
138 catch ( RepositoryAdminException e )
140 throw new ArchivaRestServiceException( e.getMessage() );
144 public Boolean removeFileType( String fileTypeId )
145 throws ArchivaRestServiceException
149 archivaAdministration.removeFileType( fileTypeId, getAuditInformation() );
152 catch ( RepositoryAdminException e )
154 throw new ArchivaRestServiceException( e.getMessage() );
158 public Boolean addKnownContentConsumer( String knownContentConsumer )
159 throws ArchivaRestServiceException
163 archivaAdministration.addKnownContentConsumer( knownContentConsumer, getAuditInformation() );
166 catch ( RepositoryAdminException e )
168 throw new ArchivaRestServiceException( e.getMessage() );
172 public void setKnownContentConsumers( List<String> knownContentConsumers )
173 throws ArchivaRestServiceException
177 archivaAdministration.setKnownContentConsumers( knownContentConsumers, getAuditInformation() );
179 catch ( RepositoryAdminException e )
181 throw new ArchivaRestServiceException( e.getMessage() );
185 public Boolean removeKnownContentConsumer( String knownContentConsumer )
186 throws ArchivaRestServiceException
190 archivaAdministration.removeKnownContentConsumer( knownContentConsumer, getAuditInformation() );
193 catch ( RepositoryAdminException e )
195 throw new ArchivaRestServiceException( e.getMessage() );
199 public Boolean addInvalidContentConsumer( String invalidContentConsumer )
200 throws ArchivaRestServiceException
204 archivaAdministration.addInvalidContentConsumer( invalidContentConsumer, getAuditInformation() );
207 catch ( RepositoryAdminException e )
209 throw new ArchivaRestServiceException( e.getMessage() );
213 public void setInvalidContentConsumers( List<String> invalidContentConsumers )
214 throws ArchivaRestServiceException
218 archivaAdministration.setInvalidContentConsumers( invalidContentConsumers, getAuditInformation() );
220 catch ( RepositoryAdminException e )
222 throw new ArchivaRestServiceException( e.getMessage() );
226 public Boolean removeInvalidContentConsumer( String invalidContentConsumer )
227 throws ArchivaRestServiceException
231 archivaAdministration.removeInvalidContentConsumer( invalidContentConsumer, getAuditInformation() );
234 catch ( RepositoryAdminException e )
236 throw new ArchivaRestServiceException( e.getMessage() );
240 public List<FileType> getFileTypes()
241 throws ArchivaRestServiceException
245 List<FileType> modelfileTypes = archivaAdministration.getFileTypes();
246 if ( modelfileTypes == null || modelfileTypes.isEmpty() )
248 return Collections.emptyList();
250 return modelfileTypes;
252 catch ( RepositoryAdminException e )
254 throw new ArchivaRestServiceException( e.getMessage() );
258 public List<String> getKnownContentConsumers()
259 throws ArchivaRestServiceException
263 return new ArrayList<String>( archivaAdministration.getKnownContentConsumers() );
265 catch ( RepositoryAdminException e )
267 throw new ArchivaRestServiceException( e.getMessage() );
271 public List<String> getInvalidContentConsumers()
272 throws ArchivaRestServiceException
276 return new ArrayList<String>( archivaAdministration.getInvalidContentConsumers() );
278 catch ( RepositoryAdminException e )
280 throw new ArchivaRestServiceException( e.getMessage() );
284 public OrganisationInformation getOrganisationInformation()
285 throws ArchivaRestServiceException
289 return archivaAdministration.getOrganisationInformation();
291 catch ( RepositoryAdminException e )
293 throw new ArchivaRestServiceException( e.getMessage() );
297 public void setOrganisationInformation( OrganisationInformation organisationInformation )
298 throws ArchivaRestServiceException
302 archivaAdministration.setOrganisationInformation( organisationInformation );
304 catch ( RepositoryAdminException e )
306 throw new ArchivaRestServiceException( e.getMessage() );
311 public UiConfiguration getUiConfiguration()
312 throws ArchivaRestServiceException
316 return archivaAdministration.getUiConfiguration();
318 catch ( RepositoryAdminException e )
320 throw new ArchivaRestServiceException( e.getMessage() );
324 public void setUiConfiguration( UiConfiguration uiConfiguration )
325 throws ArchivaRestServiceException
329 archivaAdministration.updateUiConfiguration( uiConfiguration );
331 catch ( RepositoryAdminException e )
333 throw new ArchivaRestServiceException( e.getMessage() );
337 public NetworkConfiguration getNetworkConfiguration()
338 throws ArchivaRestServiceException
342 return archivaAdministration.getNetworkConfiguration();
344 catch ( RepositoryAdminException e )
346 throw new ArchivaRestServiceException( e.getMessage() );
350 public void setNetworkConfiguration( NetworkConfiguration networkConfiguration )
351 throws ArchivaRestServiceException
355 archivaAdministration.setNetworkConfiguration( networkConfiguration );
357 catch ( RepositoryAdminException e )
359 throw new ArchivaRestServiceException( e.getMessage() );