From 01e4a3c3e1a8f14686c6b70ad4b5a014a6435b71 Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Fri, 4 Aug 2006 17:03:54 +0000 Subject: [PATCH] [MRM-138] add repository deletion git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@428785 13f79535-47bb-0310-9956-ffa450edef68 --- .../action/admin/DeleteRepositoryAction.java | 109 ++++++++++++++++++ .../src/main/resources/webwork.properties | 2 + .../src/main/resources/xwork.xml | 5 + .../WEB-INF/jsp/admin/deleteRepository.jsp | 47 ++++++++ .../admin/include/managedRepositoryForm.jspf | 2 +- .../main/webapp/WEB-INF/jsp/admin/index.jsp | 5 +- .../template/repository-manager/radiomap.ftl | 39 +++++++ .../repository-manager/theme.properties | 17 +++ 8 files changed, 223 insertions(+), 3 deletions(-) create mode 100644 maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/DeleteRepositoryAction.java create mode 100644 maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/deleteRepository.jsp create mode 100644 maven-repository-webapp/src/main/webapp/template/repository-manager/radiomap.ftl create mode 100644 maven-repository-webapp/src/main/webapp/template/repository-manager/theme.properties diff --git a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/DeleteRepositoryAction.java b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/DeleteRepositoryAction.java new file mode 100644 index 000000000..451989b5a --- /dev/null +++ b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/DeleteRepositoryAction.java @@ -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; + } +} diff --git a/maven-repository-webapp/src/main/resources/webwork.properties b/maven-repository-webapp/src/main/resources/webwork.properties index f340ff19f..8cd7e97cb 100644 --- a/maven-repository-webapp/src/main/resources/webwork.properties +++ b/maven-repository-webapp/src/main/resources/webwork.properties @@ -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 \ No newline at end of file diff --git a/maven-repository-webapp/src/main/resources/xwork.xml b/maven-repository-webapp/src/main/resources/xwork.xml index cae7f2d5e..ee78e7313 100644 --- a/maven-repository-webapp/src/main/resources/xwork.xml +++ b/maven-repository-webapp/src/main/resources/xwork.xml @@ -137,6 +137,11 @@ index + + /WEB-INF/jsp/admin/deleteRepository.jsp + index + + /WEB-INF/jsp/admin/configure.jsp diff --git a/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/deleteRepository.jsp b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/deleteRepository.jsp new file mode 100644 index 000000000..cb2245256 --- /dev/null +++ b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/deleteRepository.jsp @@ -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" %> + + + + Configuration + + + + + +

Configuration

+ +
+ +

Delete Managed Repository

+ +
+ WARNING: This operation can not be undone. +
+ + + + + + +
+ + + \ No newline at end of file diff --git a/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/include/managedRepositoryForm.jspf b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/include/managedRepositoryForm.jspf index c698c4306..2dcbce3be 100644 --- a/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/include/managedRepositoryForm.jspf +++ b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/include/managedRepositoryForm.jspf @@ -18,6 +18,6 @@ - diff --git a/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/index.jsp b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/index.jsp index 34d7a033c..85f7c9e4c 100644 --- a/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/index.jsp +++ b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/index.jsp @@ -64,8 +64,9 @@
<%-- TODO! replace with icons --%> ">Edit - Repository | Delete Repository - <%-- TODO! serious confirmation, implement, prompt whether to delete contents too, remember index --%> + Repository | ">Delete + Repository

${repository.name}

diff --git a/maven-repository-webapp/src/main/webapp/template/repository-manager/radiomap.ftl b/maven-repository-webapp/src/main/webapp/template/repository-manager/radiomap.ftl new file mode 100644 index 000000000..89ef578d1 --- /dev/null +++ b/maven-repository-webapp/src/main/webapp/template/repository-manager/radiomap.ftl @@ -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 parameters.listValue?exists> + <#assign itemValue = stack.findString(parameters.listValue)/> + <#else> + <#assign itemValue = stack.findString('top')/> + + +<#if tag.contains(parameters.nameValue, itemKey)> + checked="checked"<#rt/> + +<#if itemKey?exists> + value="${itemKey?html}"<#rt/> + +<#if parameters.disabled?default(false)> + disabled="disabled"<#rt/> + +<#if parameters.tabindex?exists> + tabindex="${parameters.tabindex?html}"<#rt/> + +<#if parameters.cssClass?exists> + class="${parameters.cssClass?html}"<#rt/> + +<#if parameters.cssStyle?exists> + style="${parameters.cssStyle?html}"<#rt/> + +<#if parameters.title?exists> + title="${parameters.title?html}"<#rt/> + +<#include "/${parameters.templateDir}/simple/scripting-events.ftl" /> +/><#rt/> +
+ diff --git a/maven-repository-webapp/src/main/webapp/template/repository-manager/theme.properties b/maven-repository-webapp/src/main/webapp/template/repository-manager/theme.properties new file mode 100644 index 000000000..b0dfbe775 --- /dev/null +++ b/maven-repository-webapp/src/main/webapp/template/repository-manager/theme.properties @@ -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 -- 2.39.5