This project has retired. For details please refer to its
Attic page.
DefaultRepositoryGroupService xref
1 package org.apache.archiva.rest.services;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 import org.apache.archiva.admin.model.RepositoryAdminException;
22 import org.apache.archiva.admin.model.beans.RepositoryGroup;
23 import org.apache.archiva.admin.model.group.RepositoryGroupAdmin;
24 import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
25 import org.apache.archiva.rest.api.services.RepositoryGroupService;
26 import org.apache.commons.lang.StringUtils;
27 import org.springframework.stereotype.Service;
28
29 import javax.inject.Inject;
30 import java.util.ArrayList;
31 import java.util.List;
32
33
34
35
36 @Service("repositoryGroupService#rest")
37 public class DefaultRepositoryGroupService
38 extends AbstractRestService
39 implements RepositoryGroupService
40 {
41
42 @Inject
43 private RepositoryGroupAdmin repositoryGroupAdmin;
44
45 @Override
46 public List<RepositoryGroup> getRepositoriesGroups()
47 throws ArchivaRestServiceException
48 {
49 try
50 {
51 List<RepositoryGroup> repositoriesGroups =
52 new ArrayList<>( repositoryGroupAdmin.getRepositoriesGroups().size() );
53 for ( org.apache.archiva.admin.model.beans.RepositoryGroup repoGroup : repositoryGroupAdmin.getRepositoriesGroups() )
54 {
55 repositoriesGroups.add( new RepositoryGroup( repoGroup.getId(), new ArrayList<>(
56 repoGroup.getRepositories() ) ).mergedIndexPath( repoGroup.getMergedIndexPath() ).mergedIndexTtl(
57 repoGroup.getMergedIndexTtl() ).cronExpression( repoGroup.getCronExpression() ) );
58 }
59 return repositoriesGroups;
60 }
61 catch ( RepositoryAdminException e )
62 {
63 throw new ArchivaRestServiceException( e.getMessage(), e );
64 }
65 }
66
67 @Override
68 public RepositoryGroup getRepositoryGroup( String repositoryGroupId )
69 throws ArchivaRestServiceException
70 {
71 for ( RepositoryGroup repositoryGroup : getRepositoriesGroups() )
72 {
73 if ( StringUtils.equals( repositoryGroupId, repositoryGroup.getId() ) )
74 {
75 return repositoryGroup;
76 }
77 }
78 return null;
79 }
80
81 @Override
82 public Boolean addRepositoryGroup( RepositoryGroup repoGroup )
83 throws ArchivaRestServiceException
84 {
85 try
86 {
87 return repositoryGroupAdmin.addRepositoryGroup(
88 new org.apache.archiva.admin.model.beans.RepositoryGroup( repoGroup.getId(), new ArrayList<>(
89 repoGroup.getRepositories() ) ).mergedIndexPath( repoGroup.getMergedIndexPath() ).mergedIndexTtl(
90 repoGroup.getMergedIndexTtl() ).cronExpression( repoGroup.getCronExpression() ),
91 getAuditInformation() );
92 }
93 catch ( RepositoryAdminException e )
94 {
95 throw new ArchivaRestServiceException( e.getMessage(), e );
96 }
97 }
98
99 @Override
100 public Boolean updateRepositoryGroup( RepositoryGroup repoGroup )
101 throws ArchivaRestServiceException
102 {
103 try
104 {
105 return repositoryGroupAdmin.updateRepositoryGroup(
106 new org.apache.archiva.admin.model.beans.RepositoryGroup( repoGroup.getId(), new ArrayList<>(
107 repoGroup.getRepositories() ) ).mergedIndexPath( repoGroup.getMergedIndexPath() ).mergedIndexTtl(
108 repoGroup.getMergedIndexTtl() ).cronExpression( repoGroup.getCronExpression() ),
109 getAuditInformation() );
110 }
111 catch ( RepositoryAdminException e )
112 {
113 throw new ArchivaRestServiceException( e.getMessage(), e );
114 }
115 }
116
117 @Override
118 public Boolean deleteRepositoryGroup( String repositoryGroupId )
119 throws ArchivaRestServiceException
120 {
121 try
122 {
123 return repositoryGroupAdmin.deleteRepositoryGroup( repositoryGroupId, getAuditInformation() );
124 }
125 catch ( RepositoryAdminException e )
126 {
127 throw new ArchivaRestServiceException( e.getMessage(), e );
128 }
129 }
130
131 @Override
132 public Boolean addRepositoryToGroup( String repositoryGroupId, String repositoryId )
133 throws ArchivaRestServiceException
134 {
135 try
136 {
137 return repositoryGroupAdmin.addRepositoryToGroup( repositoryGroupId, repositoryId, getAuditInformation() );
138 }
139 catch ( RepositoryAdminException e )
140 {
141 throw new ArchivaRestServiceException( e.getMessage(), e );
142 }
143 }
144
145 @Override
146 public Boolean deleteRepositoryFromGroup( String repositoryGroupId, String repositoryId )
147 throws ArchivaRestServiceException
148 {
149 try
150 {
151 return repositoryGroupAdmin.deleteRepositoryFromGroup( repositoryGroupId, repositoryId,
152 getAuditInformation() );
153 }
154 catch ( RepositoryAdminException e )
155 {
156 throw new ArchivaRestServiceException( e.getMessage(), e );
157 }
158 }
159 }