mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged DEV to HEAD:
30289, 30366, 30381, 30607: (record-only) 30621, 30658, 30674, 30689, 30700: MT-aware Solr (THOR-129) - enabler only (subject to QA) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31975 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -20,6 +20,8 @@ package org.alfresco.repo.solr;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.repo.tenant.TenantService;
|
||||
|
||||
/**
|
||||
* Bean for SOLR ACL readers.
|
||||
*
|
||||
@@ -31,11 +33,12 @@ public class AclReaders
|
||||
private Long aclId;
|
||||
private Set<String> readers;
|
||||
private long aclChangeSetId;
|
||||
private String tenantDomain = TenantService.DEFAULT_DOMAIN;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "AclReaders [aclId=" + aclId + ", readers=" + readers + ", aclChangeSetId=" + aclChangeSetId + "]";
|
||||
return "AclReaders [aclId=" + aclId + ", readers=" + readers + ", aclChangeSetId=" + aclChangeSetId + ", tenantDomain=" + tenantDomain + "]";
|
||||
}
|
||||
public Long getAclId()
|
||||
{
|
||||
@@ -61,5 +64,12 @@ public class AclReaders
|
||||
{
|
||||
this.aclChangeSetId = aclChangeSetId;
|
||||
}
|
||||
|
||||
public String getTenantDomain()
|
||||
{
|
||||
return tenantDomain;
|
||||
}
|
||||
public void setTenantDomain(String tenantDomain)
|
||||
{
|
||||
this.tenantDomain = tenantDomain;
|
||||
}
|
||||
}
|
||||
|
@@ -23,7 +23,6 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.zip.CRC32;
|
||||
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
@@ -50,6 +49,7 @@ public class NodeMetaData
|
||||
private Long parentAssocsCrc;
|
||||
private List<Long> childIds;
|
||||
private Long txnId;
|
||||
private String tenantDomain;
|
||||
|
||||
public String getOwner()
|
||||
{
|
||||
@@ -156,6 +156,13 @@ public class NodeMetaData
|
||||
public void setTxnId(Long txnId)
|
||||
{
|
||||
this.txnId = txnId;
|
||||
}
|
||||
|
||||
}
|
||||
public String getTenantDomain()
|
||||
{
|
||||
return tenantDomain;
|
||||
}
|
||||
public void setTenantDomain(String tenantDomain)
|
||||
{
|
||||
this.tenantDomain = tenantDomain;
|
||||
}
|
||||
}
|
||||
|
@@ -39,6 +39,7 @@ import org.alfresco.repo.domain.node.NodeDAO.ChildAssocRefQueryCallback;
|
||||
import org.alfresco.repo.domain.permissions.AclDAO;
|
||||
import org.alfresco.repo.domain.qname.QNameDAO;
|
||||
import org.alfresco.repo.domain.solr.SOLRDAO;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.tenant.TenantService;
|
||||
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
@@ -185,6 +186,8 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent
|
||||
* This is an N+1 query that should, in theory, make use of cached ACL readers data.
|
||||
*/
|
||||
|
||||
Map<Long, String> aclChangeSetTenant = new HashMap<Long, String>(aclIds.size());
|
||||
|
||||
List<AclReaders> aclsReaders = new ArrayList<AclReaders>(aclIds.size() * 10);
|
||||
for (Long aclId : aclIds)
|
||||
{
|
||||
@@ -192,10 +195,30 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent
|
||||
AclReaders readers = new AclReaders();
|
||||
readers.setAclId(aclId);
|
||||
readers.setReaders(readersSet);
|
||||
readers.setAclChangeSetId(aclDAO.getAccessControlList(aclId).getProperties().getAclChangeSetId());
|
||||
|
||||
Long aclChangeSetId = aclDAO.getAccessControlList(aclId).getProperties().getAclChangeSetId();
|
||||
readers.setAclChangeSetId(aclChangeSetId);
|
||||
|
||||
if (AuthenticationUtil.isMtEnabled())
|
||||
{
|
||||
// MT - for now, derive the tenant for acl (via acl change set)
|
||||
String tenantDomain = aclChangeSetTenant.get(aclChangeSetId);
|
||||
if (tenantDomain == null)
|
||||
{
|
||||
tenantDomain = getTenant(aclId, aclChangeSetId);
|
||||
if (tenantDomain == null)
|
||||
{
|
||||
// skip this acl !
|
||||
continue;
|
||||
}
|
||||
aclChangeSetTenant.put(aclChangeSetId, tenantDomain);
|
||||
}
|
||||
readers.setTenantDomain(tenantDomain);
|
||||
}
|
||||
|
||||
aclsReaders.add(readers);
|
||||
}
|
||||
|
||||
|
||||
return aclsReaders;
|
||||
}
|
||||
else
|
||||
@@ -203,7 +226,51 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent
|
||||
return Collections.<AclReaders>emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String getTenant(long aclId, long aclChangeSetId)
|
||||
{
|
||||
String tenantDomain = getAclTenant(aclId);
|
||||
if (tenantDomain == null)
|
||||
{
|
||||
List<Long> aclChangeSetIds = new ArrayList<Long>(1);
|
||||
aclChangeSetIds.add(aclChangeSetId);
|
||||
|
||||
List<Acl> acls = solrDAO.getAcls(aclChangeSetIds, null, 1024);
|
||||
for (Acl acl : acls)
|
||||
{
|
||||
tenantDomain = getAclTenant(acl.getId());
|
||||
if (tenantDomain != null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (tenantDomain == null)
|
||||
{
|
||||
// tenant not found - log warning ?
|
||||
tenantDomain = null; // temp - for debug breakpoint only
|
||||
}
|
||||
}
|
||||
return tenantDomain;
|
||||
}
|
||||
|
||||
private String getAclTenant(long aclId)
|
||||
{
|
||||
List<Long> nodeIds = aclDAO.getADMNodesByAcl(aclId, 1);
|
||||
if (nodeIds.size() == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Pair<Long, NodeRef> nodePair = nodeDAO.getNodePair(nodeIds.get(0));
|
||||
if (nodePair == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return tenantService.getDomain(nodePair.getSecond().getStoreRef().getIdentifier());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Transaction> getTransactions(Long minTxnId, Long fromCommitTime, int maxResults)
|
||||
{
|
||||
@@ -519,12 +586,16 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent
|
||||
|
||||
nodeMetaData.setPaths(paths);
|
||||
}
|
||||
|
||||
|
||||
NodeRef nodeRef = pair.getSecond();
|
||||
|
||||
if(includeNodeRef)
|
||||
{
|
||||
nodeMetaData.setNodeRef(pair.getSecond());
|
||||
nodeMetaData.setNodeRef(tenantService.getBaseName(nodeRef, true));
|
||||
}
|
||||
|
||||
|
||||
nodeMetaData.setTenantDomain(tenantService.getDomain(nodeRef.getStoreRef().getIdentifier()));
|
||||
|
||||
if(includeChildAssociations)
|
||||
{
|
||||
final List<ChildAssociationRef> childAssocs = new ArrayList<ChildAssociationRef>(100);
|
||||
@@ -546,7 +617,7 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent
|
||||
public boolean handle(Pair<Long, ChildAssociationRef> childAssocPair, Pair<Long, NodeRef> parentNodePair,
|
||||
Pair<Long, NodeRef> childNodePair)
|
||||
{
|
||||
childAssocs.add(childAssocPair.getSecond());
|
||||
childAssocs.add(tenantService.getBaseName(childAssocPair.getSecond(), true));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -612,7 +683,7 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent
|
||||
public boolean handle(Pair<Long, ChildAssociationRef> childAssocPair,
|
||||
Pair<Long, NodeRef> parentNodePair, Pair<Long, NodeRef> childNodePair)
|
||||
{
|
||||
parentAssocs.add(childAssocPair.getSecond());
|
||||
parentAssocs.add(tenantService.getBaseName(childAssocPair.getSecond(), true));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user