use of org.alfresco.repo.web.scripts.config.OpenSearchConfigElement.ProxyConfig 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.alfresco.repo.web.scripts.config.OpenSearchConfigElement.ProxyConfig in project alfresco-remote-api by Alfresco.
the class SearchProxy method afterPropertiesSet.
/* (non-Javadoc)
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
*/
public void afterPropertiesSet() throws Exception {
Config config = configService.getConfig("OpenSearch");
searchConfig = (OpenSearchConfigElement) config.getConfigElement(OpenSearchConfigElement.CONFIG_ELEMENT_ID);
if (searchConfig == null) {
throw new WebScriptException("OpenSearch configuration not found");
}
ProxyConfig proxyConfig = searchConfig.getProxy();
if (proxyConfig == null) {
throw new WebScriptException("OpenSearch proxy configuration not found");
}
proxyPath = proxyConfig.getUrl();
}
Aggregations