mirror of
https://github.com/Alfresco/SearchServices.git
synced 2026-09-16 18:12:56 +00:00
Merge branch 'fix/SEARCH_2181_node-by-node-fallback-processing' into 'fix/SEARCH_2175_CascadeTracker'
SEARCH_2181 RepositoryClient Exception Handling on SolrInformationServer See merge request search_discovery/insightengine!454
This commit is contained in:
+30
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2020 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;
|
||||
|
||||
/**
|
||||
* Marker exception thrown for indicating a failure in obtaining / releasing a lock.
|
||||
*/
|
||||
public class AlfrescoLockException extends Exception
|
||||
{
|
||||
AlfrescoLockException(String message)
|
||||
{
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
+76
-20
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Alfresco Software Limited.
|
||||
* Copyright (C) 2020 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -69,6 +69,7 @@ import static org.alfresco.repo.search.adaptor.lucene.QueryConstants.FIELD_TXCOM
|
||||
import static org.alfresco.repo.search.adaptor.lucene.QueryConstants.FIELD_TXID;
|
||||
import static org.alfresco.repo.search.adaptor.lucene.QueryConstants.FIELD_TYPE;
|
||||
import static org.alfresco.repo.search.adaptor.lucene.QueryConstants.FIELD_VERSION;
|
||||
import static org.alfresco.solr.utils.Utils.notNullOrEmpty;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -85,7 +86,6 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@@ -451,7 +451,7 @@ public class SolrInformationServer implements InformationServer
|
||||
this.core = core;
|
||||
this.nativeRequestHandler = core.getRequestHandler(REQUEST_HANDLER_NATIVE);
|
||||
this.cloud = new Cloud();
|
||||
this.repositoryClient = repositoryClient;
|
||||
this.repositoryClient = Objects.requireNonNull(repositoryClient);
|
||||
this.solrContentStore = solrContentStore;
|
||||
|
||||
Properties p = core.getResourceLoader().getCoreProperties();
|
||||
@@ -1502,7 +1502,7 @@ public class SolrInformationServer implements InformationServer
|
||||
NodeMetaDataParameters nmdp = new NodeMetaDataParameters();
|
||||
nmdp.setFromNodeId(node.getId());
|
||||
nmdp.setToNodeId(node.getId());
|
||||
List<NodeMetaData> nodeMetaDatas;
|
||||
Collection<NodeMetaData> nodeMetaDatas;
|
||||
if ((node.getStatus() == SolrApiNodeStatus.DELETED)
|
||||
|| cascadeTrackingEnabled() && ((node.getStatus() == SolrApiNodeStatus.NON_SHARD_DELETED)
|
||||
|| (node.getStatus() == SolrApiNodeStatus.NON_SHARD_UPDATED)))
|
||||
@@ -1513,13 +1513,14 @@ public class SolrInformationServer implements InformationServer
|
||||
}
|
||||
else
|
||||
{
|
||||
nodeMetaDatas = repositoryClient.getNodesMetaData(nmdp, Integer.MAX_VALUE);
|
||||
nmdp.setMaxResults(Integer.MAX_VALUE);
|
||||
nodeMetaDatas = getNodesMetaDataFromRepository(nmdp);
|
||||
}
|
||||
|
||||
NodeMetaData nodeMetaData;
|
||||
if (!nodeMetaDatas.isEmpty())
|
||||
{
|
||||
nodeMetaData = nodeMetaDatas.get(0);
|
||||
nodeMetaData = nodeMetaDatas.iterator().next();
|
||||
if (!(nodeMetaData.getTxnId() > node.getTxnId()))
|
||||
{
|
||||
if (node.getStatus() == SolrApiNodeStatus.DELETED)
|
||||
@@ -1557,15 +1558,15 @@ public class SolrInformationServer implements InformationServer
|
||||
NodeMetaDataParameters nmdp = new NodeMetaDataParameters();
|
||||
nmdp.setFromNodeId(node.getId());
|
||||
nmdp.setToNodeId(node.getId());
|
||||
|
||||
List<NodeMetaData> nodeMetaDatas = repositoryClient.getNodesMetaData(nmdp, Integer.MAX_VALUE);
|
||||
nmdp.setMaxResults(Integer.MAX_VALUE);
|
||||
Collection<NodeMetaData> nodeMetaDatas = getNodesMetaDataFromRepository(nmdp);
|
||||
|
||||
AddUpdateCommand addDocCmd = new AddUpdateCommand(request);
|
||||
addDocCmd.overwrite = overwrite;
|
||||
|
||||
if (!nodeMetaDatas.isEmpty())
|
||||
{
|
||||
NodeMetaData nodeMetaData = nodeMetaDatas.get(0);
|
||||
NodeMetaData nodeMetaData = nodeMetaDatas.iterator().next();
|
||||
if(node.getTxnId() == Long.MAX_VALUE) {
|
||||
//This is a re-index. We need to clear the txnId from the pr
|
||||
this.cleanContentCache.remove(nodeMetaData.getTxnId());
|
||||
@@ -1722,8 +1723,9 @@ public class SolrInformationServer implements InformationServer
|
||||
nmdp.setIncludePaths(true);
|
||||
nmdp.setIncludeProperties(false);
|
||||
nmdp.setIncludeTxnId(true);
|
||||
nmdp.setMaxResults(1);
|
||||
// Gets only one
|
||||
List<NodeMetaData> nodeMetaDatas = repositoryClient.getNodesMetaData(nmdp, 1);
|
||||
Collection<NodeMetaData> nodeMetaDatas = getNodesMetaDataFromRepository(nmdp);
|
||||
allNodeMetaDatas.addAll(nodeMetaDatas);
|
||||
}
|
||||
|
||||
@@ -1808,6 +1810,14 @@ public class SolrInformationServer implements InformationServer
|
||||
processor.processAdd(addDocCmd);
|
||||
}
|
||||
}
|
||||
catch (AlfrescoLockException exception)
|
||||
{
|
||||
LOGGER.error(exception.getMessage());
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
LOGGER.error("Unable to update the text content of node {}. See the stacktrace below for further details.", dbId, exception);
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock(dbId);
|
||||
@@ -1862,7 +1872,8 @@ public class SolrInformationServer implements InformationServer
|
||||
nmdp.setIncludeAspects(false);
|
||||
nmdp.setIncludePaths(false);
|
||||
nmdp.setIncludeParentAssociations(false);
|
||||
nodeMetaDatas.addAll(repositoryClient.getNodesMetaData(nmdp, Integer.MAX_VALUE));
|
||||
nmdp.setMaxResults(Integer.MAX_VALUE);
|
||||
nodeMetaDatas.addAll(getNodesMetaDataFromRepository(nmdp));
|
||||
}
|
||||
|
||||
for (NodeMetaData nodeMetaData : nodeMetaDatas)
|
||||
@@ -1881,6 +1892,14 @@ public class SolrInformationServer implements InformationServer
|
||||
|
||||
solrContentStore.removeDocFromContentStore(nodeMetaData);
|
||||
}
|
||||
catch (AlfrescoLockException exception)
|
||||
{
|
||||
LOGGER.error(exception.getMessage());
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
LOGGER.error("Unable to remove document {} from the content store. See the stacktrace below for further details.", nodeMetaData.getId(), exception);
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock(nodeMetaData.getId());
|
||||
@@ -1907,7 +1926,8 @@ public class SolrInformationServer implements InformationServer
|
||||
nmdp.setIncludeChildAssociations(false);
|
||||
|
||||
// Fetches bulk metadata
|
||||
List<NodeMetaData> nodeMetaDatas = repositoryClient.getNodesMetaData(nmdp, Integer.MAX_VALUE);
|
||||
nmdp.setMaxResults(Integer.MAX_VALUE);
|
||||
Collection<NodeMetaData> nodeMetaDatas = getNodesMetaDataFromRepository(nmdp);
|
||||
|
||||
NEXT_NODE:
|
||||
for (NodeMetaData nodeMetaData : nodeMetaDatas)
|
||||
@@ -1977,6 +1997,14 @@ public class SolrInformationServer implements InformationServer
|
||||
long end = System.nanoTime();
|
||||
this.trackerStats.addNodeTime(end - start);
|
||||
}
|
||||
catch (AlfrescoLockException exception)
|
||||
{
|
||||
LOGGER.error(exception.getMessage());
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
LOGGER.error("Upsert failure on Node {}. See the stacktrace below for further details.", nodeId, exception);
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock(nodeId);
|
||||
@@ -2484,11 +2512,12 @@ public class SolrInformationServer implements InformationServer
|
||||
NodeMetaDataParameters nmdp = new NodeMetaDataParameters();
|
||||
nmdp.setFromNodeId(dbId);
|
||||
nmdp.setToNodeId(dbId);
|
||||
List<NodeMetaData> nodeMetaDatas = repositoryClient.getNodesMetaData(nmdp, Integer.MAX_VALUE);
|
||||
nmdp.setMaxResults(Integer.MAX_VALUE);
|
||||
Collection<NodeMetaData> nodeMetaDatas = getNodesMetaDataFromRepository(nmdp);
|
||||
SolrInputDocument newDoc = null;
|
||||
if (!nodeMetaDatas.isEmpty())
|
||||
{
|
||||
NodeMetaData nodeMetaData = nodeMetaDatas.get(0);
|
||||
NodeMetaData nodeMetaData = nodeMetaDatas.iterator().next();
|
||||
newDoc = createNewDoc(nodeMetaData, DOC_TYPE_NODE);
|
||||
addFieldsToDoc(nodeMetaData, newDoc);
|
||||
boolean isContentIndexedForNode = isContentIndexedForNode(nodeMetaData.getProperties());
|
||||
@@ -3155,10 +3184,10 @@ public class SolrInformationServer implements InformationServer
|
||||
}
|
||||
}
|
||||
|
||||
private void lock(Object id) throws IOException
|
||||
private void lock(Object id) throws AlfrescoLockException
|
||||
{
|
||||
long startTime = System.currentTimeMillis();
|
||||
while(!lockRegistry.add(id))
|
||||
while (!lockRegistry.add(id))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -3169,9 +3198,9 @@ public class SolrInformationServer implements InformationServer
|
||||
// I don't think we are concerned with this exception.
|
||||
}
|
||||
|
||||
if(System.currentTimeMillis() - startTime > 120000)
|
||||
if (System.currentTimeMillis() - startTime > 120000)
|
||||
{
|
||||
throw new IOException("Unable to acquire lock on nodeId " + id + " after " + 120000 + " msecs.");
|
||||
throw new AlfrescoLockException("Unable to acquire lock on nodeId " + id + " after " + 120000 + " msecs.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3375,12 +3404,13 @@ public class SolrInformationServer implements InformationServer
|
||||
nmdp.setIncludeProperties(false);
|
||||
nmdp.setIncludeType(false);
|
||||
nmdp.setIncludeTxnId(true);
|
||||
nmdp.setMaxResults(1);
|
||||
// Gets only one
|
||||
List<NodeMetaData> nodeMetaDatas = repositoryClient.getNodesMetaData(nmdp, 1);
|
||||
Collection<NodeMetaData> nodeMetaDatas = getNodesMetaDataFromRepository(nmdp);
|
||||
|
||||
if (!nodeMetaDatas.isEmpty())
|
||||
{
|
||||
NodeMetaData nodeMetaData = nodeMetaDatas.get(0);
|
||||
NodeMetaData nodeMetaData = nodeMetaDatas.iterator().next();
|
||||
|
||||
// Only cascade update nods we know can not have changed and must be in this shard
|
||||
// Node in the current TX will be explicitly updated in the outer loop
|
||||
@@ -3432,6 +3462,14 @@ public class SolrInformationServer implements InformationServer
|
||||
LOGGER.debug("No child doc found to update {}", childId);
|
||||
}
|
||||
}
|
||||
catch (AlfrescoLockException exception)
|
||||
{
|
||||
LOGGER.error(exception.getMessage());
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
LOGGER.error("Cascade update failure on child document {}. See the stacktrace below for further details.", childId, exception);
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock(nodeId);
|
||||
@@ -3823,4 +3861,22 @@ public class SolrInformationServer implements InformationServer
|
||||
{
|
||||
solrContentStore.flushChangeSet();
|
||||
}
|
||||
|
||||
private Collection<NodeMetaData> getNodesMetaDataFromRepository(NodeMetaDataParameters parameters)
|
||||
{
|
||||
try
|
||||
{
|
||||
return notNullOrEmpty(repositoryClient.getNodesMetaData(parameters));
|
||||
}
|
||||
catch (JSONException exception)
|
||||
{
|
||||
// Nothing to be done here: the exception has been already logged in repositoryClient
|
||||
return Collections.emptyList();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
LOGGER.error("Unable to get nodes metadata from repository. See the stacktrace below for further details.", exception);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
+29
-28
@@ -1,31 +1,32 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Solr Client
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Solr Client
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.solr.client;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.OptionalInt;
|
||||
|
||||
/**
|
||||
* Stores node meta data query parameters for use in SOLR remote api calls
|
||||
@@ -39,7 +40,7 @@ public class NodeMetaDataParameters
|
||||
private Long toTxnId;
|
||||
|
||||
// default is 'all' results
|
||||
private int maxResults = 0;
|
||||
private OptionalInt maxResults = OptionalInt.empty();
|
||||
|
||||
private Long fromNodeId;
|
||||
private Long toNodeId;
|
||||
@@ -147,14 +148,14 @@ public class NodeMetaDataParameters
|
||||
this.includeParentAssociations = includeParentAssociations;
|
||||
}
|
||||
|
||||
public int getMaxResults()
|
||||
public OptionalInt getMaxResults()
|
||||
{
|
||||
return maxResults;
|
||||
}
|
||||
|
||||
public void setMaxResults(int maxResults)
|
||||
{
|
||||
this.maxResults = maxResults;
|
||||
this.maxResults = OptionalInt.of(maxResults);
|
||||
}
|
||||
|
||||
public List<Long> getNodeIds()
|
||||
|
||||
+6
-3
@@ -732,7 +732,7 @@ public class SOLRAPIClient
|
||||
return ret;
|
||||
}
|
||||
|
||||
public List<NodeMetaData> getNodesMetaData(NodeMetaDataParameters params, int maxResults) throws AuthenticationException, IOException, JSONException
|
||||
public List<NodeMetaData> getNodesMetaData(NodeMetaDataParameters params) throws AuthenticationException, IOException, JSONException
|
||||
{
|
||||
List<Long> nodeIds = params.getNodeIds();
|
||||
|
||||
@@ -801,13 +801,16 @@ public class SOLRAPIClient
|
||||
body.put("includeTxnId", params.isIncludeTxnId());
|
||||
}
|
||||
|
||||
body.put("maxResults", maxResults);
|
||||
if (params.getMaxResults().isPresent())
|
||||
{
|
||||
body.put("maxResults", params.getMaxResults());
|
||||
}
|
||||
|
||||
PostRequest req = new PostRequest(url.toString(), body.toString(), "application/json");
|
||||
JSONObject json = callRepository(GET_METADATA_URL, req);
|
||||
|
||||
JSONArray jsonNodes = json.getJSONArray("nodes");
|
||||
List<NodeMetaData> nodes = new ArrayList<NodeMetaData>(jsonNodes.length());
|
||||
List<NodeMetaData> nodes = new ArrayList<>(jsonNodes.length());
|
||||
for(int i = 0; i < jsonNodes.length(); i++)
|
||||
{
|
||||
JSONObject jsonNodeInfo = jsonNodes.getJSONObject(i);
|
||||
|
||||
+116
-108
@@ -1,93 +1,93 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Solr Client
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Solr Client
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.solr.client;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.security.AlgorithmParameters;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.alfresco.encryption.DefaultEncryptionUtils;
|
||||
import org.alfresco.encryption.KeyProvider;
|
||||
import org.alfresco.encryption.KeyResourceLoader;
|
||||
import org.alfresco.encryption.KeyStoreParameters;
|
||||
import org.alfresco.encryption.MACUtils.MACInput;
|
||||
import org.alfresco.encryption.ssl.SSLEncryptionParameters;
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.httpclient.AlfrescoHttpClient;
|
||||
import org.alfresco.httpclient.AuthenticationException;
|
||||
import org.alfresco.httpclient.HttpClientFactory;
|
||||
import org.alfresco.httpclient.HttpClientFactory.SecureCommsType;
|
||||
import org.alfresco.opencmis.dictionary.CMISDictionaryRegistry;
|
||||
import org.alfresco.opencmis.dictionary.CMISStrictDictionaryService;
|
||||
import org.alfresco.opencmis.mapping.CMISMapping;
|
||||
import org.alfresco.opencmis.mapping.RuntimePropertyLuceneBuilderMapping;
|
||||
import org.alfresco.repo.cache.MemoryCache;
|
||||
import org.alfresco.repo.dictionary.CompiledModelsCache;
|
||||
import org.alfresco.repo.dictionary.DictionaryComponent;
|
||||
import org.alfresco.repo.dictionary.DictionaryDAOImpl;
|
||||
import org.alfresco.repo.dictionary.DictionaryNamespaceComponent;
|
||||
import org.alfresco.repo.dictionary.M2Model;
|
||||
import org.alfresco.repo.dictionary.M2Namespace;
|
||||
import org.alfresco.repo.dictionary.NamespaceDAO;
|
||||
import org.alfresco.repo.i18n.StaticMessageLookup;
|
||||
import org.alfresco.repo.tenant.SingleTServiceImpl;
|
||||
import org.alfresco.repo.tenant.TenantService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.DynamicallySizedThreadPoolExecutor;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.alfresco.util.TraceableThreadFactory;
|
||||
import org.alfresco.util.cache.DefaultAsynchronouslyRefreshedCacheRegistry;
|
||||
import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
|
||||
import org.apache.commons.httpclient.HttpMethod;
|
||||
import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
|
||||
import org.apache.commons.httpclient.methods.PostMethod;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.json.JSONException;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.security.AlgorithmParameters;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.alfresco.encryption.DefaultEncryptionUtils;
|
||||
import org.alfresco.encryption.KeyProvider;
|
||||
import org.alfresco.encryption.KeyResourceLoader;
|
||||
import org.alfresco.encryption.KeyStoreParameters;
|
||||
import org.alfresco.encryption.MACUtils.MACInput;
|
||||
import org.alfresco.encryption.ssl.SSLEncryptionParameters;
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.httpclient.AlfrescoHttpClient;
|
||||
import org.alfresco.httpclient.AuthenticationException;
|
||||
import org.alfresco.httpclient.HttpClientFactory;
|
||||
import org.alfresco.httpclient.HttpClientFactory.SecureCommsType;
|
||||
import org.alfresco.opencmis.dictionary.CMISDictionaryRegistry;
|
||||
import org.alfresco.opencmis.dictionary.CMISStrictDictionaryService;
|
||||
import org.alfresco.opencmis.mapping.CMISMapping;
|
||||
import org.alfresco.opencmis.mapping.RuntimePropertyLuceneBuilderMapping;
|
||||
import org.alfresco.repo.cache.MemoryCache;
|
||||
import org.alfresco.repo.dictionary.CompiledModelsCache;
|
||||
import org.alfresco.repo.dictionary.DictionaryComponent;
|
||||
import org.alfresco.repo.dictionary.DictionaryDAOImpl;
|
||||
import org.alfresco.repo.dictionary.DictionaryNamespaceComponent;
|
||||
import org.alfresco.repo.dictionary.M2Model;
|
||||
import org.alfresco.repo.dictionary.M2Namespace;
|
||||
import org.alfresco.repo.dictionary.NamespaceDAO;
|
||||
import org.alfresco.repo.i18n.StaticMessageLookup;
|
||||
import org.alfresco.repo.tenant.SingleTServiceImpl;
|
||||
import org.alfresco.repo.tenant.TenantService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.DynamicallySizedThreadPoolExecutor;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.alfresco.util.TraceableThreadFactory;
|
||||
import org.alfresco.util.cache.DefaultAsynchronouslyRefreshedCacheRegistry;
|
||||
import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
|
||||
import org.apache.commons.httpclient.HttpMethod;
|
||||
import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
|
||||
import org.apache.commons.httpclient.methods.PostMethod;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.json.JSONException;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Tests {@link SOLRAPIClient} Note: need to make sure that source/solr/instance is on the run classpath. Note: doesn't
|
||||
* currently work, need to change to use SSL.
|
||||
@@ -109,7 +109,7 @@ public class SOLRAPIClientTest extends TestCase
|
||||
private DictionaryDAOImpl dictionaryDAO;
|
||||
|
||||
private CMISStrictDictionaryService cmisDictionaryService;
|
||||
|
||||
|
||||
private static final String CORENAME = "collection1";
|
||||
|
||||
// private M2Model testModel;
|
||||
@@ -140,10 +140,10 @@ public class SOLRAPIClientTest extends TestCase
|
||||
{
|
||||
if(client == null)
|
||||
{
|
||||
TenantService tenantService = new SingleTServiceImpl();
|
||||
TenantService tenantService = new SingleTServiceImpl();
|
||||
|
||||
dictionaryDAO = new DictionaryDAOImpl();
|
||||
NamespaceDAO namespaceDAO = dictionaryDAO;
|
||||
NamespaceDAO namespaceDAO = dictionaryDAO;
|
||||
dictionaryDAO.setTenantService(tenantService);
|
||||
|
||||
CompiledModelsCache compiledModelsCache = new CompiledModelsCache();
|
||||
@@ -163,7 +163,7 @@ public class SOLRAPIClientTest extends TestCase
|
||||
dictionaryDAO.setResourceClassLoader(getResourceClassLoader());
|
||||
dictionaryDAO.init();
|
||||
|
||||
DictionaryComponent dictionaryComponent = new DictionaryComponent();
|
||||
DictionaryComponent dictionaryComponent = new DictionaryComponent();
|
||||
dictionaryComponent.setDictionaryDAO(dictionaryDAO);
|
||||
dictionaryComponent.setMessageLookup(new StaticMessageLookup());
|
||||
|
||||
@@ -283,7 +283,7 @@ public class SOLRAPIClientTest extends TestCase
|
||||
8443, 40, 40, 0);
|
||||
// TODO need to make port configurable depending on secure comms, or just make redirects
|
||||
// work
|
||||
return httpClientFactory.getRepoClient("localhost", 8443);
|
||||
return httpClientFactory.getRepoClient("localhost", 8443);
|
||||
}
|
||||
|
||||
public ClassLoader getResourceClassLoader()
|
||||
@@ -452,7 +452,8 @@ public class SOLRAPIClientTest extends TestCase
|
||||
|
||||
NodeMetaDataParameters metaParams = new NodeMetaDataParameters();
|
||||
metaParams.setNodeIds(nodeIds);
|
||||
List<NodeMetaData> metadata = client.getNodesMetaData(metaParams, 3);
|
||||
metaParams.setMaxResults(3);
|
||||
List<NodeMetaData> metadata = client.getNodesMetaData(metaParams);
|
||||
for (NodeMetaData info : metadata)
|
||||
{
|
||||
logger.debug(info);
|
||||
@@ -463,9 +464,10 @@ public class SOLRAPIClientTest extends TestCase
|
||||
{
|
||||
NodeMetaDataParameters metaParams = new NodeMetaDataParameters();
|
||||
List<Long> nodeIds = new ArrayList<Long>(1);
|
||||
nodeIds.add(1l);
|
||||
nodeIds.add(1L);
|
||||
metaParams.setMaxResults(3);
|
||||
metaParams.setNodeIds(nodeIds);
|
||||
List<NodeMetaData> metadata = client.getNodesMetaData(metaParams, 3);
|
||||
List<NodeMetaData> metadata = client.getNodesMetaData(metaParams);
|
||||
for (NodeMetaData info : metadata)
|
||||
{
|
||||
logger.debug(info);
|
||||
@@ -473,9 +475,10 @@ public class SOLRAPIClientTest extends TestCase
|
||||
|
||||
metaParams = new NodeMetaDataParameters();
|
||||
nodeIds = new ArrayList<Long>(1);
|
||||
nodeIds.add(9l);
|
||||
nodeIds.add(9L);
|
||||
metaParams.setNodeIds(nodeIds);
|
||||
metadata = client.getNodesMetaData(metaParams, 3);
|
||||
metaParams.setMaxResults(3);
|
||||
metadata = client.getNodesMetaData(metaParams);
|
||||
for (NodeMetaData info : metadata)
|
||||
{
|
||||
logger.debug(info);
|
||||
@@ -483,9 +486,10 @@ public class SOLRAPIClientTest extends TestCase
|
||||
|
||||
metaParams = new NodeMetaDataParameters();
|
||||
nodeIds = new ArrayList<Long>(1);
|
||||
nodeIds.add(19l);
|
||||
nodeIds.add(19L);
|
||||
metaParams.setNodeIds(nodeIds);
|
||||
metadata = client.getNodesMetaData(metaParams, 3);
|
||||
metaParams.setMaxResults(3);
|
||||
metadata = client.getNodesMetaData(metaParams);
|
||||
for (NodeMetaData info : metadata)
|
||||
{
|
||||
logger.debug(info);
|
||||
@@ -495,9 +499,10 @@ public class SOLRAPIClientTest extends TestCase
|
||||
// TODO check why the category path has a null QName
|
||||
metaParams = new NodeMetaDataParameters();
|
||||
nodeIds = new ArrayList<Long>(1);
|
||||
nodeIds.add(49437l);
|
||||
nodeIds.add(49437L);
|
||||
metaParams.setNodeIds(nodeIds);
|
||||
metadata = client.getNodesMetaData(metaParams, 3);
|
||||
metaParams.setMaxResults(3);
|
||||
metadata = client.getNodesMetaData(metaParams);
|
||||
for (NodeMetaData info : metadata)
|
||||
{
|
||||
logger.debug(info);
|
||||
@@ -506,9 +511,10 @@ public class SOLRAPIClientTest extends TestCase
|
||||
// content with tags
|
||||
metaParams = new NodeMetaDataParameters();
|
||||
nodeIds = new ArrayList<Long>(1);
|
||||
nodeIds.add(49431l);
|
||||
nodeIds.add(49431L);
|
||||
metaParams.setNodeIds(nodeIds);
|
||||
metadata = client.getNodesMetaData(metaParams, 3);
|
||||
metaParams.setMaxResults(3);
|
||||
metadata = client.getNodesMetaData(metaParams);
|
||||
for (NodeMetaData info : metadata)
|
||||
{
|
||||
logger.debug(info);
|
||||
@@ -525,9 +531,10 @@ public class SOLRAPIClientTest extends TestCase
|
||||
// content with null property values for author
|
||||
metaParams = new NodeMetaDataParameters();
|
||||
nodeIds = new ArrayList<Long>(1);
|
||||
nodeIds.add(117630l);
|
||||
nodeIds.add(117630L);
|
||||
metaParams.setNodeIds(nodeIds);
|
||||
metadata = client.getNodesMetaData(metaParams, 3);
|
||||
metaParams.setMaxResults(3);
|
||||
metadata = client.getNodesMetaData(metaParams);
|
||||
for (NodeMetaData info : metadata)
|
||||
{
|
||||
logger.debug(info);
|
||||
@@ -536,9 +543,10 @@ public class SOLRAPIClientTest extends TestCase
|
||||
// content with accented characters in title properties
|
||||
metaParams = new NodeMetaDataParameters();
|
||||
nodeIds = new ArrayList<Long>(1);
|
||||
nodeIds.add(117678l);
|
||||
nodeIds.add(117678L);
|
||||
metaParams.setNodeIds(nodeIds);
|
||||
metadata = client.getNodesMetaData(metaParams, 3);
|
||||
metaParams.setMaxResults(3);
|
||||
metadata = client.getNodesMetaData(metaParams);
|
||||
for (NodeMetaData info : metadata)
|
||||
{
|
||||
logger.debug(info);
|
||||
|
||||
Reference in New Issue
Block a user