Merged 5.1.N (5.1.2) to 5.2.N (5.2.1)

125605 rmunteanu: Merged 5.1.1 (5.1.1) to 5.1.N (5.1.2)
      125498 slanglois: MNT-16155 Update source headers - remove svn:eol-style property on Java and JSP source files


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@125783 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Raluca Munteanu
2016-04-26 13:03:25 +00:00
parent d6f9f50c39
commit dead3c3825
265 changed files with 44099 additions and 44099 deletions

View File

@@ -1,192 +1,192 @@
package org.alfresco.web.bean.forums;
import java.text.MessageFormat;
import java.util.List;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ForumModel;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.RegexQNamePattern;
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.ReportedException;
import org.alfresco.web.ui.common.Utils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Bean implementation for the "Create Discusssion Dialog".
*
* @author gavinc
*/
public class CreateDiscussionDialog extends CreateTopicDialog
{
private static final long serialVersionUID = 3500493916528264014L;
protected NodeRef discussingNodeRef;
private static final Log logger = LogFactory.getLog(CreateDiscussionDialog.class);
// ------------------------------------------------------------------------------
// Wizard implementation
@Override
public void init(Map<String, String> parameters)
{
super.init(parameters);
// get the id of the node we are creating the discussion for
String id = parameters.get("id");
if (id == null || id.length() == 0)
{
throw new AlfrescoRuntimeException("createDiscussion called without an id");
}
// create the topic to hold the discussions
createTopic(id);
}
@Override
public String cancel()
{
// if the user cancels the creation of a discussion all the setup that was done
// when the dialog started needs to be undone i.e. removing the created forum
// and the discussable aspect
deleteTopic();
// as we are cancelling the creation of a discussion we know we need to go back
// to the browse screen, this also makes sure we don't end up in the forum that
// just got deleted!
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().remove(
AlfrescoNavigationHandler.EXTERNAL_CONTAINER_SESSION);
return getDefaultCancelOutcome();
}
// ------------------------------------------------------------------------------
// Helper methods
/**
* Creates a topic for the node with the given id
*
* @param id The id of the node to discuss
*/
protected void createTopic(final String id)
{
RetryingTransactionCallback<NodeRef> createTopicCallback = new RetryingTransactionCallback<NodeRef>()
{
public NodeRef execute() throws Throwable
{
NodeRef forumNodeRef = null;
discussingNodeRef = new NodeRef(Repository.getStoreRef(), id);
if (getNodeService().hasAspect(discussingNodeRef, ForumModel.ASPECT_DISCUSSABLE))
{
throw new AlfrescoRuntimeException("createDiscussion called for an object that already has a discussion!");
}
// Add the discussable aspect
getNodeService().addAspect(discussingNodeRef, ForumModel.ASPECT_DISCUSSABLE, null);
// The discussion aspect create the necessary child
List<ChildAssociationRef> destChildren = getNodeService().getChildAssocs(
discussingNodeRef,
ForumModel.ASSOC_DISCUSSION,
RegexQNamePattern.MATCH_ALL);
// Take the first one
if (destChildren.size() == 0)
{
// Drop the aspect and recreate it. This should not happen, but just in case ...
getNodeService().removeAspect(discussingNodeRef, ForumModel.ASPECT_DISCUSSABLE);
getNodeService().addAspect(discussingNodeRef, ForumModel.ASPECT_DISCUSSABLE, null);
// The discussion aspect create the necessary child
destChildren = getNodeService().getChildAssocs(
discussingNodeRef,
ForumModel.ASSOC_DISCUSSION,
RegexQNamePattern.MATCH_ALL);
}
if (destChildren.size() == 0)
{
throw new AlfrescoRuntimeException("The discussable aspect behaviour is not creating a topic");
}
else
{
// We just take the first one
ChildAssociationRef discussionAssoc = destChildren.get(0);
forumNodeRef = discussionAssoc.getChildRef();
}
if (logger.isDebugEnabled())
logger.debug("created forum for content: " + discussingNodeRef.toString());
return forumNodeRef;
}
};
FacesContext context = FacesContext.getCurrentInstance();
NodeRef forumNodeRef = null;
try
{
forumNodeRef = getTransactionService().getRetryingTransactionHelper().doInTransaction(
createTopicCallback, false);
}
catch (InvalidNodeRefException refErr)
{
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
FacesContext.getCurrentInstance(), Repository.ERROR_NODEREF), new Object[] {id}) );
throw new AbortProcessingException("Invalid node reference");
}
catch (Throwable e)
{
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
context, Repository.ERROR_GENERIC), e.getMessage()), e);
ReportedException.throwIfNecessary(e);
}
// finally setup the context for the forum we just created
if (forumNodeRef != null)
{
this.browseBean.clickSpace(forumNodeRef);
}
}
/**
* Deletes the setup performed during the initialisation of the dialog.
*/
protected void deleteTopic()
{
RetryingTransactionCallback<Object> deleteTopicCallback = new RetryingTransactionCallback<Object>()
{
public Object execute() throws Throwable
{
// remove this node from the breadcrumb if required
Node forumNode = navigator.getCurrentNode();
browseBean.removeSpaceFromBreadcrumb(forumNode);
// remove the discussable aspect from the node we were going to discuss!
// AWC-1519: removing the aspect that defines the child association now does the
// cascade delete so we no longer have to delete the child explicitly
getNodeService().removeAspect(discussingNodeRef, ForumModel.ASPECT_DISCUSSABLE);
// Done
return null;
}
};
FacesContext context = FacesContext.getCurrentInstance();
try
{
getTransactionService().getRetryingTransactionHelper().doInTransaction(deleteTopicCallback, false);
}
catch (Throwable e)
{
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
context, Repository.ERROR_GENERIC), e.getMessage()), e);
ReportedException.throwIfNecessary(e);
}
}
}
package org.alfresco.web.bean.forums;
import java.text.MessageFormat;
import java.util.List;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ForumModel;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.RegexQNamePattern;
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.ReportedException;
import org.alfresco.web.ui.common.Utils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Bean implementation for the "Create Discusssion Dialog".
*
* @author gavinc
*/
public class CreateDiscussionDialog extends CreateTopicDialog
{
private static final long serialVersionUID = 3500493916528264014L;
protected NodeRef discussingNodeRef;
private static final Log logger = LogFactory.getLog(CreateDiscussionDialog.class);
// ------------------------------------------------------------------------------
// Wizard implementation
@Override
public void init(Map<String, String> parameters)
{
super.init(parameters);
// get the id of the node we are creating the discussion for
String id = parameters.get("id");
if (id == null || id.length() == 0)
{
throw new AlfrescoRuntimeException("createDiscussion called without an id");
}
// create the topic to hold the discussions
createTopic(id);
}
@Override
public String cancel()
{
// if the user cancels the creation of a discussion all the setup that was done
// when the dialog started needs to be undone i.e. removing the created forum
// and the discussable aspect
deleteTopic();
// as we are cancelling the creation of a discussion we know we need to go back
// to the browse screen, this also makes sure we don't end up in the forum that
// just got deleted!
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().remove(
AlfrescoNavigationHandler.EXTERNAL_CONTAINER_SESSION);
return getDefaultCancelOutcome();
}
// ------------------------------------------------------------------------------
// Helper methods
/**
* Creates a topic for the node with the given id
*
* @param id The id of the node to discuss
*/
protected void createTopic(final String id)
{
RetryingTransactionCallback<NodeRef> createTopicCallback = new RetryingTransactionCallback<NodeRef>()
{
public NodeRef execute() throws Throwable
{
NodeRef forumNodeRef = null;
discussingNodeRef = new NodeRef(Repository.getStoreRef(), id);
if (getNodeService().hasAspect(discussingNodeRef, ForumModel.ASPECT_DISCUSSABLE))
{
throw new AlfrescoRuntimeException("createDiscussion called for an object that already has a discussion!");
}
// Add the discussable aspect
getNodeService().addAspect(discussingNodeRef, ForumModel.ASPECT_DISCUSSABLE, null);
// The discussion aspect create the necessary child
List<ChildAssociationRef> destChildren = getNodeService().getChildAssocs(
discussingNodeRef,
ForumModel.ASSOC_DISCUSSION,
RegexQNamePattern.MATCH_ALL);
// Take the first one
if (destChildren.size() == 0)
{
// Drop the aspect and recreate it. This should not happen, but just in case ...
getNodeService().removeAspect(discussingNodeRef, ForumModel.ASPECT_DISCUSSABLE);
getNodeService().addAspect(discussingNodeRef, ForumModel.ASPECT_DISCUSSABLE, null);
// The discussion aspect create the necessary child
destChildren = getNodeService().getChildAssocs(
discussingNodeRef,
ForumModel.ASSOC_DISCUSSION,
RegexQNamePattern.MATCH_ALL);
}
if (destChildren.size() == 0)
{
throw new AlfrescoRuntimeException("The discussable aspect behaviour is not creating a topic");
}
else
{
// We just take the first one
ChildAssociationRef discussionAssoc = destChildren.get(0);
forumNodeRef = discussionAssoc.getChildRef();
}
if (logger.isDebugEnabled())
logger.debug("created forum for content: " + discussingNodeRef.toString());
return forumNodeRef;
}
};
FacesContext context = FacesContext.getCurrentInstance();
NodeRef forumNodeRef = null;
try
{
forumNodeRef = getTransactionService().getRetryingTransactionHelper().doInTransaction(
createTopicCallback, false);
}
catch (InvalidNodeRefException refErr)
{
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
FacesContext.getCurrentInstance(), Repository.ERROR_NODEREF), new Object[] {id}) );
throw new AbortProcessingException("Invalid node reference");
}
catch (Throwable e)
{
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
context, Repository.ERROR_GENERIC), e.getMessage()), e);
ReportedException.throwIfNecessary(e);
}
// finally setup the context for the forum we just created
if (forumNodeRef != null)
{
this.browseBean.clickSpace(forumNodeRef);
}
}
/**
* Deletes the setup performed during the initialisation of the dialog.
*/
protected void deleteTopic()
{
RetryingTransactionCallback<Object> deleteTopicCallback = new RetryingTransactionCallback<Object>()
{
public Object execute() throws Throwable
{
// remove this node from the breadcrumb if required
Node forumNode = navigator.getCurrentNode();
browseBean.removeSpaceFromBreadcrumb(forumNode);
// remove the discussable aspect from the node we were going to discuss!
// AWC-1519: removing the aspect that defines the child association now does the
// cascade delete so we no longer have to delete the child explicitly
getNodeService().removeAspect(discussingNodeRef, ForumModel.ASPECT_DISCUSSABLE);
// Done
return null;
}
};
FacesContext context = FacesContext.getCurrentInstance();
try
{
getTransactionService().getRetryingTransactionHelper().doInTransaction(deleteTopicCallback, false);
}
catch (Throwable e)
{
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
context, Repository.ERROR_GENERIC), e.getMessage()), e);
ReportedException.throwIfNecessary(e);
}
}
}

