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 @Controller( "addProxyConnectorAction" )
34 public class AddProxyConnectorAction
35 extends AbstractProxyConnectorFormAction
41 connector = new ProxyConnectorConfiguration();
47 if ( connector != null )
50 connector.setBlackListPatterns( escapePatterns( connector.getBlackListPatterns() ) );
51 connector.setWhiteListPatterns( escapePatterns( connector.getWhiteListPatterns() ) );
57 public String commit()
59 /* Too complex for webwork's ${Action}-validation.xml techniques.
60 * Not appropriate for use with webwork's implements Validatable, as that validates regardless of
61 * the request method, such as .addProperty() or .addWhiteList().
63 * This validation is ultimately only useful on this one request method.
65 String sourceId = connector.getSourceRepoId();
66 String targetId = connector.getTargetRepoId();
68 ProxyConnectorConfiguration otherConnector = findProxyConnector( sourceId, targetId );
69 if ( otherConnector != null )
72 "Unable to add proxy connector, as one already exists with source repository id [" + sourceId
73 + "] and target repository id [" + targetId + "]." );
78 if ( hasActionErrors() )
83 if ( StringUtils.equals( DIRECT_CONNECTION, connector.getProxyId() ) )
85 connector.setProxyId( null );
89 connector.setBlackListPatterns( unescapePatterns( connector.getBlackListPatterns() ) );
90 connector.setWhiteListPatterns( unescapePatterns( connector.getWhiteListPatterns() ) );
92 addProxyConnector( connector );
93 return saveConfiguration();