1 package org.apache.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;
23 import org.apache.archiva.admin.model.RepositoryAdminException;
24 import org.apache.archiva.admin.model.beans.ManagedRepository;
25 import org.apache.commons.lang.StringUtils;
26 import org.springframework.context.annotation.Scope;
27 import org.springframework.stereotype.Controller;
30 * DeleteManagedRepositoryAction
34 @Controller( "deleteManagedRepositoryAction" )
36 public class DeleteManagedRepositoryAction
37 extends AbstractManagedRepositoriesAction
42 private ManagedRepository repository;
44 private ManagedRepository stagingRepository;
46 private String repoid;
49 throws RepositoryAdminException
51 if ( StringUtils.isNotBlank( repoid ) )
53 this.repository = getManagedRepositoryAdmin().getManagedRepository( repoid );
54 this.stagingRepository = getManagedRepositoryAdmin().getManagedRepository( repoid + "-stage" );
58 public String confirmDelete()
60 if ( StringUtils.isBlank( repoid ) )
62 addActionError( "Unable to delete managed repository: repository id was blank." );
69 public String deleteEntry()
71 return deleteRepository( false );
74 public String deleteContents()
76 return deleteRepository( true );
79 private String deleteRepository( boolean deleteContents )
81 ManagedRepository existingRepository = repository;
82 if ( existingRepository == null )
84 addActionError( "A repository with that id does not exist" );
88 String result = SUCCESS;
92 getManagedRepositoryAdmin().deleteManagedRepository( existingRepository.getId(), getAuditInformation(),
95 catch ( RepositoryAdminException e )
98 "Unable to delete repository, content may already be partially removed: " + e.getMessage() );
99 log.error( e.getMessage(), e );
105 public ManagedRepository getRepository()
110 public void setRepository( ManagedRepository repository )
112 this.repository = repository;
115 public String getRepoid()
120 public void setRepoid( String repoid )
122 this.repoid = repoid;