View File

@@ -1,36 +1,36 @@
package org.alfresco.web.bean.forums;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.model.ForumModel;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.spaces.CreateSpaceDialog;
/**
* Bean used to implement the "Create Forum Dialog".
*
* @author gavinc
*/
public class CreateForumDialog extends CreateSpaceDialog
{
// ------------------------------------------------------------------------------
// Wizard implementation
private static final long serialVersionUID = 277281993463789379L;
@Override
public void init(Map<String, String> parameters)
{
super.init(parameters);
this.spaceType = ForumModel.TYPE_FORUM.toString();
}
@Override
public String getFinishButtonLabel()
{
return Application.getMessage(FacesContext.getCurrentInstance(), "create_forum");
}
}
package org.alfresco.web.bean.forums;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.model.ForumModel;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.spaces.CreateSpaceDialog;
/**
* Bean used to implement the "Create Forum Dialog".
*
* @author gavinc
*/
public class CreateForumDialog extends CreateSpaceDialog
{
// ------------------------------------------------------------------------------
// Wizard implementation
private static final long serialVersionUID = 277281993463789379L;
@Override
public void init(Map<String, String> parameters)
{
super.init(parameters);
this.spaceType = ForumModel.TYPE_FORUM.toString();
}
@Override
public String getFinishButtonLabel()
{
return Application.getMessage(FacesContext.getCurrentInstance(), "create_forum");
}
}

