As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
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");
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; }