diff --git a/config/alfresco/index-recovery-context.xml b/config/alfresco/index-recovery-context.xml index 4cb4597592..a90af3d333 100644 --- a/config/alfresco/index-recovery-context.xml +++ b/config/alfresco/index-recovery-context.xml @@ -43,6 +43,15 @@ + + + + + + ${version.store.version2Store} + ${version.store.deprecated.lightWeightVersionStore} + + diff --git a/config/alfresco/node-services-context.xml b/config/alfresco/node-services-context.xml index 53ab6f5e78..68820d729a 100644 --- a/config/alfresco/node-services-context.xml +++ b/config/alfresco/node-services-context.xml @@ -147,6 +147,7 @@ ${version.store.version2Store} + diff --git a/source/java/org/alfresco/repo/node/index/AbstractReindexComponent.java b/source/java/org/alfresco/repo/node/index/AbstractReindexComponent.java index e7a6afc15a..1fcae654a2 100644 --- a/source/java/org/alfresco/repo/node/index/AbstractReindexComponent.java +++ b/source/java/org/alfresco/repo/node/index/AbstractReindexComponent.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2007 Alfresco Software Limited. + * Copyright (C) 2005-2009 Alfresco Software Limited. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -26,6 +26,7 @@ package org.alfresco.repo.node.index; import java.io.PrintWriter; import java.io.StringWriter; +import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.concurrent.LinkedBlockingQueue; @@ -43,6 +44,7 @@ import org.alfresco.repo.search.impl.lucene.LuceneQueryParser; import org.alfresco.repo.search.impl.lucene.fts.FullTextSearchIndexer; import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.tenant.TenantService; import org.alfresco.repo.transaction.AlfrescoTransactionSupport; import org.alfresco.repo.transaction.TransactionListenerAdapter; import org.alfresco.repo.transaction.TransactionServiceImpl; @@ -94,6 +96,9 @@ public abstract class AbstractReindexComponent implements IndexRecovery /** the component that holds the reindex worker threads */ private ThreadPoolExecutor threadPoolExecutor; + private TenantService tenantService; + private List storesToIgnore = new ArrayList(0); + private volatile boolean shutdown; private final WriteLock indexerWriteLock; @@ -203,6 +208,21 @@ public abstract class AbstractReindexComponent implements IndexRecovery { this.threadPoolExecutor = threadPoolExecutor; } + + public void setTenantService(TenantService tenantService) + { + this.tenantService = tenantService; + } + + public void setStoresToIgnore(List storesToIgnore) + { + this.storesToIgnore = storesToIgnore; + } + + public List getStoresToIgnore() + { + return this.storesToIgnore; + } /** * Determines if calls to {@link #reindexImpl()} should be wrapped in a transaction or not. @@ -321,6 +341,23 @@ public abstract class AbstractReindexComponent implements IndexRecovery storeRefsIterator.remove(); } } + + List storesToIgnore = getStoresToIgnore(); + if (storesToIgnore != null) + { + + storeRefsIterator = storeRefs.iterator(); + while (storeRefsIterator.hasNext()) + { + // Remove stores to ignore + StoreRef storeRef = storeRefsIterator.next(); + if (storesToIgnore.contains(storeRef.toString())) + { + storeRefsIterator.remove(); + } + } + } + // Change the ordering to favour the most common stores if (storeRefs.contains(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE)) { @@ -385,7 +422,41 @@ public abstract class AbstractReindexComponent implements IndexRecovery { // If none of the stores have the transaction, then that might be because it consists of 0 modifications int updateCount = nodeDaoService.getTxnUpdateCount(txnId); - if (updateCount > 0) + + /* Alternative (r15360) + // exclude updates in the version store + if(updateCount > 0) + { + // the updates could all be in the version stores ... + List changes = nodeDaoService.getTxnChanges(txnId); + for(NodeRef change : changes) + { + StoreRef changeStore = change.getStoreRef(); + if(changeStore.getProtocol().equals(StoreRef.PROTOCOL_WORKSPACE)) + { + if(changeStore.getIdentifier().equals("lightWeightVersionStore")) + { + Status nodeStatus = nodeService.getNodeStatus(change); + if(!nodeStatus.isDeleted()) + { + updateCount--; + } + } + if(changeStore.getIdentifier().equals("version2Store")) + { + Status nodeStatus = nodeService.getNodeStatus(change); + if(!nodeStatus.isDeleted()) + { + updateCount--; + } + } + } + + } + } + */ + + if ((updateCount > 0) && (! allUpdatedNodesCanBeIgnored(txnId))) { // There were updates, but there is no sign in the indexes result = InIndex.NO; @@ -472,6 +543,47 @@ public abstract class AbstractReindexComponent implements IndexRecovery } } + protected boolean allUpdatedNodesCanBeIgnored(Long txnId) + { + boolean allUpdatedNodesCanBeIgnored = false; + List storesToIgnore = getStoresToIgnore(); + if ((storesToIgnore != null) && (storesToIgnore.size() > 0) && (txnId != null)) + { + List nodeRefs = nodeDaoService.getTxnChanges(txnId); + + allUpdatedNodesCanBeIgnored = true; + for (NodeRef nodeRef : nodeRefs) + { + if (nodeRef != null) + { + Status nodeStatus = nodeService.getNodeStatus(nodeRef); + if (nodeStatus == null) + { + // it's not there any more + continue; + } + if (! nodeStatus.isDeleted()) + { + // updated node (ie. not deleted) + StoreRef storeRef = nodeRef.getStoreRef(); + if (tenantService != null) + { + storeRef = tenantService.getBaseName(nodeRef.getStoreRef()); + } + + if (! storesToIgnore.contains(storeRef.toString())) + { + allUpdatedNodesCanBeIgnored = false; + break; + } + } + } + } + } + + return allUpdatedNodesCanBeIgnored; + } + private boolean haveNodesBeenRemovedFromIndex(final StoreRef storeRef, final Transaction txn) { final Long txnId = txn.getId(); diff --git a/source/java/org/alfresco/repo/version/Version2ServiceImpl.java b/source/java/org/alfresco/repo/version/Version2ServiceImpl.java index f8c96ba01b..36907cc2e3 100644 --- a/source/java/org/alfresco/repo/version/Version2ServiceImpl.java +++ b/source/java/org/alfresco/repo/version/Version2ServiceImpl.java @@ -667,7 +667,7 @@ public class Version2ServiceImpl extends VersionServiceImpl implements VersionSe } // TODO consolidate with VersionUtil.convertFrozenToOriginalProps - nodeProperties.remove(ContentModel.PROP_DESCRIPTION); + for (QName key : nodeProperties.keySet()) { Serializable value = nodeProperties.get(key); @@ -695,12 +695,21 @@ public class Version2ServiceImpl extends VersionServiceImpl implements VersionSe } else { - // all other properties - versionProperties.put(keyName, value); + if (keyName.equals(Version.PROP_DESCRIPTION) || + keyName.equals(VersionBaseModel.PROP_VERSION_LABEL) || + keyName.equals(VersionBaseModel.PROP_VERSION_NUMBER)) + { + // ignore reserved localname (including cm:description, cm:versionLabel) + } + else + { + // all other properties + versionProperties.put(keyName, value); + } } } } - + // Create and return the version object NodeRef newNodeRef = new NodeRef(new StoreRef(Version2Model.STORE_PROTOCOL, Version2Model.STORE_ID), versionRef.getId()); Version result = new VersionImpl(versionProperties, newNodeRef);