Search in sources :

Example 1 with Config

use of org.springframework.extensions.config.Config in project alfresco-remote-api by Alfresco.

the class SearchEngines method getUrls.

/**
 * Retrieve registered search engines
 *
 * @return  set of search engines
 */
private Set<UrlTemplate> getUrls(String urlType) {
    if (logger.isDebugEnabled())
        logger.debug("Search Engine parameters: urltype=" + urlType);
    Set<UrlTemplate> urls = new HashSet<UrlTemplate>();
    Config config = configService.getConfig("OpenSearch");
    OpenSearchConfigElement searchConfig = (OpenSearchConfigElement) config.getConfigElement(OpenSearchConfigElement.CONFIG_ELEMENT_ID);
    for (OpenSearchConfigElement.EngineConfig engineConfig : searchConfig.getEngines()) {
        Map<String, String> engineUrls = engineConfig.getUrls();
        for (Map.Entry<String, String> engineUrl : engineUrls.entrySet()) {
            String type = engineUrl.getKey();
            String url = searchProxy.createUrl(engineConfig, type);
            if ((urlType.equals(URL_ARG_ALL)) || (urlType.equals(URL_ARG_DESCRIPTION) && type.equals(MimetypeMap.MIMETYPE_OPENSEARCH_DESCRIPTION)) || (urlType.equals(URL_ARG_TEMPLATE) && !type.equals(MimetypeMap.MIMETYPE_OPENSEARCH_DESCRIPTION))) {
                String label = engineConfig.getLabel();
                String labelId = engineConfig.getLabelId();
                if (labelId != null && labelId.length() > 0) {
                    String i18nLabel = I18NUtil.getMessage(labelId);
                    if (i18nLabel == null && label == null) {
                        label = (i18nLabel == null) ? "$$" + labelId + "$$" : i18nLabel;
                    }
                }
                urls.add(new UrlTemplate(label, type, url));
            } else // TODO: Extract URL templates from OpenSearch description
            if (urlType.equals(URL_ARG_TEMPLATE) && type.equals(MimetypeMap.MIMETYPE_OPENSEARCH_DESCRIPTION)) {
            }
        }
    }
    if (logger.isDebugEnabled())
        logger.debug("Retrieved " + urls.size() + " engine registrations");
    return urls;
}
Also used : Config(org.springframework.extensions.config.Config) OpenSearchConfigElement(org.alfresco.repo.web.scripts.config.OpenSearchConfigElement) MimetypeMap(org.alfresco.repo.content.MimetypeMap) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 2 with Config

use of org.springframework.extensions.config.Config in project acs-community-packaging by Alfresco.

the class SidebarBean method getSidebarConfig.

// ------------------------------------------------------------------------------
// Helper methods
/**
 * Returns the SidebarConfigElement for the application
 *
 * @param context Faces context
 * @return The SidebarConfigElement object or null if it's not found
 */
public static SidebarConfigElement getSidebarConfig(FacesContext context) {
    SidebarConfigElement config = null;
    Config cfg = Application.getConfigService(context).getConfig("Sidebar");
    if (cfg != null) {
        config = (SidebarConfigElement) cfg.getConfigElement(SidebarConfigElement.CONFIG_ELEMENT_ID);
    }
    return config;
}
Also used : SidebarPluginConfig(org.alfresco.web.config.SidebarConfigElement.SidebarPluginConfig) Config(org.springframework.extensions.config.Config) SidebarConfigElement(org.alfresco.web.config.SidebarConfigElement)

Example 3 with Config

use of org.springframework.extensions.config.Config in project acs-community-packaging by Alfresco.

the class BaseActionWizard method getTestableAspects.

/**
 * Returns a list of aspects that can be tested i.e. hasAspect
 *
 * @return List of SelectItem objects representing the aspects that can be tested for
 */
