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.RemoteRepositoryConfiguration;
29 * DeleteRemoteRepositoryAction
31 * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
34 * @plexus.component role="com.opensymphony.xwork.Action" role-hint="deleteRemoteRepositoryAction"
36 public class DeleteRemoteRepositoryAction
37 extends AbstractRemoteRepositoriesAction
40 private RemoteRepositoryConfiguration repository;
42 private String repoid;
46 if ( StringUtils.isNotBlank( repoid ) )
48 this.repository = archivaConfiguration.getConfiguration().findRemoteRepositoryById( repoid );
52 public String confirmDelete()
54 if ( StringUtils.isBlank( repoid ) )
56 addActionError( "Unable to delete remote repository: repository id was blank." );
63 public String delete()
65 String result = SUCCESS;
66 RemoteRepositoryConfiguration existingRepository = repository;
67 if ( existingRepository == null )
69 addActionError( "A repository with that id does not exist" );
73 Configuration configuration = archivaConfiguration.getConfiguration();
74 removeRepository( repoid, configuration );
75 result = saveConfiguration( configuration );
77 cleanupRepositoryData( existingRepository );
82 private void cleanupRepositoryData( RemoteRepositoryConfiguration existingRepository )
84 // TODO: [MRM-520] Proxy Connectors are not deleted with the deletion of a Repository.
87 public RemoteRepositoryConfiguration getRepository()
92 public void setRepository( RemoteRepositoryConfiguration repository )
94 this.repository = repository;
97 public String getRepoid()
102 public void setRepoid( String repoid )
104 this.repoid = repoid;