Merge from HEAD into WCM-DEV2. Also fixes build breakage in

jndi-client and catalina-virtual that I introduced earlier. 


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3393 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-07-24 18:27:41 +00:00
parent ca9496d090
commit f6355ea108
171 changed files with 11880 additions and 3450 deletions

View File

@@ -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)
{

View File

@@ -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;
@@ -62,32 +60,4 @@ public class CreateReplyDialog extends CreatePostDialog
{
return Application.getMessage(FacesContext.getCurrentInstance(), "reply");
}
// ------------------------------------------------------------------------------
// Bean Getters and Setters
/**
* Returns the content of the post we are replying to
*
* @return The content
*/
public String getReplyContent()
{
if (this.replyContent == null)
{
// get the content reader of the node we are replying to
NodeRef replyNode = this.browseBean.getDocument().getNodeRef();
if (replyNode != null)
{
ContentReader reader = this.contentService.getReader(replyNode, ContentModel.PROP_CONTENT);
if (reader != null)
{
this.replyContent = reader.getContentString();
}
}
}
return this.replyContent;
}
}

View 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()});
}
}

View File

@@ -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;
}
}
}

View File

@@ -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")});
}
}

View File

@@ -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()});
}
}

View File

@@ -17,6 +17,7 @@
package org.alfresco.web.bean.forums;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
@@ -50,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;
@@ -536,6 +536,61 @@ public class ForumsBean implements IContextListener
}
}
/**
* Returns the HTML to represent a bubble rendition of the text of the the
* forum article being replied to.
*
* @return The HTML for the bubble
*/
public String getReplyBubbleHTML()
{
try
{
// if the forum being replied to was a new post show the orange bubble
// with the user on the left otherwise show the yellow bubble with the
// user on the right.
StringWriter writer = new StringWriter();
FacesContext context = FacesContext.getCurrentInstance();
Node replyToNode = this.browseBean.getDocument();
boolean isReplyPost = this.nodeService.hasAspect(replyToNode.getNodeRef(),
ContentModel.ASPECT_REFERENCING);
String contextPath = context.getExternalContext().getRequestContextPath();
String colour = isReplyPost ? "yellow" : "orange";
String bgColour = isReplyPost ? "#FFF5A3" : "#FCC75E";
// build the HTML to represent the user that posted the article being replied to
StringBuilder replyPosterHTML = new StringBuilder("<td valign='top'>");
replyPosterHTML.append("<img src='");
replyPosterHTML.append(contextPath);
replyPosterHTML.append("/images/icons/user_large.gif' /><br/>");
replyPosterHTML.append((String)replyToNode.getProperties().get("creator"));
replyPosterHTML.append("</td>");
// start the table
writer.write("<table border='0' cellpadding='0' cellspacing='0' width='100%'><tr>");
if (isReplyPost)
{
renderReplyContentHTML(context, replyToNode, writer, contextPath, colour, bgColour);
writer.write(replyPosterHTML.toString());
}
else
{
writer.write(replyPosterHTML.toString());
renderReplyContentHTML(context, replyToNode, writer, contextPath, colour, bgColour);
}
// finish the table
writer.write("</tr></table>");
return writer.toString();
}
catch (IOException ioe)
{
throw new AlfrescoRuntimeException("Failed to render reply bubble HTML", ioe);
}
}
// ------------------------------------------------------------------------------
// IContextListener implementation
@@ -697,159 +752,21 @@ public class ForumsBean implements IContextListener
ForumModel.ASSOC_DISCUSSION, RegexQNamePattern.MATCH_ALL);
// there should only be one child, retrieve it if there is
if (children.size() != 1)
if (children.size() == 1)
{
throw new IllegalStateException("Node has the discussable aspect but does not have 1 child, it has " +
children.size() + " children!");
// show the forum for the discussion
NodeRef forumNodeRef = children.get(0).getChildRef();
this.browseBean.clickSpace(forumNodeRef);
context.getApplication().getNavigationHandler().handleNavigation(context, null, "showForum");
}
else
{
// this should never happen as the action evaluator should stop the action
// from displaying, just in case print a warning to the console
logger.warn("Node has the discussable aspect but does not have 1 child, it has " +
children.size() + " children!");
}
// show the forum for the discussion
NodeRef forumNodeRef = children.get(0).getChildRef();
this.browseBean.clickSpace(forumNodeRef);
context.getApplication().getNavigationHandler().handleNavigation(context, null, "showForum");
}
/**
* 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
@@ -943,7 +860,7 @@ public class ForumsBean implements IContextListener
// ------------------------------------------------------------------------------
// Private helpers
// Helpers
/**
* Initialise default values from client configuration
@@ -980,6 +897,37 @@ public class ForumsBean implements IContextListener
}
}
protected void renderReplyContentHTML(FacesContext context,
Node replyToNode, StringWriter writer,
String contextPath, String colour, String bgColour)
throws IOException
{
// get the content of the article being replied to
String replyContent = "";
ContentReader reader = this.contentService.getReader(replyToNode.getNodeRef(),
ContentModel.PROP_CONTENT);
if (reader != null)
{
replyContent = reader.getContentString();
}
// get the date of the article being replied to
String postedDate = Utils.getDateTimeFormat(context).
format(replyToNode.getProperties().get("created"));
// generate the HTML
writer.write("<td width='100%'>");
TopicBubbleViewRenderer.renderBubbleTop(writer, contextPath, colour, bgColour);
writer.write("<span class='mainSubTitle'>");
writer.write(Application.getMessage(context, "posted"));
writer.write(":&nbsp</span>");
writer.write(postedDate);
TopicBubbleViewRenderer.renderBubbleMiddle(writer, contextPath, colour);
writer.write(replyContent);
TopicBubbleViewRenderer.renderBubbleBottom(writer, contextPath, colour);
writer.write("</td>");
}
/**
* Class to implement a bubble view for the RichList component used in the topics screen
*