View File

@@ -1,36 +1,36 @@
package org.alfresco.web.bean.forums;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.model.ForumModel;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.spaces.CreateSpaceDialog;
/**
* Bean used to implement the "Create Forums Dialog".
*
* @author gavinc
*/
public class CreateForumsDialog extends CreateSpaceDialog
{
// ------------------------------------------------------------------------------
// Wizard implementation
private static final long serialVersionUID = 4371868975654509241L;
@Override
public void init(Map<String, String> parameters)
{
super.init(parameters);
this.spaceType = ForumModel.TYPE_FORUMS.toString();
}
@Override
public String getFinishButtonLabel()
{
return Application.getMessage(FacesContext.getCurrentInstance(), "create_forums");
}
}
package org.alfresco.web.bean.forums;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.model.ForumModel;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.spaces.CreateSpaceDialog;
/**
* Bean used to implement the "Create Forums Dialog".
*
* @author gavinc
*/
public class CreateForumsDialog extends CreateSpaceDialog
{
// ------------------------------------------------------------------------------
// Wizard implementation
private static final long serialVersionUID = 4371868975654509241L;
@Override
public void init(Map<String, String> parameters)
{
super.init(parameters);
this.spaceType = ForumModel.TYPE_FORUMS.toString();
}
@Override
public String getFinishButtonLabel()
{
return Application.getMessage(FacesContext.getCurrentInstance(), "create_forums");
}
}

