1 package org.apache.maven.archiva.web.action.admin.connectors.proxy;
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.xwork.Preparable;
23 import org.apache.commons.collections.Closure;
24 import org.apache.commons.collections.CollectionUtils;
25 import org.apache.commons.collections.Transformer;
26 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
27 import org.apache.maven.archiva.configuration.Configuration;
28 import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
29 import org.apache.maven.archiva.security.ArchivaRoleConstants;
30 import org.apache.maven.archiva.web.action.admin.repositories.AdminRepositoryConfiguration;
31 import org.codehaus.plexus.redback.rbac.Resource;
32 import org.codehaus.plexus.redback.xwork.interceptor.SecureAction;
33 import org.codehaus.plexus.redback.xwork.interceptor.SecureActionBundle;
34 import org.codehaus.plexus.redback.xwork.interceptor.SecureActionException;
35 import org.codehaus.plexus.xwork.action.PlexusActionSupport;
37 import java.util.ArrayList;
38 import java.util.HashMap;
39 import java.util.List;
43 * ProxyConnectorsAction
45 * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
47 * @plexus.component role="com.opensymphony.xwork.Action" role-hint="proxyConnectorsAction"
49 public class ProxyConnectorsAction
50 extends PlexusActionSupport
51 implements SecureAction, Preparable
54 * @plexus.requirement role-hint="adminrepoconfig"
56 private Transformer repoConfigToAdmin;
61 private ArchivaConfiguration archivaConfiguration;
63 private Map /*<String,AdminRepositoryConfiguration>*/repoMap;
66 * Map of Proxy Connectors.
68 private Map /*<String,AdminProxyConnector>*/proxyConnectorMap;
73 Configuration config = archivaConfiguration.getConfiguration();
75 repoMap = new HashMap();
77 Closure addToRepoMap = new Closure()
79 public void execute( Object input )
81 AdminRepositoryConfiguration arepo =
82 (AdminRepositoryConfiguration) repoConfigToAdmin.transform( input );
83 repoMap.put( arepo.getId(), arepo );
87 CollectionUtils.forAllDo( config.getManagedRepositories(), addToRepoMap );
88 CollectionUtils.forAllDo( config.getRemoteRepositories(), addToRepoMap );
90 proxyConnectorMap = new HashMap();
92 Closure addToProxyConnectorMap = new Closure()
94 public void execute( Object input )
96 if ( input instanceof ProxyConnectorConfiguration )
98 ProxyConnectorConfiguration proxyConfig = (ProxyConnectorConfiguration) input;
99 String key = proxyConfig.getSourceRepoId();
101 List connectors = (List) proxyConnectorMap.get( key );
102 if ( connectors == null )
104 connectors = new ArrayList();
105 proxyConnectorMap.put( key, connectors );
108 connectors.add( proxyConfig );
113 CollectionUtils.forAllDo( config.getProxyConnectors(), addToProxyConnectorMap );
116 public SecureActionBundle getSecureActionBundle()
117 throws SecureActionException
119 SecureActionBundle bundle = new SecureActionBundle();
121 bundle.setRequiresAuthentication( true );
122 bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );
127 public Map getRepoMap()
132 public void setRepoMap( Map repoMap )
134 this.repoMap = repoMap;
137 public Map getProxyConnectorMap()
139 return proxyConnectorMap;
142 public void setProxyConnectorMap( Map proxyConnectorMap )
144 this.proxyConnectorMap = proxyConnectorMap;