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

@@ -10,6 +10,7 @@
<value>classpath:alfresco/web-client-config-properties.xml</value> <value>classpath:alfresco/web-client-config-properties.xml</value>
<value>classpath:alfresco/web-client-config-navigation.xml</value> <value>classpath:alfresco/web-client-config-navigation.xml</value>
<value>classpath:alfresco/web-client-config-actions.xml</value> <value>classpath:alfresco/web-client-config-actions.xml</value>
<value>classpath:alfresco/web-client-config-forum-actions.xml</value>
<value>classpath:alfresco/extension/web-client-config-custom.xml</value> <value>classpath:alfresco/extension/web-client-config-custom.xml</value>
</list> </list>
</constructor-arg> </constructor-arg>

View File

@@ -80,8 +80,6 @@
<target>cifs</target> <target>cifs</target>
</action> </action>
<!-- TODO: need an overridden version of this actions in the Forums actions XML
as the checkin evaluator has additional logic needed for Forums -->
<!-- Checkin document --> <!-- Checkin document -->
<action id="checkin_doc"> <action id="checkin_doc">
<evaluator>org.alfresco.web.action.evaluator.CheckinDocEvaluator</evaluator> <evaluator>org.alfresco.web.action.evaluator.CheckinDocEvaluator</evaluator>
@@ -118,33 +116,6 @@
</params> </params>
</action> </action>
<!-- TODO: move to Forums actions XML - override the document/space_browse groups? -->
<!-- Discuss document or space e.g. jump to Forums view for this node -->
<action id="discuss_node">
<evaluator>org.alfresco.web.action.evaluator.DiscussNodeEvaluator</evaluator>
<label-id>discuss</label-id>
<image>/images/icons/forum-16.gif</image>
<action-listener>#{ForumsBean.discuss}</action-listener>
<params>
<param name="id">#{actionContext.id}</param>
</params>
</action>
<!-- TODO: move to Forums actions XML - override the document/space_browse groups? -->
<!-- Discuss document or space e.g. jump to Forums view for this node -->
<action id="create_forum_node">
<permissions>
<permission allow="true">CreateChildren</permission>
</permissions>
<evaluator>org.alfresco.web.action.evaluator.CreateForumNodeEvaluator</evaluator>
<label-id>start_discussion</label-id>
<image>/images/icons/create_forum.gif</image>
<action-listener>#{CreateDiscussionDialog.startWizard}</action-listener>
<params>
<param name="id">#{actionContext.id}</param>
</params>
</action>
<!-- View document details --> <!-- View document details -->
<action id="details_doc"> <action id="details_doc">
<label-id>view_details</label-id> <label-id>view_details</label-id>
@@ -459,7 +430,6 @@
<!-- the component is responsible for making the context Node object available with name <!-- the component is responsible for making the context Node object available with name
of 'actionContext' so the actions can access it directly to get properties --> of 'actionContext' so the actions can access it directly to get properties -->
<!-- TODO: add overriden doc browse actions for forum module? -->
<!-- Actions for a document in the Browse screen --> <!-- Actions for a document in the Browse screen -->
<action-group id="document_browse"> <action-group id="document_browse">
<show-link>false</show-link> <show-link>false</show-link>
@@ -470,11 +440,10 @@
<action idref="edit_doc_cifs" /> <action idref="edit_doc_cifs" />
<action idref="checkout_doc" /> <action idref="checkout_doc" />
<action idref="checkin_doc" /> <action idref="checkin_doc" />
<action idref="discuss_node" />
<action idref="details_doc" /> <action idref="details_doc" />
<action idref="preview_doc" /> <action idref="preview_doc" />
<!-- Example action defined inline rather than by reference <!-- Example action defined in-line rather than by reference
<action id="example2_checkout_doc"> <action id="example2_checkout_doc">
<permissions> <permissions>
<permission allow="true">CheckOut</permission> <permission allow="true">CheckOut</permission>
@@ -497,7 +466,6 @@
<action idref="reject_doc" /> <action idref="reject_doc" />
<action idref="cut_node" /> <action idref="cut_node" />
<action idref="copy_node" /> <action idref="copy_node" />
<action idref="create_forum_node" />
</action-group> </action-group>
<!-- Actions for a space in the Browse screen --> <!-- Actions for a space in the Browse screen -->
@@ -506,7 +474,6 @@
<style-class>inlineAction</style-class> <style-class>inlineAction</style-class>
<action idref="preview_space" /> <action idref="preview_space" />
<action idref="discuss_node" />
<action idref="cut_node" /> <action idref="cut_node" />
<action idref="copy_node" /> <action idref="copy_node" />
<action idref="details_space" /> <action idref="details_space" />
@@ -515,7 +482,6 @@
<!-- Actions Menu for a space in the Browse screen --> <!-- Actions Menu for a space in the Browse screen -->
<action-group id="space_browse_menu"> <action-group id="space_browse_menu">
<action idref="delete_space" /> <action idref="delete_space" />
<action idref="create_forum_node" />
</action-group> </action-group>
<!-- Actions Menu for Create in Browse screen --> <!-- Actions Menu for Create in Browse screen -->
@@ -556,8 +522,6 @@
<action idref="take_ownership_doc" /> <action idref="take_ownership_doc" />
<action idref="manage_content_users" /> <action idref="manage_content_users" />
<action idref="create_shortcut" /> <action idref="create_shortcut" />
<action idref="discuss_node" />
<action idref="create_forum_node" />
<action idref="preview_doc" /> <action idref="preview_doc" />
<action idref="run_action" /> <action idref="run_action" />
</action-group> </action-group>
@@ -572,8 +536,6 @@
<action idref="create_shortcut" /> <action idref="create_shortcut" />
<action idref="take_ownership_space" /> <action idref="take_ownership_space" />
<action idref="manage_space_rules" /> <action idref="manage_space_rules" />
<action idref="discuss_node" />
<action idref="create_forum_node" />
<action idref="preview_space" /> <action idref="preview_space" />
</action-group> </action-group>

