private UIComponent addUIExtension(UIExtension extension, Map<String, Object> context) throws Exception { UIExtensionManager manager = getApplicationComponent(UIExtensionManager.class); UIComponent component = manager.addUIExtension(extension, context, this); if (component == null) return null; synchronized (component) { if (component instanceof UIAbstractManagerComponent) { // You can access to the given extension and the extension is valid UIAbstractManagerComponent uiAbstractManagerComponent = (UIAbstractManagerComponent) component; uiAbstractManagerComponent.setUIExtensionName(extension.getName()); uiAbstractManagerComponent.setUIExtensionCategory(extension.getCategory()); return component; } else if (component != null) { // You can access to the given extension but the extension is not valid if (LOG.isWarnEnabled()) { LOG.warn( "All the extension '" + extension.getName() + "' of type '" + EXTENSION_TYPE + "' must be associated to a component of type " + UIAbstractManagerComponent.class); } removeChild(component.getClass()); } } return null; }
public String getActionsExtensionList(Node node) throws Exception { StringBuffer actionsList = new StringBuffer(1024); List<UIExtension> uiExtensionList = getUIExtensionList(); UIComponent uiAddedActionManage; try { NodeFinder nodeFinder = getApplicationComponent(NodeFinder.class); nodeFinder.getItem(getAncestorOfType(UIJCRExplorer.class).getSession(), node.getPath()); } catch (PathNotFoundException pne) { return ""; } for (UIExtension uiextension : uiExtensionList) { if (uiextension.getCategory().startsWith(ITEM_CONTEXT_MENU) || ITEM_GROUND_CONTEXT_MENU.equals(uiextension.getCategory())) { uiAddedActionManage = addUIExtension(uiextension, createContext(node)); if (uiAddedActionManage != null) { actionsList.append(uiextension.getName()).append(","); } } } if (actionsList.length() > 0) { return actionsList.substring(0, actionsList.length() - 1); } return actionsList.toString(); }