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 org.apache.archiva.admin.repository.RepositoryAdminException;
23 import org.apache.archiva.admin.repository.managed.ManagedRepositoryAdmin;
24 import org.apache.archiva.admin.repository.proxyconnector.ProxyConnector;
25 import org.apache.archiva.admin.repository.proxyconnector.ProxyConnectorAdmin;
26 import org.apache.archiva.admin.repository.remote.RemoteRepositoryAdmin;
27 import org.apache.archiva.security.common.ArchivaRoleConstants;
28 import org.apache.commons.lang.StringUtils;
29 import org.apache.maven.archiva.web.action.AbstractActionSupport;
30 import org.codehaus.plexus.redback.rbac.Resource;
31 import org.codehaus.redback.integration.interceptor.SecureAction;
32 import org.codehaus.redback.integration.interceptor.SecureActionBundle;
33 import org.codehaus.redback.integration.interceptor.SecureActionException;
35 import javax.inject.Inject;
36 import java.util.List;
40 * AbstractProxyConnectorAction
44 public abstract class AbstractProxyConnectorAction
45 extends AbstractActionSupport
46 implements SecureAction
48 public static final String DIRECT_CONNECTION = "(direct connection)";
51 private ProxyConnectorAdmin proxyConnectorAdmin;
54 private RemoteRepositoryAdmin remoteRepositoryAdmin;
57 private ManagedRepositoryAdmin managedRepositoryAdmin;
59 public SecureActionBundle getSecureActionBundle()
60 throws SecureActionException
62 SecureActionBundle bundle = new SecureActionBundle();
64 bundle.setRequiresAuthentication( true );
65 bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );
71 protected void addProxyConnector( ProxyConnector proxyConnector )
72 throws RepositoryAdminException
74 getProxyConnectorAdmin().addProxyConnector( proxyConnector, getAuditInformation() );
77 protected ProxyConnector findProxyConnector( String sourceId, String targetId )
78 throws RepositoryAdminException
80 if ( StringUtils.isBlank( sourceId ) )
85 if ( StringUtils.isBlank( targetId ) )
90 return getProxyConnectorAdmin().findProxyConnector( sourceId, targetId );
93 protected Map<String, List<ProxyConnector>> createProxyConnectorMap()
94 throws RepositoryAdminException
96 return getProxyConnectorAdmin().getProxyConnectorAsMap();
99 protected void removeConnector( String sourceId, String targetId )
100 throws RepositoryAdminException
102 ProxyConnector proxyConnector = findProxyConnector( sourceId, targetId );
103 if ( proxyConnector != null )
105 getProxyConnectorAdmin().deleteProxyConnector( proxyConnector, getAuditInformation() );
109 protected void removeProxyConnector( ProxyConnector connector )
110 throws RepositoryAdminException
112 getProxyConnectorAdmin().deleteProxyConnector( connector, getAuditInformation() );
116 public ProxyConnectorAdmin getProxyConnectorAdmin()
118 return proxyConnectorAdmin;
121 public void setProxyConnectorAdmin( ProxyConnectorAdmin proxyConnectorAdmin )
123 this.proxyConnectorAdmin = proxyConnectorAdmin;
126 public RemoteRepositoryAdmin getRemoteRepositoryAdmin()
128 return remoteRepositoryAdmin;
131 public void setRemoteRepositoryAdmin( RemoteRepositoryAdmin remoteRepositoryAdmin )
133 this.remoteRepositoryAdmin = remoteRepositoryAdmin;
136 public ManagedRepositoryAdmin getManagedRepositoryAdmin()
138 return managedRepositoryAdmin;
141 public void setManagedRepositoryAdmin( ManagedRepositoryAdmin managedRepositoryAdmin )
143 this.managedRepositoryAdmin = managedRepositoryAdmin;