diff --git a/source/java/org/alfresco/repo/domain/hibernate/Node.hbm.xml b/source/java/org/alfresco/repo/domain/hibernate/Node.hbm.xml index d160f513ca..a138826da8 100644 --- a/source/java/org/alfresco/repo/domain/hibernate/Node.hbm.xml +++ b/source/java/org/alfresco/repo/domain/hibernate/Node.hbm.xml @@ -59,7 +59,7 @@ column="store_id" not-null="true" lazy="false" - foreign-key="fk_alf_n_store" + foreign-key="fk_alf_node_store" fetch="join" /> diff --git a/source/java/org/alfresco/repo/domain/hibernate/Transaction.hbm.xml b/source/java/org/alfresco/repo/domain/hibernate/Transaction.hbm.xml index 207bb6f43f..a4f1bc45e5 100644 --- a/source/java/org/alfresco/repo/domain/hibernate/Transaction.hbm.xml +++ b/source/java/org/alfresco/repo/domain/hibernate/Transaction.hbm.xml @@ -122,6 +122,13 @@ ]]> + + select + count(txn.id) + from + org.alfresco.repo.domain.hibernate.TransactionImpl as txn + + select count(node.uuid) diff --git a/source/java/org/alfresco/repo/search/impl/lucene/index/IndexInfo.java b/source/java/org/alfresco/repo/search/impl/lucene/index/IndexInfo.java index 9fb8cda11f..999191c0df 100644 --- a/source/java/org/alfresco/repo/search/impl/lucene/index/IndexInfo.java +++ b/source/java/org/alfresco/repo/search/impl/lucene/index/IndexInfo.java @@ -1868,7 +1868,7 @@ public class IndexInfo File location = new File(indexDirectory, id).getCanonicalFile(); if (IndexReader.indexExists(location)) { - if (size > config.getMaxDocsForInMemoryMerge()) + if ((config != null) && (size > config.getMaxDocsForInMemoryMerge())) { reader = IndexReader.open(location); } diff --git a/source/java/org/alfresco/repo/security/authority/AuthorityServiceTest.java b/source/java/org/alfresco/repo/security/authority/AuthorityServiceTest.java index 4b11e59b0f..fc4cb1c24e 100644 --- a/source/java/org/alfresco/repo/security/authority/AuthorityServiceTest.java +++ b/source/java/org/alfresco/repo/security/authority/AuthorityServiceTest.java @@ -27,6 +27,7 @@ package org.alfresco.repo.security.authority; import java.io.Serializable; import java.util.HashMap; import java.util.Map; +import java.util.Set; import javax.transaction.UserTransaction; @@ -323,6 +324,20 @@ public class AuthorityServiceTest extends TestCase assertEquals(0, pubAuthorityService.getAllAuthorities(AuthorityType.ROLE).size()); assertEquals(0, pubAuthorityService.getAllRootAuthorities(AuthorityType.ROLE).size()); } + + private void checkAuthorityCollectionSize(int expected, Set actual, AuthorityType type) + { + if (actual.size() != expected) + { + String msg = + "Incorrect number of authorities.\n" + + " Type: " + type + "\n" + + " Expected Count: " + expected + "\n" + + " Actual Count: " + actual.size() + "\n" + + " Authorities: " + actual; + fail(msg); + } + } public void testCreateAuthTree() { @@ -357,12 +372,12 @@ public class AuthorityServiceTest extends TestCase assertEquals(6, pubAuthorityService.getAllAuthorities(AuthorityType.GROUP).size()); assertEquals(3, pubAuthorityService.getAllRootAuthorities(AuthorityType.GROUP).size()); - assertEquals(3, pubAuthorityService.getAllAuthorities(AuthorityType.USER).size()); + checkAuthorityCollectionSize(3, pubAuthorityService.getAllAuthorities(AuthorityType.USER), AuthorityType.USER); pubAuthorityService.addAuthority(auth5, "andy"); assertEquals(6, pubAuthorityService.getAllAuthorities(AuthorityType.GROUP).size()); assertEquals(3, pubAuthorityService.getAllRootAuthorities(AuthorityType.GROUP).size()); // The next call looks for people not users :-) - assertEquals(3, pubAuthorityService.getAllAuthorities(AuthorityType.USER).size()); + checkAuthorityCollectionSize(3, pubAuthorityService.getAllAuthorities(AuthorityType.USER), AuthorityType.USER); assertEquals(2, pubAuthorityService.getContainingAuthorities(null, "andy", false).size()); assertTrue(pubAuthorityService.getContainingAuthorities(null, "andy", false).contains(auth5)); assertTrue(pubAuthorityService.getContainingAuthorities(null, "andy", false).contains(auth2)); @@ -380,7 +395,7 @@ public class AuthorityServiceTest extends TestCase assertEquals(6, pubAuthorityService.getAllAuthorities(AuthorityType.GROUP).size()); assertEquals(3, pubAuthorityService.getAllRootAuthorities(AuthorityType.GROUP).size()); // The next call looks for people not users :-) - assertEquals(3, pubAuthorityService.getAllAuthorities(AuthorityType.USER).size()); + checkAuthorityCollectionSize(3, pubAuthorityService.getAllAuthorities(AuthorityType.USER), AuthorityType.USER); assertEquals(0, pubAuthorityService.getContainingAuthorities(null, "andy", false).size()); assertEquals(1, pubAuthorityService.getContainingAuthorities(null, auth5, false).size()); assertTrue(pubAuthorityService.getContainingAuthorities(null, auth5, false).contains(auth2)); @@ -426,7 +441,7 @@ public class AuthorityServiceTest extends TestCase assertEquals(6, pubAuthorityService.getAllAuthorities(AuthorityType.GROUP).size()); assertEquals(3, pubAuthorityService.getAllRootAuthorities(AuthorityType.GROUP).size()); // The next call looks for people not users :-) - assertEquals(3, pubAuthorityService.getAllAuthorities(AuthorityType.USER).size()); + checkAuthorityCollectionSize(3, pubAuthorityService.getAllAuthorities(AuthorityType.USER), AuthorityType.USER); assertEquals(3, pubAuthorityService.getContainingAuthorities(null, "andy", false).size()); assertTrue(pubAuthorityService.getContainingAuthorities(null, "andy", false).contains(auth5)); assertTrue(pubAuthorityService.getContainingAuthorities(null, "andy", false).contains(auth2)); @@ -445,7 +460,7 @@ public class AuthorityServiceTest extends TestCase assertEquals(6, pubAuthorityService.getAllAuthorities(AuthorityType.GROUP).size()); assertEquals(3, pubAuthorityService.getAllRootAuthorities(AuthorityType.GROUP).size()); // The next call looks for people not users :-) - assertEquals(3, pubAuthorityService.getAllAuthorities(AuthorityType.USER).size()); + checkAuthorityCollectionSize(3, pubAuthorityService.getAllAuthorities(AuthorityType.USER), AuthorityType.USER); assertEquals(2, pubAuthorityService.getContainingAuthorities(null, "andy", false).size()); assertTrue(pubAuthorityService.getContainingAuthorities(null, "andy", false).contains(auth5)); assertTrue(pubAuthorityService.getContainingAuthorities(null, "andy", false).contains(auth2)); @@ -486,14 +501,14 @@ public class AuthorityServiceTest extends TestCase assertEquals(6, pubAuthorityService.getAllAuthorities(AuthorityType.GROUP).size()); assertEquals(3, pubAuthorityService.getAllRootAuthorities(AuthorityType.GROUP).size()); - assertEquals(3, pubAuthorityService.getAllAuthorities(AuthorityType.USER).size()); + checkAuthorityCollectionSize(3, pubAuthorityService.getAllAuthorities(AuthorityType.USER), AuthorityType.USER); pubAuthorityService.addAuthority(auth5, "andy"); pubAuthorityService.addAuthority(auth1, "andy"); assertEquals(6, pubAuthorityService.getAllAuthorities(AuthorityType.GROUP).size()); assertEquals(3, pubAuthorityService.getAllRootAuthorities(AuthorityType.GROUP).size()); // The next call looks for people not users :-) - assertEquals(3, pubAuthorityService.getAllAuthorities(AuthorityType.USER).size()); + checkAuthorityCollectionSize(3, pubAuthorityService.getAllAuthorities(AuthorityType.USER), AuthorityType.USER); assertEquals(3, pubAuthorityService.getContainingAuthorities(null, "andy", false).size()); assertTrue(pubAuthorityService.getContainingAuthorities(null, "andy", false).contains(auth5)); assertTrue(pubAuthorityService.getContainingAuthorities(null, "andy", false).contains(auth2)); @@ -513,7 +528,7 @@ public class AuthorityServiceTest extends TestCase assertEquals(6, pubAuthorityService.getAllAuthorities(AuthorityType.GROUP).size()); assertEquals(3, pubAuthorityService.getAllRootAuthorities(AuthorityType.GROUP).size()); // The next call looks for people not users :-) - assertEquals(3, pubAuthorityService.getAllAuthorities(AuthorityType.USER).size()); + checkAuthorityCollectionSize(3, pubAuthorityService.getAllAuthorities(AuthorityType.USER), AuthorityType.USER); assertEquals(4, pubAuthorityService.getContainingAuthorities(null, "andy", false).size()); assertTrue(pubAuthorityService.getContainingAuthorities(null, "andy", false).contains(auth5)); assertTrue(pubAuthorityService.getContainingAuthorities(null, "andy", false).contains(auth2)); diff --git a/source/java/org/alfresco/repo/security/person/PersonDaoImpl.java b/source/java/org/alfresco/repo/security/person/PersonDaoImpl.java index 821e7ee65c..e40bd4ad62 100644 --- a/source/java/org/alfresco/repo/security/person/PersonDaoImpl.java +++ b/source/java/org/alfresco/repo/security/person/PersonDaoImpl.java @@ -71,11 +71,12 @@ public class PersonDaoImpl extends HibernateDaoSupport implements PersonDao { public Object doInHibernate(Session session) { - SQLQuery query = getSession().createSQLQuery("SELECT {n.*} FROM alf_node n JOIN alf_node_properties p ON n.id = p.node_id JOIN alf_child_assoc c on c.child_node_id = n.id WHERE c.qname_localname = :userName1 AND p.qname_id = :qnameId AND p.string_value = :userName2"); + SQLQuery query = getSession().createSQLQuery("SELECT {n.*} FROM alf_node n JOIN alf_node_properties p ON n.id = p.node_id JOIN alf_child_assoc c on c.child_node_id = n.id WHERE c.qname_localname = :userName1 AND p.qname_id = :qnameId AND p.string_value = :userName2 and n.node_deleted = :False"); query.addEntity("n", NodeImpl.class); query.setParameter("qnameId", qNameId); query.setParameter("userName1", searchUserName); query.setParameter("userName2", searchUserName); + query.setParameter("False", Boolean.FALSE); return query.list(); } }; @@ -127,9 +128,10 @@ public class PersonDaoImpl extends HibernateDaoSupport implements PersonDao { public Object doInHibernate(Session session) { - SQLQuery query = getSession().createSQLQuery("SELECT {n.*} FROM alf_node n JOIN alf_node_properties p ON n.id = p.node_id WHERE p.qname_id = :qnameId"); + SQLQuery query = getSession().createSQLQuery("SELECT {n.*} FROM alf_node n JOIN alf_node_properties p ON n.id = p.node_id WHERE p.qname_id = :qnameId and n.node_deleted = :False"); query.addEntity("n", NodeImpl.class); query.setParameter("qnameId", qNameId); + query.setParameter("False", Boolean.FALSE); return query.list(); } }; diff --git a/source/java/org/alfresco/util/TestWithUserUtils.java b/source/java/org/alfresco/util/TestWithUserUtils.java index 36f8fb7bbc..6126c76e03 100644 --- a/source/java/org/alfresco/util/TestWithUserUtils.java +++ b/source/java/org/alfresco/util/TestWithUserUtils.java @@ -74,7 +74,7 @@ public abstract class TestWithUserUtils HashMap properties = new HashMap(); properties.put(ContentModel.PROP_USERNAME, userName); - nodeService.createNode(typesNodeRef, children, ContentModel.TYPE_PERSON, container, properties); + nodeService.createNode(typesNodeRef, children, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, userName) , container, properties); // Create the users