View File

@@ -0,0 +1,142 @@
<alfresco-config>
<config evaluator="string-compare" condition="Actions">
<actions>
<!-- Forums overrides the checkin document action - as it has more complex evaluation
logic which takes into account any child forums attached to a node. -->
<!-- Checkin document -->
<action id="checkin_doc">
<evaluator>org.alfresco.web.action.evaluator.ForumsCheckinDocEvaluator</evaluator>
<label-id>checkin</label-id>
<image>/images/icons/CheckIn_icon.gif</image>
<action-listener>#{CheckinCheckoutBean.setupContentAction}</action-listener>
<action>checkinFile</action>
<params>
<param name="id">#{actionContext.id}</param>
</params>
</action>
<!-- Discuss document or space e.g. jump to Forums view for this node -->
<action id="discuss_node">
<evaluator>org.alfresco.web.action.evaluator.DiscussNodeEvaluator</evaluator>
<label-id>discuss</label-id>
<image>/images/icons/forum-16.gif</image>
<action-listener>#{ForumsBean.discuss}</action-listener>
<params>
<param name="id">#{actionContext.id}</param>
</params>
</action>
<!-- Discuss document or space e.g. jump to Forums view for this node -->
<action id="create_forum_node">
<permissions>
<permission allow="true">CreateChildren</permission>
</permissions>
<evaluator>org.alfresco.web.action.evaluator.CreateForumNodeEvaluator</evaluator>
<label-id>start_discussion</label-id>
<image>/images/icons/create_forum.gif</image>
<action-listener>#{CreateDiscussionDialog.startWizard}</action-listener>
<params>
<param name="id">#{actionContext.id}</param>
</params>
</action>
<!-- the 'actions' elements define unique blocks of actions that reference the actions
as defined above and can override or supply display elements for the group of actions -->
<!-- the component is responsible for making the context Node object available with name
of 'actionContext' so the actions can access it directly to get properties -->
<!-- Override browse actions and doc/space details screen actions for the Forums module -->
<!-- Actions for a document in the Browse screen -->
<action-group id="document_browse">
<show-link>false</show-link>
<style-class>inlineAction</style-class>
<action idref="edit_doc_http" />
<action idref="edit_doc_webdav" />
<action idref="edit_doc_cifs" />
<action idref="checkout_doc" />
<action idref="checkin_doc" />
<action idref="discuss_node" />
<action idref="details_doc" />
<action idref="preview_doc" />
</action-group>
<!-- Actions Menu for a document in the Browse screen -->
<action-group id="document_browse_menu">
<action idref="delete_doc" />
<action idref="update_doc" />
<action idref="cancelcheckout_doc" />
<action idref="approve_doc" />
<action idref="reject_doc" />
<action idref="cut_node" />
<action idref="copy_node" />
<action idref="create_forum_node" />
</action-group>
<!-- Actions for a space in the Browse screen -->
<action-group id="space_browse">
<show-link>false</show-link>
<style-class>inlineAction</style-class>
<action idref="preview_space" />
<action idref="discuss_node" />
<action idref="cut_node" />
<action idref="copy_node" />
<action idref="details_space" />
</action-group>
<!-- Actions Menu for a space in the Browse screen -->
<action-group id="space_browse_menu">
<action idref="delete_space" />
<action idref="create_forum_node" />
</action-group>
<!-- Actions Menu for Document Details screen -->
<action-group id="doc_details_actions">
<action idref="checkout_doc" />
<action idref="checkin_doc" />
<action idref="cancelcheckout_doc" />
<action idref="approve_doc_details" />
<action idref="reject_doc_details" />
<action idref="edit_doc_http" />
<!-- TODO: add these once the appropriate props (webdavUrl and cifsPath) are added
to the node bean as resolvers (probably need to change valuebindings also)
<action idref="edit_doc_webdav" />
<action idref="edit_doc_cifs" />
-->
<action idref="update_doc" />
<action idref="cut_node" />
<action idref="copy_node" />
<action idref="delete_doc" />
<action idref="take_ownership_doc" />
<action idref="manage_content_users" />
<action idref="create_shortcut" />
<action idref="discuss_node" />
<action idref="create_forum_node" />
<action idref="preview_doc" />
<action idref="run_action" />
</action-group>
<!-- Actions Menu for Space Details screen -->
<action-group id="space_details_actions">
<action idref="cut_node" />
<action idref="copy_node" />
<action idref="delete_space" />
<action idref="import_space" />
<action idref="export_space" />
<action idref="create_shortcut" />
<action idref="take_ownership_space" />
<action idref="manage_space_rules" />
<action idref="discuss_node" />
<action idref="create_forum_node" />
<action idref="preview_space" />
</action-group>
</actions>
</config>
</alfresco-config>