View File

@@ -1,65 +1,65 @@
package org.alfresco.web.bean.forums;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.model.ForumModel;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.content.CreateContentWizard;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.ui.common.Utils;
/**
* Bean implementation of the "New Post Dialog".
*
* @author gavinc
*/
public class CreatePostDialog extends CreateContentWizard
{
// ------------------------------------------------------------------------------
// Wizard implementation
private static final long serialVersionUID = -2859329677883776068L;
@Override
public void init(Map<String, String> parameters)
{
super.init(parameters);
// set up for creating a post
this.objectType = ForumModel.TYPE_POST.toString();
// make sure we don't show the edit properties dialog after creation
this.showOtherProperties = false;
}
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
// create appropriate values for filename and content type
this.fileName = ForumsBean.createPostFileName();
this.mimeType = Repository.getMimeTypeForFileName(
FacesContext.getCurrentInstance(), this.fileName);
// remove link breaks and replace with <br>
this.content = Utils.replaceLineBreaks(this.content, false);
// set UTF-8 encoding for the post (all original posts are UTF-8 also)
this.encoding = "UTF-8";
return super.finishImpl(context, outcome);
}
@Override
public String getFinishButtonLabel()
{
return Application.getMessage(FacesContext.getCurrentInstance(), "post");
}
@Override
public boolean getFinishButtonDisabled()
{
return true;
}
}
package org.alfresco.web.bean.forums;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.model.ForumModel;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.content.CreateContentWizard;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.ui.common.Utils;
/**
* Bean implementation of the "New Post Dialog".
*
* @author gavinc
*/
public class CreatePostDialog extends CreateContentWizard
{
// ------------------------------------------------------------------------------
// Wizard implementation
private static final long serialVersionUID = -2859329677883776068L;
@Override
public void init(Map<String, String> parameters)
{
super.init(parameters);
// set up for creating a post
this.objectType = ForumModel.TYPE_POST.toString();
// make sure we don't show the edit properties dialog after creation
this.showOtherProperties = false;
}
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
// create appropriate values for filename and content type
this.fileName = ForumsBean.createPostFileName();
this.mimeType = Repository.getMimeTypeForFileName(
FacesContext.getCurrentInstance(), this.fileName);
// remove link breaks and replace with <br>
this.content = Utils.replaceLineBreaks(this.content, false);
// set UTF-8 encoding for the post (all original posts are UTF-8 also)
this.encoding = "UTF-8";
return super.finishImpl(context, outcome);
}
@Override
public String getFinishButtonLabel()
{
return Application.getMessage(FacesContext.getCurrentInstance(), "post");
}
@Override
public boolean getFinishButtonDisabled()
{
return true;
}
}

View File

