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;
23 import org.apache.archiva.admin.repository.RepositoryAdminException;
24 import org.apache.commons.lang.StringUtils;
25 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
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 ManagedRepositoryConfiguration repository;
44 private ManagedRepositoryConfiguration stagingRepository;
46 private String repoid;
48 // FIXME olamy use ManagedRepositoryAdmin rather tha, directly archivaConfiguration
51 if ( StringUtils.isNotBlank( repoid ) )
53 this.repository = archivaConfiguration.getConfiguration().findManagedRepositoryById( repoid );
54 this.stagingRepository =
55 archivaConfiguration.getConfiguration().findManagedRepositoryById( repoid + "-stage" );
59 public String confirmDelete()
61 if ( StringUtils.isBlank( repoid ) )
63 addActionError( "Unable to delete managed repository: repository id was blank." );
70 public String deleteEntry()
72 return deleteRepository( false );
75 public String deleteContents()
77 return deleteRepository( true );
80 private String deleteRepository( boolean deleteContents )
82 ManagedRepositoryConfiguration existingRepository = repository;
83 if ( existingRepository == null )
85 addActionError( "A repository with that id does not exist" );
89 String result = SUCCESS;
93 getManagedRepositoryAdmin().deleteManagedRepository( existingRepository.getId(), getAuditInformation(),
96 catch ( RepositoryAdminException e )
99 "Unable to delete repository, content may already be partially removed: " + e.getMessage() );
100 log.error( e.getMessage(), e );
106 public ManagedRepositoryConfiguration getRepository()
111 public void setRepository( ManagedRepositoryConfiguration repository )
113 this.repository = repository;
116 public String getRepoid()
121 public void setRepoid( String repoid )
123 this.repoid = repoid;