1 package org.apache.archiva.web.action.admin.repositories;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import com.opensymphony.xwork2.Preparable;
23 import org.apache.archiva.admin.model.RepositoryAdminException;
24 import org.apache.archiva.admin.model.beans.ManagedRepository;
25 import org.apache.archiva.admin.model.beans.RepositoryGroup;
26 import org.apache.archiva.admin.model.group.RepositoryGroupAdmin;
27 import org.apache.archiva.web.util.ContextUtils;
28 import org.apache.struts2.interceptor.ServletRequestAware;
29 import org.springframework.context.annotation.Scope;
30 import org.springframework.stereotype.Controller;
32 import javax.inject.Inject;
33 import javax.servlet.http.HttpServletRequest;
34 import java.util.List;
36 import java.util.regex.Pattern;
39 * RepositoryGroupsAction
41 @Controller( "repositoryGroupsAction" )
43 public class RepositoryGroupsAction
44 extends AbstractRepositoriesAdminAction
45 implements ServletRequestAware, Preparable
49 private RepositoryGroupAdmin repositoryGroupAdmin;
51 private RepositoryGroup repositoryGroup;
53 private Map<String, RepositoryGroup> repositoryGroups;
55 private Map<String, ManagedRepository> managedRepositories;
57 private Map<String, List<String>> groupToRepositoryMap;
59 private String repoGroupId;
61 private String repoId;
64 * Used to construct the repository WebDAV URL in the repository action.
66 private String baseUrl;
68 public void setServletRequest( HttpServletRequest request )
70 this.baseUrl = ContextUtils.getBaseURL( request, "repository" );
74 throws RepositoryAdminException
77 repositoryGroup = new RepositoryGroup();
78 repositoryGroups = getRepositoryGroupAdmin().getRepositoryGroupsAsMap();
79 managedRepositories = getManagedRepositoryAdmin().getManagedRepositoriesAsMap();
80 groupToRepositoryMap = getRepositoryGroupAdmin().getGroupToRepositoryMap();
83 public String addRepositoryGroup()
87 getRepositoryGroupAdmin().addRepositoryGroup( repositoryGroup, getAuditInformation() );
89 catch ( RepositoryAdminException e )
91 addActionError( e.getMessage() );
98 public String addRepositoryToGroup()
102 getRepositoryGroupAdmin().addRepositoryToGroup( repoGroupId, repoId, getAuditInformation() );
104 catch ( RepositoryAdminException e )
106 addActionError( e.getMessage() );
112 public String removeRepositoryFromGroup()
116 getRepositoryGroupAdmin().deleteRepositoryFromGroup( repoGroupId, repoId, getAuditInformation() );
118 catch ( RepositoryAdminException e )
120 addActionError( e.getMessage() );
127 public RepositoryGroup getRepositoryGroup()
129 return repositoryGroup;
132 public void setRepositoryGroup( RepositoryGroup repositoryGroup )
134 this.repositoryGroup = repositoryGroup;
137 public Map<String, RepositoryGroup> getRepositoryGroups()
139 return repositoryGroups;
142 public void setRepositoryGroups( Map<String, RepositoryGroup> repositoryGroups )
144 this.repositoryGroups = repositoryGroups;
147 public Map<String, ManagedRepository> getManagedRepositories()
149 return managedRepositories;
152 public Map<String, List<String>> getGroupToRepositoryMap()
154 return this.groupToRepositoryMap;
157 public String getRepoGroupId()
162 public void setRepoGroupId( String repoGroupId )
164 this.repoGroupId = repoGroupId;
167 public String getRepoId()
172 public void setRepoId( String repoId )
174 this.repoId = repoId;
177 public String getBaseUrl()
182 public RepositoryGroupAdmin getRepositoryGroupAdmin()
184 return repositoryGroupAdmin;
187 public void setRepositoryGroupAdmin( RepositoryGroupAdmin repositoryGroupAdmin )
189 this.repositoryGroupAdmin = repositoryGroupAdmin;