public List<SelectItem> getTestableAspects() {
    if ((this.testableAspects == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
        // get the list of common aspects
        this.testableAspects = new ArrayList<SelectItem>();
        this.testableAspects.addAll(getCommonAspects());
        // get those aspects configured to appear only in the remove aspect action
        ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());
        Config wizardCfg = svc.getConfig("Action Wizards");
        if (wizardCfg != null) {
            ConfigElement aspectsCfg = wizardCfg.getConfigElement("aspects-test");
            if (aspectsCfg != null) {
                List<SelectItem> aspects = readAspectsConfig(FacesContext.getCurrentInstance(), aspectsCfg);
                this.testableAspects.addAll(aspects);
            } else {
                logger.warn("Could not find 'aspects-test' configuration element");
            }
        } else {
            logger.warn("Could not find 'Action Wizards' configuration section");
        }
        // make sure the list is sorted by the label
        QuickSort sorter = new QuickSort(this.testableAspects, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
        sorter.sort();
    }
    return this.testableAspects;
}
Also used : QuickSort(org.alfresco.web.data.QuickSort) ConfigService(org.springframework.extensions.config.ConfigService) ConfigElement(org.springframework.extensions.config.ConfigElement) SelectItem(javax.faces.model.SelectItem) Config(org.springframework.extensions.config.Config)

Example 4 with Config

use of org.springframework.extensions.config.Config in project acs-community-packaging by Alfresco.

the class BaseActionWizard method initialiseActionHandlers.

/**
 * Initialises the action handlers from the current configuration.
 */
protected void initialiseActionHandlers() {
    if ((this.actionHandlers == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
        ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());
        Config wizardCfg = svc.getConfig("Action Wizards");
        if (wizardCfg != null) {
            ConfigElement actionHandlerCfg = wizardCfg.getConfigElement("action-handlers");
            if (actionHandlerCfg != null) {
                this.actionHandlers = new HashMap<String, IHandler>(20);
                // instantiate each handler and store in the map
                for (ConfigElement child : actionHandlerCfg.getChildren()) {
                    String actionName = child.getAttribute("name");
                    String handlerClass = child.getAttribute("class");
                    if (actionName != null && actionName.length() > 0 && handlerClass != null && handlerClass.length() > 0) {
                        try {
                            @SuppressWarnings("unchecked") Class klass = Class.forName(handlerClass);
                            IHandler handler = (IHandler) klass.newInstance();
                            this.actionHandlers.put(actionName, handler);
                        } catch (Exception e) {
                            throw new AlfrescoRuntimeException("Failed to setup action handler for '" + actionName + "'", e);
                        }
                    }
                }
            } else {
                logger.warn("Could not find 'action-handlers' configuration element");
            }
        } else {
            logger.warn("Could not find 'Action Wizards' configuration section");
        }
    }
}
Also used : ConfigService(org.springframework.extensions.config.ConfigService) ConfigElement(org.springframework.extensions.config.ConfigElement) Config(org.springframework.extensions.config.Config) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException)

Example 5 with Config

use of org.springframework.extensions.config.Config in project acs-community-packaging by Alfresco.

the class UIPropertySheet method encodeBegin.

/**
 * @see javax.faces.component.UIComponent#encodeBegin(javax.faces.context.FacesContext)
 */
