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.commons.lang.StringUtils;
23 import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
24 import org.springframework.context.annotation.Scope;
25 import org.springframework.stereotype.Controller;
28 * AddProxyConnectorAction
32 * plexus.component role="com.opensymphony.xwork2.Action" role-hint="addProxyConnectorAction" instantiation-strategy="per-lookup"
34 @Controller( "addProxyConnectorAction" )
36 public class AddProxyConnectorAction
37 extends AbstractProxyConnectorFormAction
43 connector = new ProxyConnectorConfiguration();
49 if ( connector != null )
52 connector.setBlackListPatterns( escapePatterns( connector.getBlackListPatterns() ) );
53 connector.setWhiteListPatterns( escapePatterns( connector.getWhiteListPatterns() ) );
59 public String commit()
61 /* Too complex for webwork's ${Action}-validation.xml techniques.
62 * Not appropriate for use with webwork's implements Validatable, as that validates regardless of
63 * the request method, such as .addProperty() or .addWhiteList().
65 * This validation is ultimately only useful on this one request method.
67 String sourceId = connector.getSourceRepoId();
68 String targetId = connector.getTargetRepoId();
70 ProxyConnectorConfiguration otherConnector = findProxyConnector( sourceId, targetId );
71 if ( otherConnector != null )
74 "Unable to add proxy connector, as one already exists with source repository id [" + sourceId
75 + "] and target repository id [" + targetId + "]." );
80 if ( hasActionErrors() )
85 if ( StringUtils.equals( DIRECT_CONNECTION, connector.getProxyId() ) )
87 connector.setProxyId( null );
91 connector.setBlackListPatterns( unescapePatterns( connector.getBlackListPatterns() ) );
92 connector.setWhiteListPatterns( unescapePatterns( connector.getWhiteListPatterns() ) );
94 addProxyConnector( connector );
95 return saveConfiguration();