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;
}
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;
}
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;
}
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");
}
}
}
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);
}
Aggregations