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.springframework.stereotype.Service;
30 import javax.inject.Inject;
31 import java.util.ArrayList;
32 import java.util.List;
35 * @author Olivier Lamy
38 @Service( "archivaAdministrationService#default" )
39 public class DefaultArchivaAdministrationService
40 extends AbstractRestService
41 implements ArchivaAdministrationService
44 private ArchivaAdministration archivaAdministration;
46 public List<LegacyArtifactPath> getLegacyArtifactPaths()
47 throws RepositoryAdminException
49 List<LegacyArtifactPath> legacyArtifactPaths = new ArrayList<LegacyArtifactPath>();
50 for ( org.apache.archiva.admin.repository.admin.LegacyArtifactPath legacyArtifactPath : archivaAdministration.getLegacyArtifactPaths() )
52 legacyArtifactPaths.add(
53 new BeanReplicator().replicateBean( legacyArtifactPath, LegacyArtifactPath.class ) );
55 return legacyArtifactPaths;
58 public void addLegacyArtifactPath( LegacyArtifactPath legacyArtifactPath )
59 throws RepositoryAdminException
61 archivaAdministration.addLegacyArtifactPath( new BeanReplicator().replicateBean( legacyArtifactPath,
62 org.apache.archiva.admin.repository.admin.LegacyArtifactPath.class ),
63 getAuditInformation() );
66 public Boolean deleteLegacyArtifactPath( String path )
67 throws RepositoryAdminException
69 archivaAdministration.deleteLegacyArtifactPath( path, getAuditInformation() );
73 public RepositoryScanning getRepositoryScanning()
74 throws RepositoryAdminException
76 return new BeanReplicator().replicateBean( archivaAdministration.getRepositoryScanning(),
77 RepositoryScanning.class );
80 public void updateRepositoryScanning( RepositoryScanning repositoryScanning )
81 throws RepositoryAdminException
83 archivaAdministration.updateRepositoryScanning( new BeanReplicator().replicateBean( getRepositoryScanning(),
84 org.apache.archiva.admin.repository.admin.RepositoryScanning.class ),
85 getAuditInformation() );
88 public Boolean addFileTypePattern( String fileTypeId, String pattern )
89 throws RepositoryAdminException
91 archivaAdministration.addFileTypePattern( fileTypeId, pattern, getAuditInformation() );
95 public Boolean removeFileTypePattern( String fileTypeId, String pattern )
96 throws RepositoryAdminException
98 archivaAdministration.removeFileTypePattern( fileTypeId, pattern, getAuditInformation() );
102 public FileType getFileType( String fileTypeId )
103 throws RepositoryAdminException
105 org.apache.archiva.admin.repository.admin.FileType fileType = archivaAdministration.getFileType( fileTypeId );
106 if ( fileType == null )
110 return new BeanReplicator().replicateBean( fileType, FileType.class );
113 public void addFileType( FileType fileType )
114 throws RepositoryAdminException
116 archivaAdministration.addFileType(
117 new BeanReplicator().replicateBean( fileType, org.apache.archiva.admin.repository.admin.FileType.class ),
118 getAuditInformation() );
122 public Boolean removeFileType( String fileTypeId )
123 throws RepositoryAdminException
125 archivaAdministration.removeFileType( fileTypeId, getAuditInformation() );
129 public Boolean addKnownContentConsumer( String knownContentConsumer )
130 throws RepositoryAdminException
132 archivaAdministration.addKnownContentConsumer( knownContentConsumer, getAuditInformation() );
136 public void setKnownContentConsumers( List<String> knownContentConsumers )
137 throws RepositoryAdminException
139 archivaAdministration.setKnownContentConsumers( knownContentConsumers, getAuditInformation() );
142 public Boolean removeKnownContentConsumer( String knownContentConsumer )
143 throws RepositoryAdminException
145 archivaAdministration.removeKnownContentConsumer( knownContentConsumer, getAuditInformation() );
149 public Boolean addInvalidContentConsumer( String invalidContentConsumer )
150 throws RepositoryAdminException
152 archivaAdministration.addInvalidContentConsumer( invalidContentConsumer, getAuditInformation() );
156 public void setInvalidContentConsumers( List<String> invalidContentConsumers )
157 throws RepositoryAdminException
159 archivaAdministration.setInvalidContentConsumers( invalidContentConsumers, getAuditInformation() );
162 public Boolean removeInvalidContentConsumer( String invalidContentConsumer )
163 throws RepositoryAdminException
165 archivaAdministration.removeInvalidContentConsumer( invalidContentConsumer, getAuditInformation() );