use of org.springframework.extensions.config.ConfigElement in project alfresco-remote-api by Alfresco.
the class OpenSearchElementReader method parse.
/**
* @see org.springframework.extensions.config.xml.elementreader.ConfigElementReader#parse(org.dom4j.Element)
*/
@SuppressWarnings("unchecked")
public ConfigElement parse(Element element) {
OpenSearchConfigElement configElement = null;
if (element != null) {
String elementName = element.getName();
if (elementName.equals(ELEMENT_OPENSEARCH) == false) {
throw new ConfigException("OpenSearchElementReader can only parse " + ELEMENT_OPENSEARCH + "elements, the element passed was '" + elementName + "'");
}
// go through the registered engines
configElement = new OpenSearchConfigElement();
Element pluginsElem = element.element(ELEMENT_ENGINES);
if (pluginsElem != null) {
Iterator<Element> engines = pluginsElem.elementIterator(ELEMENT_ENGINE);
while (engines.hasNext()) {
// construct engine
Element engineElem = engines.next();
String label = engineElem.attributeValue(ATTR_LABEL);
String labelId = engineElem.attributeValue(ATTR_LABEL_ID);
String proxy = engineElem.attributeValue(ATTR_PROXY);
EngineConfig engineCfg = new EngineConfig(label, labelId, proxy);
// construct urls for engine
Iterator<Element> urlsConfig = engineElem.elementIterator(ELEMENT_URL);
while (urlsConfig.hasNext()) {
Element urlConfig = urlsConfig.next();
String type = urlConfig.attributeValue(ATTR_TYPE);
String url = urlConfig.getTextTrim();
engineCfg.addUrl(type, url);
}
// register engine config
configElement.addEngine(engineCfg);
}
}
// extract proxy configuration
String url = null;
Element proxyElem = element.element(ELEMENT_PROXY);
if (proxyElem != null) {
Element urlElem = proxyElem.element(ELEMENT_URL);
if (urlElem != null) {
url = urlElem.getTextTrim();
ProxyConfig proxyCfg = new ProxyConfig(url);
configElement.setProxy(proxyCfg);
}
}
}
return configElement;
}
use of org.springframework.extensions.config.ConfigElement 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.ConfigElement 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.ConfigElement in project acs-community-packaging by Alfresco.
the class BaseActionWizard method readAspectsConfig.
protected List<SelectItem> readAspectsConfig(FacesContext context, ConfigElement aspectsCfg) {
List<SelectItem> aspects = new ArrayList<SelectItem>();
for (ConfigElement child : aspectsCfg.getChildren()) {
QName idQName = Repository.resolveToQName(child.getAttribute("name"));
if (idQName != null) {
// try and get the display label from config
String label = Utils.getDisplayLabel(context, child);
// if there wasn't a client based label try and get it from the dictionary
if (label == null) {
AspectDefinition aspectDef = this.getDictionaryService().getAspect(idQName);
if (aspectDef != null) {
label = aspectDef.getTitle(this.getDictionaryService());
} else {
label = idQName.getLocalName();
}
}
aspects.add(new SelectItem(idQName.toString(), label));
} else {
logger.warn("Failed to resolve aspect '" + child.getAttribute("name") + "'");
}
}
return aspects;
}
use of org.springframework.extensions.config.ConfigElement in project acs-community-packaging by Alfresco.
the class CreateRuleWizard method initialiseConditionHandlers.
/**
* Initialises the condition handlers from the current configuration.
*/
protected void initialiseConditionHandlers() {
if ((this.conditionHandlers == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());
Config wizardCfg = svc.getConfig("Action Wizards");
if (wizardCfg != null) {
ConfigElement conditionHandlerCfg = wizardCfg.getConfigElement("condition-handlers");
if (conditionHandlerCfg != null) {
this.conditionHandlers = new HashMap<String, IHandler>(20);
// instantiate each handler and store in the map
for (ConfigElement child : conditionHandlerCfg.getChildren()) {
String conditionName = child.getAttribute("name");
String handlerClass = child.getAttribute("class");
if (conditionName != null && conditionName.length() > 0 && handlerClass != null && handlerClass.length() > 0) {
try {
@SuppressWarnings("unchecked") Class klass = Class.forName(handlerClass);
IHandler handler = (IHandler) klass.newInstance();
this.conditionHandlers.put(conditionName, handler);
} catch (Exception e) {
throw new AlfrescoRuntimeException("Failed to setup condition handler for '" + conditionName + "'", e);
}
}
}
} else {
logger.warn("Could not find 'condition-handlers' configuration element");
}
} else {
logger.warn("Could not find 'Action Wizards' configuration section");
}
}
}
Aggregations