mirror of
https://github.com/Alfresco/SearchServices.git
synced 2025-09-17 14:21:20 +00:00
Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)
77082: Merged PLATFORM1 (5.0/Cloud) to HEAD-BUG-FIX (5.0/Cloud) 72904: ACE-1677: SOLR 4 - Track model changes, persist somewhere, update Alfresco model in SOLR - Added some implementation of SolrInformationServer. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@77931 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,6 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package org.alfresco.solr.adapters;
|
package org.alfresco.solr.adapters;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The reason we have this interface is so that lucene-free dependent classes can be dependent on ISimpleOrderedMap instead of the
|
||||||
|
* lucene-version-specific SimpleOrderedMap.
|
||||||
|
* @author Ahmed Owian
|
||||||
|
*/
|
||||||
public interface ISimpleOrderedMap<T>
|
public interface ISimpleOrderedMap<T>
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.alfresco.solr.client;
|
package org.alfresco.solr.client;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -32,7 +33,8 @@ import org.alfresco.repo.dictionary.NamespaceDAO;
|
|||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This factory encapsulates the creation of a SOLRAPIClient and the management of that resource.
|
* This factory encapsulates the creation of a SOLRAPIClient and the management of that resource.
|
||||||
|
*
|
||||||
* @author Ahmed Owian
|
* @author Ahmed Owian
|
||||||
*/
|
*/
|
||||||
public class SOLRAPIClientFactory
|
public class SOLRAPIClientFactory
|
||||||
@@ -41,14 +43,14 @@ public class SOLRAPIClientFactory
|
|||||||
* Pool of cached client resources keyed on alfresco instances
|
* Pool of cached client resources keyed on alfresco instances
|
||||||
*/
|
*/
|
||||||
private static Map<String, SOLRAPIClient> clientsPerAlfresco = new HashMap<>();
|
private static Map<String, SOLRAPIClient> clientsPerAlfresco = new HashMap<>();
|
||||||
|
|
||||||
// encryption related parameters
|
// encryption related parameters
|
||||||
private String secureCommsType; // "none", "https"
|
private String secureCommsType; // "none", "https"
|
||||||
private String keyStoreType;
|
private String keyStoreType;
|
||||||
private String keyStoreProvider;
|
private String keyStoreProvider;
|
||||||
private String passwordFileLocation;
|
private String passwordFileLocation;
|
||||||
private String keyStoreLocation;
|
private String keyStoreLocation;
|
||||||
|
|
||||||
// ssl
|
// ssl
|
||||||
private String sslKeyStoreType;
|
private String sslKeyStoreType;
|
||||||
private String sslKeyStoreProvider;
|
private String sslKeyStoreProvider;
|
||||||
@@ -62,14 +64,15 @@ public class SOLRAPIClientFactory
|
|||||||
private int alfrescoPort;
|
private int alfrescoPort;
|
||||||
private int alfrescoPortSSL;
|
private int alfrescoPortSSL;
|
||||||
private String baseUrl;
|
private String baseUrl;
|
||||||
|
|
||||||
// http client
|
// http client
|
||||||
private int maxTotalConnections = 40;
|
private int maxTotalConnections = 40;
|
||||||
private int maxHostConnections = 40;
|
private int maxHostConnections = 40;
|
||||||
private int socketTimeout = 120000;
|
private int socketTimeout = 120000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the client resource from the pool.
|
* Gets the client resource from the pool.
|
||||||
|
*
|
||||||
* @param alfrescoHost
|
* @param alfrescoHost
|
||||||
* @param alfrescoPort
|
* @param alfrescoPort
|
||||||
* @param alfrescoPortSSL
|
* @param alfrescoPortSSL
|
||||||
@@ -83,6 +86,7 @@ public class SOLRAPIClientFactory
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a key to identify a unique alfresco instance to which the client will connect.
|
* Constructs a key to identify a unique alfresco instance to which the client will connect.
|
||||||
|
*
|
||||||
* @param alfrescoHost
|
* @param alfrescoHost
|
||||||
* @param alfrescoPort
|
* @param alfrescoPort
|
||||||
* @param alfrescoPortSSL
|
* @param alfrescoPortSSL
|
||||||
@@ -92,9 +96,10 @@ public class SOLRAPIClientFactory
|
|||||||
{
|
{
|
||||||
return alfrescoHost + alfrescoPort + alfrescoPortSSL;
|
return alfrescoHost + alfrescoPort + alfrescoPortSSL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the client in the resource pool.
|
* Sets the client in the resource pool.
|
||||||
|
*
|
||||||
* @param alfrescoHost
|
* @param alfrescoHost
|
||||||
* @param alfrescoPort
|
* @param alfrescoPort
|
||||||
* @param alfrescoPortSSL
|
* @param alfrescoPortSSL
|
||||||
@@ -105,21 +110,23 @@ public class SOLRAPIClientFactory
|
|||||||
String key = constructKey(alfrescoHost, alfrescoPort, alfrescoPortSSL);
|
String key = constructKey(alfrescoHost, alfrescoPort, alfrescoPortSSL);
|
||||||
clientsPerAlfresco.put(key, client);
|
clientsPerAlfresco.put(key, client);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the SOLRAPIClient or gets it from a pool
|
* Creates the SOLRAPIClient or gets it from a pool
|
||||||
|
*
|
||||||
* @param props solrcore.properties in the <coreName>/conf directory
|
* @param props solrcore.properties in the <coreName>/conf directory
|
||||||
* @param keyResourceLoader reads encryption key resources
|
* @param keyResourceLoader reads encryption key resources
|
||||||
* @param dictionaryService represents the Repository Data Dictionary
|
* @param dictionaryService represents the Repository Data Dictionary
|
||||||
* @param namespaceDAO allows retrieving and creating Namespace definitions
|
* @param namespaceDAO allows retrieving and creating Namespace definitions
|
||||||
* @return an instance of SOLRAPIClient
|
* @return an instance of SOLRAPIClient
|
||||||
*/
|
*/
|
||||||
public SOLRAPIClient getSOLRAPIClient(Properties props, KeyResourceLoader keyResourceLoader, DictionaryService dictionaryService, NamespaceDAO namespaceDAO)
|
public SOLRAPIClient getSOLRAPIClient(Properties props, KeyResourceLoader keyResourceLoader,
|
||||||
|
DictionaryService dictionaryService, NamespaceDAO namespaceDAO)
|
||||||
{
|
{
|
||||||
alfrescoHost = props.getProperty("alfresco.host", "localhost");
|
alfrescoHost = props.getProperty("alfresco.host", "localhost");
|
||||||
alfrescoPort = Integer.parseInt(props.getProperty("alfresco.port", "8080"));
|
alfrescoPort = Integer.parseInt(props.getProperty("alfresco.port", "8080"));
|
||||||
alfrescoPortSSL = Integer.parseInt(props.getProperty("alfresco.port.ssl", "8443"));
|
alfrescoPortSSL = Integer.parseInt(props.getProperty("alfresco.port.ssl", "8443"));
|
||||||
|
|
||||||
SOLRAPIClient client = getCachedClient(alfrescoHost, alfrescoPort, alfrescoPortSSL);
|
SOLRAPIClient client = getCachedClient(alfrescoHost, alfrescoPort, alfrescoPortSSL);
|
||||||
if (client == null)
|
if (client == null)
|
||||||
{
|
{
|
||||||
@@ -130,35 +137,43 @@ public class SOLRAPIClientFactory
|
|||||||
keyStoreLocation = props.getProperty("alfresco.encryption.keystore.location");
|
keyStoreLocation = props.getProperty("alfresco.encryption.keystore.location");
|
||||||
sslKeyStoreType = props.getProperty("alfresco.encryption.ssl.keystore.type");
|
sslKeyStoreType = props.getProperty("alfresco.encryption.ssl.keystore.type");
|
||||||
sslKeyStoreProvider = props.getProperty("alfresco.encryption.ssl.keystore.provider", "");
|
sslKeyStoreProvider = props.getProperty("alfresco.encryption.ssl.keystore.provider", "");
|
||||||
sslKeyStoreLocation = props.getProperty("alfresco.encryption.ssl.keystore.location", "ssl.repo.client.keystore");
|
sslKeyStoreLocation = props.getProperty("alfresco.encryption.ssl.keystore.location",
|
||||||
sslKeyStorePasswordFileLocation = props.getProperty("alfresco.encryption.ssl.keystore.passwordFileLocation", "ssl-keystore-passwords.properties");
|
"ssl.repo.client.keystore");
|
||||||
|
sslKeyStorePasswordFileLocation = props.getProperty(
|
||||||
|
"alfresco.encryption.ssl.keystore.passwordFileLocation", "ssl-keystore-passwords.properties");
|
||||||
sslTrustStoreType = props.getProperty("alfresco.encryption.ssl.truststore.type", "JCEKS");
|
sslTrustStoreType = props.getProperty("alfresco.encryption.ssl.truststore.type", "JCEKS");
|
||||||
sslTrustStoreProvider = props.getProperty("alfresco.encryption.ssl.truststore.provider", "");
|
sslTrustStoreProvider = props.getProperty("alfresco.encryption.ssl.truststore.provider", "");
|
||||||
sslTrustStoreLocation = props.getProperty("alfresco.encryption.ssl.truststore.location", "ssl.repo.client.truststore");
|
sslTrustStoreLocation = props.getProperty("alfresco.encryption.ssl.truststore.location",
|
||||||
sslTrustStorePasswordFileLocation = props.getProperty("alfresco.encryption.ssl.truststore.passwordFileLocation", "ssl-truststore-passwords.properties");
|
"ssl.repo.client.truststore");
|
||||||
|
sslTrustStorePasswordFileLocation = props.getProperty(
|
||||||
|
"alfresco.encryption.ssl.truststore.passwordFileLocation",
|
||||||
|
"ssl-truststore-passwords.properties");
|
||||||
secureCommsType = props.getProperty("alfresco.secureComms", "https");
|
secureCommsType = props.getProperty("alfresco.secureComms", "https");
|
||||||
maxTotalConnections = Integer.parseInt(props.getProperty("alfresco.maxTotalConnections", "40"));
|
maxTotalConnections = Integer.parseInt(props.getProperty("alfresco.maxTotalConnections", "40"));
|
||||||
maxHostConnections = Integer.parseInt(props.getProperty("alfresco.maxHostConnections", "40"));
|
maxHostConnections = Integer.parseInt(props.getProperty("alfresco.maxHostConnections", "40"));
|
||||||
socketTimeout = Integer.parseInt(props.getProperty("alfresco.socketTimeout", "0"));
|
socketTimeout = Integer.parseInt(props.getProperty("alfresco.socketTimeout", "0"));
|
||||||
|
|
||||||
client = new SOLRAPIClient(getRepoClient(keyResourceLoader), dictionaryService, namespaceDAO);
|
client = new SOLRAPIClient(getRepoClient(keyResourceLoader), dictionaryService, namespaceDAO);
|
||||||
setCachedClient(alfrescoHost, alfrescoPort, alfrescoPortSSL, client);
|
setCachedClient(alfrescoHost, alfrescoPort, alfrescoPortSSL, client);
|
||||||
}
|
}
|
||||||
|
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AlfrescoHttpClient getRepoClient(KeyResourceLoader keyResourceLoader)
|
protected AlfrescoHttpClient getRepoClient(KeyResourceLoader keyResourceLoader)
|
||||||
{
|
{
|
||||||
// TODO i18n
|
// TODO i18n
|
||||||
KeyStoreParameters keyStoreParameters = new KeyStoreParameters("SSL Key Store", sslKeyStoreType, sslKeyStoreProvider, sslKeyStorePasswordFileLocation, sslKeyStoreLocation);
|
KeyStoreParameters keyStoreParameters = new KeyStoreParameters("SSL Key Store", sslKeyStoreType,
|
||||||
KeyStoreParameters trustStoreParameters = new KeyStoreParameters("SSL Trust Store", sslTrustStoreType, sslTrustStoreProvider, sslTrustStorePasswordFileLocation, sslTrustStoreLocation);
|
sslKeyStoreProvider, sslKeyStorePasswordFileLocation, sslKeyStoreLocation);
|
||||||
SSLEncryptionParameters sslEncryptionParameters = new SSLEncryptionParameters(keyStoreParameters, trustStoreParameters);
|
KeyStoreParameters trustStoreParameters = new KeyStoreParameters("SSL Trust Store", sslTrustStoreType,
|
||||||
|
sslTrustStoreProvider, sslTrustStorePasswordFileLocation, sslTrustStoreLocation);
|
||||||
|
SSLEncryptionParameters sslEncryptionParameters = new SSLEncryptionParameters(keyStoreParameters,
|
||||||
|
trustStoreParameters);
|
||||||
|
|
||||||
HttpClientFactory httpClientFactory = new HttpClientFactory(SecureCommsType.getType(secureCommsType),
|
HttpClientFactory httpClientFactory = new HttpClientFactory(SecureCommsType.getType(secureCommsType),
|
||||||
sslEncryptionParameters, keyResourceLoader, null, null, alfrescoHost, alfrescoPort, alfrescoPortSSL, maxTotalConnections, maxHostConnections, socketTimeout);
|
sslEncryptionParameters, keyResourceLoader, null, null, alfrescoHost, alfrescoPort,
|
||||||
// TODO need to make port configurable depending on secure comms, or just make redirects
|
alfrescoPortSSL, maxTotalConnections, maxHostConnections, socketTimeout);
|
||||||
// work
|
// TODO need to make port configurable depending on secure comms, or just make redirects work
|
||||||
AlfrescoHttpClient repoClient = httpClientFactory.getRepoClient(alfrescoHost, alfrescoPortSSL);
|
AlfrescoHttpClient repoClient = httpClientFactory.getRepoClient(alfrescoHost, alfrescoPortSSL);
|
||||||
repoClient.setBaseUrl(baseUrl);
|
repoClient.setBaseUrl(baseUrl);
|
||||||
return repoClient;
|
return repoClient;
|
||||||
|
Reference in New Issue
Block a user