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.repository.RepositoryAdminException;
22 import org.apache.archiva.admin.repository.group.RepositoryGroupAdmin;
23 import org.apache.archiva.rest.api.model.RepositoryGroup;
24 import org.apache.archiva.rest.api.services.RepositoryGroupService;
25 import org.apache.commons.lang.StringUtils;
26 import org.springframework.stereotype.Service;
28 import javax.inject.Inject;
29 import java.util.ArrayList;
30 import java.util.List;
33 * @author Olivier Lamy
35 @Service( "repositoryGroupService#rest" )
36 public class DefaultRepositoryGroupService
37 extends AbstractRestService
38 implements RepositoryGroupService
42 private RepositoryGroupAdmin repositoryGroupAdmin;
44 public List<RepositoryGroup> getRepositoriesGroups()
45 throws RepositoryAdminException
47 List<RepositoryGroup> repositoriesGroups = new ArrayList<RepositoryGroup>();
48 for ( org.apache.archiva.admin.repository.group.RepositoryGroup repoGroup : repositoryGroupAdmin.getRepositoriesGroups() )
50 repositoriesGroups.add(
51 new RepositoryGroup( repoGroup.getId(), new ArrayList<String>( repoGroup.getRepositories() ) ) );
53 return repositoriesGroups;
56 public RepositoryGroup getRepositoryGroup( String repositoryGroupId )
57 throws RepositoryAdminException
59 for ( RepositoryGroup repositoryGroup : getRepositoriesGroups() )
61 if ( StringUtils.equals( repositoryGroupId, repositoryGroup.getId() ) )
63 return repositoryGroup;
69 public Boolean addRepositoryGroup( RepositoryGroup repoGroup )
70 throws RepositoryAdminException
72 return repositoryGroupAdmin.addRepositoryGroup(
73 new org.apache.archiva.admin.repository.group.RepositoryGroup( repoGroup.getId(), new ArrayList<String>(
74 repoGroup.getRepositories() ) ), getAuditInformation() );
77 public Boolean updateRepositoryGroup( RepositoryGroup repoGroup )
78 throws RepositoryAdminException
80 return repositoryGroupAdmin.updateRepositoryGroup(
81 new org.apache.archiva.admin.repository.group.RepositoryGroup( repoGroup.getId(), new ArrayList<String>(
82 repoGroup.getRepositories() ) ), getAuditInformation() );
85 public Boolean deleteRepositoryGroup( String repositoryGroupId )
86 throws RepositoryAdminException
88 return repositoryGroupAdmin.deleteRepositoryGroup( repositoryGroupId, getAuditInformation() );
91 public Boolean addRepositoryToGroup( String repositoryGroupId, String repositoryId )
92 throws RepositoryAdminException
94 return repositoryGroupAdmin.addRepositoryToGroup( repositoryGroupId, repositoryId, getAuditInformation() );
97 public Boolean deleteRepositoryFromGroup( String repositoryGroupId, String repositoryId )
98 throws RepositoryAdminException
100 return repositoryGroupAdmin.deleteRepositoryFromGroup( repositoryGroupId, repositoryId, getAuditInformation() );