diff --git a/config/alfresco/messages/webclient.properties b/config/alfresco/messages/webclient.properties
index 71c0b8ae2d..3783dec8dc 100644
--- a/config/alfresco/messages/webclient.properties
+++ b/config/alfresco/messages/webclient.properties
@@ -903,6 +903,13 @@ new_password=New Password
edit_user_details=Edit User Details
edit_user_details_description=Use this view to change your user details and email address
+# Delete Space Dialog messages
+select_delete_operation=Select the delete operation you wish to perform:
+delete_op_all=All - delete this space and all its contents.
+delete_op_files=Files Only - delete only the files within this space.
+delete_op_folders=Folders Only - delete only the folders within this space.
+delete_op_contents=Contents Only - delete all files and folders within this space.
+
# Workflow messages
start_workflow=Start Workflow
start_workflow_wizard=Start New Workflow Wizard
@@ -1084,19 +1091,19 @@ error_shortcut_permissions=Unable to navigate to the item as it cannot be read b
# Confirmations
return_to_application=Return to application
-delete_space_info=To remove this space and all of its contents, click Yes.
+delete_space_info=To remove this space and all of its contents, click OK.
delete_space_confirm=Are you sure you want to delete \"{0}\" and all its contents?
-delete_forums_info=To remove this forum space and its contents, click Yes.
-delete_forum_info=To remove this forum and its topics, click Yes.
+delete_forums_info=To remove this forum space and its contents, click OK.
+delete_forum_info=To remove this forum and its topics, click OK.
delete_forum_confirm=Are you sure you want to delete \"{0}\" and all its topics?
-delete_topic_info=To remove this topic and its posts, click Yes.
+delete_topic_info=To remove this topic and its posts, click OK.
delete_topic_confirm=Are you sure you want to delete \"{0}\" and all its posts?
-delete_post_info=To remove this post, click Yes.
+delete_post_info=To remove this post from the topic, click OK.
delete_post_confirm=Are you sure you want to delete the post from \"{0}\"?
-delete_file_info=To remove this file and any previous versions, click Yes.
+delete_file_info=To remove this file and any previous versions, click OK.
delete_file_confirm=Are you sure you want to delete \"{0}\" and all previous versions?
-delete_rule_info=To remove this rule, click Yes.
-delete_user_info=To delete this user, click Yes.
+delete_rule_info=To remove this rule from the space, click Yes.
+delete_user_info=To delete this user from the system, click Yes.
delete_rule_confirm=Are you sure you want to delete \"{0}\"?
delete_user_confirm=The User will no longer be able to access the system. Are you sure you want to delete user \"{0}\"?
remove_invited_user_confirm=The User will no longer be able to access the documents and folders in this space. Are you sure you want to remove user \"{0}\"?
diff --git a/config/alfresco/web-client-config-dialogs.xml b/config/alfresco/web-client-config-dialogs.xml
index 1b6028ba91..14e25ad8a8 100644
--- a/config/alfresco/web-client-config-dialogs.xml
+++ b/config/alfresco/web-client-config-dialogs.xml
@@ -19,7 +19,7 @@
description-id="editspace_description" />
-
diff --git a/source/java/org/alfresco/web/bean/spaces/DeleteSpaceDialog.java b/source/java/org/alfresco/web/bean/spaces/DeleteSpaceDialog.java
index 5001db6ca6..2409f1ae78 100644
--- a/source/java/org/alfresco/web/bean/spaces/DeleteSpaceDialog.java
+++ b/source/java/org/alfresco/web/bean/spaces/DeleteSpaceDialog.java
@@ -1,15 +1,27 @@
package org.alfresco.web.bean.spaces;
import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
+import javax.transaction.UserTransaction;
+import org.alfresco.model.ContentModel;
+import org.alfresco.service.cmr.dictionary.TypeDefinition;
+import org.alfresco.service.cmr.repository.ChildAssociationRef;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.namespace.QName;
+import org.alfresco.service.namespace.RegexQNamePattern;
+import org.alfresco.service.transaction.TransactionService;
import org.alfresco.web.app.AlfrescoNavigationHandler;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.content.DeleteContentDialog;
import org.alfresco.web.bean.dialog.BaseDialogBean;
+import org.alfresco.web.bean.repository.MapNode;
import org.alfresco.web.bean.repository.Node;
+import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.ui.common.Utils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -22,6 +34,14 @@ import org.apache.commons.logging.LogFactory;
public class DeleteSpaceDialog extends BaseDialogBean
{
private static final Log logger = LogFactory.getLog(DeleteContentDialog.class);
+
+ private static final String DELETE_ALL = "all";
+ private static final String DELETE_FILES = "files";
+ private static final String DELETE_FOLDERS = "folders";
+ private static final String DELETE_CONTENTS = "contents";
+
+ private String deleteMode = DELETE_ALL;
+
// ------------------------------------------------------------------------------
// Dialog implementation
@@ -34,10 +54,84 @@ public class DeleteSpaceDialog extends BaseDialogBean
Node node = this.browseBean.getActionSpace();
if (node != null)
{
+ // force cache of name property so we can use it after the delete
+ node.getName();
+
if (logger.isDebugEnabled())
- logger.debug("Trying to delete space: " + node.getId());
+ logger.debug("Trying to delete space: " + node.getId() + " using delete mode: " + this.deleteMode);
+
+ if (DELETE_ALL.equals(this.deleteMode))
+ {
+ this.nodeService.deleteNode(node.getNodeRef());
+ }
+ else
+ {
+ List childRefs = this.nodeService.getChildAssocs(node.getNodeRef(),
+ ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
+ List deleteRefs = new ArrayList(childRefs.size());
+ for (ChildAssociationRef ref : childRefs)
+ {
+ NodeRef nodeRef = ref.getChildRef();
+
+ if (this.nodeService.exists(nodeRef))
+ {
+ if (DELETE_CONTENTS.equals(this.deleteMode))
+ {
+ deleteRefs.add(nodeRef);
+ }
+ else
+ {
+ // find it's type so we can see if it's a node we are interested in
+ QName type = this.nodeService.getType(nodeRef);
+
+ // make sure the type is defined in the data dictionary
+ TypeDefinition typeDef = this.dictionaryService.getType(type);
+
+ if (typeDef != null)
+ {
+ if (DELETE_FOLDERS.equals(this.deleteMode))
+ {
+ // look for folder type
+ if (this.dictionaryService.isSubClass(type, ContentModel.TYPE_FOLDER) == true &&
+ this.dictionaryService.isSubClass(type, ContentModel.TYPE_SYSTEM_FOLDER) == false)
+ {
+ deleteRefs.add(nodeRef);
+ }
+ }
+ else if (DELETE_FILES.equals(this.deleteMode))
+ {
+ // look for content file type
+ if (this.dictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT))
+ {
+ deleteRefs.add(nodeRef);
+ }
+ }
+ }
+ }
+ }
+ }
- this.nodeService.deleteNode(node.getNodeRef());
+ // delete the list of refs
+ TransactionService txService = Repository.getServiceRegistry(context).getTransactionService();
+ for (NodeRef nodeRef : deleteRefs)
+ {
+ UserTransaction tx = null;
+
+ try
+ {
+ tx = txService.getNonPropagatingUserTransaction();
+ tx.begin();
+
+ this.nodeService.deleteNode(nodeRef);
+
+ tx.commit();
+ }
+ catch (Throwable err)
+ {
+ try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
+ }
+ }
+ }
}
else
{
@@ -52,21 +146,28 @@ public class DeleteSpaceDialog extends BaseDialogBean
{
Node node = this.browseBean.getActionSpace();
- // remove this node from the breadcrumb if required
- this.browseBean.removeSpaceFromBreadcrumb(node);
-
- // add a message to inform the user that the delete was OK
- String statusMsg = MessageFormat.format(
- Application.getMessage(FacesContext.getCurrentInstance(), "status_space_deleted"),
- new Object[]{node.getName()});
- Utils.addStatusMessage(FacesMessage.SEVERITY_INFO, statusMsg);
-
- // clear action context
- this.browseBean.setActionSpace(null);
-
- // setting the outcome will show the browse view again
- return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME +
- AlfrescoNavigationHandler.OUTCOME_SEPARATOR + "browse";
+ if (node != null && this.nodeService.exists(node.getNodeRef()) == false)
+ {
+ // remove this node from the breadcrumb if required
+ this.browseBean.removeSpaceFromBreadcrumb(node);
+
+ // add a message to inform the user that the delete was OK
+ String statusMsg = MessageFormat.format(
+ Application.getMessage(FacesContext.getCurrentInstance(), "status_space_deleted"),
+ new Object[]{node.getName()});
+ Utils.addStatusMessage(FacesMessage.SEVERITY_INFO, statusMsg);
+
+ // clear action context
+ this.browseBean.setActionSpace(null);
+
+ // setting the outcome will show the browse view again
+ return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME +
+ AlfrescoNavigationHandler.OUTCOME_SEPARATOR + "browse";
+ }
+ else
+ {
+ return outcome;
+ }
}
@Override
@@ -81,6 +182,7 @@ public class DeleteSpaceDialog extends BaseDialogBean
return false;
}
+
// ------------------------------------------------------------------------------
// Bean Getters and Setters
@@ -97,4 +199,20 @@ public class DeleteSpaceDialog extends BaseDialogBean
return MessageFormat.format(fileConfirmMsg,
new Object[] {this.browseBean.getActionSpace().getName()});
}
+
+ /**
+ * @return Returns the delete operation mode.
+ */
+ public String getDeleteMode()
+ {
+ return this.deleteMode;
+ }
+
+ /**
+ * @param deleteMode The delete operation mode to set.
+ */
+ public void setDeleteMode(String deleteMode)
+ {
+ this.deleteMode = deleteMode;
+ }
}
diff --git a/source/web/jsp/dialog/delete-space.jsp b/source/web/jsp/dialog/delete-space.jsp
new file mode 100644
index 0000000000..a4a7578775
--- /dev/null
+++ b/source/web/jsp/dialog/delete-space.jsp
@@ -0,0 +1,34 @@
+<%--
+ Copyright (C) 2005 Alfresco, Inc.
+
+ Licensed under the Mozilla Public License version 1.1
+ with a permitted attribution clause. You may obtain a
+ copy of the License at
+
+ http://www.alfresco.org/legal/license.txt
+
+ 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 uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %>
+<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %>
+
+<%@ page buffer="8kb" contentType="text/html;charset=UTF-8" %>
+<%@ page isELIgnored="false" %>
+
+
+
+
+
+
+
+
+
+