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; }
templateActionsMenu = "<a title=\"S�lectionneur de Mod�les\" onclick=\"javascript:toggleTemplateActions(event, '"+nodeRef.getId()+"', '"+dbid+"');return false;\">" + "<img src=\"/alfresco/images/icons/more.gif\" style=\"border-width: 0px;\" alt=\"\" title=\"\"/>" + "</a>" + "<br/>" + "<div id=\"template-actions-menu_"+dbid+"\" style=\"position: absolute; right: 15; overflow: visible; display: none; padding-left: 2px; *width:0px\">" + "<table class=\"moreActionsMenu\" cellspacing=\"1\" cellpadding=\"0\" border=\"0\">" + "<tr><td><img src=\"/alfresco/images/icons/ajax_anim.gif\"></td><td> <i>Chargement…</i></td>" + "</table>" + "</div>"; actions += templateActionsMenu;
function toggleTemplateActions(event, id, dbid) { parent.YAHOO.util.Connect.asyncRequest( "GET", '/alfresco/wcservice/****/templateactions?id='+id, { success: displayTemplateActions, failure: parent.handleErrorYahoo, // global error handler argument: { dbid:dbid } }); _toggleMenu(event, "template-actions-menu_"+dbid); }
@Override protected Map<String, Object> executeImpl(WebScriptRequest req, WebScriptStatus status) { Map<String, Object> model = new HashMap<String, Object>(); // Extract parameters String id = req.getParameter("id"); logger.debug("id: "+id); model.put("id", id); // Build node NodeRef nodeRef = new NodeRef(Repository.getStoreRef(), id); Node node = new Node(nodeRef); // Get parent for forwarding after action execution NodeRef parentNodeRef = nodeService.getPrimaryParent(nodeRef).getParentRef(); logger.debug("parentId: "+parentNodeRef.getId()); model.put("parentId", parentNodeRef.getId()); // Read actions config 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"); // Get list of actions List<Map<String, String>> actions; try { actions = buildActionGroup(context, actionConfig, actionGroup, node); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } model.put("actions", actions); return model; } /** * Build action list after evaluation of each of them. * Code inspired by UIActions.buildActionGroup. * * @see UIActions#buildActionGroup * @return List of actions, each action being transfered as a Map<String, String>. * @throws UnsupportedEncodingException */ 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; }