mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V2.0 to HEAD
svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V2.0@5118 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V2.0@5119 . - OpenSearch Proxy svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V2.0@5121 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V2.0@5122 . - Extract sample OpenSearch engine registrations into extension config file. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5125 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -37,8 +37,10 @@ public class OpenSearchConfigElement extends ConfigElementAdapter
|
||||
{
|
||||
public static final String CONFIG_ELEMENT_ID = "opensearch";
|
||||
|
||||
private ProxyConfig proxy;
|
||||
private Set<EngineConfig> engines = new HashSet<EngineConfig>(8, 10f);
|
||||
|
||||
private Map<String, EngineConfig> enginesByProxy = new HashMap<String, EngineConfig>();
|
||||
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
@@ -85,10 +87,37 @@ public class OpenSearchConfigElement extends ConfigElementAdapter
|
||||
{
|
||||
combinedElement.addEngine(plugin);
|
||||
}
|
||||
|
||||
// set the proxy configuration
|
||||
ProxyConfig proxyConfig = this.getProxy();
|
||||
if (proxyConfig != null)
|
||||
{
|
||||
combinedElement.setProxy(proxyConfig);
|
||||
}
|
||||
|
||||
return combinedElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the proxy configuration
|
||||
*
|
||||
* @param proxyConfig
|
||||
*/
|
||||
/*package*/ void setProxy(ProxyConfig proxyConfig)
|
||||
{
|
||||
this.proxy = proxyConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the proxy configuration
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ProxyConfig getProxy()
|
||||
{
|
||||
return this.proxy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns a set of the engines
|
||||
*/
|
||||
@@ -96,6 +125,15 @@ public class OpenSearchConfigElement extends ConfigElementAdapter
|
||||
{
|
||||
return this.engines;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param proxy name of engine proxy
|
||||
* @return associated engine config (or null, if none registered against proxy)
|
||||
*/
|
||||
public EngineConfig getEngine(String proxy)
|
||||
{
|
||||
return this.enginesByProxy.get(proxy);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an engine
|
||||
@@ -105,6 +143,11 @@ public class OpenSearchConfigElement extends ConfigElementAdapter
|
||||
/*package*/ void addEngine(EngineConfig engineConfig)
|
||||
{
|
||||
this.engines.add(engineConfig);
|
||||
String proxy = engineConfig.getProxy();
|
||||
if (proxy != null && proxy.length() > 0)
|
||||
{
|
||||
this.enginesByProxy.put(proxy, engineConfig);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -117,8 +160,10 @@ public class OpenSearchConfigElement extends ConfigElementAdapter
|
||||
{
|
||||
protected String label;
|
||||
protected String labelId;
|
||||
protected String proxy;
|
||||
protected Map<String, String> urls = new HashMap<String, String>(8, 10f);
|
||||
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
@@ -134,7 +179,20 @@ public class OpenSearchConfigElement extends ConfigElementAdapter
|
||||
this.label = label;
|
||||
this.labelId = labelId;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param label
|
||||
* @param labelId
|
||||
* @param proxy
|
||||
*/
|
||||
public EngineConfig(String label, String labelId, String proxy)
|
||||
{
|
||||
this(label, labelId);
|
||||
this.proxy = proxy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return I18N label id
|
||||
*/
|
||||
@@ -151,6 +209,14 @@ public class OpenSearchConfigElement extends ConfigElementAdapter
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return proxy
|
||||
*/
|
||||
public String getProxy()
|
||||
{
|
||||
return proxy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the urls supported by this engine
|
||||
*
|
||||
@@ -171,17 +237,39 @@ public class OpenSearchConfigElement extends ConfigElementAdapter
|
||||
this.urls.put(mimetype, uri);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Inner class representing the configuration of the OpenSearch proxy
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public static class ProxyConfig
|
||||
{
|
||||
protected String url;
|
||||
|
||||
/**
|
||||
* @see java.lang.Object#toString()
|
||||
* Construct
|
||||
*
|
||||
* @param url
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
public ProxyConfig(String url)
|
||||
{
|
||||
StringBuilder buffer = new StringBuilder(super.toString());
|
||||
buffer.append(" {label=").append(this.label);
|
||||
buffer.append(" labelId=").append(this.labelId).append(")");
|
||||
return buffer.toString();
|
||||
}
|
||||
if (url == null || url.length() == 0)
|
||||
{
|
||||
throw new IllegalArgumentException("'url' must be specified");
|
||||
}
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return url
|
||||
*/
|
||||
public String getUrl()
|
||||
{
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user