@@ -1,65 +1,65 @@
package org.alfresco.web.bean.forums;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.web.app.Application;
import org.alfresco.web.ui.common.Utils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Bean implementation of the "Create Reply Dialog".
*
* @author gavinc
*/
public class CreateReplyDialog extends CreatePostDialog
{
private static final long serialVersionUID = 8036934269090933533L;
protected String replyContent = null;
private static final Log logger = LogFactory.getLog(CreateReplyDialog.class);
// ------------------------------------------------------------------------------
// Wizard implementation
@Override
public void init(Map<String, String> parameters)
{
super.init(parameters);
this.replyContent = null;
}
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
// remove link breaks and replace with <br>
this.content = Utils.replaceLineBreaks(this.content, false);
super.finishImpl(context, outcome);
// setup the referencing aspect with the references association
// between the new post and the one being replied to
this.getNodeService().addAspect(this.createdNode, ContentModel.ASPECT_REFERENCING, null);
this.getNodeService().createAssociation(this.createdNode, this.browseBean.getDocument().getNodeRef(),
ContentModel.ASSOC_REFERENCES);
if (logger.isDebugEnabled())
{
logger.debug("created new node: " + this.createdNode);
logger.debug("existing node: " + this.browseBean.getDocument().getNodeRef());
}
return outcome;
}
@Override
public String getFinishButtonLabel()
{
return Application.getMessage(FacesContext.getCurrentInstance(), "reply");
}
}
package org.alfresco.web.bean.forums;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.web.app.Application;
import org.alfresco.web.ui.common.Utils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Bean implementation of the "Create Reply Dialog".
*
* @author gavinc
*/
public class CreateReplyDialog extends CreatePostDialog
{
private static final long serialVersionUID = 8036934269090933533L;
protected String replyContent = null;
private static final Log logger = LogFactory.getLog(CreateReplyDialog.class);
// ------------------------------------------------------------------------------
// Wizard implementation
@Override
public void init(Map<String, String> parameters)
{
super.init(parameters);
this.replyContent = null;
}
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
// remove link breaks and replace with <br>
this.content = Utils.replaceLineBreaks(this.content, false);
super.finishImpl(context, outcome);
// setup the referencing aspect with the references association
// between the new post and the one being replied to
this.getNodeService().addAspect(this.createdNode, ContentModel.ASPECT_REFERENCING, null);
this.getNodeService().createAssociation(this.createdNode, this.browseBean.getDocument().getNodeRef(),
ContentModel.ASSOC_REFERENCES);
if (logger.isDebugEnabled())
{
logger.debug("created new node: " + this.createdNode);
logger.debug("existing node: " + this.browseBean.getDocument().getNodeRef());
}
return outcome;
}
@Override
public String getFinishButtonLabel()
{
return Application.getMessage(FacesContext.getCurrentInstance(), "reply");
}
}

View File

