From 8a34293e848e2b01f83d1c0a77811ac798b4cb23 Mon Sep 17 00:00:00 2001 From: Alan Davis Date: Thu, 3 Nov 2016 13:15:53 +0000 Subject: [PATCH] Merged 5.2.N (5.2.1) to HEAD (5.2) 130755 jbernstein: SEARCH-165: Simulate down repo in test cases git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@132175 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../solr/client/SOLRAPIQueueClient.java | 47 +++++++++++++++---- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/search-services/alfresco-solrclient-lib/source/java/org/alfresco/solr/client/SOLRAPIQueueClient.java b/search-services/alfresco-solrclient-lib/source/java/org/alfresco/solr/client/SOLRAPIQueueClient.java index 01a8d4020..d4395d5f2 100644 --- a/search-services/alfresco-solrclient-lib/source/java/org/alfresco/solr/client/SOLRAPIQueueClient.java +++ b/search-services/alfresco-solrclient-lib/source/java/org/alfresco/solr/client/SOLRAPIQueueClient.java @@ -27,6 +27,7 @@ package org.alfresco.solr.client; import java.io.*; +import java.net.ConnectException; import java.util.*; import org.alfresco.httpclient.AuthenticationException; @@ -53,25 +54,24 @@ public class SOLRAPIQueueClient extends SOLRAPIClient public static List transactionQueue = Collections.synchronizedList(new ArrayList()); public static Map> nodeMap = Collections.synchronizedMap(new HashMap()); public static Map nodeMetaDataMap = Collections.synchronizedMap(new HashMap()); + private static boolean throwException; public SOLRAPIQueueClient(NamespaceDAO namespaceDAO) { super(null,null,namespaceDAO); } - /** - * Get the ACL ChangeSets - * - * @param fromCommitTime the lowest commit time (optional) - * @param minAclChangeSetId the lowest ChangeSet ID (optional) - * @param maxResults the maximum number of results (a reasonable value only) - * @return the ACL ChangeSets in order of commit time and ID - */ - + public static void setThrowException(boolean _throwException) { + throwException = _throwException; + } public AclChangeSets getAclChangeSets(Long fromCommitTime, Long minAclChangeSetId, Long toCommitTime, Long maxAclChangeSetId, int maxResults) throws AuthenticationException, IOException, JSONException { + if(throwException) { + throw new ConnectException("THROWING EXCEPTION, better be ready!"); + } + int size = aclChangeSetQueue.size(); long maxTime = 0L; long maxId = 0L; @@ -140,6 +140,10 @@ public class SOLRAPIQueueClient extends SOLRAPIClient */ public List getAcls(List aclChangeSets, Long minAclId, int maxResults) throws AuthenticationException, IOException, JSONException { + if(throwException) { + throw new ConnectException("THROWING EXCEPTION, better be ready!"); + } + List allAcls = new ArrayList(); for(AclChangeSet aclChangeSet : aclChangeSets) { @@ -157,6 +161,10 @@ public class SOLRAPIQueueClient extends SOLRAPIClient */ public List getAclReaders(List acls) throws AuthenticationException, IOException, JSONException { + if(throwException) { + throw new ConnectException("THROWING EXCEPTION, better be ready!"); + } + List allAclReaders = new ArrayList(); for(Acl acl : acls) { @@ -169,12 +177,18 @@ public class SOLRAPIQueueClient extends SOLRAPIClient public List getModelsDiff(List currentModels) throws AuthenticationException, IOException, JSONException { + if(throwException) { + throw new ConnectException("THROWING EXCEPTION, better be ready!"); + } return new ArrayList(); } public Transactions getTransactions(Long fromCommitTime, Long minTxnId, Long toCommitTime, Long maxTxnId, int maxResults) throws AuthenticationException, IOException, JSONException { + if(throwException) { + throw new ConnectException("THROWING EXCEPTION, better be ready!"); + } try { return getTransactions(fromCommitTime, minTxnId, toCommitTime, maxTxnId, maxResults, null); @@ -190,6 +204,10 @@ public class SOLRAPIQueueClient extends SOLRAPIClient public Transactions getTransactions(Long fromCommitTime, Long minTxnId, Long toCommitTime, Long maxTxnId, int maxResults, ShardState shardState) throws AuthenticationException, IOException, JSONException, EncoderException { + if(throwException) { + throw new ConnectException("THROWING EXCEPTION, better be ready!"); + } + int size = transactionQueue.size(); long maxTime = 0L; @@ -250,6 +268,10 @@ public class SOLRAPIQueueClient extends SOLRAPIClient public List getNodes(GetNodesParameters parameters, int maxResults) throws AuthenticationException, IOException, JSONException { + if(throwException) { + throw new ConnectException("THROWING EXCEPTION, better be ready!"); + } + List txnIds = parameters.getTransactionIds(); List allNodes = new ArrayList(); for(long txnId : txnIds) @@ -263,6 +285,10 @@ public class SOLRAPIQueueClient extends SOLRAPIClient public List getNodesMetaData(NodeMetaDataParameters params, int maxResults) throws AuthenticationException, IOException, JSONException { + if(throwException) { + throw new ConnectException("THROWING EXCEPTION, better be ready!"); + } + List nodeMetaDatas = new ArrayList(); List nodeIds = params.getNodeIds(); if(nodeIds != null) { @@ -281,6 +307,9 @@ public class SOLRAPIQueueClient extends SOLRAPIClient public GetTextContentResponse getTextContent(Long nodeId, QName propertyQName, Long modifiedSince) throws AuthenticationException, IOException { + if(throwException) { + throw new ConnectException("THROWING EXCEPTION, better be ready!"); + } //Just put the nodeId innto the content so we query for this in tests. return new GetTextContentResponse(new DummyResponse("Hello world "+nodeId)); }