mirror of
https://github.com/Alfresco/SearchServices.git
synced 2025-09-10 14:11:25 +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;
|
||||
|
||||
|
||||
/**
|
||||
* 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>
|
||||
{
|
||||
|
||||
|
@@ -16,6 +16,7 @@
|
||||
* 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.client;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -32,7 +33,8 @@ import org.alfresco.repo.dictionary.NamespaceDAO;
|
||||
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
|
||||
*/
|
||||
public class SOLRAPIClientFactory
|
||||
@@ -41,14 +43,14 @@ public class SOLRAPIClientFactory
|
||||
* Pool of cached client resources keyed on alfresco instances
|
||||
*/
|
||||
private static Map<String, SOLRAPIClient> clientsPerAlfresco = new HashMap<>();
|
||||
|
||||
|
||||
// encryption related parameters
|
||||
private String secureCommsType; // "none", "https"
|
||||
private String keyStoreType;
|
||||
private String keyStoreProvider;
|
||||
private String passwordFileLocation;
|
||||
private String keyStoreLocation;
|
||||
|
||||
|
||||
// ssl
|
||||
private String sslKeyStoreType;
|
||||
private String sslKeyStoreProvider;
|
||||
@@ -62,14 +64,15 @@ public class SOLRAPIClientFactory
|
||||
private int alfrescoPort;
|
||||
private int alfrescoPortSSL;
|
||||
private String baseUrl;
|
||||
|
||||
|
||||
// http client
|
||||
private int maxTotalConnections = 40;
|
||||
private int maxHostConnections = 40;
|
||||
private int socketTimeout = 120000;
|
||||
|
||||
|
||||
/**
|
||||
* Gets the client resource from the pool.
|
||||
*
|
||||
* @param alfrescoHost
|
||||
* @param alfrescoPort
|
||||
* @param alfrescoPortSSL
|
||||
@@ -83,6 +86,7 @@ public class SOLRAPIClientFactory
|
||||
|
||||
/**
|
||||
* Constructs a key to identify a unique alfresco instance to which the client will connect.
|
||||
*
|
||||
* @param alfrescoHost
|
||||
* @param alfrescoPort
|
||||
* @param alfrescoPortSSL
|
||||
@@ -92,9 +96,10 @@ public class SOLRAPIClientFactory
|
||||
{
|
||||
return alfrescoHost + alfrescoPort + alfrescoPortSSL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the client in the resource pool.
|
||||
*
|
||||
* @param alfrescoHost
|
||||
* @param alfrescoPort
|
||||
* @param alfrescoPortSSL
|
||||
@@ -105,21 +110,23 @@ public class SOLRAPIClientFactory
|
||||
String key = constructKey(alfrescoHost, alfrescoPort, alfrescoPortSSL);
|
||||
clientsPerAlfresco.put(key, client);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates the SOLRAPIClient or gets it from a pool
|
||||
*
|
||||
* @param props solrcore.properties in the <coreName>/conf directory
|
||||
* @param keyResourceLoader reads encryption key resources
|
||||
* @param dictionaryService represents the Repository Data Dictionary
|
||||
* @param namespaceDAO allows retrieving and creating Namespace definitions
|
||||
* @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");
|
||||
alfrescoPort = Integer.parseInt(props.getProperty("alfresco.port", "8080"));
|
||||
alfrescoPortSSL = Integer.parseInt(props.getProperty("alfresco.port.ssl", "8443"));
|
||||
|
||||
|
||||
SOLRAPIClient client = getCachedClient(alfrescoHost, alfrescoPort, alfrescoPortSSL);
|
||||
if (client == null)
|
||||
{
|
||||
@@ -130,35 +137,43 @@ public class SOLRAPIClientFactory
|
||||
keyStoreLocation = props.getProperty("alfresco.encryption.keystore.location");
|
||||
sslKeyStoreType = props.getProperty("alfresco.encryption.ssl.keystore.type");
|
||||
sslKeyStoreProvider = props.getProperty("alfresco.encryption.ssl.keystore.provider", "");
|
||||
sslKeyStoreLocation = props.getProperty("alfresco.encryption.ssl.keystore.location", "ssl.repo.client.keystore");
|
||||
sslKeyStorePasswordFileLocation = props.getProperty("alfresco.encryption.ssl.keystore.passwordFileLocation", "ssl-keystore-passwords.properties");
|
||||
sslKeyStoreLocation = props.getProperty("alfresco.encryption.ssl.keystore.location",
|
||||
"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");
|
||||
sslTrustStoreProvider = props.getProperty("alfresco.encryption.ssl.truststore.provider", "");
|
||||
sslTrustStoreLocation = props.getProperty("alfresco.encryption.ssl.truststore.location", "ssl.repo.client.truststore");
|
||||
sslTrustStorePasswordFileLocation = props.getProperty("alfresco.encryption.ssl.truststore.passwordFileLocation", "ssl-truststore-passwords.properties");
|
||||
sslTrustStoreLocation = props.getProperty("alfresco.encryption.ssl.truststore.location",
|
||||
"ssl.repo.client.truststore");
|
||||
sslTrustStorePasswordFileLocation = props.getProperty(
|
||||
"alfresco.encryption.ssl.truststore.passwordFileLocation",
|
||||
"ssl-truststore-passwords.properties");
|
||||
secureCommsType = props.getProperty("alfresco.secureComms", "https");
|
||||
maxTotalConnections = Integer.parseInt(props.getProperty("alfresco.maxTotalConnections", "40"));
|
||||
maxHostConnections = Integer.parseInt(props.getProperty("alfresco.maxHostConnections", "40"));
|
||||
socketTimeout = Integer.parseInt(props.getProperty("alfresco.socketTimeout", "0"));
|
||||
|
||||
|
||||
client = new SOLRAPIClient(getRepoClient(keyResourceLoader), dictionaryService, namespaceDAO);
|
||||
setCachedClient(alfrescoHost, alfrescoPort, alfrescoPortSSL, client);
|
||||
}
|
||||
|
||||
return client;
|
||||
|
||||
return client;
|
||||
}
|
||||
|
||||
|
||||
protected AlfrescoHttpClient getRepoClient(KeyResourceLoader keyResourceLoader)
|
||||
{
|
||||
// TODO i18n
|
||||
KeyStoreParameters keyStoreParameters = new KeyStoreParameters("SSL Key Store", sslKeyStoreType, sslKeyStoreProvider, sslKeyStorePasswordFileLocation, sslKeyStoreLocation);
|
||||
KeyStoreParameters trustStoreParameters = new KeyStoreParameters("SSL Trust Store", sslTrustStoreType, sslTrustStoreProvider, sslTrustStorePasswordFileLocation, sslTrustStoreLocation);
|
||||
SSLEncryptionParameters sslEncryptionParameters = new SSLEncryptionParameters(keyStoreParameters, trustStoreParameters);
|
||||
|
||||
KeyStoreParameters keyStoreParameters = new KeyStoreParameters("SSL Key Store", sslKeyStoreType,
|
||||
sslKeyStoreProvider, sslKeyStorePasswordFileLocation, sslKeyStoreLocation);
|
||||
KeyStoreParameters trustStoreParameters = new KeyStoreParameters("SSL Trust Store", sslTrustStoreType,
|
||||
sslTrustStoreProvider, sslTrustStorePasswordFileLocation, sslTrustStoreLocation);
|
||||
SSLEncryptionParameters sslEncryptionParameters = new SSLEncryptionParameters(keyStoreParameters,
|
||||
trustStoreParameters);
|
||||
|
||||
HttpClientFactory httpClientFactory = new HttpClientFactory(SecureCommsType.getType(secureCommsType),
|
||||
sslEncryptionParameters, keyResourceLoader, null, null, alfrescoHost, alfrescoPort, alfrescoPortSSL, maxTotalConnections, maxHostConnections, socketTimeout);
|
||||
// TODO need to make port configurable depending on secure comms, or just make redirects
|
||||
// work
|
||||
sslEncryptionParameters, keyResourceLoader, null, null, alfrescoHost, alfrescoPort,
|
||||
alfrescoPortSSL, maxTotalConnections, maxHostConnections, socketTimeout);
|
||||
// TODO need to make port configurable depending on secure comms, or just make redirects work
|
||||
AlfrescoHttpClient repoClient = httpClientFactory.getRepoClient(alfrescoHost, alfrescoPortSSL);
|
||||
repoClient.setBaseUrl(baseUrl);
|
||||
return repoClient;
|
||||
|
Reference in New Issue
Block a user