@@ -1,156 +1,156 @@
package org.alfresco.web.bean.forums;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel;
import org.alfresco.model.ForumModel;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.ContentWriter;
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.Repository;
import org.alfresco.web.bean.spaces.CreateSpaceDialog;
import org.alfresco.web.ui.common.Utils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Bean implementation of the "Create Topic Dialog".
*
* @author gavinc
*/
public class CreateTopicDialog extends CreateSpaceDialog
{
private static final long serialVersionUID = -8672220556613430308L;
protected String message;
transient private ContentService contentService;
private static final Log logger = LogFactory.getLog(CreateTopicDialog.class);
// ------------------------------------------------------------------------------
// Wizard implementation
@Override
public void init(Map<String, String> parameters)
{
super.init(parameters);
this.spaceType = ForumModel.TYPE_TOPIC.toString();
this.message = null;
}
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
super.finishImpl(context, outcome);
// do topic specific processing
// get the node ref of the node that will contain the content
NodeRef containerNodeRef = this.createdNode;
// create a unique file name for the message content
String fileName = ForumsBean.createPostFileName();
FileInfo fileInfo = this.getFileFolderService().create(containerNodeRef,
fileName, ForumModel.TYPE_POST);
NodeRef postNodeRef = fileInfo.getNodeRef();
if (logger.isDebugEnabled())
logger.debug("Created post node with filename: " + fileName);
// apply the titled aspect - title and description
Map<QName, Serializable> titledProps = new HashMap<QName, Serializable>(3, 1.0f);
titledProps.put(ContentModel.PROP_TITLE, fileName);
this.getNodeService().addAspect(postNodeRef, ContentModel.ASPECT_TITLED, titledProps);
if (logger.isDebugEnabled())
logger.debug("Added titled aspect with properties: " + titledProps);
Map<QName, Serializable> editProps = new HashMap<QName, Serializable>(1, 1.0f);
editProps.put(ApplicationModel.PROP_EDITINLINE, true);
this.getNodeService().addAspect(postNodeRef, ApplicationModel.ASPECT_INLINEEDITABLE, editProps);
if (logger.isDebugEnabled())
logger.debug("Added inlineeditable aspect with properties: " + editProps);
// get a writer for the content and put the file
ContentWriter writer = getContentService().getWriter(postNodeRef, ContentModel.PROP_CONTENT, true);
// set the mimetype and encoding
writer.setMimetype(Repository.getMimeTypeForFileName(context, fileName));
writer.setEncoding("UTF-8");
writer.putContent(Utils.replaceLineBreaks(this.message, false));
return outcome;
}
@Override
protected String doPostCommitProcessing(FacesContext context, String outcome)
{
// if the creation was successful we need to simulate a user
// selecting the topic, the dispatching will take us to the
// correct view.
this.browseBean.clickSpace(this.createdNode);
return outcome + AlfrescoNavigationHandler.OUTCOME_SEPARATOR + "showTopic";
}
@Override
public String getFinishButtonLabel()
{
return Application.getMessage(FacesContext.getCurrentInstance(), "create_topic");
}
// ------------------------------------------------------------------------------
// Bean Getters and Setters
/**
* Returns the message entered by the user for the first post
*
* @return The message for the first post
*/
public String getMessage()
{
return this.message;
}
/**
* Sets the message
*
* @param message The message
*/
public void setMessage(String message)
{
this.message = message;
}
// ------------------------------------------------------------------------------
// Service Injection
/**
* @param contentService The contentService to set.
*/
public void setContentService(ContentService contentService)
{
this.contentService = contentService;
}
protected ContentService getContentService()
{
if (contentService == null)
{
contentService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getContentService();
}
return contentService;
}
}
package org.alfresco.web.bean.forums;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel;
import org.alfresco.model.ForumModel;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.ContentWriter;
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.Repository;
import org.alfresco.web.bean.spaces.CreateSpaceDialog;
import org.alfresco.web.ui.common.Utils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Bean implementation of the "Create Topic Dialog".
*
* @author gavinc
*/
public class CreateTopicDialog extends CreateSpaceDialog
{
private static final long serialVersionUID = -8672220556613430308L;
protected String message;
transient private ContentService contentService;
private static final Log logger = LogFactory.getLog(CreateTopicDialog.class);
// ------------------------------------------------------------------------------
// Wizard implementation
@Override
public void init(Map<String, String> parameters)
{
super.init(parameters);
this.spaceType = ForumModel.TYPE_TOPIC.toString();
this.message = null;
}
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
super.finishImpl(context, outcome);
// do topic specific processing
// get the node ref of the node that will contain the content
NodeRef containerNodeRef = this.createdNode;
// create a unique file name for the message content
String fileName = ForumsBean.createPostFileName();
FileInfo fileInfo = this.getFileFolderService().create(containerNodeRef,
fileName, ForumModel.TYPE_POST);
NodeRef postNodeRef = fileInfo.getNodeRef();
if (logger.isDebugEnabled())
logger.debug("Created post node with filename: " + fileName);
// apply the titled aspect - title and description
Map<QName, Serializable> titledProps = new HashMap<QName, Serializable>(3, 1.0f);
titledProps.put(ContentModel.PROP_TITLE, fileName);
this.getNodeService().addAspect(postNodeRef, ContentModel.ASPECT_TITLED, titledProps);
if (logger.isDebugEnabled())
logger.debug("Added titled aspect with properties: " + titledProps);
Map<QName, Serializable> editProps = new HashMap<QName, Serializable>(1, 1.0f);
editProps.put(ApplicationModel.PROP_EDITINLINE, true);
this.getNodeService().addAspect(postNodeRef, ApplicationModel.ASPECT_INLINEEDITABLE, editProps);
if (logger.isDebugEnabled())
logger.debug("Added inlineeditable aspect with properties: " + editProps);
// get a writer for the content and put the file
ContentWriter writer = getContentService().getWriter(postNodeRef, ContentModel.PROP_CONTENT, true);
// set the mimetype and encoding
writer.setMimetype(Repository.getMimeTypeForFileName(context, fileName));
writer.setEncoding("UTF-8");
writer.putContent(Utils.replaceLineBreaks(this.message, false));
return outcome;
}
@Override
protected String doPostCommitProcessing(FacesContext context, String outcome)
{
// if the creation was successful we need to simulate a user
// selecting the topic, the dispatching will take us to the
// correct view.
this.browseBean.clickSpace(this.createdNode);
return outcome + AlfrescoNavigationHandler.OUTCOME_SEPARATOR + "showTopic";
}
@Override
public String getFinishButtonLabel()
{
return Application.getMessage(FacesContext.getCurrentInstance(), "create_topic");
}
// ------------------------------------------------------------------------------
// Bean Getters and Setters
/**
* Returns the message entered by the user for the first post
*
* @return The message for the first post
*/
public String getMessage()
{
return this.message;
}
/**
* Sets the message
*
* @param message The message
*/
public void setMessage(String message)
{
this.message = message;
}
// ------------------------------------------------------------------------------
// Service Injection
/**
* @param contentService The contentService to set.
*/
public void setContentService(ContentService contentService)
{
this.contentService = contentService;
}
protected ContentService getContentService()
{
if (contentService == null)
{
contentService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getContentService();
}
return contentService;
}
}

