Forums overriden actions (checkin) and Discuss/Create Forum actions now externalised

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2556 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-03-20 14:10:44 +00:00
parent 5d3872279f
commit 65d874e9c9
10 changed files with 263 additions and 153 deletions

View File

@@ -412,7 +412,8 @@ public class BrowseBean implements IContextListener
* Setup the common properties required at data-binding time.
* <p>
* These are properties used by components on the page when iterating over the nodes.
* Information such as whether the node is locked, a working copy, download URL etc.
* The properties are available as the Node is a Map so they can be accessed directly
* by name. Information such as download URL, size and filetype are provided etc.
* <p>
* We use a set of anonymous inner classes to provide the implemention for the property
* getters. The interfaces are only called when the properties are first requested.
@@ -422,15 +423,10 @@ public class BrowseBean implements IContextListener
public void setupCommonBindingProperties(Node node)
{
// special properties to be used by the value binding components on the page
node.addPropertyResolver("locked", this.resolverlocked);
node.addPropertyResolver("owner", this.resolverOwner);
node.addPropertyResolver("workingCopy", this.resolverWorkingCopy);
node.addPropertyResolver("url", this.resolverUrl);
node.addPropertyResolver("fileType16", this.resolverFileType16);
node.addPropertyResolver("fileType32", this.resolverFileType32);
node.addPropertyResolver("size", this.resolverSize);
node.addPropertyResolver("cancelCheckOut", this.resolverCancelCheckOut);
node.addPropertyResolver("checkIn", this.resolverCheckIn);
node.addPropertyResolver("editLinkType", this.resolverEditLinkType);
node.addPropertyResolver("webdavUrl", this.resolverWebdavUrl);
node.addPropertyResolver("cifsPath", this.resolverCifsPath);
@@ -775,36 +771,36 @@ public class BrowseBean implements IContextListener
// ------------------------------------------------------------------------------
// Property Resolvers
public NodePropertyResolver resolverlocked = new NodePropertyResolver() {
/*public NodePropertyResolver resolverlocked = new NodePropertyResolver() {
public Object get(Node node) {
return node.isLocked();
}
};
};*/
public NodePropertyResolver resolverOwner = new NodePropertyResolver() {
/*public NodePropertyResolver resolverOwner = new NodePropertyResolver() {
public Object get(Node node) {
return getDocument().isWorkingCopyOwner();
}
};
};*/
public NodePropertyResolver resolverCancelCheckOut = new NodePropertyResolver() {
/*public NodePropertyResolver resolverCancelCheckOut = new NodePropertyResolver() {
public Object get(Node node) {
return node.hasAspect(ContentModel.ASPECT_WORKING_COPY) && node.hasPermission(PermissionService.CANCEL_CHECK_OUT);
}
};
};*/
public NodePropertyResolver resolverCheckIn = new NodePropertyResolver() {
/*public NodePropertyResolver resolverCheckIn = new NodePropertyResolver() {
public Object get(Node node) {
return node.hasAspect(ContentModel.ASPECT_WORKING_COPY) && node.hasPermission(PermissionService.CHECK_IN);
}
};
};*/
public NodePropertyResolver resolverWorkingCopy = new NodePropertyResolver() {
/*public NodePropertyResolver resolverWorkingCopy = new NodePropertyResolver() {
public Object get(Node node) {
return node.hasAspect(ContentModel.ASPECT_WORKING_COPY);
}
};
};*/
public NodePropertyResolver resolverDownload = new NodePropertyResolver() {
public Object get(Node node) {
return DownloadContentServlet.generateDownloadURL(node.getNodeRef(), node.getName());
@@ -1152,8 +1148,6 @@ public class BrowseBean implements IContextListener
node.addPropertyResolver("fileType32", this.resolverFileType32);
node.addPropertyResolver("mimetype", this.resolverMimetype);
node.addPropertyResolver("size", this.resolverSize);
node.addPropertyResolver("cancelCheckOut", this.resolverCancelCheckOut);
node.addPropertyResolver("checkIn", this.resolverCheckIn);
for (NodeEventListener listener : getNodeEventListeners())
{

View File

@@ -47,7 +47,6 @@ import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.search.QueryParameterDefinition;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
@@ -74,7 +73,7 @@ import org.apache.commons.logging.LogFactory;
*
* @author gavinc
*/
public class ForumsBean implements IContextListener, NodeEventListener
public class ForumsBean implements IContextListener
{
private static Log logger = LogFactory.getLog(ForumsBean.class);
private static final String PAGE_NAME_FORUMS = "forums";
@@ -594,25 +593,6 @@ public class ForumsBean implements IContextListener, NodeEventListener
}
// ------------------------------------------------------------------------------
// NodeEventListener implementation
/**
* @see org.alfresco.web.bean.NodeEventListener#created(org.alfresco.web.bean.repository.Node, org.alfresco.service.namespace.QName)
*/
public void created(Node node, QName type)
{
// override the checkin resolver if appropriate
if (node.containsPropertyResolver("checkIn") == true)
{
node.addPropertyResolver("checkIn", this.resolverCheckIn);
}
// add the forums specific action resolver
node.addPropertyResolver("beingDiscussed", this.resolverBeingDiscussed);
}
// ------------------------------------------------------------------------------
// Navigation action event handlers
@@ -872,44 +852,6 @@ public class ForumsBean implements IContextListener, NodeEventListener
// ------------------------------------------------------------------------------
// Property Resolvers
public NodePropertyResolver resolverCheckIn = new NodePropertyResolver() {
public Object get(Node node)
{
boolean canCheckin = false;
// if the working copy has a discussion the user will also need to have
// contributor permission on the locked node
if (node.hasAspect(ContentModel.ASPECT_WORKING_COPY))
{
if (node.hasAspect(ForumModel.ASPECT_DISCUSSABLE))
{
// get the original locked node (via the copiedfrom aspect)
NodeRef lockedNodeRef = (NodeRef)nodeService.getProperty(node.getNodeRef(), ContentModel.PROP_COPY_REFERENCE);
if (lockedNodeRef != null)
{
Node lockedNode = new Node(lockedNodeRef);
canCheckin = node.hasPermission(PermissionService.CHECK_IN) &&
lockedNode.hasPermission(PermissionService.CONTRIBUTOR);
}
}
else
{
// there is no discussion so just check they have checkin permission
// for the node
canCheckin = node.hasPermission(PermissionService.CHECK_IN);
}
}
return canCheckin;
}
};
public NodePropertyResolver resolverBeingDiscussed = new NodePropertyResolver() {
public Object get(Node node) {
return node.hasAspect(ForumModel.ASPECT_DISCUSSABLE);
}
};
public NodePropertyResolver resolverReplies = new NodePropertyResolver() {
public Object get(Node node)
{
@@ -942,7 +884,6 @@ public class ForumsBean implements IContextListener, NodeEventListener
// get the content property from the node and retrieve the
// full content as a string (obviously should only be used
// for small amounts of content)
ContentReader reader = contentService.getReader(node.getNodeRef(),
ContentModel.PROP_CONTENT);
@@ -960,7 +901,6 @@ public class ForumsBean implements IContextListener, NodeEventListener
{
// determine if this node is a reply to another post, if so find
// the creator of the original poster
String replyTo = null;
List<AssociationRef> assocs = nodeService.getTargetAssocs(node.getNodeRef(),