. Enhanced Delete Space dialog

- Now displays options to delete files, folders, all content or by default the entire space and it's contents

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3519 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-08-15 15:06:52 +00:00
parent 66f1b61052
commit a3f3a6f2c6
4 changed files with 185 additions and 26 deletions

View File

@@ -903,6 +903,13 @@ new_password=New Password
edit_user_details=Edit User Details edit_user_details=Edit User Details
edit_user_details_description=Use this view to change your user details and email address 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 # Workflow messages
start_workflow=Start Workflow start_workflow=Start Workflow
start_workflow_wizard=Start New Workflow Wizard 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 # Confirmations
return_to_application=Return to application 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_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_forums_info=To remove this forum space and its contents, click OK.
delete_forum_info=To remove this forum and its topics, click Yes. 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_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_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_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_file_confirm=Are you sure you want to delete \"{0}\" and all previous versions?
delete_rule_info=To remove this rule, click Yes. delete_rule_info=To remove this rule from the space, click Yes.
delete_user_info=To delete this user, 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_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}\"? 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}\"? 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}\"?

View File

@@ -19,7 +19,7 @@
description-id="editspace_description" /> description-id="editspace_description" />
<!-- Definition of the delete space dialog --> <!-- Definition of the delete space dialog -->
<dialog name="deleteSpace" page="/jsp/dialog/delete.jsp" managed-bean="DeleteSpaceDialog" <dialog name="deleteSpace" page="/jsp/dialog/delete-space.jsp" managed-bean="DeleteSpaceDialog"
icon="/images/icons/delete_large.gif" title-id="delete_space" icon="/images/icons/delete_large.gif" title-id="delete_space"
description-id="delete_space_info" /> description-id="delete_space_info" />

View File

@@ -1,15 +1,27 @@
package org.alfresco.web.bean.spaces; package org.alfresco.web.bean.spaces;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import javax.faces.application.FacesMessage; import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext; 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.AlfrescoNavigationHandler;
import org.alfresco.web.app.Application; import org.alfresco.web.app.Application;
import org.alfresco.web.bean.content.DeleteContentDialog; import org.alfresco.web.bean.content.DeleteContentDialog;
import org.alfresco.web.bean.dialog.BaseDialogBean; 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.Node;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.ui.common.Utils; import org.alfresco.web.ui.common.Utils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@@ -23,6 +35,14 @@ public class DeleteSpaceDialog extends BaseDialogBean
{ {
private static final Log logger = LogFactory.getLog(DeleteContentDialog.class); 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 // Dialog implementation
@@ -34,12 +54,86 @@ public class DeleteSpaceDialog extends BaseDialogBean
Node node = this.browseBean.getActionSpace(); Node node = this.browseBean.getActionSpace();
if (node != null) if (node != null)
{ {
if (logger.isDebugEnabled()) // force cache of name property so we can use it after the delete
logger.debug("Trying to delete space: " + node.getId()); node.getName();
if (logger.isDebugEnabled())
logger.debug("Trying to delete space: " + node.getId() + " using delete mode: " + this.deleteMode);
if (DELETE_ALL.equals(this.deleteMode))
{
this.nodeService.deleteNode(node.getNodeRef()); this.nodeService.deleteNode(node.getNodeRef());
} }
else else
{
List<ChildAssociationRef> childRefs = this.nodeService.getChildAssocs(node.getNodeRef(),
ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
List<NodeRef> deleteRefs = new ArrayList<NodeRef>(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);
}
}
}
}
}
}
// 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
{ {
logger.warn("WARNING: delete called without a current Space!"); logger.warn("WARNING: delete called without a current Space!");
} }
@@ -52,6 +146,8 @@ public class DeleteSpaceDialog extends BaseDialogBean
{ {
Node node = this.browseBean.getActionSpace(); Node node = this.browseBean.getActionSpace();
if (node != null && this.nodeService.exists(node.getNodeRef()) == false)
{
// remove this node from the breadcrumb if required // remove this node from the breadcrumb if required
this.browseBean.removeSpaceFromBreadcrumb(node); this.browseBean.removeSpaceFromBreadcrumb(node);
@@ -68,6 +164,11 @@ public class DeleteSpaceDialog extends BaseDialogBean
return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME + return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME +
AlfrescoNavigationHandler.OUTCOME_SEPARATOR + "browse"; AlfrescoNavigationHandler.OUTCOME_SEPARATOR + "browse";
} }
else
{
return outcome;
}
}
@Override @Override
protected String getErrorMessageId() protected String getErrorMessageId()
@@ -81,6 +182,7 @@ public class DeleteSpaceDialog extends BaseDialogBean
return false; return false;
} }
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Bean Getters and Setters // Bean Getters and Setters
@@ -97,4 +199,20 @@ public class DeleteSpaceDialog extends BaseDialogBean
return MessageFormat.format(fileConfirmMsg, return MessageFormat.format(fileConfirmMsg,
new Object[] {this.browseBean.getActionSpace().getName()}); 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;
}
} }

View File

@@ -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" %>
<h:outputText value="#{msg.select_delete_operation}" styleClass="mainSubTitle" />
<h:panelGrid columns="1" cellpadding="2" cellspacing="2" border="0">
<h:selectOneRadio id="delete-operation" layout="pageDirection" value="#{DialogManager.bean.deleteMode}">
<f:selectItem itemValue="all" itemLabel="#{msg.delete_op_all}" />
<f:selectItem itemValue="files" itemLabel="#{msg.delete_op_files}" />
<f:selectItem itemValue="folders" itemLabel="#{msg.delete_op_folders}" />
<f:selectItem itemValue="contents" itemLabel="#{msg.delete_op_contents}" />
</h:selectOneRadio>
</h:panelGrid>