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.proxyconnector.ProxyConnector;
24 import org.apache.commons.lang.StringUtils;
25 import org.springframework.context.annotation.Scope;
26 import org.springframework.stereotype.Controller;
29 * AddProxyConnectorAction
33 @Controller( "addProxyConnectorAction" )
35 public class AddProxyConnectorAction
36 extends AbstractProxyConnectorFormAction
40 throws RepositoryAdminException
43 connector = new ProxyConnector();
49 if ( connector != null )
52 connector.setBlackListPatterns( escapePatterns( connector.getBlackListPatterns() ) );
53 connector.setWhiteListPatterns( escapePatterns( connector.getWhiteListPatterns() ) );
59 public String commit()
60 throws RepositoryAdminException
62 /* Too complex for webwork's ${Action}-validation.xml techniques.
63 * Not appropriate for use with webwork's implements Validatable, as that validates regardless of
64 * the request method, such as .addProperty() or .addWhiteList().
66 * This validation is ultimately only useful on this one request method.
68 String sourceId = connector.getSourceRepoId();
69 String targetId = connector.getTargetRepoId();
71 ProxyConnector otherConnector = findProxyConnector( sourceId, targetId );
72 if ( otherConnector != null )
75 "Unable to add proxy connector, as one already exists with source repository id [" + sourceId
76 + "] and target repository id [" + targetId + "]." );
81 if ( hasActionErrors() )
86 if ( StringUtils.equals( DIRECT_CONNECTION, connector.getProxyId() ) )
88 connector.setProxyId( null );
92 connector.setBlackListPatterns( unescapePatterns( connector.getBlackListPatterns() ) );
93 connector.setWhiteListPatterns( unescapePatterns( connector.getWhiteListPatterns() ) );
95 addProxyConnector( connector );