1 package org.apache.maven.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.repository.RepositoryAdminException;
24 import org.apache.archiva.admin.repository.group.RepositoryGroup;
25 import org.apache.archiva.admin.repository.group.RepositoryGroupAdmin;
26 import org.apache.archiva.admin.repository.managed.ManagedRepository;
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 private static final Pattern REPO_GROUP_ID_PATTERN = Pattern.compile( "[A-Za-z0-9\\._\\-]+" );
70 public void setServletRequest( HttpServletRequest request )
72 this.baseUrl = ContextUtils.getBaseURL( request, "repository" );
76 throws RepositoryAdminException
79 repositoryGroup = new RepositoryGroup();
80 repositoryGroups = getRepositoryGroupAdmin().getRepositoryGroupsAsMap();
81 managedRepositories = getManagedRepositoryAdmin().getManagedRepositoriesAsMap();
82 groupToRepositoryMap = getRepositoryGroupAdmin().getGroupToRepositoryMap();
85 public String addRepositoryGroup()
89 getRepositoryGroupAdmin().addRepositoryGroup( repositoryGroup, getAuditInformation() );
91 catch ( RepositoryAdminException e )
93 addActionError( e.getMessage() );
100 public String addRepositoryToGroup()
104 getRepositoryGroupAdmin().addRepositoryToGroup( repoGroupId, repoId, getAuditInformation() );
106 catch ( RepositoryAdminException e )
108 addActionError( e.getMessage() );
114 public String removeRepositoryFromGroup()
118 getRepositoryGroupAdmin().deleteRepositoryFromGroup( repoGroupId, repoId, getAuditInformation() );
120 catch ( RepositoryAdminException e )
122 addActionError( e.getMessage() );
129 public RepositoryGroup getRepositoryGroup()
131 return repositoryGroup;
134 public void setRepositoryGroup( RepositoryGroup repositoryGroup )
136 this.repositoryGroup = repositoryGroup;
139 public Map<String, RepositoryGroup> getRepositoryGroups()
141 return repositoryGroups;
144 public void setRepositoryGroups( Map<String, RepositoryGroup> repositoryGroups )
146 this.repositoryGroups = repositoryGroups;
149 public Map<String, ManagedRepository> getManagedRepositories()
151 return managedRepositories;
154 public Map<String, List<String>> getGroupToRepositoryMap()
156 return this.groupToRepositoryMap;
159 public String getRepoGroupId()
164 public void setRepoGroupId( String repoGroupId )
166 this.repoGroupId = repoGroupId;
169 public String getRepoId()
174 public void setRepoId( String repoId )
176 this.repoId = repoId;
179 public String getBaseUrl()
184 public RepositoryGroupAdmin getRepositoryGroupAdmin()
186 return repositoryGroupAdmin;
189 public void setRepositoryGroupAdmin( RepositoryGroupAdmin repositoryGroupAdmin )
191 this.repositoryGroupAdmin = repositoryGroupAdmin;