@SuppressWarnings("unchecked")
public void encodeBegin(FacesContext context) throws IOException {
    int howManyChildren = getChildren().size();
    Boolean externalConfig = (Boolean) getAttributes().get("externalConfig");
    // generate a variable name to use if necessary
    if (this.variable == null) {
        this.variable = DEFAULT_VAR_NAME;
    }
    // force retrieval of node info
    Node node = getNode();
    if (howManyChildren == 0) {
        if (externalConfig != null && externalConfig.booleanValue()) {
            // configure the component using the config service
            if (logger.isDebugEnabled())
                logger.debug("Configuring property sheet using ConfigService");
            // get the properties to display
            ConfigService configSvc = Application.getConfigService(FacesContext.getCurrentInstance());
            Config configProps = null;
            if (getConfigArea() == null) {
                configProps = configSvc.getConfig(node);
            } else {
                // only look within the given area
                configProps = configSvc.getConfig(node, new ConfigLookupContext(getConfigArea()));
            }
            PropertySheetConfigElement itemsToDisplay = (PropertySheetConfigElement) configProps.getConfigElement("property-sheet");
            if (itemsToDisplay != null) {
                Collection<ItemConfig> itemsToRender = null;
                if (this.getMode().equalsIgnoreCase(EDIT_MODE)) {
                    itemsToRender = itemsToDisplay.getEditableItemsToShow().values();
                    if (logger.isDebugEnabled())
                        logger.debug("Items to render: " + itemsToDisplay.getEditableItemNamesToShow());
                } else {
                    itemsToRender = itemsToDisplay.getItemsToShow().values();
                    if (logger.isDebugEnabled())
                        logger.debug("Items to render: " + itemsToDisplay.getItemNamesToShow());
                }
                createComponentsFromConfig(context, itemsToRender);
            } else {
                if (logger.isDebugEnabled())
                    logger.debug("There are no items to render!");
            }
        } else {
            // show all the properties for the current node
            if (logger.isDebugEnabled())
                logger.debug("Configuring property sheet using node's current state");
            createComponentsFromNode(context, node);
        }
    }
    // put the node in the session if it is not there already
    Map sessionMap = getFacesContext().getExternalContext().getSessionMap();
    sessionMap.put(this.variable, node);
    if (logger.isDebugEnabled())
        logger.debug("Put node into session with key '" + this.variable + "': " + node);
    super.encodeBegin(context);
}
Also used : ItemConfig(org.alfresco.web.config.PropertySheetConfigElement.ItemConfig) ConfigLookupContext(org.springframework.extensions.config.ConfigLookupContext) ConfigService(org.springframework.extensions.config.ConfigService) PropertySheetConfigElement(org.alfresco.web.config.PropertySheetConfigElement) PropertyConfig(org.alfresco.web.config.PropertySheetConfigElement.PropertyConfig) SeparatorConfig(org.alfresco.web.config.PropertySheetConfigElement.SeparatorConfig) AssociationConfig(org.alfresco.web.config.PropertySheetConfigElement.AssociationConfig) ChildAssociationConfig(org.alfresco.web.config.PropertySheetConfigElement.ChildAssociationConfig) ItemConfig(org.alfresco.web.config.PropertySheetConfigElement.ItemConfig) Config(org.springframework.extensions.config.Config) Node(org.alfresco.web.bean.repository.Node) Map(java.util.Map)

Aggregations

Config (org.springframework.extensions.config.Config)38 ConfigService (org.springframework.extensions.config.ConfigService)28 ConfigElement (org.springframework.extensions.config.ConfigElement)21 SelectItem (javax.faces.model.SelectItem)11 FacesContext (javax.faces.context.FacesContext)10 QuickSort (org.alfresco.web.data.QuickSort)9 Map (java.util.Map)5 QName (org.alfresco.service.namespace.QName)5 DialogConfig (org.alfresco.web.config.DialogsConfigElement.DialogConfig)5 WizardConfig (org.alfresco.web.config.WizardsConfigElement.WizardConfig)5 TypeDefinition (org.alfresco.service.cmr.dictionary.TypeDefinition)4 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)3 LanguagesConfigElement (org.alfresco.web.config.LanguagesConfigElement)3 UIListItem (org.alfresco.web.ui.common.component.UIListItem)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 UIComponent (javax.faces.component.UIComponent)2 MimetypeMap (org.alfresco.repo.content.MimetypeMap)2 OpenSearchConfigElement (org.alfresco.repo.web.scripts.config.OpenSearchConfigElement)2