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;
27 import javax.inject.Inject;
28 import java.util.ArrayList;
29 import java.util.List;
32 * @author Olivier Lamy
34 public class DefaultRepositoryGroupService
35 extends AbstractRestService
36 implements RepositoryGroupService
40 private RepositoryGroupAdmin repositoryGroupAdmin;
42 public List<RepositoryGroup> getRepositoriesGroups()
43 throws RepositoryAdminException
45 List<RepositoryGroup> repositoriesGroups = new ArrayList<RepositoryGroup>();
46 for ( org.apache.archiva.admin.repository.group.RepositoryGroup repoGroup : repositoryGroupAdmin.getRepositoriesGroups() )
48 repositoriesGroups.add(
49 new RepositoryGroup( repoGroup.getId(), new ArrayList<String>( repoGroup.getRepositories() ) ) );
51 return repositoriesGroups;
54 public RepositoryGroup getRepositoryGroup( String repositoryGroupId )
55 throws RepositoryAdminException
57 for ( RepositoryGroup repositoryGroup : getRepositoriesGroups() )
59 if ( StringUtils.equals( repositoryGroupId, repositoryGroup.getId() ) )
61 return repositoryGroup;
67 public Boolean addRepositoryGroup( RepositoryGroup repoGroup )
68 throws RepositoryAdminException
70 return repositoryGroupAdmin.addRepositoryGroup(
71 new org.apache.archiva.admin.repository.group.RepositoryGroup( repoGroup.getId(), new ArrayList<String>(
72 repoGroup.getRepositories() ) ), getAuditInformation() );
75 public Boolean updateRepositoryGroup( RepositoryGroup repoGroup )
76 throws RepositoryAdminException
78 return repositoryGroupAdmin.updateRepositoryGroup(
79 new org.apache.archiva.admin.repository.group.RepositoryGroup( repoGroup.getId(), new ArrayList<String>(
80 repoGroup.getRepositories() ) ), getAuditInformation() );
83 public Boolean deleteRepositoryGroup( String repositoryGroupId )
84 throws RepositoryAdminException
86 return repositoryGroupAdmin.deleteRepositoryGroup( repositoryGroupId, getAuditInformation() );
89 public Boolean addRepositoryToGroup( String repositoryGroupId, String repositoryId )
90 throws RepositoryAdminException
92 return repositoryGroupAdmin.addRepositoryToGroup( repositoryGroupId, repositoryId, getAuditInformation() );
95 public Boolean deleteRepositoryFromGroup( String repositoryGroupId, String repositoryId )
96 throws RepositoryAdminException
98 return repositoryGroupAdmin.deleteRepositoryFromGroup( repositoryGroupId, repositoryId, getAuditInformation() );