mirror of https://github.com/apache/archiva.git
[MRM-138] add repository deletion
git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@428785 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
33dce55980
commit
01e4a3c3e1
|
@ -0,0 +1,109 @@
|
|||
package org.apache.maven.repository.manager.web.action.admin;
|
||||
|
||||
/*
|
||||
* Copyright 2005-2006 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.repository.configuration.Configuration;
|
||||
import org.apache.maven.repository.configuration.ConfigurationChangeException;
|
||||
import org.apache.maven.repository.configuration.ConfigurationStore;
|
||||
import org.apache.maven.repository.configuration.ConfigurationStoreException;
|
||||
import org.apache.maven.repository.configuration.InvalidConfigurationException;
|
||||
import org.apache.maven.repository.configuration.RepositoryConfiguration;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
import org.codehaus.plexus.xwork.action.PlexusActionSupport;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Configures the application repositories.
|
||||
*
|
||||
* @plexus.component role="com.opensymphony.xwork.Action" role-hint="deleteRepositoryAction"
|
||||
*/
|
||||
public class DeleteRepositoryAction
|
||||
extends PlexusActionSupport
|
||||
{
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private ConfigurationStore configurationStore;
|
||||
|
||||
/**
|
||||
* The repository ID to lookup when editing a repository.
|
||||
*/
|
||||
private String repoId;
|
||||
|
||||
/**
|
||||
* Which operation to select.
|
||||
*/
|
||||
private String operation = "unmodified";
|
||||
|
||||
public String execute()
|
||||
throws ConfigurationStoreException, IOException, InvalidConfigurationException, ConfigurationChangeException
|
||||
{
|
||||
// TODO: if this didn't come from the form, go to configure.action instead of going through with re-saving what was just loaded
|
||||
|
||||
if ( "delete-entry".equals( operation ) || "delete-contents".equals( operation ) )
|
||||
{
|
||||
Configuration configuration = configurationStore.getConfigurationFromStore();
|
||||
|
||||
RepositoryConfiguration existingRepository = configuration.getRepositoryById( repoId );
|
||||
if ( existingRepository == null )
|
||||
{
|
||||
addActionError( "A repository with that id does not exist" );
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
// TODO: remove from index too!
|
||||
|
||||
configuration.removeRepository( existingRepository );
|
||||
|
||||
configurationStore.storeConfiguration( configuration );
|
||||
|
||||
if ( "delete-contents".equals( operation ) )
|
||||
{
|
||||
getLogger().info( "Removing " + existingRepository.getDirectory() );
|
||||
FileUtils.deleteDirectory( existingRepository.getDirectory() );
|
||||
}
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public String input()
|
||||
{
|
||||
return INPUT;
|
||||
}
|
||||
|
||||
public String getRepoId()
|
||||
{
|
||||
return repoId;
|
||||
}
|
||||
|
||||
public void setRepoId( String repoId )
|
||||
{
|
||||
this.repoId = repoId;
|
||||
}
|
||||
|
||||
public String getOperation()
|
||||
{
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation( String operation )
|
||||
{
|
||||
this.operation = operation;
|
||||
}
|
||||
}
|
|
@ -1,3 +1,5 @@
|
|||
# define our own action mapper here
|
||||
webwork.mapper.class=org.apache.maven.repository.manager.web.mapper.RepositoryActionMapper
|
||||
webwork.objectFactory = org.codehaus.plexus.xwork.PlexusObjectFactory
|
||||
|
||||
# TODO! package up a theme and share with Continuum. Should contain everything from xhtml, and set templateDir to WEB-INF/themes
|
|
@ -137,6 +137,11 @@
|
|||
<result type="redirect-action">index</result>
|
||||
</action>
|
||||
|
||||
<action name="deleteRepository" class="deleteRepositoryAction">
|
||||
<result name="input">/WEB-INF/jsp/admin/deleteRepository.jsp</result>
|
||||
<result type="redirect-action">index</result>
|
||||
</action>
|
||||
|
||||
<action name="configure" class="configureAction" method="input">
|
||||
<result name="input">/WEB-INF/jsp/admin/configure.jsp</result>
|
||||
<interceptor-ref name="defaultStack"/>
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
<%--
|
||||
~ Copyright 2005-2006 The Apache Software Foundation.
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
--%>
|
||||
|
||||
<%@ taglib prefix="ww" uri="/webwork" %>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Configuration</title>
|
||||
<ww:head />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<h1>Configuration</h1>
|
||||
|
||||
<div id="contentArea">
|
||||
|
||||
<h2>Delete Managed Repository</h2>
|
||||
|
||||
<blockquote>
|
||||
<strong><span class="statusFailed">WARNING:</span> This operation can not be undone.</strong>
|
||||
</blockquote>
|
||||
|
||||
<ww:form method="post" action="deleteRepository" namespace="/admin" validate="true">
|
||||
<ww:hidden name="repoId" />
|
||||
<ww:radio list="#@java.util.LinkedHashMap@{'delete-contents' : 'Remove the repository and delete its contents from disk',
|
||||
'delete-entry' : 'Remove the repository from the management list, but leave the contents unmodified',
|
||||
'unmodified' : 'Leave the repository unmodified'}" name="operation" theme="repository-manager" />
|
||||
<ww:submit value="Go" />
|
||||
</ww:form>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -18,6 +18,6 @@
|
|||
|
||||
<ww:textfield name="name" label="Name" size="50" />
|
||||
<ww:textfield name="directory" label="Directory" size="100" />
|
||||
<ww:select list="#@java.util.HashMap@{'default' : 'Maven 2.x Repository', 'legacy' : 'Maven 1.x Repository'}"
|
||||
<ww:select list="#@java.util.LinkedHashMap@{'default' : 'Maven 2.x Repository', 'legacy' : 'Maven 1.x Repository'}"
|
||||
name="layout" label="Type" />
|
||||
<ww:checkbox name="includeSnapshots" fieldValue="true" label="Snapshots Included" />
|
||||
|
|
|
@ -64,8 +64,9 @@
|
|||
<div style="float: right">
|
||||
<%-- TODO! replace with icons --%>
|
||||
<a href="<ww:url action="editRepository" method="input"><ww:param name="repoId" value="%{'${repository.id}'}" /></ww:url>">Edit
|
||||
Repository</a> | <a href="#">Delete Repository</a>
|
||||
<%-- TODO! serious confirmation, implement, prompt whether to delete contents too, remember index --%>
|
||||
Repository</a> | <a
|
||||
href="<ww:url action="deleteRepository" method="input"><ww:param name="repoId" value="%{'${repository.id}'}" /></ww:url>">Delete
|
||||
Repository</a>
|
||||
</div>
|
||||
<h3>${repository.name}</h3>
|
||||
<table>
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
<@ww.iterator value="parameters.list">
|
||||
<#if parameters.listKey?exists>
|
||||
<#assign itemKey = stack.findValue(parameters.listKey)/>
|
||||
<#else>
|
||||
<#assign itemKey = stack.findValue('top')/>
|
||||
</#if>
|
||||
<#if parameters.listValue?exists>
|
||||
<#assign itemValue = stack.findString(parameters.listValue)/>
|
||||
<#else>
|
||||
<#assign itemValue = stack.findString('top')/>
|
||||
</#if>
|
||||
<input type="radio" name="${parameters.name?html}" id="${parameters.id?html}${itemKey?html}"<#rt/>
|
||||
<#if tag.contains(parameters.nameValue, itemKey)>
|
||||
checked="checked"<#rt/>
|
||||
</#if>
|
||||
<#if itemKey?exists>
|
||||
value="${itemKey?html}"<#rt/>
|
||||
</#if>
|
||||
<#if parameters.disabled?default(false)>
|
||||
disabled="disabled"<#rt/>
|
||||
</#if>
|
||||
<#if parameters.tabindex?exists>
|
||||
tabindex="${parameters.tabindex?html}"<#rt/>
|
||||
</#if>
|
||||
<#if parameters.cssClass?exists>
|
||||
class="${parameters.cssClass?html}"<#rt/>
|
||||
</#if>
|
||||
<#if parameters.cssStyle?exists>
|
||||
style="${parameters.cssStyle?html}"<#rt/>
|
||||
</#if>
|
||||
<#if parameters.title?exists>
|
||||
title="${parameters.title?html}"<#rt/>
|
||||
</#if>
|
||||
<#include "/${parameters.templateDir}/simple/scripting-events.ftl" />
|
||||
/><#rt/>
|
||||
<label for="${parameters.id?html}${itemKey?html}"><#rt/>
|
||||
${itemValue}<#t/>
|
||||
</label><br/>
|
||||
</@ww.iterator>
|
|
@ -0,0 +1,17 @@
|
|||
#
|
||||
# Copyright 2005-2006 The Apache Software Foundation.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
parent = xhtml
|
Loading…
Reference in New Issue