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 net.sf.beanlib.provider.replicator.BeanReplicator;
22 import org.apache.archiva.admin.repository.RepositoryAdminException;
23 import org.apache.archiva.admin.repository.admin.ArchivaAdministration;
24 import org.apache.archiva.rest.api.model.FileType;
25 import org.apache.archiva.rest.api.model.LegacyArtifactPath;
26 import org.apache.archiva.rest.api.model.RepositoryScanning;
27 import org.apache.archiva.rest.api.services.ArchivaAdministrationService;
28 import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
29 import org.springframework.stereotype.Service;
31 import javax.inject.Inject;
32 import java.util.ArrayList;
33 import java.util.List;
36 * @author Olivier Lamy
39 @Service( "archivaAdministrationService#default" )
40 public class DefaultArchivaAdministrationService
41 extends AbstractRestService
42 implements ArchivaAdministrationService
45 private ArchivaAdministration archivaAdministration;
47 public List<LegacyArtifactPath> getLegacyArtifactPaths()
48 throws ArchivaRestServiceException
52 List<LegacyArtifactPath> legacyArtifactPaths = new ArrayList<LegacyArtifactPath>();
53 for ( org.apache.archiva.admin.repository.admin.LegacyArtifactPath legacyArtifactPath : archivaAdministration.getLegacyArtifactPaths() )
55 legacyArtifactPaths.add(
56 new BeanReplicator().replicateBean( legacyArtifactPath, LegacyArtifactPath.class ) );
58 return legacyArtifactPaths;
60 catch ( RepositoryAdminException e )
62 throw new ArchivaRestServiceException( e.getMessage() );
66 public void addLegacyArtifactPath( LegacyArtifactPath legacyArtifactPath )
67 throws ArchivaRestServiceException
71 archivaAdministration.addLegacyArtifactPath( new BeanReplicator().replicateBean( legacyArtifactPath,
72 org.apache.archiva.admin.repository.admin.LegacyArtifactPath.class ),
73 getAuditInformation() );
75 catch ( RepositoryAdminException e )
77 throw new ArchivaRestServiceException( e.getMessage() );
81 public Boolean deleteLegacyArtifactPath( String path )
82 throws ArchivaRestServiceException
86 archivaAdministration.deleteLegacyArtifactPath( path, getAuditInformation() );
89 catch ( RepositoryAdminException e )
91 throw new ArchivaRestServiceException( e.getMessage() );
95 public RepositoryScanning getRepositoryScanning()
96 throws ArchivaRestServiceException
100 return new BeanReplicator().replicateBean( archivaAdministration.getRepositoryScanning(),
101 RepositoryScanning.class );
103 catch ( RepositoryAdminException e )
105 throw new ArchivaRestServiceException( e.getMessage() );
109 public void updateRepositoryScanning( RepositoryScanning repositoryScanning )
110 throws ArchivaRestServiceException
114 archivaAdministration.updateRepositoryScanning( new BeanReplicator().replicateBean( getRepositoryScanning(),
115 org.apache.archiva.admin.repository.admin.RepositoryScanning.class ),
116 getAuditInformation() );
118 catch ( RepositoryAdminException e )
120 throw new ArchivaRestServiceException( e.getMessage() );
124 public Boolean addFileTypePattern( String fileTypeId, String pattern )
125 throws ArchivaRestServiceException
129 archivaAdministration.addFileTypePattern( fileTypeId, pattern, getAuditInformation() );
132 catch ( RepositoryAdminException e )
134 throw new ArchivaRestServiceException( e.getMessage() );
138 public Boolean removeFileTypePattern( String fileTypeId, String pattern )
139 throws ArchivaRestServiceException
143 archivaAdministration.removeFileTypePattern( fileTypeId, pattern, getAuditInformation() );
146 catch ( RepositoryAdminException e )
148 throw new ArchivaRestServiceException( e.getMessage() );
152 public FileType getFileType( String fileTypeId )
153 throws ArchivaRestServiceException
157 org.apache.archiva.admin.repository.admin.FileType fileType =
158 archivaAdministration.getFileType( fileTypeId );
159 if ( fileType == null )
163 return new BeanReplicator().replicateBean( fileType, FileType.class );
165 catch ( RepositoryAdminException e )
167 throw new ArchivaRestServiceException( e.getMessage() );
171 public void addFileType( FileType fileType )
172 throws ArchivaRestServiceException
176 archivaAdministration.addFileType( new BeanReplicator().replicateBean( fileType,
177 org.apache.archiva.admin.repository.admin.FileType.class ),
178 getAuditInformation() );
180 catch ( RepositoryAdminException e )
182 throw new ArchivaRestServiceException( e.getMessage() );
186 public Boolean removeFileType( String fileTypeId )
187 throws ArchivaRestServiceException
191 archivaAdministration.removeFileType( fileTypeId, getAuditInformation() );
194 catch ( RepositoryAdminException e )
196 throw new ArchivaRestServiceException( e.getMessage() );
200 public Boolean addKnownContentConsumer( String knownContentConsumer )
201 throws ArchivaRestServiceException
205 archivaAdministration.addKnownContentConsumer( knownContentConsumer, getAuditInformation() );
208 catch ( RepositoryAdminException e )
210 throw new ArchivaRestServiceException( e.getMessage() );
214 public void setKnownContentConsumers( List<String> knownContentConsumers )
215 throws ArchivaRestServiceException
219 archivaAdministration.setKnownContentConsumers( knownContentConsumers, getAuditInformation() );
221 catch ( RepositoryAdminException e )
223 throw new ArchivaRestServiceException( e.getMessage() );
227 public Boolean removeKnownContentConsumer( String knownContentConsumer )
228 throws ArchivaRestServiceException
232 archivaAdministration.removeKnownContentConsumer( knownContentConsumer, getAuditInformation() );
235 catch ( RepositoryAdminException e )
237 throw new ArchivaRestServiceException( e.getMessage() );
241 public Boolean addInvalidContentConsumer( String invalidContentConsumer )
242 throws ArchivaRestServiceException
246 archivaAdministration.addInvalidContentConsumer( invalidContentConsumer, getAuditInformation() );
249 catch ( RepositoryAdminException e )
251 throw new ArchivaRestServiceException( e.getMessage() );
255 public void setInvalidContentConsumers( List<String> invalidContentConsumers )
256 throws ArchivaRestServiceException
260 archivaAdministration.setInvalidContentConsumers( invalidContentConsumers, getAuditInformation() );
262 catch ( RepositoryAdminException e )
264 throw new ArchivaRestServiceException( e.getMessage() );
268 public Boolean removeInvalidContentConsumer( String invalidContentConsumer )
269 throws ArchivaRestServiceException
273 archivaAdministration.removeInvalidContentConsumer( invalidContentConsumer, getAuditInformation() );
276 catch ( RepositoryAdminException e )
278 throw new ArchivaRestServiceException( e.getMessage() );