View File

@@ -116,9 +116,10 @@
<config evaluator="string-compare" condition="Node Event Listeners"> <config evaluator="string-compare" condition="Node Event Listeners">
<!-- Managed beans that wish to be notified of Node events from the BrowseBean --> <!-- Managed beans that wish to be notified of Node events from the BrowseBean -->
<!-- Example - bean must implement org.alfresco.web.bean.NodeEventListener
<node-event-listeners> <node-event-listeners>
<listener>ForumsBean</listener> <listener>ForumsBean</listener>
</node-event-listeners> </node-event-listeners> -->
</config> </config>
<config evaluator="string-compare" condition="Advanced Search"> <config evaluator="string-compare" condition="Advanced Search">

View File

@@ -0,0 +1,72 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.model.ForumModel;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.web.action.ActionEvaluator;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
/**
* UI Action Evaluator - Checkin a document with potentially a Forum attached.
*
* @author Kevin Roast
*/
public final class ForumsCheckinDocEvaluator implements ActionEvaluator
{
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
boolean allow = false;
if (node.hasAspect(ContentModel.ASPECT_WORKING_COPY))
{
if (node.hasAspect(ForumModel.ASPECT_DISCUSSABLE))
{
NodeService nodeService =
Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getNodeService();
// 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);
allow = (node.hasPermission(PermissionService.CHECK_IN) &&
lockedNode.hasPermission(PermissionService.CONTRIBUTOR));
}
}
else
{
// there is no discussion so just check they have checkin permission for the node
allow = node.hasPermission(PermissionService.CHECK_IN);
}
}
return allow;
}
}
/*
<a:booleanEvaluator value="#{r.checkIn == true}">
*/