View File

@@ -1,106 +1,106 @@
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" dialog
*
* @author gavinc
*/
public class DeleteForumDialog extends DeleteSpaceDialog
{
private static final long serialVersionUID = -4246549059188399460L;
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();
NodeRef parent = null;
ChildAssociationRef assoc = this.getNodeService().getPrimaryParent(node.getNodeRef());
if (assoc != null)
{
// get the parent node
parent = assoc.getParentRef();
// 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.getNodeService().getType(parent);
if (parentType.equals(ForumModel.TYPE_FORUMS))
{
this.reDisplayForums = true;
}
}
// delete the forum itself
outcome = super.finishImpl(context, outcome);
// remove the discussable aspect if appropriate
if (assoc != null && parent != null)
{
// 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.getNodeService().removeAspect(parent, ForumModel.ASPECT_DISCUSSABLE);
}
}
return 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;
}
}
/**
* Returns the message bundle id of the confirmation message to display to
* the user before deleting the forum.
*
* @return The message bundle id
*/
@Override
protected String getConfirmMessageId()
{
return "delete_forum_confirm";
}
}
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" dialog
*
* @author gavinc
*/
public class DeleteForumDialog extends DeleteSpaceDialog
{
private static final long serialVersionUID = -4246549059188399460L;
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();
NodeRef parent = null;
ChildAssociationRef assoc = this.getNodeService().getPrimaryParent(node.getNodeRef());
if (assoc != null)
{
// get the parent node
parent = assoc.getParentRef();
// 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.getNodeService().getType(parent);
if (parentType.equals(ForumModel.TYPE_FORUMS))
{
this.reDisplayForums = true;
}
}
// delete the forum itself
outcome = super.finishImpl(context, outcome);
// remove the discussable aspect if appropriate
if (assoc != null && parent != null)
{
// 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.getNodeService().removeAspect(parent, ForumModel.ASPECT_DISCUSSABLE);
}
}
return 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;
}
}
/**
* Returns the message bundle id of the confirmation message to display to
* the user before deleting the forum.
*
* @return The message bundle id
*/
@Override
protected String getConfirmMessageId()
{
return "delete_forum_confirm";
}
}

View File

@@ -1,72 +1,72 @@
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
{
private static final long serialVersionUID = -1673691210425371041L;
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.getNodeService().getPrimaryParent(node.getNodeRef());
if (assoc != null)
{
NodeRef parent = assoc.getParentRef();
QName parentType = this.getNodeService().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;
}
}
}
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
{
private static final long serialVersionUID = -1673691210425371041L;
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.getNodeService().getPrimaryParent(node.getNodeRef());
if (assoc != null)
{
NodeRef parent = assoc.getParentRef();
QName parentType = this.getNodeService().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

@@ -1,46 +1,46 @@
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
private static final long serialVersionUID = 6804626884508461423L;
@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")});
}
}
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
private static final long serialVersionUID = 6804626884508461423L;
@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

@@ -1,84 +1,84 @@
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 Topic" dialog
*
* @author gavinc
*/
public class DeleteTopicDialog extends DeleteSpaceDialog
{
private static final long serialVersionUID = 548182341698381545L;
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.getNodeService().getPrimaryParent(node.getNodeRef());
if (assoc != null)
{
NodeRef parent = assoc.getParentRef();
QName parentType = this.getNodeService().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;
}
}
/**
* Returns the message bundle id of the confirmation message to display to
* the user before deleting the topic.
*
* @return The message bundle id
*/
@Override
protected String getConfirmMessageId()
{
return "delete_topic_confirm";
}
}
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 Topic" dialog
*
* @author gavinc
*/
public class DeleteTopicDialog extends DeleteSpaceDialog
{
private static final long serialVersionUID = 548182341698381545L;
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.getNodeService().getPrimaryParent(node.getNodeRef());
if (assoc != null)
{
NodeRef parent = assoc.getParentRef();
QName parentType = this.getNodeService().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;
}
}
/**
* Returns the message bundle id of the confirmation message to display to
* the user before deleting the topic.
*
* @return The message bundle id
*/
@Override
protected String getConfirmMessageId()
{
return "delete_topic_confirm";
}
}

