1 package org.apache.maven.archiva.web.action.admin.repositories;
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 com.opensymphony.xwork.Preparable;
24 import org.apache.commons.lang.StringUtils;
25 import org.apache.maven.archiva.configuration.Configuration;
26 import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
27 import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
29 import java.util.List;
32 * DeleteRemoteRepositoryAction
34 * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
37 * @plexus.component role="com.opensymphony.xwork.Action" role-hint="deleteRemoteRepositoryAction"
39 public class DeleteRemoteRepositoryAction
40 extends AbstractRemoteRepositoriesAction
43 private RemoteRepositoryConfiguration repository;
45 private String repoid;
49 if ( StringUtils.isNotBlank( repoid ) )
51 this.repository = archivaConfiguration.getConfiguration().findRemoteRepositoryById( repoid );
55 public String confirmDelete()
57 if ( StringUtils.isBlank( repoid ) )
59 addActionError( "Unable to delete remote repository: repository id was blank." );
66 public String delete()
68 String result = SUCCESS;
69 RemoteRepositoryConfiguration existingRepository = repository;
70 if ( existingRepository == null )
72 addActionError( "A repository with that id does not exist" );
76 Configuration configuration = archivaConfiguration.getConfiguration();
77 removeRepository( repoid, configuration );
78 result = saveConfiguration( configuration );
80 cleanupRepositoryData( existingRepository );
85 private void cleanupRepositoryData( RemoteRepositoryConfiguration existingRepository )
87 // [MRM-520] Proxy Connectors are not deleted with the deletion of a Repository.
89 List<ProxyConnectorConfiguration> proxyConnectors = getProxyConnectors();
90 for ( ProxyConnectorConfiguration proxyConnector : proxyConnectors )
92 if ( StringUtils.equals( proxyConnector.getTargetRepoId(), existingRepository.getId() ) )
94 archivaConfiguration.getConfiguration().removeProxyConnector( proxyConnector );
99 public RemoteRepositoryConfiguration getRepository()
104 public void setRepository( RemoteRepositoryConfiguration repository )
106 this.repository = repository;
109 public String getRepoid()
114 public void setRepoid( String repoid )
116 this.repoid = repoid;