1 package org.apache.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.model.RepositoryAdminException;
23 import org.apache.archiva.admin.model.beans.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();
52 public String commit()
53 throws RepositoryAdminException
55 /* Too complex for webwork's ${Action}-validation.xml techniques.
56 * Not appropriate for use with webwork's implements Validatable, as that validates regardless of
57 * the request method, such as .addProperty() or .addWhiteList().
59 * This validation is ultimately only useful on this one request method.
61 String sourceId = connector.getSourceRepoId();
62 String targetId = connector.getTargetRepoId();
64 ProxyConnector otherConnector = findProxyConnector( sourceId, targetId );
65 if ( otherConnector != null )
68 "Unable to add proxy connector, as one already exists with source repository id [" + sourceId
69 + "] and target repository id [" + targetId + "]." );
74 if ( hasActionErrors() )
79 if ( StringUtils.equals( DIRECT_CONNECTION, connector.getProxyId() ) )
81 connector.setProxyId( null );
84 addProxyConnector( connector );