[SEARCH-2143]

code refactoring
This commit is contained in:
eliaporciani
2020-04-14 18:06:04 +02:00
parent e34710761c
commit 5d6812b781
5 changed files with 26 additions and 31 deletions
@@ -28,7 +28,7 @@ import org.alfresco.repo.dictionary.DictionaryComponent;
import org.alfresco.repo.dictionary.M2Model;
import org.alfresco.repo.dictionary.NamespaceDAO;
import org.alfresco.service.namespace.QName;
import org.alfresco.solr.AlfrescoSolrDataModel.TenantAclIdDbId;
import org.alfresco.solr.AlfrescoSolrDataModel.TenantDbId;
import org.alfresco.solr.adapters.IOpenBitSet;
import org.alfresco.solr.client.AclChangeSet;
import org.alfresco.solr.client.AclReaders;
@@ -148,9 +148,9 @@ public interface InformationServer extends InformationServerCollectionProvider
IndexHealthReport reportIndexTransactions(Long minTxId, IOpenBitSet txIdsInDb, long maxTxId) throws IOException;
List<TenantAclIdDbId> getDocsWithUncleanContent(int start, int rows) throws IOException;
List<TenantDbId> getDocsWithUncleanContent(int start, int rows) throws IOException;
void updateContent(TenantAclIdDbId docRef) throws Exception;
void updateContent(TenantDbId docRef) throws Exception;
void addCommonNodeReportInfo(NodeReport nodeReport);
@@ -126,7 +126,7 @@ import org.alfresco.service.cmr.security.AuthorityType;
import org.alfresco.service.namespace.QName;
import org.alfresco.solr.AlfrescoSolrDataModel.FieldInstance;
import org.alfresco.solr.AlfrescoSolrDataModel.IndexedField;
import org.alfresco.solr.AlfrescoSolrDataModel.TenantAclIdDbId;
import org.alfresco.solr.AlfrescoSolrDataModel.TenantDbId;
import org.alfresco.solr.adapters.IOpenBitSet;
import org.alfresco.solr.adapters.ISimpleOrderedMap;
import org.alfresco.solr.adapters.SolrOpenBitSetAdapter;
@@ -802,12 +802,12 @@ public class SolrInformationServer implements InformationServer
}
@Override
public List<TenantAclIdDbId> getDocsWithUncleanContent(int start, int rows) throws IOException
public List<TenantDbId> getDocsWithUncleanContent(int start, int rows) throws IOException
{
RefCounted<SolrIndexSearcher> refCounted = null;
try
{
List<TenantAclIdDbId> docIds = new ArrayList<>();
List<TenantDbId> docIds = new ArrayList<>();
refCounted = this.core.getSearcher();
SolrIndexSearcher searcher = refCounted.get();
@@ -929,7 +929,7 @@ public class SolrInformationServer implements InformationServer
processedTxns.add(txnId);
IndexableField id = document.getField(FIELD_SOLR4_ID);
String idString = id.stringValue();
TenantAclIdDbId tenantAndDbId = AlfrescoSolrDataModel.decodeNodeDocumentId(idString);
TenantDbId tenantAndDbId = AlfrescoSolrDataModel.decodeNodeDocumentId(idString);
ofNullable(document.getField(CONTENT_LOCALE_FIELD))
.map(IndexableField::stringValue)
@@ -1767,7 +1767,7 @@ public class SolrInformationServer implements InformationServer
Document document = searcher.doc(docId, REQUEST_ONLY_ID_FIELD);
IndexableField indexableField = document.getField(FIELD_SOLR4_ID);
String id = indexableField.stringValue();
TenantAclIdDbId ids = AlfrescoSolrDataModel.decodeNodeDocumentId(id);
TenantDbId ids = AlfrescoSolrDataModel.decodeNodeDocumentId(id);
parentNodesId.add(ids.dbId);
}
}
@@ -1830,7 +1830,7 @@ public class SolrInformationServer implements InformationServer
}
@Override
public void updateContent(TenantAclIdDbId docRef) throws Exception
public void updateContent(TenantDbId docRef) throws Exception
{
LOGGER.debug("Text content of Document DBID={} is going to be updated.", docRef.dbId);
@@ -2535,7 +2535,7 @@ public class SolrInformationServer implements InformationServer
}
}
private void addContentToDoc(TenantAclIdDbId docRef, SolrInputDocument doc, long dbId) throws AuthenticationException, IOException
private void addContentToDoc(TenantDbId docRef, SolrInputDocument doc, long dbId) throws AuthenticationException, IOException
{
String locale = (String) docRef.optionalBag.get(CONTENT_LOCALE_FIELD);
String qNamePart = CONTENT_LOCALE_FIELD.substring(AlfrescoSolrDataModel.CONTENT_S_LOCALE_PREFIX.length());
@@ -3362,7 +3362,7 @@ public class SolrInformationServer implements InformationServer
Document document = searcher.doc(docId, REQUEST_ONLY_ID_FIELD);
IndexableField indexableField = document.getField(FIELD_SOLR4_ID);
String id = indexableField.stringValue();
TenantAclIdDbId ids = AlfrescoSolrDataModel.decodeNodeDocumentId(id);
TenantDbId ids = AlfrescoSolrDataModel.decodeNodeDocumentId(id);
childIds.add(ids.dbId);
}
}
@@ -3497,7 +3497,7 @@ public class SolrInformationServer implements InformationServer
for (SolrDocument doc : docs)
{
String id = getFieldValueString(doc, FIELD_SOLR4_ID);
TenantAclIdDbId ids = AlfrescoSolrDataModel.decodeNodeDocumentId(id);
TenantDbId ids = AlfrescoSolrDataModel.decodeNodeDocumentId(id);
childIds.add(ids.dbId);
}
@@ -22,7 +22,7 @@ import java.io.IOException;
import java.util.List;
import java.util.Properties;
import org.alfresco.solr.AlfrescoSolrDataModel.TenantAclIdDbId;
import org.alfresco.solr.AlfrescoSolrDataModel.TenantDbId;
import org.alfresco.solr.InformationServer;
import org.alfresco.solr.client.SOLRAPIClient;
@@ -73,7 +73,7 @@ public class ContentTracker extends AbstractTracker implements Tracker
getWriteLock().acquire();
List<TenantAclIdDbId> docs = notNullOrEmpty(infoSrv.getDocsWithUncleanContent(start, ROWS));
List<TenantDbId> docs = notNullOrEmpty(infoSrv.getDocsWithUncleanContent(start, ROWS));
if (docs.isEmpty())
{
LOGGER.debug("No unclean document has been detected in the current ContentTracker cycle.");
@@ -81,7 +81,7 @@ public class ContentTracker extends AbstractTracker implements Tracker
}
int docsUpdatedSinceLastCommit = 0;
for (TenantAclIdDbId doc : docs)
for (TenantDbId doc : docs)
{
ContentIndexWorkerRunnable ciwr = new ContentIndexWorkerRunnable(super.threadHandler, doc, infoSrv);
super.threadHandler.scheduleTask(ciwr);
@@ -143,9 +143,9 @@ public class ContentTracker extends AbstractTracker implements Tracker
class ContentIndexWorkerRunnable extends AbstractWorkerRunnable
{
InformationServer infoServer;
TenantAclIdDbId docRef;
TenantDbId docRef;
ContentIndexWorkerRunnable(QueueHandler queueHandler, TenantAclIdDbId docRef, InformationServer infoServer)
ContentIndexWorkerRunnable(QueueHandler queueHandler, TenantDbId docRef, InformationServer infoServer)
{
super(queueHandler);
@@ -21,12 +21,7 @@ package org.alfresco.solr;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.io.InputStream;
import org.alfresco.repo.dictionary.M2Model;
import org.alfresco.service.namespace.QName;
import org.alfresco.solr.AlfrescoSolrDataModel.FieldUse;
import org.alfresco.solr.AlfrescoSolrDataModel.TenantAclIdDbId;
import org.junit.Test;
/**
@@ -24,7 +24,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import org.alfresco.solr.AlfrescoSolrDataModel.TenantAclIdDbId;
import org.alfresco.solr.AlfrescoSolrDataModel.TenantDbId;
import org.alfresco.solr.SolrInformationServer;
import org.alfresco.solr.client.SOLRAPIClient;
import org.junit.Assert;
@@ -80,25 +80,25 @@ public class ContentTrackerIT
@Ignore("Superseded by AlfrescoSolrTrackerTest")
public void doTrackWithContentUpdatesContent() throws Exception
{
List<TenantAclIdDbId> docs1 = new ArrayList<>();
List<TenantAclIdDbId> docs2 = new ArrayList<>();
List<TenantAclIdDbId> emptyList = new ArrayList<>();
List<TenantDbId> docs1 = new ArrayList<>();
List<TenantDbId> docs2 = new ArrayList<>();
List<TenantDbId> emptyList = new ArrayList<>();
// Adds one more than the UPDATE_BATCH
for (int i = 0; i <= UPDATE_BATCH; i++)
{
TenantAclIdDbId doc = new TenantAclIdDbId();
TenantDbId doc = new TenantDbId();
doc.dbId = 1l;
doc.tenant = "1";
docs1.add(doc);
}
TenantAclIdDbId thirdDoc = docs1.get(UPDATE_BATCH);
TenantDbId thirdDoc = docs1.get(UPDATE_BATCH);
thirdDoc.dbId = 3l;
thirdDoc.tenant = "3";
// Adds UPDATE_BATCH
for (long i = 0; i < UPDATE_BATCH; i++)
{
TenantAclIdDbId doc = new TenantAclIdDbId();
TenantDbId doc = new TenantDbId();
doc.dbId = 2l;
doc.tenant = "2";
docs2.add(doc);
@@ -120,7 +120,7 @@ public class ContentTrackerIT
*/
// From docs1
TenantAclIdDbId docRef = new TenantAclIdDbId();
TenantDbId docRef = new TenantDbId();
docRef.dbId = 1L;
docRef.tenant = "1";
@@ -134,7 +134,7 @@ public class ContentTrackerIT
order.verify(srv).getDocsWithUncleanContent(0 + READ_BATCH, READ_BATCH);
// From docs2
docRef = new TenantAclIdDbId();
docRef = new TenantDbId();
docRef.dbId = 2L;
docRef.tenant = "2";
order.verify(srv, times(UPDATE_BATCH)).updateContent(docRef);