From bc7fb95b8357da6b0210cc2015917807e1424fcd Mon Sep 17 00:00:00 2001 From: Alan Davis Date: Sun, 11 May 2014 22:08:45 +0000 Subject: [PATCH] ACE-1640: Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud) 70016: Merged V4.2-BUG-FIX (4.2.3) to HEAD-BUG-FIX (4.3/Cloud) 70015: Merged V4.1-BUG-FIX (4.1.9) to V4.2-BUG-FIX (4.2.3) 70014: MNT-11437: Merged V4.1.5 (4.1.5.14) to V4.1-BUG-FIX (4.1.9) 70009: Revised fix for MNT-11107 Documents uploaded by another user are not filtered via tags in My Files Fix for MNT-11427 Impossible to start reindex process for bm-0010 and bm-0013 tests: api/solr/aclchangesets return status:502 - test fixes and maintain order git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@70017 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../alfresco/repo/domain/solr/AclEntity.java | 62 +++++++++++++++++++ .../repo/domain/solr/ibatis/SOLRDAOImpl.java | 22 ++++--- source/java/org/alfresco/repo/solr/Acl.java | 2 +- .../repo/domain/solr/SOLRDAOTest.java | 19 +++++- .../repo/solr/SOLRTrackingComponentTest.java | 45 +++++++------- 5 files changed, 115 insertions(+), 35 deletions(-) diff --git a/source/java/org/alfresco/repo/domain/solr/AclEntity.java b/source/java/org/alfresco/repo/domain/solr/AclEntity.java index 0f11f88bc9..f23a810720 100644 --- a/source/java/org/alfresco/repo/domain/solr/AclEntity.java +++ b/source/java/org/alfresco/repo/domain/solr/AclEntity.java @@ -69,4 +69,66 @@ public class AclEntity implements Acl { this.inheritedId = inheritedId; } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + ((aclChangeSetId == null) ? 0 : aclChangeSetId.hashCode()); + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((inheritedId == null) ? 0 : inheritedId.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) + { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + AclEntity other = (AclEntity) obj; + if (aclChangeSetId == null) + { + if (other.aclChangeSetId != null) + return false; + } + else if (!aclChangeSetId.equals(other.aclChangeSetId)) + return false; + if (id == null) + { + if (other.id != null) + return false; + } + else if (!id.equals(other.id)) + return false; + if (inheritedId == null) + { + if (other.inheritedId != null) + return false; + } + else if (!inheritedId.equals(other.inheritedId)) + return false; + return true; + } + + /* (non-Javadoc) + * @see java.lang.Comparable#compareTo(java.lang.Object) + */ + @Override + public int compareTo(Acl o) + { + return this.getId().compareTo(o.getId()); + } + + } diff --git a/source/java/org/alfresco/repo/domain/solr/ibatis/SOLRDAOImpl.java b/source/java/org/alfresco/repo/domain/solr/ibatis/SOLRDAOImpl.java index 796d6b82db..41851b5d2a 100644 --- a/source/java/org/alfresco/repo/domain/solr/ibatis/SOLRDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/solr/ibatis/SOLRDAOImpl.java @@ -21,6 +21,7 @@ package org.alfresco.repo.domain.solr.ibatis; import java.util.ArrayList; import java.util.HashSet; import java.util.List; +import java.util.TreeSet; import org.alfresco.model.ContentModel; import org.alfresco.repo.domain.node.Node; @@ -133,29 +134,30 @@ public class SOLRDAOImpl implements SOLRDAO source = (List) template.selectList(SELECT_ACLS_BY_CHANGESET_IDS, params, new RowBounds(0, maxResults)); } // Add any unlinked shared ACLs from defining nodes to index them now - ArrayList answer = new ArrayList(source); - HashSet acls = new HashSet(); - for(Acl acl : answer) + TreeSet sorted = new TreeSet(source); + HashSet found = new HashSet(); + for(Acl acl : source) { - acls.add(acl.getId()); + found.add(acl.getId()); } - ArrayList sharedAndUnlinked = new ArrayList(); - for(Acl acl : answer) + + for(Acl acl : source) { if(acl.getInheritedId() != null) { - if(!acls.contains(acl.getInheritedId())) + if(!found.contains(acl.getInheritedId())) { AclEntity shared = new AclEntity(); shared.setId(acl.getInheritedId()); shared.setAclChangeSetId(acl.getAclChangeSetId()); shared.setInheritedId(acl.getInheritedId()); - sharedAndUnlinked.add(shared); - acls.add(shared.getId()); + sorted.add(shared); } } } - answer.addAll(sharedAndUnlinked); + + ArrayList answer = new ArrayList(); + answer.addAll(sorted); return answer; } diff --git a/source/java/org/alfresco/repo/solr/Acl.java b/source/java/org/alfresco/repo/solr/Acl.java index 4ff26b6c22..b10174f465 100644 --- a/source/java/org/alfresco/repo/solr/Acl.java +++ b/source/java/org/alfresco/repo/solr/Acl.java @@ -24,7 +24,7 @@ package org.alfresco.repo.solr; * @author Derek Hulley * @since 4.0 */ -public interface Acl +public interface Acl extends Comparable { Long getId(); Long getInheritedId(); diff --git a/source/test-java/org/alfresco/repo/domain/solr/SOLRDAOTest.java b/source/test-java/org/alfresco/repo/domain/solr/SOLRDAOTest.java index ffd5ffa033..c2a1ed85af 100644 --- a/source/test-java/org/alfresco/repo/domain/solr/SOLRDAOTest.java +++ b/source/test-java/org/alfresco/repo/domain/solr/SOLRDAOTest.java @@ -254,11 +254,24 @@ public class SOLRDAOTest extends TestCase { break; } - assertEquals("Expected exactly one result", 1, acls.size()); - totalAclCount++; + if(acls.size() == 1) + { + // OK single acl + } + else if(acls.size() == 2) + { + // definning has unlinkfd shared acl + assertEquals("Not a defining and shared pair", acls.get(0).getInheritedId(), acls.get(1).getId()); + } + else + { + fail("More then two acls"); + } + totalAclCount++;; minAclId = acls.get(0).getId() + 1; } - assertEquals("Expected to page to exact number of results", aclCount, totalAclCount); + // This may not be true - it depands on lazy/eager shared acl creation. + //assertEquals("Expected to page to exact number of results", aclCount, totalAclCount); } private List toIds(List aclChangeSets) diff --git a/source/test-java/org/alfresco/repo/solr/SOLRTrackingComponentTest.java b/source/test-java/org/alfresco/repo/solr/SOLRTrackingComponentTest.java index ec47704ca5..f35f321bfe 100644 --- a/source/test-java/org/alfresco/repo/solr/SOLRTrackingComponentTest.java +++ b/source/test-java/org/alfresco/repo/solr/SOLRTrackingComponentTest.java @@ -138,27 +138,30 @@ public class SOLRTrackingComponentTest extends TestCase } - public void testGetAcls_Simple() - { - List cs = getAclChangeSets(null, null, null, null, 50); - assertTrue("Expected results to be limited in number", cs.size() <= 50); - int totalAcls = 0; - for (AclChangeSet aclChangeSet : cs) - { - totalAcls += aclChangeSet.getAclCount(); - } - int totalAclsCheck = 0; - - for (AclChangeSet aclChangeSet : cs) - { - List acls = getAcls(Arrays.asList(new Long[]{aclChangeSet.getId()}), null, 200); - assertEquals(aclChangeSet.getAclCount(), acls.size()); - totalAclsCheck += acls.size(); - } - - // Double check number of ACLs - assertEquals("ACL count should have matched", totalAcls, totalAclsCheck); - } + // This test is no longer valid as we may or may include shared acls not linked to defining ones + // If they are not linked to a node they will be counted wring ... + +// public void testGetAcls_Simple() +// { +// List cs = getAclChangeSets(null, null, null, null, 50); +// assertTrue("Expected results to be limited in number", cs.size() <= 50); +// int totalAcls = 0; +// for (AclChangeSet aclChangeSet : cs) +// { +// totalAcls += aclChangeSet.getAclCount(); +// } +// int totalAclsCheck = 0; +// +// for (AclChangeSet aclChangeSet : cs) +// { +// List acls = getAcls(Arrays.asList(new Long[]{aclChangeSet.getId()}), null, 200); +// assertEquals(aclChangeSet.getAclCount(), acls.size()); +// totalAclsCheck += acls.size(); +// } +// +// // Double check number of ACLs +// assertEquals("ACL count should have matched", totalAcls, totalAclsCheck); +// } public void testGetNodeMetaData() {