mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
- Converted delete content, delete space and all forum item deletes to use the new dialog framework
- Removed old JSPs (AWC-748) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3364 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -266,11 +266,18 @@ public class AlfrescoNavigationHandler extends NavigationHandler
|
||||
|
||||
if (dispatchContext != null)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Using dispatch context for dialog lookup: " +
|
||||
dispatchContext.getType().toString());
|
||||
|
||||
// use the node to perform the lookup (this will include the global section)
|
||||
config = configSvc.getConfig(dispatchContext);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Looking up dialog in global config");
|
||||
|
||||
// just use the global
|
||||
config = configSvc.getGlobalConfig();
|
||||
}
|
||||
@@ -306,11 +313,18 @@ public class AlfrescoNavigationHandler extends NavigationHandler
|
||||
|
||||
if (dispatchContext != null)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Using dispatch context for wizard lookup: " +
|
||||
dispatchContext.getType().toString());
|
||||
|
||||
// use the node to perform the lookup (this will include the global section)
|
||||
config = configSvc.getConfig(dispatchContext);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Looking up wizard in global config");
|
||||
|
||||
// just use the global
|
||||
config = configSvc.getGlobalConfig();
|
||||
}
|
||||
|
@@ -1350,117 +1350,38 @@ public class BrowseBean implements IContextListener
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler called upon the completion of the Delete Space page
|
||||
* Removes the given node from the breadcrumb i.e. following a delete
|
||||
*
|
||||
* @return outcome
|
||||
* @param node The space to remove from the breadcrumb
|
||||
*/
|
||||
public String deleteSpaceOK()
|
||||
public void removeSpaceFromBreadcrumb(Node node)
|
||||
{
|
||||
String outcome = null;
|
||||
|
||||
Node node = getActionSpace();
|
||||
if (node != null)
|
||||
List<IBreadcrumbHandler> location = navigator.getLocation();
|
||||
IBreadcrumbHandler handler = location.get(location.size() - 1);
|
||||
if (handler instanceof BrowseBreadcrumbHandler)
|
||||
{
|
||||
try
|
||||
// see if the current breadcrumb location is our node
|
||||
if ( ((BrowseBreadcrumbHandler)handler).getNodeRef().equals(node.getNodeRef()) == true )
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Trying to delete space: " + node.getId());
|
||||
location.remove(location.size() - 1);
|
||||
|
||||
this.nodeService.deleteNode(node.getNodeRef());
|
||||
|
||||
// remove this node from the breadcrumb if required
|
||||
List<IBreadcrumbHandler> location = navigator.getLocation();
|
||||
IBreadcrumbHandler handler = location.get(location.size() - 1);
|
||||
if (handler instanceof BrowseBreadcrumbHandler)
|
||||
// now work out which node to set the list to refresh against
|
||||
if (location.size() != 0)
|
||||
{
|
||||
// see if the current breadcrumb location is our node
|
||||
if ( ((BrowseBreadcrumbHandler)handler).getNodeRef().equals(node.getNodeRef()) == true )
|
||||
handler = location.get(location.size() - 1);
|
||||
if (handler instanceof BrowseBreadcrumbHandler)
|
||||
{
|
||||
location.remove(location.size() - 1);
|
||||
|
||||
// now work out which node to set the list to refresh against
|
||||
if (location.size() != 0)
|
||||
{
|
||||
handler = location.get(location.size() - 1);
|
||||
if (handler instanceof BrowseBreadcrumbHandler)
|
||||
{
|
||||
// change the current node Id
|
||||
navigator.setCurrentNodeId(((BrowseBreadcrumbHandler)handler).getNodeRef().getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: shouldn't do this - but for now the user home dir is the root!
|
||||
navigator.setCurrentNodeId(Application.getCurrentUser(FacesContext.getCurrentInstance()).getHomeSpaceId());
|
||||
}
|
||||
}
|
||||
// change the current node Id
|
||||
navigator.setCurrentNodeId(((BrowseBreadcrumbHandler)handler).getNodeRef().getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: shouldn't do this - but for now the user home dir is the root!
|
||||
navigator.setCurrentNodeId(Application.getCurrentUser(FacesContext.getCurrentInstance()).getHomeSpaceId());
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
setActionSpace(null);
|
||||
|
||||
// setting the outcome will show the browse view again
|
||||
outcome = AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME +
|
||||
AlfrescoNavigationHandler.OUTCOME_SEPARATOR + "browse";
|
||||
}
|
||||
catch (Throwable err)
|
||||
{
|
||||
Utils.addErrorMessage(Application.getMessage(
|
||||
FacesContext.getCurrentInstance(), MSG_ERROR_DELETE_SPACE) + err.getMessage(), err);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.warn("WARNING: deleteSpaceOK called without a current Space!");
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler called upon the completion of the Delete File page
|
||||
*
|
||||
* @return outcome
|
||||
*/
|
||||
public String deleteFileOK()
|
||||
{
|
||||
String outcome = null;
|
||||
|
||||
Node node = getDocument();
|
||||
if (node != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Trying to delete content node: " + node.getId());
|
||||
|
||||
this.nodeService.deleteNode(node.getNodeRef());
|
||||
|
||||
// clear action context
|
||||
setDocument(null);
|
||||
|
||||
// setting the outcome will show the browse view again
|
||||
outcome = AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME +
|
||||
AlfrescoNavigationHandler.OUTCOME_SEPARATOR + "browse";
|
||||
}
|
||||
catch (Throwable err)
|
||||
{
|
||||
Utils.addErrorMessage(Application.getMessage(
|
||||
FacesContext.getCurrentInstance(), MSG_ERROR_DELETE_FILE) + err.getMessage(), err);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.warn("WARNING: deleteFileOK called without a current Document!");
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1724,8 +1645,6 @@ public class BrowseBean implements IContextListener
|
||||
private static final String PAGE_NAME_BROWSE = "browse";
|
||||
|
||||
/** I18N messages */
|
||||
private static final String MSG_ERROR_DELETE_FILE = "error_delete_file";
|
||||
private static final String MSG_ERROR_DELETE_SPACE = "error_delete_space";
|
||||
private static final String MSG_DELETE_COMPANYROOT = "delete_companyroot_confirm";
|
||||
private static final String MSG_SEARCH_MINIMUM = "search_minimum";
|
||||
|
||||
|
@@ -0,0 +1,87 @@
|
||||
package org.alfresco.web.bean.content;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.web.app.AlfrescoNavigationHandler;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Bean implementation for the "Delete Content" dialog
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class DeleteContentDialog extends BaseDialogBean
|
||||
{
|
||||
private static final Log logger = LogFactory.getLog(DeleteContentDialog.class);
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Dialog implementation
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome)
|
||||
throws Exception
|
||||
{
|
||||
// get the content to delete
|
||||
Node node = this.browseBean.getDocument();
|
||||
if (node != null)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Trying to delete content node: " + node.getId());
|
||||
|
||||
// delete the node
|
||||
this.nodeService.deleteNode(node.getNodeRef());
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.warn("WARNING: delete called without a current Document!");
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doPostCommitProcessing(FacesContext context, String outcome)
|
||||
{
|
||||
// clear action context
|
||||
this.browseBean.setDocument(null);
|
||||
|
||||
// setting the outcome will show the browse view again
|
||||
return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME +
|
||||
AlfrescoNavigationHandler.OUTCOME_SEPARATOR + "browse";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getErrorMessageId()
|
||||
{
|
||||
return "error_delete_file";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFinishButtonDisabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Bean Getters and Setters
|
||||
|
||||
/**
|
||||
* Returns the confirmation to display to the user before deleting the content.
|
||||
*
|
||||
* @return The formatted message to display
|
||||
*/
|
||||
public String getConfirmMessage()
|
||||
{
|
||||
String fileConfirmMsg = Application.getMessage(FacesContext.getCurrentInstance(),
|
||||
"delete_file_confirm");
|
||||
|
||||
return MessageFormat.format(fileConfirmMsg,
|
||||
new Object[] {this.browseBean.getDocument().getName()});
|
||||
}
|
||||
}
|
@@ -16,6 +16,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.web.app.AlfrescoNavigationHandler;
|
||||
import org.alfresco.web.app.Application;
|
||||
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;
|
||||
@@ -154,11 +155,17 @@ public class CreateDiscussionDialog extends CreateTopicDialog
|
||||
this.nodeService.removeAspect(this.discussingNodeRef, ForumModel.ASPECT_DISCUSSABLE);
|
||||
|
||||
// delete the forum space created when the wizard started
|
||||
this.browseBean.setActionSpace(this.navigator.getCurrentNode());
|
||||
this.browseBean.deleteSpaceOK();
|
||||
|
||||
Node forumNode = this.navigator.getCurrentNode();
|
||||
this.nodeService.deleteNode(forumNode.getNodeRef());
|
||||
|
||||
// commit the transaction
|
||||
tx.commit();
|
||||
|
||||
// remove this node from the breadcrumb if required
|
||||
this.browseBean.removeSpaceFromBreadcrumb(forumNode);
|
||||
|
||||
// clear action context
|
||||
this.browseBean.setActionSpace(null);
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
|
@@ -5,8 +5,6 @@ import java.util.Map;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.apache.commons.logging.Log;
|
||||
|
103
source/java/org/alfresco/web/bean/forums/DeleteForumDialog.java
Normal file
103
source/java/org/alfresco/web/bean/forums/DeleteForumDialog.java
Normal file
@@ -0,0 +1,103 @@
|
||||
package org.alfresco.web.bean.forums;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ForumModel;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.web.app.AlfrescoNavigationHandler;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.spaces.DeleteSpaceDialog;
|
||||
|
||||
/**
|
||||
* Bean implementation for the "Delete Forum" dialog
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class DeleteForumDialog extends DeleteSpaceDialog
|
||||
{
|
||||
protected boolean reDisplayForums;
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Dialog implementation
|
||||
|
||||
@Override
|
||||
public void init(Map<String, String> parameters)
|
||||
{
|
||||
super.init(parameters);
|
||||
|
||||
// reset the reDisplayForums flag
|
||||
this.reDisplayForums = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
// find out what the parent type of the node being deleted
|
||||
Node node = this.browseBean.getActionSpace();
|
||||
ChildAssociationRef assoc = this.nodeService.getPrimaryParent(node.getNodeRef());
|
||||
if (assoc != null)
|
||||
{
|
||||
// get the parent node
|
||||
NodeRef parent = assoc.getParentRef();
|
||||
|
||||
// get the association type
|
||||
QName type = assoc.getTypeQName();
|
||||
if (type.equals(ForumModel.ASSOC_DISCUSSION))
|
||||
{
|
||||
// if the association type is the 'discussion' association we
|
||||
// need to remove the discussable aspect from the parent node
|
||||
this.nodeService.removeAspect(parent, ForumModel.ASPECT_DISCUSSABLE);
|
||||
}
|
||||
|
||||
// if the parent type is a forum space then we need the dialog to go
|
||||
// back to the forums view otherwise it will use the default of 'browse',
|
||||
// this happens when a forum being used to discuss a node is deleted.
|
||||
QName parentType = this.nodeService.getType(parent);
|
||||
if (parentType.equals(ForumModel.TYPE_FORUMS))
|
||||
{
|
||||
this.reDisplayForums = true;
|
||||
}
|
||||
}
|
||||
|
||||
return super.finishImpl(context, outcome);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doPostCommitProcessing(FacesContext context, String outcome)
|
||||
{
|
||||
outcome = super.doPostCommitProcessing(context, outcome);
|
||||
|
||||
if (this.reDisplayForums)
|
||||
{
|
||||
return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME +
|
||||
AlfrescoNavigationHandler.OUTCOME_SEPARATOR + "forumDeleted";
|
||||
}
|
||||
else
|
||||
{
|
||||
return outcome;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Bean Getters and Setters
|
||||
|
||||
/**
|
||||
* Returns the confirmation to display to the user before deleting the content.
|
||||
*
|
||||
* @return The formatted message to display
|
||||
*/
|
||||
public String getConfirmMessage()
|
||||
{
|
||||
String fileConfirmMsg = Application.getMessage(FacesContext.getCurrentInstance(),
|
||||
"delete_forum_confirm");
|
||||
|
||||
return MessageFormat.format(fileConfirmMsg,
|
||||
new Object[] {this.browseBean.getActionSpace().getName()});
|
||||
}
|
||||
}
|
@@ -0,0 +1,70 @@
|
||||
package org.alfresco.web.bean.forums;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ForumModel;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.web.app.AlfrescoNavigationHandler;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.spaces.DeleteSpaceDialog;
|
||||
|
||||
/**
|
||||
* Bean implementation for the "Delete Forum Space" dialog
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class DeleteForumsDialog extends DeleteSpaceDialog
|
||||
{
|
||||
protected boolean reDisplayForums;
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Dialog implementation
|
||||
|
||||
@Override
|
||||
public void init(Map<String, String> parameters)
|
||||
{
|
||||
super.init(parameters);
|
||||
|
||||
// reset the reDisplayForums flag
|
||||
this.reDisplayForums = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
// find out what the parent type of the node being deleted
|
||||
Node node = this.browseBean.getActionSpace();
|
||||
ChildAssociationRef assoc = this.nodeService.getPrimaryParent(node.getNodeRef());
|
||||
if (assoc != null)
|
||||
{
|
||||
NodeRef parent = assoc.getParentRef();
|
||||
QName parentType = this.nodeService.getType(parent);
|
||||
if (parentType.equals(ForumModel.TYPE_FORUMS))
|
||||
{
|
||||
this.reDisplayForums = true;
|
||||
}
|
||||
}
|
||||
|
||||
return super.finishImpl(context, outcome);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doPostCommitProcessing(FacesContext context, String outcome)
|
||||
{
|
||||
outcome = super.doPostCommitProcessing(context, outcome);
|
||||
|
||||
if (this.reDisplayForums)
|
||||
{
|
||||
return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME +
|
||||
AlfrescoNavigationHandler.OUTCOME_SEPARATOR + "forumsDeleted";
|
||||
}
|
||||
else
|
||||
{
|
||||
return outcome;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
package org.alfresco.web.bean.forums;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.content.DeleteContentDialog;
|
||||
|
||||
/**
|
||||
* Bean implementation for the "Delete Post" dialog.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class DeletePostDialog extends DeleteContentDialog
|
||||
{
|
||||
// ------------------------------------------------------------------------------
|
||||
// Dialog implementation
|
||||
|
||||
@Override
|
||||
protected String doPostCommitProcessing(FacesContext context, String outcome)
|
||||
{
|
||||
super.doPostCommitProcessing(context, outcome);
|
||||
|
||||
return this.getDefaultFinishOutcome();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Bean Getters and Setters
|
||||
|
||||
/**
|
||||
* Returns the confirmation to display to the user before deleting the content.
|
||||
*
|
||||
* @return The formatted message to display
|
||||
*/
|
||||
public String getConfirmMessage()
|
||||
{
|
||||
String postConfirmMsg = Application.getMessage(FacesContext.getCurrentInstance(),
|
||||
"delete_post_confirm");
|
||||
|
||||
return MessageFormat.format(postConfirmMsg,
|
||||
new Object[] {this.browseBean.getDocument().getProperties().get("creator")});
|
||||
}
|
||||
}
|
@@ -0,0 +1,89 @@
|
||||
package org.alfresco.web.bean.forums;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ForumModel;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.web.app.AlfrescoNavigationHandler;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.spaces.DeleteSpaceDialog;
|
||||
|
||||
/**
|
||||
* Bean implementation for the "Delete Topic" dialog
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class DeleteTopicDialog extends DeleteSpaceDialog
|
||||
{
|
||||
protected boolean reDisplayTopics;
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Dialog implementation
|
||||
|
||||
@Override
|
||||
public void init(Map<String, String> parameters)
|
||||
{
|
||||
super.init(parameters);
|
||||
|
||||
// reset the reDisplayTopics flag
|
||||
this.reDisplayTopics = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
// find out what the parent type of the node being deleted
|
||||
Node node = this.browseBean.getActionSpace();
|
||||
ChildAssociationRef assoc = this.nodeService.getPrimaryParent(node.getNodeRef());
|
||||
if (assoc != null)
|
||||
{
|
||||
NodeRef parent = assoc.getParentRef();
|
||||
QName parentType = this.nodeService.getType(parent);
|
||||
if (parentType.equals(ForumModel.TYPE_FORUM))
|
||||
{
|
||||
this.reDisplayTopics = true;
|
||||
}
|
||||
}
|
||||
|
||||
return super.finishImpl(context, outcome);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doPostCommitProcessing(FacesContext context, String outcome)
|
||||
{
|
||||
outcome = super.doPostCommitProcessing(context, outcome);
|
||||
|
||||
if (this.reDisplayTopics)
|
||||
{
|
||||
return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME +
|
||||
AlfrescoNavigationHandler.OUTCOME_SEPARATOR + "topicDeleted";
|
||||
}
|
||||
else
|
||||
{
|
||||
return outcome;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Bean Getters and Setters
|
||||
|
||||
/**
|
||||
* Returns the confirmation to display to the user before deleting the content.
|
||||
*
|
||||
* @return The formatted message to display
|
||||
*/
|
||||
public String getConfirmMessage()
|
||||
{
|
||||
String fileConfirmMsg = Application.getMessage(FacesContext.getCurrentInstance(),
|
||||
"delete_topic_confirm");
|
||||
|
||||
return MessageFormat.format(fileConfirmMsg,
|
||||
new Object[] {this.browseBean.getActionSpace().getName()});
|
||||
}
|
||||
}
|
@@ -51,7 +51,6 @@ import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||
import org.alfresco.web.app.AlfrescoNavigationHandler;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.app.context.IContextListener;
|
||||
import org.alfresco.web.app.context.UIContextService;
|
||||
@@ -768,148 +767,6 @@ public class ForumsBean implements IContextListener
|
||||
children.size() + " children!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the user confirms they wish to delete a forum space
|
||||
*
|
||||
* @return The outcome
|
||||
*/
|
||||
public String deleteForumsOK()
|
||||
{
|
||||
String outcomeOverride = "browse";
|
||||
|
||||
// find out what the parent type of the node being deleted
|
||||
Node node = this.browseBean.getActionSpace();
|
||||
ChildAssociationRef assoc = this.nodeService.getPrimaryParent(node.getNodeRef());
|
||||
if (assoc != null)
|
||||
{
|
||||
NodeRef parent = assoc.getParentRef();
|
||||
QName parentType = this.nodeService.getType(parent);
|
||||
if (parentType.equals(ForumModel.TYPE_FORUMS))
|
||||
{
|
||||
outcomeOverride = "forumsDeleted";
|
||||
}
|
||||
}
|
||||
|
||||
// call the generic handler
|
||||
String outcome = this.browseBean.deleteSpaceOK();
|
||||
|
||||
// if the delete was successful update the outcome
|
||||
if (outcome != null)
|
||||
{
|
||||
// return an overidden outcome which closes the dialog with an outcome
|
||||
outcome = AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME +
|
||||
AlfrescoNavigationHandler.OUTCOME_SEPARATOR + outcomeOverride;
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the user confirms they wish to delete a forum space
|
||||
*
|
||||
* @return The outcome
|
||||
*/
|
||||
public String deleteForumOK()
|
||||
{
|
||||
String outcomeOverride = "browse";
|
||||
|
||||
// if this forum is being used for a discussion on a node we also
|
||||
// need to remove the discussable aspect from the node.
|
||||
Node forumSpace = this.browseBean.getActionSpace();
|
||||
ChildAssociationRef assoc = this.nodeService.getPrimaryParent(forumSpace.getNodeRef());
|
||||
if (assoc != null)
|
||||
{
|
||||
// get the parent node
|
||||
NodeRef parent = assoc.getParentRef();
|
||||
|
||||
// get the association type
|
||||
QName type = assoc.getTypeQName();
|
||||
if (type.equals(ForumModel.ASSOC_DISCUSSION))
|
||||
{
|
||||
// if the association type is the 'discussion' association we
|
||||
// need to remove the discussable aspect from the parent node
|
||||
this.nodeService.removeAspect(parent, ForumModel.ASPECT_DISCUSSABLE);
|
||||
}
|
||||
|
||||
// if the parent type is a forum space then we need the dialog to go
|
||||
// back to the forums view otherwise it will use the default of 'browse',
|
||||
// this happens when a forum being used to discuss a node is deleted.
|
||||
QName parentType = this.nodeService.getType(parent);
|
||||
if (parentType.equals(ForumModel.TYPE_FORUMS))
|
||||
{
|
||||
outcomeOverride = "forumDeleted";
|
||||
}
|
||||
}
|
||||
|
||||
// call the generic handler
|
||||
String outcome = this.browseBean.deleteSpaceOK();
|
||||
|
||||
// if the delete was successful update the outcome
|
||||
if (outcome != null)
|
||||
{
|
||||
// return an overidden outcome which closes the dialog with an outcome
|
||||
outcome = AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME +
|
||||
AlfrescoNavigationHandler.OUTCOME_SEPARATOR + outcomeOverride;
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the user confirms they wish to delete a forum space
|
||||
*
|
||||
* @return The outcome
|
||||
*/
|
||||
public String deleteTopicOK()
|
||||
{
|
||||
String outcomeOverride = "browse";
|
||||
|
||||
// find out what the parent type of the node being deleted
|
||||
Node node = this.browseBean.getActionSpace();
|
||||
ChildAssociationRef assoc = this.nodeService.getPrimaryParent(node.getNodeRef());
|
||||
if (assoc != null)
|
||||
{
|
||||
NodeRef parent = assoc.getParentRef();
|
||||
QName parentType = this.nodeService.getType(parent);
|
||||
if (parentType.equals(ForumModel.TYPE_FORUM))
|
||||
{
|
||||
outcomeOverride = "topicDeleted";
|
||||
}
|
||||
}
|
||||
|
||||
// call the generic handler
|
||||
String outcome = this.browseBean.deleteSpaceOK();
|
||||
|
||||
// if the delete was successful update the outcome
|
||||
if (outcome != null)
|
||||
{
|
||||
outcome = AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME +
|
||||
AlfrescoNavigationHandler.OUTCOME_SEPARATOR + outcomeOverride;
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the user confirms they wish to delete a forum space
|
||||
*
|
||||
* @return The outcome
|
||||
*/
|
||||
public String deletePostOK()
|
||||
{
|
||||
// call the generic handler
|
||||
String outcome = this.browseBean.deleteFileOK();
|
||||
|
||||
// if the delete was successful update the outcome
|
||||
if (outcome != null)
|
||||
{
|
||||
outcome = AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME;
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Property Resolvers
|
||||
|
100
source/java/org/alfresco/web/bean/spaces/DeleteSpaceDialog.java
Normal file
100
source/java/org/alfresco/web/bean/spaces/DeleteSpaceDialog.java
Normal file
@@ -0,0 +1,100 @@
|
||||
package org.alfresco.web.bean.spaces;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
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.Node;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Bean implementation for the "Delete Space" dialog
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class DeleteSpaceDialog extends BaseDialogBean
|
||||
{
|
||||
private static final Log logger = LogFactory.getLog(DeleteContentDialog.class);
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Dialog implementation
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome)
|
||||
throws Exception
|
||||
{
|
||||
// get the space to delete
|
||||
Node node = this.browseBean.getActionSpace();
|
||||
if (node != null)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Trying to delete space: " + node.getId());
|
||||
|
||||
this.nodeService.deleteNode(node.getNodeRef());
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.warn("WARNING: delete called without a current Space!");
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doPostCommitProcessing(FacesContext context, String outcome)
|
||||
{
|
||||
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";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getErrorMessageId()
|
||||
{
|
||||
return "error_delete_space";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFinishButtonDisabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Bean Getters and Setters
|
||||
|
||||
/**
|
||||
* Returns the confirmation to display to the user before deleting the content.
|
||||
*
|
||||
* @return The formatted message to display
|
||||
*/
|
||||
public String getConfirmMessage()
|
||||
{
|
||||
String fileConfirmMsg = Application.getMessage(FacesContext.getCurrentInstance(),
|
||||
"delete_space_confirm");
|
||||
|
||||
return MessageFormat.format(fileConfirmMsg,
|
||||
new Object[] {this.browseBean.getActionSpace().getName()});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user