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.xwork2.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
36 * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="deleteRemoteRepositoryAction" instantiation-strategy="per-lookup"
38 public class DeleteRemoteRepositoryAction
39 extends AbstractRemoteRepositoriesAction
42 private RemoteRepositoryConfiguration repository;
44 private String repoid;
48 if ( StringUtils.isNotBlank( repoid ) )
50 this.repository = archivaConfiguration.getConfiguration().findRemoteRepositoryById( repoid );
54 public String confirmDelete()
56 if ( StringUtils.isBlank( repoid ) )
58 addActionError( "Unable to delete remote repository: repository id was blank." );
65 public String delete()
67 String result = SUCCESS;
68 RemoteRepositoryConfiguration existingRepository = repository;
69 if ( existingRepository == null )
71 addActionError( "A repository with that id does not exist" );
75 Configuration configuration = archivaConfiguration.getConfiguration();
76 removeRepository( repoid, configuration );
77 result = saveConfiguration( configuration );
79 cleanupRepositoryData( existingRepository );
84 private void cleanupRepositoryData( RemoteRepositoryConfiguration existingRepository )
86 // [MRM-520] Proxy Connectors are not deleted with the deletion of a Repository.
88 List<ProxyConnectorConfiguration> proxyConnectors = getProxyConnectors();
89 for ( ProxyConnectorConfiguration proxyConnector : proxyConnectors )
91 if ( StringUtils.equals( proxyConnector.getTargetRepoId(), existingRepository.getId() ) )
93 archivaConfiguration.getConfiguration().removeProxyConnector( proxyConnector );
98 public RemoteRepositoryConfiguration getRepository()
103 public void setRepository( RemoteRepositoryConfiguration repository )
105 this.repository = repository;
108 public String getRepoid()
113 public void setRepoid( String repoid )
115 this.repoid = repoid;