05-26-2011 05:43 AM
FacesContext context = FacesContext.getCurrentInstance();
Config config = Application.getConfigService(context).getConfig(node);
ActionsConfigElement actionConfig = (ActionsConfigElement)config.getConfigElement(ActionsConfigElement.CONFIG_ELEMENT_ID);
ActionGroup actionGroup = actionConfig.getActionGroup("template");
05-26-2011 06:23 AM
05-26-2011 08:07 AM
05-26-2011 08:12 AM
05-26-2011 08:54 AM
protected List<Map<String, String>> buildActionGroup(FacesContext context, ActionsConfigElement config, ActionGroup actionGroup, Node node) throws UnsupportedEncodingException {
javax.faces.application.Application facesApp = context.getApplication();
ResourceBundle messages = Application.getBundle(context);
List<Map<String, String>> actions = new ArrayList<Map<String, String>>();
for (String actionId : actionGroup)
{
if (logger.isDebugEnabled())
logger.debug("—processing ActionDefinition: " + actionId);
ActionDefinition actionDef = config.getActionDefinition(actionId);
if (actionDef == null)
{
throw new AlfrescoRuntimeException("Unable to find configured ActionDefinition Id: " + actionId);
}
// build a permissions evaluator component to wrap the actionlink
PermissionEvaluator permEval = null;
List<String> allow = actionDef.getAllowPermissions();
if (allow != null && allow.size() != 0)
{
// found some permissions to test
permEval = (PermissionEvaluator)facesApp.createComponent(UIActions.COMPONENT_PERMISSIONEVAL);
String condition = allow.get(0);
if (allow.size() != 1)
{
for (int i=1; i<allow.size(); i++)
{
condition += "," + allow.get(i);
}
}
permEval.setAllow(condition);
}
List<String> deny = actionDef.getDenyPermissions();
if (deny != null && deny.size() != 0)
{
if (permEval == null)
{
permEval = (PermissionEvaluator)facesApp.createComponent(UIActions.COMPONENT_PERMISSIONEVAL);
}
String condition = deny.get(0);
if (deny.size() != 1)
{
for (int i=1; i<deny.size(); i++)
{
condition += "," + deny.get(i);
}
}
permEval.setDeny(condition);
}
// Evaluate permissions
if (permEval != null) {
// Set context node
permEval.setValue(node);
if (! permEval.evaluate()) {
// Skip this action
continue;
}
}
// now prepare any code based evaluators that may be present
if (actionDef.Evaluator != null)
{
ActionInstanceEvaluator evaluator = (ActionInstanceEvaluator)facesApp.createComponent(UIActions.COMPONENT_ACTIONEVAL);
evaluator.setEvaluator(actionDef.Evaluator);
// Set context node
evaluator.setValue(node);
if (! evaluator.evaluate()) {
// Skip this action
continue;
}
}
Map<String, String> action = new HashMap<String, String>();
// Build href
StringBuilder scriptHref = new StringBuilder(100);
scriptHref.append("/command/script/execute");
if (actionDef.Script.charAt(0) == '/') {
// found a Path - encode it as a URL argument
scriptHref.append("?scriptPath=");
scriptHref.append(Utils.replace(URLEncoder.encode(actionDef.Script, "UTF-8"), "+", "%20"));
}
action.put("href", scriptHref.toString());
action.put("target", actionDef.Target);
action.put("image", actionDef.Image);
if (actionDef.TooltipMsg != null) {
action.put("tooltip", Application.getMessage(context, actionDef.TooltipMsg));
} else if (actionDef.Tooltip != null) {
action.put("tooltip", actionDef.Tooltip);
}
if (actionDef.LabelMsg != null) {
action.put("label", Application.getMessage(context, actionDef.LabelMsg));
} else if (actionDef.Label != null) {
action.put("label", actionDef.Label);
}
actions.add(action);
}
return actions;
}
To create an action group we must have a FacesContext. What is the bestPractice to create an action group with a webscript ?05-30-2011 05:45 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.