View File

@@ -412,7 +412,8 @@ public class BrowseBean implements IContextListener
* Setup the common properties required at data-binding time. * Setup the common properties required at data-binding time.
* <p> * <p>
* These are properties used by components on the page when iterating over the nodes. * 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> * <p>
* We use a set of anonymous inner classes to provide the implemention for the property * 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. * 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) public void setupCommonBindingProperties(Node node)
{ {
// special properties to be used by the value binding components on the page // 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("url", this.resolverUrl);
node.addPropertyResolver("fileType16", this.resolverFileType16); node.addPropertyResolver("fileType16", this.resolverFileType16);
node.addPropertyResolver("fileType32", this.resolverFileType32); node.addPropertyResolver("fileType32", this.resolverFileType32);
node.addPropertyResolver("size", this.resolverSize); node.addPropertyResolver("size", this.resolverSize);
node.addPropertyResolver("cancelCheckOut", this.resolverCancelCheckOut);
node.addPropertyResolver("checkIn", this.resolverCheckIn);
node.addPropertyResolver("editLinkType", this.resolverEditLinkType); node.addPropertyResolver("editLinkType", this.resolverEditLinkType);
node.addPropertyResolver("webdavUrl", this.resolverWebdavUrl); node.addPropertyResolver("webdavUrl", this.resolverWebdavUrl);
node.addPropertyResolver("cifsPath", this.resolverCifsPath); node.addPropertyResolver("cifsPath", this.resolverCifsPath);
@@ -775,36 +771,36 @@ public class BrowseBean implements IContextListener
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Property Resolvers // Property Resolvers
public NodePropertyResolver resolverlocked = new NodePropertyResolver() { /*public NodePropertyResolver resolverlocked = new NodePropertyResolver() {
public Object get(Node node) { public Object get(Node node) {
return node.isLocked(); return node.isLocked();
} }
}; };*/
public NodePropertyResolver resolverOwner = new NodePropertyResolver() { /*public NodePropertyResolver resolverOwner = new NodePropertyResolver() {
public Object get(Node node) { public Object get(Node node) {
return getDocument().isWorkingCopyOwner(); return getDocument().isWorkingCopyOwner();
} }
}; };*/
public NodePropertyResolver resolverCancelCheckOut = new NodePropertyResolver() { /*public NodePropertyResolver resolverCancelCheckOut = new NodePropertyResolver() {
public Object get(Node node) { public Object get(Node node) {
return node.hasAspect(ContentModel.ASPECT_WORKING_COPY) && node.hasPermission(PermissionService.CANCEL_CHECK_OUT); 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) { public Object get(Node node) {
return node.hasAspect(ContentModel.ASPECT_WORKING_COPY) && node.hasPermission(PermissionService.CHECK_IN); 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) { public Object get(Node node) {
return node.hasAspect(ContentModel.ASPECT_WORKING_COPY); return node.hasAspect(ContentModel.ASPECT_WORKING_COPY);
} }
};
};*/
public NodePropertyResolver resolverDownload = new NodePropertyResolver() { public NodePropertyResolver resolverDownload = new NodePropertyResolver() {
public Object get(Node node) { public Object get(Node node) {
return DownloadContentServlet.generateDownloadURL(node.getNodeRef(), node.getName()); return DownloadContentServlet.generateDownloadURL(node.getNodeRef(), node.getName());
@@ -1152,8 +1148,6 @@ public class BrowseBean implements IContextListener
node.addPropertyResolver("fileType32", this.resolverFileType32); node.addPropertyResolver("fileType32", this.resolverFileType32);
node.addPropertyResolver("mimetype", this.resolverMimetype); node.addPropertyResolver("mimetype", this.resolverMimetype);
node.addPropertyResolver("size", this.resolverSize); node.addPropertyResolver("size", this.resolverSize);
node.addPropertyResolver("cancelCheckOut", this.resolverCancelCheckOut);
node.addPropertyResolver("checkIn", this.resolverCheckIn);
for (NodeEventListener listener : getNodeEventListeners()) 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.repository.NodeService;
import org.alfresco.service.cmr.search.QueryParameterDefinition; import org.alfresco.service.cmr.search.QueryParameterDefinition;
import org.alfresco.service.cmr.search.SearchService; 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.NamespaceService;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern; import org.alfresco.service.namespace.RegexQNamePattern;
@@ -74,7 +73,7 @@ import org.apache.commons.logging.LogFactory;
* *
* @author gavinc * @author gavinc
*/ */
public class ForumsBean implements IContextListener, NodeEventListener public class ForumsBean implements IContextListener
{ {
private static Log logger = LogFactory.getLog(ForumsBean.class); private static Log logger = LogFactory.getLog(ForumsBean.class);
private static final String PAGE_NAME_FORUMS = "forums"; 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 // Navigation action event handlers
@@ -872,44 +852,6 @@ public class ForumsBean implements IContextListener, NodeEventListener
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Property Resolvers // 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 NodePropertyResolver resolverReplies = new NodePropertyResolver() {
public Object get(Node node) 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 // get the content property from the node and retrieve the
// full content as a string (obviously should only be used // full content as a string (obviously should only be used
// for small amounts of content) // for small amounts of content)
ContentReader reader = contentService.getReader(node.getNodeRef(), ContentReader reader = contentService.getReader(node.getNodeRef(),
ContentModel.PROP_CONTENT); 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 // determine if this node is a reply to another post, if so find
// the creator of the original poster // the creator of the original poster
String replyTo = null; String replyTo = null;
List<AssociationRef> assocs = nodeService.getTargetAssocs(node.getNodeRef(), List<AssociationRef> assocs = nodeService.getTargetAssocs(node.getNodeRef(),

View File

@@ -20,8 +20,10 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import org.alfresco.config.ConfigElement; import org.alfresco.config.ConfigElement;
import org.alfresco.config.ConfigException; import org.alfresco.config.ConfigException;
@@ -78,11 +80,6 @@ public class ActionsConfigElement extends ConfigElementAdapter
combinedElement.actionGroups.putAll(this.actionGroups); combinedElement.actionGroups.putAll(this.actionGroups);
combinedElement.actionGroups.putAll(existingElement.actionGroups); combinedElement.actionGroups.putAll(existingElement.actionGroups);
//
// TODO: do we need to check all groups here and update ActionDefinition references incase they
// have changed? e.g. if an actiondef ID is overriden, a group using it will not know!
//
return combinedElement; return combinedElement;
} }
@@ -170,7 +167,7 @@ public class ActionsConfigElement extends ConfigElementAdapter
return params; return params;
} }
private String id; String id;
private List<String> permissionAllow = null; private List<String> permissionAllow = null;
private List<String> permissionDeny = null; private List<String> permissionDeny = null;
private Map<String, String> params = null; private Map<String, String> params = null;
@@ -197,7 +194,7 @@ public class ActionsConfigElement extends ConfigElementAdapter
* *
* @author Kevin Roast * @author Kevin Roast
*/ */
public static class ActionGroup implements Iterable<ActionDefinition> public static class ActionGroup implements Iterable<String>
{ {
public ActionGroup(String id) public ActionGroup(String id)
{ {
@@ -213,24 +210,24 @@ public class ActionsConfigElement extends ConfigElementAdapter
return id; return id;
} }
public void addAction(ActionDefinition actionDef) public void addAction(String actionId)
{ {
actions.put(actionDef.getId(), actionDef); actions.add(actionId);
} }
/** /**
* @return Iterator to the ActionDefinition objects referenced by this group * @return Iterator over the ActionDefinition IDs referenced by this group
*/ */
public Iterator<ActionDefinition> iterator() public Iterator<String> iterator()
{ {
return actions.values().iterator(); return actions.iterator();
} }
private String id; private String id;
/** the action definitions, we use a linked hashmap to ensure we do not have more /** the action definitions, we use a Linked HashSet to ensure we do not have more
than one action with the same Id and that the insertion order is preserved */ than one action with the same Id and that the insertion order is preserved */
private Map<String, ActionDefinition> actions = new LinkedHashMap(8, 1.0f); private Set<String> actions = new LinkedHashSet<String>(16, 1.0f);
public boolean ShowLink; public boolean ShowLink;
public String Style; public String Style;

View File

@@ -107,30 +107,24 @@ public class ActionsElementReader implements ConfigElementReader
Element actionRefElement = actionRefItr.next(); Element actionRefElement = actionRefItr.next();
// look for an action referred to be Id - this is the common use-case // look for an action referred to be Id - this is the common use-case
ActionDefinition def = null;
String idRef = actionRefElement.attributeValue(ATTRIBUTE_IDREF); String idRef = actionRefElement.attributeValue(ATTRIBUTE_IDREF);
if (idRef != null && idRef.length() != 0) if (idRef == null || idRef.length() == 0)
{
// try to find the referenced action by Id
def = configElement.getActionDefinition(idRef);
if (def == null)
{
throw new ConfigException("Action group '" + groupId +
"' cannot find action definition referenced by '" + idRef + "'");
}
}
else
{ {
// look for an action defined directly rather than referenced by Id // look for an action defined directly rather than referenced by Id
String id = actionRefElement.attributeValue(ATTRIBUTE_ID); String id = actionRefElement.attributeValue(ATTRIBUTE_ID);
if (id != null && id.length() != 0) if (id != null && id.length() != 0)
{ {
def = parseActionDefinition(actionRefElement); ActionDefinition def = parseActionDefinition(actionRefElement);
// override action definition ID based on the group name to avoid conflicts
def.id = actionGroup.getId() + '_' + def.getId();
configElement.addActionDefinition(def);
actionGroup.addAction(def.getId());
} }
} }
if (def != null) else
{ {
actionGroup.addAction(def); // add the action definition ID to the group
actionGroup.addAction(idRef);
} }
} }

View File

@@ -30,6 +30,7 @@ import javax.faces.context.ResponseWriter;
import javax.faces.el.ValueBinding; import javax.faces.el.ValueBinding;
import org.alfresco.config.Config; import org.alfresco.config.Config;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.web.app.Application; import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Node; import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.config.ActionsConfigElement; import org.alfresco.web.config.ActionsConfigElement;
@@ -149,7 +150,7 @@ public class UIActions extends SelfRenderingComponent
// render the action group component tree // render the action group component tree
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("-constructing ActionGroup: " + groupId); logger.debug("-constructing ActionGroup: " + groupId);
buildActionGroup(context, actionGroup); buildActionGroup(context, actionConfig, actionGroup);
} }
else else
{ {
@@ -221,7 +222,7 @@ public class UIActions extends SelfRenderingComponent
* @param context * @param context
* @param actionGroup * @param actionGroup
*/ */
private void buildActionGroup(FacesContext context, ActionGroup actionGroup) private void buildActionGroup(FacesContext context, ActionsConfigElement config, ActionGroup actionGroup)
throws IOException throws IOException
{ {
javax.faces.application.Application facesApp = context.getApplication(); javax.faces.application.Application facesApp = context.getApplication();
@@ -238,10 +239,16 @@ public class UIActions extends SelfRenderingComponent
} }
// process each ActionDefinition in the order they were defined // process each ActionDefinition in the order they were defined
for (ActionDefinition actionDef : actionGroup) for (String actionId : actionGroup)
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("---processing ActionDefinition: " + actionDef.getId()); logger.debug("---processing ActionDefinition: " + actionId);
ActionDefinition actionDef = config.getActionDefinition(actionId);
if (actionDef == null)
{
throw new AlfrescoRuntimeException("Unable to find configured ActionDefinition Id: " + actionId);
}
UIComponent currentParent = this; UIComponent currentParent = this;
@@ -433,7 +440,7 @@ public class UIActions extends SelfRenderingComponent
} }
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("-----adding UIActionLink component for: " + actionDef.getId()); logger.debug("-----adding UIActionLink component for: " + actionId);
currentParent.getChildren().add(control); currentParent.getChildren().add(control);
} }
} }