View File

@@ -1,87 +1,87 @@
package org.alfresco.web.bean.forums;
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.ContentWriter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.ui.common.Utils;
import org.springframework.util.StringUtils;
/**
* Bean implementation for the "Edit Post Dialog".
*
* @author gavinc
*/
public class EditPostDialog extends CreatePostDialog
{
// ------------------------------------------------------------------------------
// Wizard implementation
private static final long serialVersionUID = 7925794441178897699L;
@Override
public void init(Map<String, String> parameters)
{
super.init(parameters);
// we need to remove the <br> tags and replace with carriage returns
// and then setup the content member variable
Node currentDocument = this.browseBean.getDocument();
ContentReader reader = this.getContentService().getReader(currentDocument.getNodeRef(),
ContentModel.PROP_CONTENT);
if (reader != null)
{
String htmlContent = reader.getContentString();
if (htmlContent != null)
{
// ETHREEOH-1216: replace both forms of 'br' as older posts have the <br/> version
// which doesn't work in all browsers supported by Alfresco Explorer
htmlContent = StringUtils.replace(htmlContent, "<br/>", "\r\n");
this.content = StringUtils.replace(htmlContent, "<br>", "\r\n");
}
}
}
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
// remove link breaks and replace with <br>
this.content = Utils.replaceLineBreaks(this.content, false);
// update the content
NodeRef postNode = this.browseBean.getDocument().getNodeRef();
// check that the name of this post does not contain the :
// character (used in previous versions), if it does rename
// the post.
String name = (String)this.getNodeService().getProperty(
postNode, ContentModel.PROP_NAME);
if (name.indexOf(":") != -1)
{
String newName = name.replace(':', '-');
this.getFileFolderService().rename(postNode, newName);
}
ContentWriter writer = this.getContentService().getWriter(postNode,
ContentModel.PROP_CONTENT, true);
if (writer != null)
{
writer.putContent(this.content);
}
return outcome;
}
@Override
public String getFinishButtonLabel()
{
return Application.getMessage(FacesContext.getCurrentInstance(), "ok");
}
}
package org.alfresco.web.bean.forums;
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.ContentWriter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.ui.common.Utils;
import org.springframework.util.StringUtils;
/**
* Bean implementation for the "Edit Post Dialog".
*
* @author gavinc
*/
public class EditPostDialog extends CreatePostDialog
{
// ------------------------------------------------------------------------------
// Wizard implementation
private static final long serialVersionUID = 7925794441178897699L;
@Override
public void init(Map<String, String> parameters)
{
super.init(parameters);
// we need to remove the <br> tags and replace with carriage returns
// and then setup the content member variable
Node currentDocument = this.browseBean.getDocument();
ContentReader reader = this.getContentService().getReader(currentDocument.getNodeRef(),
ContentModel.PROP_CONTENT);
if (reader != null)
{
String htmlContent = reader.getContentString();
if (htmlContent != null)
{
// ETHREEOH-1216: replace both forms of 'br' as older posts have the <br/> version
// which doesn't work in all browsers supported by Alfresco Explorer
htmlContent = StringUtils.replace(htmlContent, "<br/>", "\r\n");
this.content = StringUtils.replace(htmlContent, "<br>", "\r\n");
}
}
}
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
// remove link breaks and replace with <br>
this.content = Utils.replaceLineBreaks(this.content, false);
// update the content
NodeRef postNode = this.browseBean.getDocument().getNodeRef();
// check that the name of this post does not contain the :
// character (used in previous versions), if it does rename
// the post.
String name = (String)this.getNodeService().getProperty(
postNode, ContentModel.PROP_NAME);
if (name.indexOf(":") != -1)
{
String newName = name.replace(':', '-');
this.getFileFolderService().rename(postNode, newName);
}
ContentWriter writer = this.getContentService().getWriter(postNode,
ContentModel.PROP_CONTENT, true);
if (writer != null)
{
writer.putContent(this.content);
}
return outcome;
}
@Override
public String getFinishButtonLabel()
{
return Application.getMessage(FacesContext.getCurrentInstance(), "ok");
}
}

File diff suppressed because it is too large Load Diff