mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged DEV/SWIFT to HEAD
26007: ALF-7070: - null property values - mltext properties include locales and values - content properties include locale, encoding, mimetype, size, id - node pre-loading support - wip - paths include direct paths and category paths 26058: ALF-7070 - fixed null content encoding, mimetype 26301: Merged BRANCHES/DEV/BM to BRANCHES/DEV/SWIFT: 24572: WebDAV - switch lock check (to get prop before status) and use getPrimaryParent 24574: WebDAV - getNodeLockInfo (add request caches for indirect lookup) 24833: BM - WebDAV perf tweak (getNodeLockInfo - including PutMethod / checkNode) (note: related to ALF-6267 / ALF-6224) 26319: Removed System.out messages 26320: Moved away from BaseSpringTest 26321: WIP: ALF-7339: RSOLR 009: Index track and build from SOLR - track simple properties (no locale, no dual tokenisation, no sort, no content, no ml text, no acls) 26322: Merged BRANCHES/DEV/BM to BRANCHES/DEV/SWIFT: 24745: (RECORD ONLY) Adjust Audit Model Registry for Subsystem read write locks 24789: (RECORD ONLY) Remove unsafe use of SimpleDateFormat 24862: (RECORD ONLY) Test content read with larger buffer size 26331: Fixed ibatis -> mybatis merge issues 26350: Build fix: iBatis -> myBatis merge error 26354: Removed svn:mergeinfo git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@28257 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -261,6 +261,7 @@
|
|||||||
<property name="nodeDAO" ref="nodeDAO"/>
|
<property name="nodeDAO" ref="nodeDAO"/>
|
||||||
<property name="qNameDAO" ref="qnameDAO"/>
|
<property name="qNameDAO" ref="qnameDAO"/>
|
||||||
<property name="ownableService" ref="ownableService"/>
|
<property name="ownableService" ref="ownableService"/>
|
||||||
|
<property name="tenantService" ref="tenantService"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
|
@@ -604,6 +604,19 @@
|
|||||||
</foreach>
|
</foreach>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="select_NodesByIds" parameterType="NodeBatchLoad" resultMap="result_Node">
|
||||||
|
<include refid="alfresco.node.select_Node_Results"/>
|
||||||
|
from
|
||||||
|
alf_node node
|
||||||
|
join alf_store store on (store.id = node.store_id)
|
||||||
|
join alf_transaction txn on (txn.id = node.transaction_id)
|
||||||
|
where
|
||||||
|
node.id in
|
||||||
|
<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
|
|
||||||
<sql id="select_NodeProperty_Results">
|
<sql id="select_NodeProperty_Results">
|
||||||
select
|
select
|
||||||
prop.node_id as node_id,
|
prop.node_id as node_id,
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
version.major=4
|
version.major=4
|
||||||
version.minor=0
|
version.minor=0
|
||||||
version.revision=0
|
version.revision=0
|
||||||
version.label=a
|
version.label=unstable
|
||||||
|
|
||||||
# Edition label
|
# Edition label
|
||||||
|
|
||||||
|
@@ -25,6 +25,10 @@ import java.util.Locale;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.transaction.UserTransaction;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.action.evaluator.NoConditionEvaluator;
|
import org.alfresco.repo.action.evaluator.NoConditionEvaluator;
|
||||||
import org.alfresco.repo.action.executer.AddFeaturesActionExecuter;
|
import org.alfresco.repo.action.executer.AddFeaturesActionExecuter;
|
||||||
@@ -40,8 +44,9 @@ import org.alfresco.repo.dictionary.M2Type;
|
|||||||
import org.alfresco.repo.rule.RuleModel;
|
import org.alfresco.repo.rule.RuleModel;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
|
||||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||||
|
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||||
|
import org.alfresco.service.ServiceRegistry;
|
||||||
import org.alfresco.service.cmr.action.Action;
|
import org.alfresco.service.cmr.action.Action;
|
||||||
import org.alfresco.service.cmr.action.ActionCondition;
|
import org.alfresco.service.cmr.action.ActionCondition;
|
||||||
import org.alfresco.service.cmr.action.ActionService;
|
import org.alfresco.service.cmr.action.ActionService;
|
||||||
@@ -67,20 +72,26 @@ import org.alfresco.service.cmr.security.PersonService;
|
|||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||||
import org.alfresco.util.BaseSpringTest;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
|
import org.alfresco.util.ApplicationContextHelper;
|
||||||
import org.alfresco.util.PropertyMap;
|
import org.alfresco.util.PropertyMap;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.extensions.surf.util.I18NUtil;
|
import org.springframework.extensions.surf.util.I18NUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit tests for copy service
|
* Unit tests for copy service
|
||||||
*
|
*
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
|
* @author Derek Hulley
|
||||||
*/
|
*/
|
||||||
public class CopyServiceImplTest extends BaseSpringTest
|
public class CopyServiceImplTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
||||||
|
|
||||||
|
/*
|
||||||
* Services used by the tests
|
* Services used by the tests
|
||||||
*/
|
*/
|
||||||
|
private TransactionService transactionService;
|
||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
private NodeService publicNodeService;
|
private NodeService publicNodeService;
|
||||||
private CopyService copyService;
|
private CopyService copyService;
|
||||||
@@ -93,9 +104,10 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
private AuthenticationComponent authenticationComponent;
|
private AuthenticationComponent authenticationComponent;
|
||||||
private MutableAuthenticationService authenticationService;
|
private MutableAuthenticationService authenticationService;
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Data used by the tests
|
* Data used by the tests
|
||||||
*/
|
*/
|
||||||
|
private UserTransaction txn;
|
||||||
private StoreRef storeRef;
|
private StoreRef storeRef;
|
||||||
private NodeRef sourceNodeRef;
|
private NodeRef sourceNodeRef;
|
||||||
private NodeRef rootNodeRef;
|
private NodeRef rootNodeRef;
|
||||||
@@ -104,7 +116,7 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
private NodeRef childNodeRef;
|
private NodeRef childNodeRef;
|
||||||
private NodeRef destinationNodeRef;
|
private NodeRef destinationNodeRef;
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Types and properties used by the tests
|
* Types and properties used by the tests
|
||||||
*/
|
*/
|
||||||
private static final String TEST_TYPE_NAMESPACE = "testTypeNamespaceURI";
|
private static final String TEST_TYPE_NAMESPACE = "testTypeNamespaceURI";
|
||||||
@@ -145,52 +157,50 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
*/
|
*/
|
||||||
private static final String SOME_CONTENT = "This is some content ...";
|
private static final String SOME_CONTENT = "This is some content ...";
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the meta model DAO
|
|
||||||
*
|
|
||||||
* @param dictionaryDAO the meta model DAO
|
|
||||||
*/
|
|
||||||
public void setDictionaryDAO(DictionaryDAO dictionaryDAO)
|
|
||||||
{
|
|
||||||
this.dictionaryDAO = dictionaryDAO;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* On setup in transaction implementation
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected void onSetUpInTransaction()
|
protected void setUp() throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
// Set the services
|
if (AlfrescoTransactionSupport.isActualTransactionActive())
|
||||||
this.nodeService = (NodeService)this.applicationContext.getBean("dbNodeService");
|
{
|
||||||
this.publicNodeService = (NodeService)this.applicationContext.getBean("NodeService");
|
fail("Test started with transaction in progress");
|
||||||
this.copyService = (CopyService)this.applicationContext.getBean("copyService");
|
}
|
||||||
this.contentService = (ContentService)this.applicationContext.getBean("contentService");
|
|
||||||
this.ruleService = (RuleService)this.applicationContext.getBean("ruleService");
|
|
||||||
this.actionService = (ActionService)this.applicationContext.getBean("actionService");
|
|
||||||
this.permissionService = (PermissionService)this.applicationContext.getBean("PermissionService");
|
|
||||||
this.personService = (PersonService)this.applicationContext.getBean("PersonService");
|
|
||||||
this.authenticationComponent = (AuthenticationComponent)this.applicationContext.getBean("authenticationComponent");
|
|
||||||
this.authenticationService = (MutableAuthenticationService) this.applicationContext.getBean("authenticationService");
|
|
||||||
|
|
||||||
this.authenticationComponent.setSystemUserAsCurrentUser();
|
ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
|
||||||
|
// Set the services
|
||||||
|
transactionService = serviceRegistry.getTransactionService();
|
||||||
|
nodeService = (NodeService) ctx.getBean("dbNodeService");
|
||||||
|
publicNodeService = serviceRegistry.getNodeService();
|
||||||
|
copyService = (CopyService) ctx.getBean("copyService");
|
||||||
|
contentService = (ContentService) ctx.getBean("contentService");
|
||||||
|
ruleService = (RuleService) ctx.getBean("ruleService");
|
||||||
|
actionService = (ActionService)ctx.getBean("actionService");
|
||||||
|
permissionService = (PermissionService)ctx.getBean("PermissionService");
|
||||||
|
personService = serviceRegistry.getPersonService();
|
||||||
|
authenticationComponent = (AuthenticationComponent)ctx.getBean("authenticationComponent");
|
||||||
|
authenticationService = (MutableAuthenticationService) ctx.getBean("authenticationService");
|
||||||
|
dictionaryDAO = (DictionaryDAO) ctx.getBean("dictionaryDAO");
|
||||||
|
|
||||||
|
authenticationComponent.setSystemUserAsCurrentUser();
|
||||||
|
|
||||||
|
// Ensure that a transaction is present
|
||||||
|
txn = transactionService.getUserTransaction();
|
||||||
|
txn.begin();
|
||||||
|
|
||||||
// Create the test model
|
// Create the test model
|
||||||
createTestModel();
|
createTestModel();
|
||||||
|
|
||||||
// Create the store and get the root node reference
|
// Create the store and get the root node reference
|
||||||
this.storeRef = this.nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis());
|
storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis());
|
||||||
this.rootNodeRef = this.nodeService.getRootNode(storeRef);
|
rootNodeRef = nodeService.getRootNode(storeRef);
|
||||||
|
|
||||||
// Create the node used for copying
|
// Create the node used for copying
|
||||||
ChildAssociationRef childAssocRef = this.nodeService.createNode(
|
ChildAssociationRef childAssocRef = nodeService.createNode(
|
||||||
rootNodeRef,
|
rootNodeRef,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
QName.createQName("{test}test"),
|
QName.createQName("{test}test"),
|
||||||
TEST_TYPE_QNAME,
|
TEST_TYPE_QNAME,
|
||||||
createTypePropertyBag());
|
createTypePropertyBag());
|
||||||
this.sourceNodeRef = childAssocRef.getChildRef();
|
sourceNodeRef = childAssocRef.getChildRef();
|
||||||
|
|
||||||
// Create another bag of properties
|
// Create another bag of properties
|
||||||
Map<QName, Serializable> aspectProperties = new HashMap<QName, Serializable>();
|
Map<QName, Serializable> aspectProperties = new HashMap<QName, Serializable>();
|
||||||
@@ -198,59 +208,59 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
aspectProperties.put(PROP4_QNAME_OPTIONAL, TEST_VALUE_2);
|
aspectProperties.put(PROP4_QNAME_OPTIONAL, TEST_VALUE_2);
|
||||||
|
|
||||||
// Apply the test aspect
|
// Apply the test aspect
|
||||||
this.nodeService.addAspect(
|
nodeService.addAspect(
|
||||||
this.sourceNodeRef,
|
sourceNodeRef,
|
||||||
TEST_ASPECT_QNAME,
|
TEST_ASPECT_QNAME,
|
||||||
aspectProperties);
|
aspectProperties);
|
||||||
|
|
||||||
this.nodeService.addAspect(sourceNodeRef, ContentModel.ASPECT_TITLED, null);
|
nodeService.addAspect(sourceNodeRef, ContentModel.ASPECT_TITLED, null);
|
||||||
|
|
||||||
// Add a child
|
// Add a child
|
||||||
ChildAssociationRef temp3 =this.nodeService.createNode(
|
ChildAssociationRef temp3 =nodeService.createNode(
|
||||||
this.sourceNodeRef,
|
sourceNodeRef,
|
||||||
TEST_CHILD_ASSOC_TYPE_QNAME,
|
TEST_CHILD_ASSOC_TYPE_QNAME,
|
||||||
TEST_CHILD_ASSOC_QNAME,
|
TEST_CHILD_ASSOC_QNAME,
|
||||||
TEST_TYPE_QNAME,
|
TEST_TYPE_QNAME,
|
||||||
createTypePropertyBag());
|
createTypePropertyBag());
|
||||||
this.childNodeRef = temp3.getChildRef();
|
childNodeRef = temp3.getChildRef();
|
||||||
|
|
||||||
// Add a child that is primary
|
// Add a child that is primary
|
||||||
ChildAssociationRef temp2 = this.nodeService.createNode(
|
ChildAssociationRef temp2 = nodeService.createNode(
|
||||||
rootNodeRef,
|
rootNodeRef,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
QName.createQName("{test}testNonPrimaryChild"),
|
QName.createQName("{test}testNonPrimaryChild"),
|
||||||
TEST_TYPE_QNAME,
|
TEST_TYPE_QNAME,
|
||||||
createTypePropertyBag());
|
createTypePropertyBag());
|
||||||
|
|
||||||
this.nonPrimaryChildNodeRef = temp2.getChildRef();
|
nonPrimaryChildNodeRef = temp2.getChildRef();
|
||||||
this.nodeService.addChild(
|
nodeService.addChild(
|
||||||
this.sourceNodeRef,
|
sourceNodeRef,
|
||||||
this.nonPrimaryChildNodeRef,
|
nonPrimaryChildNodeRef,
|
||||||
TEST_CHILD_ASSOC_TYPE_QNAME,
|
TEST_CHILD_ASSOC_TYPE_QNAME,
|
||||||
TEST_CHILD_ASSOC_QNAME2);
|
TEST_CHILD_ASSOC_QNAME2);
|
||||||
|
|
||||||
// Add a target assoc
|
// Add a target assoc
|
||||||
ChildAssociationRef temp = this.nodeService.createNode(
|
ChildAssociationRef temp = nodeService.createNode(
|
||||||
rootNodeRef,
|
rootNodeRef,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
QName.createQName("{test}testAssoc"),
|
QName.createQName("{test}testAssoc"),
|
||||||
TEST_TYPE_QNAME,
|
TEST_TYPE_QNAME,
|
||||||
createTypePropertyBag());
|
createTypePropertyBag());
|
||||||
this.targetNodeRef = temp.getChildRef();
|
targetNodeRef = temp.getChildRef();
|
||||||
this.nodeService.createAssociation(this.sourceNodeRef, this.targetNodeRef, TEST_ASSOC_TYPE_QNAME);
|
nodeService.createAssociation(sourceNodeRef, targetNodeRef, TEST_ASSOC_TYPE_QNAME);
|
||||||
|
|
||||||
// Create a node we can use as the destination in a copy
|
// Create a node we can use as the destination in a copy
|
||||||
Map<QName, Serializable> destinationProps = new HashMap<QName, Serializable>();
|
Map<QName, Serializable> destinationProps = new HashMap<QName, Serializable>();
|
||||||
destinationProps.put(PROP1_QNAME_MANDATORY, TEST_VALUE_1);
|
destinationProps.put(PROP1_QNAME_MANDATORY, TEST_VALUE_1);
|
||||||
destinationProps.put(PROP5_QNAME_MANDATORY, TEST_VALUE_3);
|
destinationProps.put(PROP5_QNAME_MANDATORY, TEST_VALUE_3);
|
||||||
destinationProps.put(ContentModel.PROP_CONTENT, CONTENT_DATA_TEXT);
|
destinationProps.put(ContentModel.PROP_CONTENT, CONTENT_DATA_TEXT);
|
||||||
ChildAssociationRef temp5 = this.nodeService.createNode(
|
ChildAssociationRef temp5 = nodeService.createNode(
|
||||||
this.rootNodeRef,
|
rootNodeRef,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
QName.createQName("{test}testDestinationNode"),
|
QName.createQName("{test}testDestinationNode"),
|
||||||
TEST_TYPE_QNAME,
|
TEST_TYPE_QNAME,
|
||||||
destinationProps);
|
destinationProps);
|
||||||
this.destinationNodeRef = temp5.getChildRef();
|
destinationNodeRef = temp5.getChildRef();
|
||||||
|
|
||||||
// Create two users, for use as part of
|
// Create two users, for use as part of
|
||||||
// the permission related tests
|
// the permission related tests
|
||||||
@@ -277,10 +287,13 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onTearDownInTransaction() throws Exception
|
protected void tearDown() throws Exception
|
||||||
{
|
{
|
||||||
|
if (txn != null)
|
||||||
|
{
|
||||||
|
try { txn.rollback(); } catch (Throwable e) {}
|
||||||
|
}
|
||||||
authenticationComponent.clearCurrentSecurityContext();
|
authenticationComponent.clearCurrentSecurityContext();
|
||||||
super.onTearDownInTransaction();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -370,9 +383,9 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
permissionService.setPermission(rootNodeRef, AuthenticationUtil.getGuestUserName(), PermissionService.CREATE_CHILDREN, true);
|
permissionService.setPermission(rootNodeRef, AuthenticationUtil.getGuestUserName(), PermissionService.CREATE_CHILDREN, true);
|
||||||
assertEquals(3, permissionService.getAllSetPermissions(sourceNodeRef).size());
|
assertEquals(3, permissionService.getAllSetPermissions(sourceNodeRef).size());
|
||||||
|
|
||||||
NodeRef copy = this.copyService.copy(
|
NodeRef copy = copyService.copy(
|
||||||
this.sourceNodeRef,
|
sourceNodeRef,
|
||||||
this.rootNodeRef,
|
rootNodeRef,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
QName.createQName("{test}aclCopyOne"));
|
QName.createQName("{test}aclCopyOne"));
|
||||||
|
|
||||||
@@ -380,7 +393,7 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
|
|
||||||
// Admin
|
// Admin
|
||||||
|
|
||||||
this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
|
authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
|
||||||
|
|
||||||
copy = copyService.copy(
|
copy = copyService.copy(
|
||||||
sourceNodeRef,
|
sourceNodeRef,
|
||||||
@@ -392,7 +405,7 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
|
|
||||||
// guest
|
// guest
|
||||||
|
|
||||||
this.authenticationComponent.setCurrentUser(AuthenticationUtil.getGuestUserName());
|
authenticationComponent.setCurrentUser(AuthenticationUtil.getGuestUserName());
|
||||||
|
|
||||||
copy = copyService.copy(
|
copy = copyService.copy(
|
||||||
sourceNodeRef,
|
sourceNodeRef,
|
||||||
@@ -403,9 +416,9 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
|
|
||||||
// guest with read permissions - write from ownership
|
// guest with read permissions - write from ownership
|
||||||
|
|
||||||
this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
|
authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
|
||||||
permissionService.setPermission(sourceNodeRef, AuthenticationUtil.getGuestUserName(), PermissionService.READ_PERMISSIONS, true);
|
permissionService.setPermission(sourceNodeRef, AuthenticationUtil.getGuestUserName(), PermissionService.READ_PERMISSIONS, true);
|
||||||
this.authenticationComponent.setCurrentUser(AuthenticationUtil.getGuestUserName());
|
authenticationComponent.setCurrentUser(AuthenticationUtil.getGuestUserName());
|
||||||
|
|
||||||
copy = copyService.copy(
|
copy = copyService.copy(
|
||||||
sourceNodeRef,
|
sourceNodeRef,
|
||||||
@@ -417,9 +430,9 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
|
|
||||||
// guest with read and write
|
// guest with read and write
|
||||||
|
|
||||||
this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
|
authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
|
||||||
permissionService.setPermission(rootNodeRef, AuthenticationUtil.getGuestUserName(), PermissionService.CHANGE_PERMISSIONS, true);
|
permissionService.setPermission(rootNodeRef, AuthenticationUtil.getGuestUserName(), PermissionService.CHANGE_PERMISSIONS, true);
|
||||||
this.authenticationComponent.setCurrentUser(AuthenticationUtil.getGuestUserName());
|
authenticationComponent.setCurrentUser(AuthenticationUtil.getGuestUserName());
|
||||||
|
|
||||||
copy = copyService.copy(
|
copy = copyService.copy(
|
||||||
sourceNodeRef,
|
sourceNodeRef,
|
||||||
@@ -431,9 +444,9 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
|
|
||||||
// guest with write but not read
|
// guest with write but not read
|
||||||
|
|
||||||
this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
|
authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
|
||||||
permissionService.setPermission(sourceNodeRef, AuthenticationUtil.getGuestUserName(), PermissionService.READ_PERMISSIONS, false);
|
permissionService.setPermission(sourceNodeRef, AuthenticationUtil.getGuestUserName(), PermissionService.READ_PERMISSIONS, false);
|
||||||
this.authenticationComponent.setCurrentUser(AuthenticationUtil.getGuestUserName());
|
authenticationComponent.setCurrentUser(AuthenticationUtil.getGuestUserName());
|
||||||
|
|
||||||
copy = copyService.copy(
|
copy = copyService.copy(
|
||||||
sourceNodeRef,
|
sourceNodeRef,
|
||||||
@@ -443,9 +456,9 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
|
|
||||||
assertEquals(3, permissionService.getAllSetPermissions(copy).size());
|
assertEquals(3, permissionService.getAllSetPermissions(copy).size());
|
||||||
|
|
||||||
this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
|
authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
|
||||||
permissionService.deletePermission(sourceNodeRef, AuthenticationUtil.getGuestUserName(), PermissionService.READ_PERMISSIONS);
|
permissionService.deletePermission(sourceNodeRef, AuthenticationUtil.getGuestUserName(), PermissionService.READ_PERMISSIONS);
|
||||||
this.authenticationComponent.setCurrentUser(AuthenticationUtil.getGuestUserName());
|
authenticationComponent.setCurrentUser(AuthenticationUtil.getGuestUserName());
|
||||||
|
|
||||||
copy = copyService.copy(
|
copy = copyService.copy(
|
||||||
sourceNodeRef,
|
sourceNodeRef,
|
||||||
@@ -466,37 +479,37 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
public void testCopyToNewNode()
|
public void testCopyToNewNode()
|
||||||
{
|
{
|
||||||
// Check that the node has no copies
|
// Check that the node has no copies
|
||||||
List<NodeRef> copies = this.copyService.getCopies(this.sourceNodeRef);
|
List<NodeRef> copies = copyService.getCopies(sourceNodeRef);
|
||||||
assertNotNull(copies);
|
assertNotNull(copies);
|
||||||
assertTrue(copies.isEmpty());
|
assertTrue(copies.isEmpty());
|
||||||
|
|
||||||
// Copy to new node without copying children
|
// Copy to new node without copying children
|
||||||
NodeRef copy = this.copyService.copy(
|
NodeRef copy = copyService.copy(
|
||||||
this.sourceNodeRef,
|
sourceNodeRef,
|
||||||
this.rootNodeRef,
|
rootNodeRef,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
QName.createQName("{test}copyAssoc"));
|
QName.createQName("{test}copyAssoc"));
|
||||||
checkCopiedNode(this.sourceNodeRef, copy, true, true, false);
|
checkCopiedNode(sourceNodeRef, copy, true, true, false);
|
||||||
List<NodeRef> copies2 = this.copyService.getCopies(this.sourceNodeRef);
|
List<NodeRef> copies2 = copyService.getCopies(sourceNodeRef);
|
||||||
assertNotNull(copies2);
|
assertNotNull(copies2);
|
||||||
assertEquals(1, copies2.size());
|
assertEquals(1, copies2.size());
|
||||||
|
|
||||||
// Copy to new node, copying children
|
// Copy to new node, copying children
|
||||||
NodeRef copy2 = this.copyService.copy(
|
NodeRef copy2 = copyService.copy(
|
||||||
this.sourceNodeRef,
|
sourceNodeRef,
|
||||||
this.rootNodeRef,
|
rootNodeRef,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
QName.createQName("{test}copyAssoc2"),
|
QName.createQName("{test}copyAssoc2"),
|
||||||
true);
|
true);
|
||||||
checkCopiedNode(this.sourceNodeRef, copy2, true, true, true);
|
checkCopiedNode(sourceNodeRef, copy2, true, true, true);
|
||||||
List<NodeRef> copies3 = this.copyService.getCopies(this.sourceNodeRef);
|
List<NodeRef> copies3 = copyService.getCopies(sourceNodeRef);
|
||||||
assertNotNull(copies3);
|
assertNotNull(copies3);
|
||||||
assertEquals(2, copies3.size());
|
assertEquals(2, copies3.size());
|
||||||
|
|
||||||
// Check that a copy of a copy works correctly
|
// Check that a copy of a copy works correctly
|
||||||
NodeRef copyOfCopy = this.copyService.copy(
|
NodeRef copyOfCopy = copyService.copy(
|
||||||
copy,
|
copy,
|
||||||
this.rootNodeRef,
|
rootNodeRef,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
QName.createQName("{test}copyOfCopy"));
|
QName.createQName("{test}copyOfCopy"));
|
||||||
checkCopiedNode(copy, copyOfCopy, true, true, false);
|
checkCopiedNode(copy, copyOfCopy, true, true, false);
|
||||||
@@ -505,22 +518,22 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
// TODO check copying from a lockable copy
|
// TODO check copying from a lockable copy
|
||||||
|
|
||||||
// Check copying from a node with content
|
// Check copying from a node with content
|
||||||
ContentWriter contentWriter = this.contentService.getWriter(this.sourceNodeRef, ContentModel.PROP_CONTENT, true);
|
ContentWriter contentWriter = contentService.getWriter(sourceNodeRef, ContentModel.PROP_CONTENT, true);
|
||||||
contentWriter.putContent(SOME_CONTENT);
|
contentWriter.putContent(SOME_CONTENT);
|
||||||
NodeRef copyWithContent = this.copyService.copy(
|
NodeRef copyWithContent = copyService.copy(
|
||||||
this.sourceNodeRef,
|
sourceNodeRef,
|
||||||
this.rootNodeRef,
|
rootNodeRef,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
QName.createQName("{test}copyWithContent"));
|
QName.createQName("{test}copyWithContent"));
|
||||||
checkCopiedNode(this.sourceNodeRef, copyWithContent, true, true, false);
|
checkCopiedNode(sourceNodeRef, copyWithContent, true, true, false);
|
||||||
ContentReader contentReader = this.contentService.getReader(copyWithContent, ContentModel.PROP_CONTENT);
|
ContentReader contentReader = contentService.getReader(copyWithContent, ContentModel.PROP_CONTENT);
|
||||||
assertNotNull(contentReader);
|
assertNotNull(contentReader);
|
||||||
assertEquals(SOME_CONTENT, contentReader.getContentString());
|
assertEquals(SOME_CONTENT, contentReader.getContentString());
|
||||||
|
|
||||||
// TODO check copying to a different store
|
// TODO check copying to a different store
|
||||||
|
|
||||||
//System.out.println(
|
//System.out.println(
|
||||||
// NodeStoreInspector.dumpNodeStore(this.nodeService, this.storeRef));
|
// NodeStoreInspector.dumpNodeStore(nodeService, storeRef));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCopyNodeWithRules()
|
public void testCopyNodeWithRules()
|
||||||
@@ -531,38 +544,38 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
|
|
||||||
Map<String, Serializable> props = new HashMap<String, Serializable>(1);
|
Map<String, Serializable> props = new HashMap<String, Serializable>(1);
|
||||||
props.put(AddFeaturesActionExecuter.PARAM_ASPECT_NAME, ContentModel.ASPECT_VERSIONABLE);
|
props.put(AddFeaturesActionExecuter.PARAM_ASPECT_NAME, ContentModel.ASPECT_VERSIONABLE);
|
||||||
Action action = this.actionService.createAction(AddFeaturesActionExecuter.NAME, props);
|
Action action = actionService.createAction(AddFeaturesActionExecuter.NAME, props);
|
||||||
rule.setAction(action);
|
rule.setAction(action);
|
||||||
|
|
||||||
ActionCondition actionCondition = this.actionService.createActionCondition(NoConditionEvaluator.NAME);
|
ActionCondition actionCondition = actionService.createActionCondition(NoConditionEvaluator.NAME);
|
||||||
action.addActionCondition(actionCondition);
|
action.addActionCondition(actionCondition);
|
||||||
|
|
||||||
this.ruleService.saveRule(this.sourceNodeRef, rule);
|
ruleService.saveRule(sourceNodeRef, rule);
|
||||||
assertNotNull(rule.getNodeRef());
|
assertNotNull(rule.getNodeRef());
|
||||||
assertEquals(this.sourceNodeRef, this.ruleService.getOwningNodeRef(rule));
|
assertEquals(sourceNodeRef, ruleService.getOwningNodeRef(rule));
|
||||||
|
|
||||||
//System.out.println(
|
//System.out.println(
|
||||||
// NodeStoreInspector.dumpNodeStore(this.nodeService, this.storeRef));
|
// NodeStoreInspector.dumpNodeStore(nodeService, storeRef));
|
||||||
//System.out.println(" ------------------------------ ");
|
//System.out.println(" ------------------------------ ");
|
||||||
|
|
||||||
// Now copy the node that has rules associated with it
|
// Now copy the node that has rules associated with it
|
||||||
NodeRef copy = this.copyService.copy(
|
NodeRef copy = copyService.copy(
|
||||||
this.sourceNodeRef,
|
sourceNodeRef,
|
||||||
this.rootNodeRef,
|
rootNodeRef,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
QName.createQName("{test}withRulesCopy"),
|
QName.createQName("{test}withRulesCopy"),
|
||||||
true);
|
true);
|
||||||
|
|
||||||
//System.out.println(
|
//System.out.println(
|
||||||
// NodeStoreInspector.dumpNodeStore(this.nodeService, this.storeRef));
|
// NodeStoreInspector.dumpNodeStore(nodeService, storeRef));
|
||||||
|
|
||||||
checkCopiedNode(this.sourceNodeRef, copy, true, true, true);
|
checkCopiedNode(sourceNodeRef, copy, true, true, true);
|
||||||
|
|
||||||
assertTrue(this.nodeService.hasAspect(copy, RuleModel.ASPECT_RULES));
|
assertTrue(nodeService.hasAspect(copy, RuleModel.ASPECT_RULES));
|
||||||
assertTrue(this.ruleService.hasRules(copy));
|
assertTrue(ruleService.hasRules(copy));
|
||||||
assertTrue(this.ruleService.rulesEnabled(copy));
|
assertTrue(ruleService.rulesEnabled(copy));
|
||||||
|
|
||||||
List<Rule> copiedRules = this.ruleService.getRules(copy);
|
List<Rule> copiedRules = ruleService.getRules(copy);
|
||||||
assertEquals(1, copiedRules.size());
|
assertEquals(1, copiedRules.size());
|
||||||
Rule copiedRule = copiedRules.get(0);
|
Rule copiedRule = copiedRules.get(0);
|
||||||
|
|
||||||
@@ -570,44 +583,44 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
assertFalse(copiedRule.getNodeRef().equals(rule.getNodeRef()));
|
assertFalse(copiedRule.getNodeRef().equals(rule.getNodeRef()));
|
||||||
assertEquals(rule.getTitle(), copiedRule.getTitle());
|
assertEquals(rule.getTitle(), copiedRule.getTitle());
|
||||||
assertEquals(rule.getDescription(), copiedRule.getDescription());
|
assertEquals(rule.getDescription(), copiedRule.getDescription());
|
||||||
assertEquals(copy, this.ruleService.getOwningNodeRef(copiedRule));
|
assertEquals(copy, ruleService.getOwningNodeRef(copiedRule));
|
||||||
assertEquals(rule.getAction().getActionDefinitionName(), copiedRule.getAction().getActionDefinitionName());
|
assertEquals(rule.getAction().getActionDefinitionName(), copiedRule.getAction().getActionDefinitionName());
|
||||||
|
|
||||||
// Now copy the node without copying the children and check that the rules have been copied
|
// Now copy the node without copying the children and check that the rules have been copied
|
||||||
NodeRef copy2 = this.copyService.copy(
|
NodeRef copy2 = copyService.copy(
|
||||||
this.sourceNodeRef,
|
sourceNodeRef,
|
||||||
this.rootNodeRef,
|
rootNodeRef,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
QName.createQName("{test}withRuleCopyNoChildren"),
|
QName.createQName("{test}withRuleCopyNoChildren"),
|
||||||
false);
|
false);
|
||||||
|
|
||||||
// System.out.println(
|
// System.out.println(
|
||||||
// NodeStoreInspector.dumpNodeStore(this.nodeService, this.storeRef));
|
// NodeStoreInspector.dumpNodeStore(nodeService, storeRef));
|
||||||
|
|
||||||
checkCopiedNode(this.sourceNodeRef, copy2, true, true, false);
|
checkCopiedNode(sourceNodeRef, copy2, true, true, false);
|
||||||
|
|
||||||
//assertTrue(this.configurableService.isConfigurable(copy2));
|
//assertTrue(configurableService.isConfigurable(copy2));
|
||||||
//assertNotNull(this.configurableService.getConfigurationFolder(copy2));
|
//assertNotNull(configurableService.getConfigurationFolder(copy2));
|
||||||
//assertFalse(this.configurableService.getConfigurationFolder(this.sourceNodeRef) == this.configurableService.getConfigurationFolder(copy2));
|
//assertFalse(configurableService.getConfigurationFolder(sourceNodeRef) == configurableService.getConfigurationFolder(copy2));
|
||||||
|
|
||||||
assertTrue(this.nodeService.hasAspect(copy2, RuleModel.ASPECT_RULES));
|
assertTrue(nodeService.hasAspect(copy2, RuleModel.ASPECT_RULES));
|
||||||
assertTrue(this.ruleService.hasRules(copy2));
|
assertTrue(ruleService.hasRules(copy2));
|
||||||
assertTrue(this.ruleService.rulesEnabled(copy2));
|
assertTrue(ruleService.rulesEnabled(copy2));
|
||||||
List<Rule> copiedRules2 = this.ruleService.getRules(copy2);
|
List<Rule> copiedRules2 = ruleService.getRules(copy2);
|
||||||
assertEquals(1, copiedRules.size());
|
assertEquals(1, copiedRules.size());
|
||||||
Rule copiedRule2 = copiedRules2.get(0);
|
Rule copiedRule2 = copiedRules2.get(0);
|
||||||
assertFalse(rule.getNodeRef().equals(copiedRule2.getNodeRef()));
|
assertFalse(rule.getNodeRef().equals(copiedRule2.getNodeRef()));
|
||||||
assertEquals(rule.getTitle(), copiedRule2.getTitle());
|
assertEquals(rule.getTitle(), copiedRule2.getTitle());
|
||||||
assertEquals(rule.getDescription(), copiedRule2.getDescription());
|
assertEquals(rule.getDescription(), copiedRule2.getDescription());
|
||||||
assertEquals(this.ruleService.getOwningNodeRef(copiedRule2), copy2);
|
assertEquals(ruleService.getOwningNodeRef(copiedRule2), copy2);
|
||||||
assertEquals(rule.getAction().getActionDefinitionName(), copiedRule2.getAction().getActionDefinitionName());
|
assertEquals(rule.getAction().getActionDefinitionName(), copiedRule2.getAction().getActionDefinitionName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCopyToExistingNode()
|
public void testCopyToExistingNode()
|
||||||
{
|
{
|
||||||
// Copy nodes within the same store
|
// Copy nodes within the same store
|
||||||
this.copyService.copy(this.sourceNodeRef, this.destinationNodeRef);
|
copyService.copy(sourceNodeRef, destinationNodeRef);
|
||||||
checkCopiedNode(this.sourceNodeRef, this.destinationNodeRef, false, true, true);
|
checkCopiedNode(sourceNodeRef, destinationNodeRef, false, true, true);
|
||||||
|
|
||||||
// TODO check copying from a copy
|
// TODO check copying from a copy
|
||||||
// TODO check copying from a versioned copy
|
// TODO check copying from a versioned copy
|
||||||
@@ -617,7 +630,7 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
// TODO check copying nodes between stores
|
// TODO check copying nodes between stores
|
||||||
|
|
||||||
//System.out.println(
|
//System.out.println(
|
||||||
// NodeStoreInspector.dumpNodeStore(this.nodeService, this.storeRef));
|
// NodeStoreInspector.dumpNodeStore(nodeService, storeRef));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -628,21 +641,21 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
PropertyMap props = new PropertyMap();
|
PropertyMap props = new PropertyMap();
|
||||||
// Need to create a potentially recursive node structure
|
// Need to create a potentially recursive node structure
|
||||||
props.put(ContentModel.PROP_NODE_UUID, "nodeOne");
|
props.put(ContentModel.PROP_NODE_UUID, "nodeOne");
|
||||||
NodeRef nodeOne = this.nodeService.createNode(
|
NodeRef nodeOne = nodeService.createNode(
|
||||||
this.rootNodeRef,
|
rootNodeRef,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
ContentModel.TYPE_CONTAINER,
|
ContentModel.TYPE_CONTAINER,
|
||||||
props).getChildRef();
|
props).getChildRef();
|
||||||
props.put(ContentModel.PROP_NODE_UUID, "nodeTwo");
|
props.put(ContentModel.PROP_NODE_UUID, "nodeTwo");
|
||||||
NodeRef nodeTwo = this.nodeService.createNode(
|
NodeRef nodeTwo = nodeService.createNode(
|
||||||
nodeOne,
|
nodeOne,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
ContentModel.TYPE_CONTAINER,
|
ContentModel.TYPE_CONTAINER,
|
||||||
props).getChildRef();
|
props).getChildRef();
|
||||||
props.put(ContentModel.PROP_NODE_UUID, "nodeThree");
|
props.put(ContentModel.PROP_NODE_UUID, "nodeThree");
|
||||||
NodeRef nodeThree = this.nodeService.createNode(
|
NodeRef nodeThree = nodeService.createNode(
|
||||||
nodeTwo,
|
nodeTwo,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
@@ -650,23 +663,23 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
props).getChildRef();
|
props).getChildRef();
|
||||||
|
|
||||||
// Issue a potentialy recursive copy
|
// Issue a potentialy recursive copy
|
||||||
this.copyService.copy(nodeOne, nodeThree, ContentModel.ASSOC_CHILDREN, ContentModel.ASSOC_CHILDREN, true);
|
copyService.copy(nodeOne, nodeThree, ContentModel.ASSOC_CHILDREN, ContentModel.ASSOC_CHILDREN, true);
|
||||||
|
|
||||||
//System.out.println(
|
//System.out.println(
|
||||||
// NodeStoreInspector.dumpNodeStore(this.nodeService, this.storeRef));
|
// NodeStoreInspector.dumpNodeStore(nodeService, storeRef));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCopyResidualProperties() throws Exception
|
public void testCopyResidualProperties() throws Exception
|
||||||
{
|
{
|
||||||
QName nodeOneAssocName = QName.createQName("{test}nodeOne");
|
QName nodeOneAssocName = QName.createQName("{test}nodeOne");
|
||||||
|
|
||||||
NodeRef nodeOne = this.nodeService.createNode(
|
NodeRef nodeOne = nodeService.createNode(
|
||||||
this.rootNodeRef,
|
rootNodeRef,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
nodeOneAssocName,
|
nodeOneAssocName,
|
||||||
TEST_TYPE_QNAME).getChildRef();
|
TEST_TYPE_QNAME).getChildRef();
|
||||||
this.nodeService.setProperty(nodeOne, PROP_QNAME_RESIDUAL_NODE_REF, nodeOne);
|
nodeService.setProperty(nodeOne, PROP_QNAME_RESIDUAL_NODE_REF, nodeOne);
|
||||||
this.nodeService.setProperty(nodeOne, PROP_QNAME_RESIDUAL_ANY, nodeOne);
|
nodeService.setProperty(nodeOne, PROP_QNAME_RESIDUAL_ANY, nodeOne);
|
||||||
NodeRef nodeOneCopy = copyService.copy(
|
NodeRef nodeOneCopy = copyService.copy(
|
||||||
nodeOne,
|
nodeOne,
|
||||||
rootNodeRef,
|
rootNodeRef,
|
||||||
@@ -692,56 +705,56 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
QName nodeThreeAssocName = QName.createQName("{test}nodeThree");
|
QName nodeThreeAssocName = QName.createQName("{test}nodeThree");
|
||||||
QName nodeFourAssocName = QName.createQName("{test}nodeFour");
|
QName nodeFourAssocName = QName.createQName("{test}nodeFour");
|
||||||
|
|
||||||
NodeRef nodeNotCopied = this.nodeService.createNode(
|
NodeRef nodeNotCopied = nodeService.createNode(
|
||||||
this.rootNodeRef,
|
rootNodeRef,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
nodeOneAssocName,
|
nodeOneAssocName,
|
||||||
TEST_TYPE_QNAME).getChildRef();
|
TEST_TYPE_QNAME).getChildRef();
|
||||||
NodeRef nodeOne = this.nodeService.createNode(
|
NodeRef nodeOne = nodeService.createNode(
|
||||||
this.rootNodeRef,
|
rootNodeRef,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
nodeOneAssocName,
|
nodeOneAssocName,
|
||||||
TEST_TYPE_QNAME).getChildRef();
|
TEST_TYPE_QNAME).getChildRef();
|
||||||
NodeRef nodeTwo = this.nodeService.createNode(
|
NodeRef nodeTwo = nodeService.createNode(
|
||||||
nodeOne,
|
nodeOne,
|
||||||
TEST_CHILD_ASSOC_TYPE_QNAME,
|
TEST_CHILD_ASSOC_TYPE_QNAME,
|
||||||
nodeTwoAssocName,
|
nodeTwoAssocName,
|
||||||
TEST_TYPE_QNAME).getChildRef();
|
TEST_TYPE_QNAME).getChildRef();
|
||||||
NodeRef nodeThree = this.nodeService.createNode(
|
NodeRef nodeThree = nodeService.createNode(
|
||||||
nodeTwo,
|
nodeTwo,
|
||||||
TEST_CHILD_ASSOC_TYPE_QNAME,
|
TEST_CHILD_ASSOC_TYPE_QNAME,
|
||||||
nodeThreeAssocName,
|
nodeThreeAssocName,
|
||||||
TEST_TYPE_QNAME).getChildRef();
|
TEST_TYPE_QNAME).getChildRef();
|
||||||
NodeRef nodeFour = this.nodeService.createNode(
|
NodeRef nodeFour = nodeService.createNode(
|
||||||
nodeOne,
|
nodeOne,
|
||||||
TEST_CHILD_ASSOC_TYPE_QNAME,
|
TEST_CHILD_ASSOC_TYPE_QNAME,
|
||||||
nodeFourAssocName,
|
nodeFourAssocName,
|
||||||
TEST_TYPE_QNAME).getChildRef();
|
TEST_TYPE_QNAME).getChildRef();
|
||||||
this.nodeService.addChild(nodeFour, nodeThree, TEST_CHILD_ASSOC_TYPE_QNAME, TEST_CHILD_ASSOC_QNAME);
|
nodeService.addChild(nodeFour, nodeThree, TEST_CHILD_ASSOC_TYPE_QNAME, TEST_CHILD_ASSOC_QNAME);
|
||||||
this.nodeService.createAssociation(nodeTwo, nodeThree, TEST_ASSOC_TYPE_QNAME);
|
nodeService.createAssociation(nodeTwo, nodeThree, TEST_ASSOC_TYPE_QNAME);
|
||||||
this.nodeService.createAssociation(nodeTwo, nodeNotCopied, TEST_ASSOC_TYPE_QNAME);
|
nodeService.createAssociation(nodeTwo, nodeNotCopied, TEST_ASSOC_TYPE_QNAME);
|
||||||
|
|
||||||
// Make node one actionable with a rule to copy nodes into node two
|
// Make node one actionable with a rule to copy nodes into node two
|
||||||
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
||||||
params.put(MoveActionExecuter.PARAM_DESTINATION_FOLDER, nodeTwo);
|
params.put(MoveActionExecuter.PARAM_DESTINATION_FOLDER, nodeTwo);
|
||||||
Rule rule = new Rule();
|
Rule rule = new Rule();
|
||||||
rule.setRuleType(RuleType.INBOUND);
|
rule.setRuleType(RuleType.INBOUND);
|
||||||
Action action = this.actionService.createAction(CopyActionExecuter.NAME, params);
|
Action action = actionService.createAction(CopyActionExecuter.NAME, params);
|
||||||
ActionCondition condition = this.actionService.createActionCondition(NoConditionEvaluator.NAME);
|
ActionCondition condition = actionService.createActionCondition(NoConditionEvaluator.NAME);
|
||||||
action.addActionCondition(condition);
|
action.addActionCondition(condition);
|
||||||
rule.setAction(action);
|
rule.setAction(action);
|
||||||
this.ruleService.saveRule(nodeOne, rule);
|
ruleService.saveRule(nodeOne, rule);
|
||||||
|
|
||||||
// Do a deep copy
|
// Do a deep copy
|
||||||
NodeRef nodeOneCopy = this.copyService.copy(nodeOne, this.rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{test}copiedNodeOne"), true);
|
NodeRef nodeOneCopy = copyService.copy(nodeOne, rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{test}copiedNodeOne"), true);
|
||||||
NodeRef nodeTwoCopy = null;
|
NodeRef nodeTwoCopy = null;
|
||||||
NodeRef nodeThreeCopy = null;
|
NodeRef nodeThreeCopy = null;
|
||||||
NodeRef nodeFourCopy = null;
|
NodeRef nodeFourCopy = null;
|
||||||
|
|
||||||
//System.out.println(
|
//System.out.println(
|
||||||
// NodeStoreInspector.dumpNodeStore(this.nodeService, this.storeRef));
|
// NodeStoreInspector.dumpNodeStore(nodeService, storeRef));
|
||||||
|
|
||||||
List<ChildAssociationRef> nodeOneCopyChildren = this.nodeService.getChildAssocs(nodeOneCopy);
|
List<ChildAssociationRef> nodeOneCopyChildren = nodeService.getChildAssocs(nodeOneCopy);
|
||||||
assertNotNull(nodeOneCopyChildren);
|
assertNotNull(nodeOneCopyChildren);
|
||||||
assertEquals(3, nodeOneCopyChildren.size());
|
assertEquals(3, nodeOneCopyChildren.size());
|
||||||
for (ChildAssociationRef nodeOneCopyChild : nodeOneCopyChildren)
|
for (ChildAssociationRef nodeOneCopyChild : nodeOneCopyChildren)
|
||||||
@@ -750,7 +763,7 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
{
|
{
|
||||||
nodeTwoCopy = nodeOneCopyChild.getChildRef();
|
nodeTwoCopy = nodeOneCopyChild.getChildRef();
|
||||||
|
|
||||||
List<ChildAssociationRef> nodeTwoCopyChildren = this.nodeService.getChildAssocs(nodeTwoCopy);
|
List<ChildAssociationRef> nodeTwoCopyChildren = nodeService.getChildAssocs(nodeTwoCopy);
|
||||||
assertNotNull(nodeTwoCopyChildren);
|
assertNotNull(nodeTwoCopyChildren);
|
||||||
assertEquals(1, nodeTwoCopyChildren.size());
|
assertEquals(1, nodeTwoCopyChildren.size());
|
||||||
for (ChildAssociationRef nodeTwoCopyChild : nodeTwoCopyChildren)
|
for (ChildAssociationRef nodeTwoCopyChild : nodeTwoCopyChildren)
|
||||||
@@ -771,7 +784,7 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
assertNotNull(nodeFourCopy);
|
assertNotNull(nodeFourCopy);
|
||||||
|
|
||||||
// Check the non primary child assoc
|
// Check the non primary child assoc
|
||||||
List<ChildAssociationRef> children = this.nodeService.getChildAssocs(
|
List<ChildAssociationRef> children = nodeService.getChildAssocs(
|
||||||
nodeFourCopy,
|
nodeFourCopy,
|
||||||
RegexQNamePattern.MATCH_ALL,
|
RegexQNamePattern.MATCH_ALL,
|
||||||
TEST_CHILD_ASSOC_QNAME);
|
TEST_CHILD_ASSOC_QNAME);
|
||||||
@@ -781,7 +794,7 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
assertEquals(child.getChildRef(), nodeThree);
|
assertEquals(child.getChildRef(), nodeThree);
|
||||||
|
|
||||||
// Check the target assoc
|
// Check the target assoc
|
||||||
List<AssociationRef> assocs = this.nodeService.getTargetAssocs(nodeTwoCopy, TEST_ASSOC_TYPE_QNAME);
|
List<AssociationRef> assocs = nodeService.getTargetAssocs(nodeTwoCopy, TEST_ASSOC_TYPE_QNAME);
|
||||||
assertNotNull(assocs);
|
assertNotNull(assocs);
|
||||||
assertEquals(2, assocs.size());
|
assertEquals(2, assocs.size());
|
||||||
AssociationRef assoc0 = assocs.get(0);
|
AssociationRef assoc0 = assocs.get(0);
|
||||||
@@ -790,7 +803,7 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
assertTrue(assoc1.getTargetRef().equals(nodeThreeCopy) || assoc1.getTargetRef().equals(nodeNotCopied));
|
assertTrue(assoc1.getTargetRef().equals(nodeThreeCopy) || assoc1.getTargetRef().equals(nodeNotCopied));
|
||||||
|
|
||||||
// Check that the rule parameter values have been made relative
|
// Check that the rule parameter values have been made relative
|
||||||
List<Rule> rules = this.ruleService.getRules(nodeOneCopy);
|
List<Rule> rules = ruleService.getRules(nodeOneCopy);
|
||||||
assertNotNull(rules);
|
assertNotNull(rules);
|
||||||
assertEquals(1, rules.size());
|
assertEquals(1, rules.size());
|
||||||
Rule copiedRule = rules.get(0);
|
Rule copiedRule = rules.get(0);
|
||||||
@@ -805,26 +818,26 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
public void testCopyAndRename()
|
public void testCopyAndRename()
|
||||||
{
|
{
|
||||||
// Check a normal copy with no dup restrictions
|
// Check a normal copy with no dup restrictions
|
||||||
NodeRef copy = this.copyService.copyAndRename(
|
NodeRef copy = copyService.copyAndRename(
|
||||||
this.sourceNodeRef,
|
sourceNodeRef,
|
||||||
this.rootNodeRef,
|
rootNodeRef,
|
||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
QName.createQName("{test}copyAssoc"),
|
QName.createQName("{test}copyAssoc"),
|
||||||
false);
|
false);
|
||||||
checkCopiedNode(this.sourceNodeRef, copy, true, true, false);
|
checkCopiedNode(sourceNodeRef, copy, true, true, false);
|
||||||
assertTrue(TEST_NAME.equals(this.nodeService.getProperty(copy, ContentModel.PROP_NAME)));
|
assertTrue(TEST_NAME.equals(nodeService.getProperty(copy, ContentModel.PROP_NAME)));
|
||||||
|
|
||||||
// Create a folder and content node
|
// Create a folder and content node
|
||||||
Map<QName, Serializable> propsFolder = new HashMap<QName, Serializable>(1);
|
Map<QName, Serializable> propsFolder = new HashMap<QName, Serializable>(1);
|
||||||
propsFolder.put(ContentModel.PROP_NAME, "tempFolder");
|
propsFolder.put(ContentModel.PROP_NAME, "tempFolder");
|
||||||
NodeRef folderNode = this.nodeService.createNode(this.rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{test}tempFolder"), ContentModel.TYPE_FOLDER, propsFolder).getChildRef();
|
NodeRef folderNode = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{test}tempFolder"), ContentModel.TYPE_FOLDER, propsFolder).getChildRef();
|
||||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
|
Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
|
||||||
props.put(ContentModel.PROP_NAME, TEST_NAME);
|
props.put(ContentModel.PROP_NAME, TEST_NAME);
|
||||||
NodeRef contentNode = this.nodeService.createNode(folderNode, ContentModel.ASSOC_CONTAINS, QName.createQName("{test}renametest"), ContentModel.TYPE_CONTENT, props).getChildRef();
|
NodeRef contentNode = nodeService.createNode(folderNode, ContentModel.ASSOC_CONTAINS, QName.createQName("{test}renametest"), ContentModel.TYPE_CONTENT, props).getChildRef();
|
||||||
|
|
||||||
// Now copy the content node with the duplicate name restriction
|
// Now copy the content node with the duplicate name restriction
|
||||||
NodeRef contentCopy = this.copyService.copy(contentNode, folderNode, ContentModel.ASSOC_CONTAINS, QName.createQName("{test}bobbins"), false);
|
NodeRef contentCopy = copyService.copy(contentNode, folderNode, ContentModel.ASSOC_CONTAINS, QName.createQName("{test}bobbins"), false);
|
||||||
assertFalse(TEST_NAME.equals(this.nodeService.getProperty(contentCopy, ContentModel.PROP_NAME)));
|
assertFalse(TEST_NAME.equals(nodeService.getProperty(contentCopy, ContentModel.PROP_NAME)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -835,25 +848,25 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
// Create a folder and content node
|
// Create a folder and content node
|
||||||
Map<QName, Serializable> propsFolder = new HashMap<QName, Serializable>(1);
|
Map<QName, Serializable> propsFolder = new HashMap<QName, Serializable>(1);
|
||||||
propsFolder.put(ContentModel.PROP_NAME, "tempFolder");
|
propsFolder.put(ContentModel.PROP_NAME, "tempFolder");
|
||||||
NodeRef folderNode = this.nodeService.createNode(this.rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "tempFolder"), ContentModel.TYPE_FOLDER, propsFolder).getChildRef();
|
NodeRef folderNode = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "tempFolder"), ContentModel.TYPE_FOLDER, propsFolder).getChildRef();
|
||||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
|
Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
|
||||||
props.put(ContentModel.PROP_NAME, "myDoc.txt");
|
props.put(ContentModel.PROP_NAME, "myDoc.txt");
|
||||||
NodeRef contentNode = this.nodeService.createNode(folderNode, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "myDoc.txt"), ContentModel.TYPE_CONTENT, props).getChildRef();
|
NodeRef contentNode = nodeService.createNode(folderNode, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "myDoc.txt"), ContentModel.TYPE_CONTENT, props).getChildRef();
|
||||||
|
|
||||||
NodeRef copy = this.copyService.copyAndRename(contentNode, folderNode, ContentModel.ASSOC_CONTAINS, null, false);
|
NodeRef copy = copyService.copyAndRename(contentNode, folderNode, ContentModel.ASSOC_CONTAINS, null, false);
|
||||||
assertEquals("Copy of myDoc.txt", this.nodeService.getProperty(copy, ContentModel.PROP_NAME));
|
assertEquals("Copy of myDoc.txt", nodeService.getProperty(copy, ContentModel.PROP_NAME));
|
||||||
QName copyQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "Copy of myDoc.txt");
|
QName copyQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "Copy of myDoc.txt");
|
||||||
assertEquals(copyQName, this.nodeService.getPrimaryParent(copy).getQName());
|
assertEquals(copyQName, nodeService.getPrimaryParent(copy).getQName());
|
||||||
|
|
||||||
copy = this.copyService.copyAndRename(contentNode, folderNode, ContentModel.ASSOC_CONTAINS, null, false);
|
copy = copyService.copyAndRename(contentNode, folderNode, ContentModel.ASSOC_CONTAINS, null, false);
|
||||||
assertEquals("Copy of Copy of myDoc.txt", this.nodeService.getProperty(copy, ContentModel.PROP_NAME));
|
assertEquals("Copy of Copy of myDoc.txt", nodeService.getProperty(copy, ContentModel.PROP_NAME));
|
||||||
copyQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "Copy of Copy of myDoc.txt");
|
copyQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "Copy of Copy of myDoc.txt");
|
||||||
assertEquals(copyQName, this.nodeService.getPrimaryParent(copy).getQName());
|
assertEquals(copyQName, nodeService.getPrimaryParent(copy).getQName());
|
||||||
|
|
||||||
copy = this.copyService.copyAndRename(contentNode, folderNode, ContentModel.ASSOC_CONTAINS, null, false);
|
copy = copyService.copyAndRename(contentNode, folderNode, ContentModel.ASSOC_CONTAINS, null, false);
|
||||||
assertEquals("Copy of Copy of Copy of myDoc.txt", this.nodeService.getProperty(copy, ContentModel.PROP_NAME));
|
assertEquals("Copy of Copy of Copy of myDoc.txt", nodeService.getProperty(copy, ContentModel.PROP_NAME));
|
||||||
copyQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "Copy of Copy of Copy of myDoc.txt");
|
copyQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "Copy of Copy of Copy of myDoc.txt");
|
||||||
assertEquals(copyQName, this.nodeService.getPrimaryParent(copy).getQName());
|
assertEquals(copyQName, nodeService.getPrimaryParent(copy).getQName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -867,7 +880,7 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
// Create a folder and content node
|
// Create a folder and content node
|
||||||
Map<QName, Serializable> propsFolder = new HashMap<QName, Serializable>(1);
|
Map<QName, Serializable> propsFolder = new HashMap<QName, Serializable>(1);
|
||||||
propsFolder.put(ContentModel.PROP_NAME, "tempFolder");
|
propsFolder.put(ContentModel.PROP_NAME, "tempFolder");
|
||||||
NodeRef folderNode = this.nodeService.createNode(this.rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "tempFolder"), ContentModel.TYPE_FOLDER, propsFolder).getChildRef();
|
NodeRef folderNode = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "tempFolder"), ContentModel.TYPE_FOLDER, propsFolder).getChildRef();
|
||||||
|
|
||||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
|
Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
|
||||||
props.put(ContentModel.PROP_NAME, "myDoc.txt");
|
props.put(ContentModel.PROP_NAME, "myDoc.txt");
|
||||||
@@ -883,12 +896,12 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
description.addValue(Locale.ITALY, ITALY_DESCRIPTION);
|
description.addValue(Locale.ITALY, ITALY_DESCRIPTION);
|
||||||
props.put(ContentModel.PROP_DESCRIPTION, description);
|
props.put(ContentModel.PROP_DESCRIPTION, description);
|
||||||
|
|
||||||
NodeRef contentNode = this.nodeService.createNode(folderNode, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "myDoc.txt"), ContentModel.TYPE_CONTENT, props).getChildRef();
|
NodeRef contentNode = nodeService.createNode(folderNode, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "myDoc.txt"), ContentModel.TYPE_CONTENT, props).getChildRef();
|
||||||
|
|
||||||
NodeRef copy = this.copyService.copyAndRename(contentNode, folderNode, ContentModel.ASSOC_CONTAINS, null, false);
|
NodeRef copy = copyService.copyAndRename(contentNode, folderNode, ContentModel.ASSOC_CONTAINS, null, false);
|
||||||
assertEquals("Copy of myDoc.txt", this.nodeService.getProperty(copy, ContentModel.PROP_NAME));
|
assertEquals("Copy of myDoc.txt", nodeService.getProperty(copy, ContentModel.PROP_NAME));
|
||||||
QName copyQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "Copy of myDoc.txt");
|
QName copyQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "Copy of myDoc.txt");
|
||||||
assertEquals(copyQName, this.nodeService.getPrimaryParent(copy).getQName());
|
assertEquals(copyQName, nodeService.getPrimaryParent(copy).getQName());
|
||||||
|
|
||||||
// Test uses DB Node Service.
|
// Test uses DB Node Service.
|
||||||
Serializable desc = nodeService.getProperty(copy, ContentModel.PROP_DESCRIPTION);
|
Serializable desc = nodeService.getProperty(copy, ContentModel.PROP_DESCRIPTION);
|
||||||
@@ -937,7 +950,7 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
} catch(AccessDeniedException e) {}
|
} catch(AccessDeniedException e) {}
|
||||||
|
|
||||||
// Allow the read, but the destination won't accept it
|
// Allow the read, but the destination won't accept it
|
||||||
this.authenticationComponent.setSystemUserAsCurrentUser();
|
authenticationComponent.setSystemUserAsCurrentUser();
|
||||||
permissionService.setPermission(sourceNodeRef, USER_2, PermissionService.CONTRIBUTOR, true);
|
permissionService.setPermission(sourceNodeRef, USER_2, PermissionService.CONTRIBUTOR, true);
|
||||||
permissionService.setPermission(targetNodeRef, USER_2, PermissionService.CONTRIBUTOR, false);
|
permissionService.setPermission(targetNodeRef, USER_2, PermissionService.CONTRIBUTOR, false);
|
||||||
AuthenticationUtil.setFullyAuthenticatedUser(USER_2);
|
AuthenticationUtil.setFullyAuthenticatedUser(USER_2);
|
||||||
@@ -948,7 +961,7 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
|
|
||||||
|
|
||||||
// Now allow on the destination, should go through
|
// Now allow on the destination, should go through
|
||||||
this.authenticationComponent.setSystemUserAsCurrentUser();
|
authenticationComponent.setSystemUserAsCurrentUser();
|
||||||
permissionService.setPermission(targetNodeRef, USER_2, PermissionService.CONTRIBUTOR, true);
|
permissionService.setPermission(targetNodeRef, USER_2, PermissionService.CONTRIBUTOR, true);
|
||||||
AuthenticationUtil.setFullyAuthenticatedUser(USER_2);
|
AuthenticationUtil.setFullyAuthenticatedUser(USER_2);
|
||||||
|
|
||||||
@@ -1053,9 +1066,9 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
if (sameStore == true)
|
if (sameStore == true)
|
||||||
{
|
{
|
||||||
// Check that the copy aspect has been applied to the copy
|
// Check that the copy aspect has been applied to the copy
|
||||||
boolean hasCopyAspect = this.nodeService.hasAspect(destinationNodeRef, ContentModel.ASPECT_COPIEDFROM);
|
boolean hasCopyAspect = nodeService.hasAspect(destinationNodeRef, ContentModel.ASPECT_COPIEDFROM);
|
||||||
assertTrue("Missing aspect: " + ContentModel.ASPECT_COPIEDFROM, hasCopyAspect);
|
assertTrue("Missing aspect: " + ContentModel.ASPECT_COPIEDFROM, hasCopyAspect);
|
||||||
NodeRef copyNodeRef = (NodeRef)this.nodeService.getProperty(destinationNodeRef, ContentModel.PROP_COPY_REFERENCE);
|
NodeRef copyNodeRef = (NodeRef)nodeService.getProperty(destinationNodeRef, ContentModel.PROP_COPY_REFERENCE);
|
||||||
assertNotNull(copyNodeRef);
|
assertNotNull(copyNodeRef);
|
||||||
assertEquals(sourceNodeRef, copyNodeRef);
|
assertEquals(sourceNodeRef, copyNodeRef);
|
||||||
}
|
}
|
||||||
@@ -1066,11 +1079,11 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hasTestAspect = this.nodeService.hasAspect(destinationNodeRef, TEST_ASPECT_QNAME);
|
boolean hasTestAspect = nodeService.hasAspect(destinationNodeRef, TEST_ASPECT_QNAME);
|
||||||
assertTrue(hasTestAspect);
|
assertTrue(hasTestAspect);
|
||||||
|
|
||||||
// Check that all the correct properties have been copied
|
// Check that all the correct properties have been copied
|
||||||
Map<QName, Serializable> destinationProperties = this.nodeService.getProperties(destinationNodeRef);
|
Map<QName, Serializable> destinationProperties = nodeService.getProperties(destinationNodeRef);
|
||||||
assertNotNull(destinationProperties);
|
assertNotNull(destinationProperties);
|
||||||
String value1 = (String)destinationProperties.get(PROP1_QNAME_MANDATORY);
|
String value1 = (String)destinationProperties.get(PROP1_QNAME_MANDATORY);
|
||||||
assertNotNull(value1);
|
assertNotNull(value1);
|
||||||
@@ -1086,18 +1099,18 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
assertEquals(TEST_VALUE_2, value4);
|
assertEquals(TEST_VALUE_2, value4);
|
||||||
|
|
||||||
// Check all the target associations have been copied
|
// Check all the target associations have been copied
|
||||||
List<AssociationRef> destinationTargets = this.nodeService.getTargetAssocs(destinationNodeRef, TEST_ASSOC_TYPE_QNAME);
|
List<AssociationRef> destinationTargets = nodeService.getTargetAssocs(destinationNodeRef, TEST_ASSOC_TYPE_QNAME);
|
||||||
assertNotNull(destinationTargets);
|
assertNotNull(destinationTargets);
|
||||||
assertEquals(1, destinationTargets.size());
|
assertEquals(1, destinationTargets.size());
|
||||||
AssociationRef nodeAssocRef = destinationTargets.get(0);
|
AssociationRef nodeAssocRef = destinationTargets.get(0);
|
||||||
assertNotNull(nodeAssocRef);
|
assertNotNull(nodeAssocRef);
|
||||||
assertEquals(this.targetNodeRef, nodeAssocRef.getTargetRef());
|
assertEquals(targetNodeRef, nodeAssocRef.getTargetRef());
|
||||||
|
|
||||||
// Check all the child associations have been copied
|
// Check all the child associations have been copied
|
||||||
List<ChildAssociationRef> childAssocRefs = this.nodeService.getChildAssocs(destinationNodeRef);
|
List<ChildAssociationRef> childAssocRefs = nodeService.getChildAssocs(destinationNodeRef);
|
||||||
assertNotNull(childAssocRefs);
|
assertNotNull(childAssocRefs);
|
||||||
int expectedSize = copyChildren ? 2 : 0;
|
int expectedSize = copyChildren ? 2 : 0;
|
||||||
if (this.nodeService.hasAspect(destinationNodeRef, RuleModel.ASPECT_RULES) == true)
|
if (nodeService.hasAspect(destinationNodeRef, RuleModel.ASPECT_RULES) == true)
|
||||||
{
|
{
|
||||||
expectedSize = expectedSize + 1;
|
expectedSize = expectedSize + 1;
|
||||||
}
|
}
|
||||||
@@ -1109,7 +1122,7 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
{
|
{
|
||||||
// Since this child is non-primary in the source it will always be non-primary in the destination
|
// Since this child is non-primary in the source it will always be non-primary in the destination
|
||||||
assertFalse(ref.isPrimary());
|
assertFalse(ref.isPrimary());
|
||||||
assertEquals(this.nonPrimaryChildNodeRef, ref.getChildRef());
|
assertEquals(nonPrimaryChildNodeRef, ref.getChildRef());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1118,18 +1131,18 @@ public class CopyServiceImplTest extends BaseSpringTest
|
|||||||
if (ref.getTypeQName().equals(RuleModel.ASSOC_RULE_FOLDER) == true)
|
if (ref.getTypeQName().equals(RuleModel.ASSOC_RULE_FOLDER) == true)
|
||||||
{
|
{
|
||||||
assertTrue(ref.isPrimary());
|
assertTrue(ref.isPrimary());
|
||||||
assertTrue(this.childNodeRef.equals(ref.getChildRef()) == false);
|
assertTrue(childNodeRef.equals(ref.getChildRef()) == false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assertFalse(ref.isPrimary());
|
assertFalse(ref.isPrimary());
|
||||||
assertEquals(this.childNodeRef, ref.getChildRef());
|
assertEquals(childNodeRef, ref.getChildRef());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assertTrue(ref.isPrimary());
|
assertTrue(ref.isPrimary());
|
||||||
assertTrue(this.childNodeRef.equals(ref.getChildRef()) == false);
|
assertTrue(childNodeRef.equals(ref.getChildRef()) == false);
|
||||||
|
|
||||||
// TODO need to check that the copied child has all the correct details ..
|
// TODO need to check that the copied child has all the correct details ..
|
||||||
}
|
}
|
||||||
|
@@ -3146,7 +3146,70 @@ public abstract class AbstractNodeDAOImpl implements NodeDAO, BatchingDAO
|
|||||||
/*
|
/*
|
||||||
* Bulk caching
|
* Bulk caching
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// TODO there must be a way to limit the repeated code here and in cacheNodes(List<NodeRef>)
|
||||||
|
public void cacheNodesById(List<Long> nodeIds)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* ALF-2712: Performance degradation from 3.1.0 to 3.1.2
|
||||||
|
* ALF-2784: Degradation of performance between 3.1.1 and 3.2x (observed in JSF)
|
||||||
|
*
|
||||||
|
* There is an obvious cost associated with querying the database to pull back nodes,
|
||||||
|
* and there is additional cost associated with putting the resultant entries into the
|
||||||
|
* caches. It is NO MORE expensive to check the cache than it is to put an entry into it
|
||||||
|
* - and probably cheaper considering cache replication - so we start checking nodes to see
|
||||||
|
* if they have entries before passing them over for batch loading.
|
||||||
|
*
|
||||||
|
* However, when running against a cold cache or doing a first-time query against some
|
||||||
|
* part of the repo, we will be checking for entries in the cache and consistently getting
|
||||||
|
* no results. To avoid unnecessary checking when the cache is PROBABLY cold, we
|
||||||
|
* examine the ratio of hits/misses at regular intervals.
|
||||||
|
*/
|
||||||
|
if (nodeIds.size() < 10)
|
||||||
|
{
|
||||||
|
// We only cache where the number of results is potentially
|
||||||
|
// a problem for the N+1 loading that might result.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int foundCacheEntryCount = 0;
|
||||||
|
int missingCacheEntryCount = 0;
|
||||||
|
boolean forceBatch = false;
|
||||||
|
|
||||||
|
List<Long> batchLoadNodeIds = new ArrayList<Long>(nodeIds.size());
|
||||||
|
for (Long nodeId : nodeIds)
|
||||||
|
{
|
||||||
|
if (!forceBatch)
|
||||||
|
{
|
||||||
|
// Is this node in the cache?
|
||||||
|
if (nodesCache.getValue(nodeId) != null)
|
||||||
|
{
|
||||||
|
foundCacheEntryCount++; // Don't add it to the batch
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
missingCacheEntryCount++; // Fall through and add it to the batch
|
||||||
|
}
|
||||||
|
if (foundCacheEntryCount + missingCacheEntryCount % 100 == 0)
|
||||||
|
{
|
||||||
|
// We force the batch if the number of hits drops below the number of misses
|
||||||
|
forceBatch = foundCacheEntryCount < missingCacheEntryCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
batchLoadNodeIds.add(nodeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
int size = batchLoadNodeIds.size();
|
||||||
|
cacheNodesBatch(batchLoadNodeIds);
|
||||||
|
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("Pre-loaded " + size + " nodes.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
* <p/>
|
* <p/>
|
||||||
@@ -3242,27 +3305,47 @@ public abstract class AbstractNodeDAOImpl implements NodeDAO, BatchingDAO
|
|||||||
if (batch.size() >= batchSize)
|
if (batch.size() >= batchSize)
|
||||||
{
|
{
|
||||||
// Preload
|
// Preload
|
||||||
cacheNodesNoBatch(storeId, batch);
|
cacheNodesNoBatch(selectNodesByUuids(storeId, batch));
|
||||||
batch.clear();
|
batch.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Load any remaining nodes
|
// Load any remaining nodes
|
||||||
if (batch.size() > 0)
|
if (batch.size() > 0)
|
||||||
{
|
{
|
||||||
cacheNodesNoBatch(storeId, batch);
|
cacheNodesNoBatch(selectNodesByUuids(storeId, batch));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cacheNodesBatch(List<Long> nodeIds)
|
||||||
|
{
|
||||||
|
int batchSize = 256;
|
||||||
|
SortedSet<Long> batch = new TreeSet<Long>();
|
||||||
|
for (Long nodeId : nodeIds)
|
||||||
|
{
|
||||||
|
batch.add(nodeId);
|
||||||
|
if (batch.size() >= batchSize)
|
||||||
|
{
|
||||||
|
// Preload
|
||||||
|
cacheNodesNoBatch(selectNodesByIds(batch));
|
||||||
|
batch.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Load any remaining nodes
|
||||||
|
if (batch.size() > 0)
|
||||||
|
{
|
||||||
|
cacheNodesNoBatch(selectNodesByIds(batch));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bulk-fetch the nodes for a given store. All nodes passed in are fetched.
|
* Bulk-fetch the nodes for a given store. All nodes passed in are fetched.
|
||||||
*/
|
*/
|
||||||
private void cacheNodesNoBatch(Long storeId, SortedSet<String> uuids)
|
private void cacheNodesNoBatch(List<Node> nodes)
|
||||||
{
|
{
|
||||||
// Get the nodes
|
// Get the nodes
|
||||||
List<NodeEntity> nodes = selectNodesByUuids(storeId, uuids);
|
|
||||||
SortedSet<Long> aspectNodeIds = new TreeSet<Long>();
|
SortedSet<Long> aspectNodeIds = new TreeSet<Long>();
|
||||||
SortedSet<Long> propertiesNodeIds = new TreeSet<Long>();
|
SortedSet<Long> propertiesNodeIds = new TreeSet<Long>();
|
||||||
for (NodeEntity node : nodes)
|
for (Node node : nodes)
|
||||||
{
|
{
|
||||||
Long nodeId = node.getId();
|
Long nodeId = node.getId();
|
||||||
nodesCache.setValue(nodeId, node);
|
nodesCache.setValue(nodeId, node);
|
||||||
@@ -3276,6 +3359,12 @@ public abstract class AbstractNodeDAOImpl implements NodeDAO, BatchingDAO
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("Pre-loaded " + propertiesNodeIds.size() + " properties");
|
||||||
|
logger.debug("Pre-loaded " + propertiesNodeIds.size() + " aspects");
|
||||||
|
}
|
||||||
|
|
||||||
List<NodeAspectsEntity> nodeAspects = selectNodeAspects(aspectNodeIds);
|
List<NodeAspectsEntity> nodeAspects = selectNodeAspects(aspectNodeIds);
|
||||||
for (NodeAspectsEntity nodeAspect : nodeAspects)
|
for (NodeAspectsEntity nodeAspect : nodeAspects)
|
||||||
{
|
{
|
||||||
@@ -3450,7 +3539,8 @@ public abstract class AbstractNodeDAOImpl implements NodeDAO, BatchingDAO
|
|||||||
protected abstract int deleteNodesByCommitTime(boolean deletedOnly, long maxTxnCommitTimeMs);
|
protected abstract int deleteNodesByCommitTime(boolean deletedOnly, long maxTxnCommitTimeMs);
|
||||||
protected abstract NodeEntity selectNodeById(Long id, Boolean deleted);
|
protected abstract NodeEntity selectNodeById(Long id, Boolean deleted);
|
||||||
protected abstract NodeEntity selectNodeByNodeRef(NodeRef nodeRef, Boolean deleted);
|
protected abstract NodeEntity selectNodeByNodeRef(NodeRef nodeRef, Boolean deleted);
|
||||||
protected abstract List<NodeEntity> selectNodesByUuids(Long storeId, SortedSet<String> uuids);
|
protected abstract List<Node> selectNodesByUuids(Long storeId, SortedSet<String> uuids);
|
||||||
|
protected abstract List<Node> selectNodesByIds(SortedSet<Long> ids);
|
||||||
protected abstract Map<Long, Map<NodePropertyKey, NodePropertyValue>> selectNodeProperties(Set<Long> nodeIds);
|
protected abstract Map<Long, Map<NodePropertyKey, NodePropertyValue>> selectNodeProperties(Set<Long> nodeIds);
|
||||||
protected abstract List<NodeAspectsEntity> selectNodeAspects(Set<Long> nodeIds);
|
protected abstract List<NodeAspectsEntity> selectNodeAspects(Set<Long> nodeIds);
|
||||||
protected abstract Map<NodePropertyKey, NodePropertyValue> selectNodeProperties(Long nodeId);
|
protected abstract Map<NodePropertyKey, NodePropertyValue> selectNodeProperties(Long nodeId);
|
||||||
|
@@ -30,6 +30,7 @@ public class NodeBatchLoadEntity
|
|||||||
{
|
{
|
||||||
private Long storeId;
|
private Long storeId;
|
||||||
private List<String> uuids;
|
private List<String> uuids;
|
||||||
|
private List<Long> ids;
|
||||||
|
|
||||||
public Long getStoreId()
|
public Long getStoreId()
|
||||||
{
|
{
|
||||||
@@ -47,5 +48,12 @@ public class NodeBatchLoadEntity
|
|||||||
{
|
{
|
||||||
this.uuids = uuids;
|
this.uuids = uuids;
|
||||||
}
|
}
|
||||||
|
public List<Long> getIds()
|
||||||
|
{
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
public void setIds(List<Long> ids)
|
||||||
|
{
|
||||||
|
this.ids = ids;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -31,6 +31,7 @@ import java.util.SortedSet;
|
|||||||
import org.alfresco.repo.domain.node.AbstractNodeDAOImpl;
|
import org.alfresco.repo.domain.node.AbstractNodeDAOImpl;
|
||||||
import org.alfresco.repo.domain.node.ChildAssocEntity;
|
import org.alfresco.repo.domain.node.ChildAssocEntity;
|
||||||
import org.alfresco.repo.domain.node.ChildPropertyEntity;
|
import org.alfresco.repo.domain.node.ChildPropertyEntity;
|
||||||
|
import org.alfresco.repo.domain.node.Node;
|
||||||
import org.alfresco.repo.domain.node.NodeAspectsEntity;
|
import org.alfresco.repo.domain.node.NodeAspectsEntity;
|
||||||
import org.alfresco.repo.domain.node.NodeAssocEntity;
|
import org.alfresco.repo.domain.node.NodeAssocEntity;
|
||||||
import org.alfresco.repo.domain.node.NodeEntity;
|
import org.alfresco.repo.domain.node.NodeEntity;
|
||||||
@@ -86,6 +87,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl
|
|||||||
private static final String SELECT_NODE_BY_ID = "alfresco.node.select_NodeById";
|
private static final String SELECT_NODE_BY_ID = "alfresco.node.select_NodeById";
|
||||||
private static final String SELECT_NODE_BY_NODEREF = "alfresco.node.select_NodeByNodeRef";
|
private static final String SELECT_NODE_BY_NODEREF = "alfresco.node.select_NodeByNodeRef";
|
||||||
private static final String SELECT_NODES_BY_UUIDS = "alfresco.node.select_NodesByUuids";
|
private static final String SELECT_NODES_BY_UUIDS = "alfresco.node.select_NodesByUuids";
|
||||||
|
private static final String SELECT_NODES_BY_IDS = "alfresco.node.select_NodesByIds";
|
||||||
private static final String SELECT_NODE_PROPERTIES = "alfresco.node.select_NodeProperties";
|
private static final String SELECT_NODE_PROPERTIES = "alfresco.node.select_NodeProperties";
|
||||||
private static final String SELECT_NODE_ASPECTS = "alfresco.node.select_NodeAspects";
|
private static final String SELECT_NODE_ASPECTS = "alfresco.node.select_NodeAspects";
|
||||||
private static final String INSERT_NODE_PROPERTY = "alfresco.node.insert.insert_NodeProperty";
|
private static final String INSERT_NODE_PROPERTY = "alfresco.node.insert.insert_NodeProperty";
|
||||||
@@ -379,15 +381,26 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
protected List<NodeEntity> selectNodesByUuids(Long storeId, SortedSet<String> uuids)
|
protected List<Node> selectNodesByUuids(Long storeId, SortedSet<String> uuids)
|
||||||
{
|
{
|
||||||
NodeBatchLoadEntity nodeBatchLoadEntity = new NodeBatchLoadEntity();
|
NodeBatchLoadEntity nodeBatchLoadEntity = new NodeBatchLoadEntity();
|
||||||
nodeBatchLoadEntity.setStoreId(storeId);
|
nodeBatchLoadEntity.setStoreId(storeId);
|
||||||
nodeBatchLoadEntity.setUuids(new ArrayList<String>(uuids));
|
nodeBatchLoadEntity.setUuids(new ArrayList<String>(uuids));
|
||||||
|
|
||||||
return (List<NodeEntity>) template.selectList(SELECT_NODES_BY_UUIDS, nodeBatchLoadEntity);
|
return (List<Node>) template.selectList(SELECT_NODES_BY_UUIDS, nodeBatchLoadEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
protected List<Node> selectNodesByIds(SortedSet<Long> ids)
|
||||||
|
{
|
||||||
|
NodeBatchLoadEntity nodeBatchLoadEntity = new NodeBatchLoadEntity();
|
||||||
|
nodeBatchLoadEntity.setIds(new ArrayList<Long>(ids));
|
||||||
|
|
||||||
|
return (List<Node>) template.selectList(SELECT_NODES_BY_IDS, nodeBatchLoadEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pull out the key-value pairs from the rows
|
* Pull out the key-value pairs from the rows
|
||||||
*/
|
*/
|
||||||
|
@@ -19,6 +19,7 @@
|
|||||||
package org.alfresco.repo.domain.solr;
|
package org.alfresco.repo.domain.solr;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -27,11 +28,12 @@ import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
|||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.Path;
|
import org.alfresco.service.cmr.repository.Path;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
|
import org.alfresco.util.Pair;
|
||||||
|
|
||||||
public interface NodeMetaData
|
public interface NodeMetaData
|
||||||
{
|
{
|
||||||
public NodeRef getNodeRef();
|
public NodeRef getNodeRef();
|
||||||
public List<Path> getPaths();
|
public Collection<Pair<Path, QName>> getPaths();
|
||||||
public QName getNodeType();
|
public QName getNodeType();
|
||||||
public Long getNodeId();
|
public Long getNodeId();
|
||||||
public Long getAclId();
|
public Long getAclId();
|
||||||
|
@@ -19,6 +19,7 @@
|
|||||||
package org.alfresco.repo.domain.solr;
|
package org.alfresco.repo.domain.solr;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -27,6 +28,7 @@ import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
|||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.Path;
|
import org.alfresco.service.cmr.repository.Path;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
|
import org.alfresco.util.Pair;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -42,7 +44,8 @@ public class NodeMetaDataEntity implements NodeMetaData
|
|||||||
private Long aclId;
|
private Long aclId;
|
||||||
private Map<QName, Serializable> properties;
|
private Map<QName, Serializable> properties;
|
||||||
private Set<QName> aspects;
|
private Set<QName> aspects;
|
||||||
private List<Path> paths;
|
// private List<Path> paths;
|
||||||
|
private Collection<Pair<Path, QName>> paths;
|
||||||
private List<ChildAssociationRef> childAssocs;
|
private List<ChildAssociationRef> childAssocs;
|
||||||
|
|
||||||
public String getOwner()
|
public String getOwner()
|
||||||
@@ -61,11 +64,11 @@ public class NodeMetaDataEntity implements NodeMetaData
|
|||||||
{
|
{
|
||||||
this.nodeRef = nodeRef;
|
this.nodeRef = nodeRef;
|
||||||
}
|
}
|
||||||
public List<Path> getPaths()
|
public Collection<Pair<Path, QName>> getPaths()
|
||||||
{
|
{
|
||||||
return paths;
|
return paths;
|
||||||
}
|
}
|
||||||
public void setPaths(List<Path> paths)
|
public void setPaths(Collection<Pair<Path, QName>> paths)
|
||||||
{
|
{
|
||||||
this.paths = paths;
|
this.paths = paths;
|
||||||
}
|
}
|
||||||
|
@@ -28,6 +28,7 @@ import java.util.Set;
|
|||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
|
import org.alfresco.repo.domain.node.ContentDataWithId;
|
||||||
import org.alfresco.repo.domain.node.Node;
|
import org.alfresco.repo.domain.node.Node;
|
||||||
import org.alfresco.repo.domain.node.NodeDAO;
|
import org.alfresco.repo.domain.node.NodeDAO;
|
||||||
import org.alfresco.repo.domain.solr.SOLRDAO.NodeMetaDataQueryCallback;
|
import org.alfresco.repo.domain.solr.SOLRDAO.NodeMetaDataQueryCallback;
|
||||||
@@ -38,9 +39,9 @@ import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransacti
|
|||||||
import org.alfresco.service.ServiceRegistry;
|
import org.alfresco.service.ServiceRegistry;
|
||||||
import org.alfresco.service.cmr.model.FileFolderService;
|
import org.alfresco.service.cmr.model.FileFolderService;
|
||||||
import org.alfresco.service.cmr.model.FileInfo;
|
import org.alfresco.service.cmr.model.FileInfo;
|
||||||
|
import org.alfresco.service.cmr.repository.MLText;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
import org.alfresco.service.cmr.repository.Path;
|
|
||||||
import org.alfresco.service.cmr.repository.StoreRef;
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.service.transaction.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
@@ -94,12 +95,12 @@ public class SOLRDAOTest extends TestCase
|
|||||||
storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, getName() + System.currentTimeMillis());
|
storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, getName() + System.currentTimeMillis());
|
||||||
rootNodeRef = nodeService.getRootNode(storeRef);
|
rootNodeRef = nodeService.getRootNode(storeRef);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
public void testQueryTransactions1()
|
public void testQueryTransactions1()
|
||||||
{
|
{
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
SOLRTest st = new SOLRTest1(txnHelper, fileFolderService, nodeService, rootNodeRef, "testQueryTransactions1", true, true);
|
SOLRTest st = new SOLRTest1(txnHelper, fileFolderService, nodeDAO, nodeService, rootNodeRef, "testQueryTransactions1", true, true);
|
||||||
st.buildTransactions();
|
st.buildTransactions();
|
||||||
|
|
||||||
List<Transaction> txns = solrDAO.getTransactions(null, startTime, 0);
|
List<Transaction> txns = solrDAO.getTransactions(null, startTime, 0);
|
||||||
@@ -119,7 +120,7 @@ public class SOLRDAOTest extends TestCase
|
|||||||
{
|
{
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
SOLRTest st = new SOLRTest2(txnHelper, fileFolderService, nodeService, rootNodeRef, "testQueryTransactions2", true, true);
|
SOLRTest st = new SOLRTest2(txnHelper, fileFolderService, nodeDAO, nodeService, rootNodeRef, "testQueryTransactions2", true, true);
|
||||||
st.buildTransactions();
|
st.buildTransactions();
|
||||||
|
|
||||||
List<Transaction> txns = solrDAO.getTransactions(null, startTime, 0);
|
List<Transaction> txns = solrDAO.getTransactions(null, startTime, 0);
|
||||||
@@ -149,7 +150,7 @@ public class SOLRDAOTest extends TestCase
|
|||||||
{
|
{
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
SOLRTest st = new SOLRTest3(txnHelper, fileFolderService, nodeService, rootNodeRef, "testGetNodeMetaData", true, true);
|
SOLRTest st = new SOLRTest3(txnHelper, fileFolderService, nodeDAO, nodeService, rootNodeRef, "testGetNodeMetaData", true, true);
|
||||||
st.buildTransactions();
|
st.buildTransactions();
|
||||||
|
|
||||||
List<Transaction> txns = solrDAO.getTransactions(null, startTime, 0);
|
List<Transaction> txns = solrDAO.getTransactions(null, startTime, 0);
|
||||||
@@ -175,7 +176,7 @@ public class SOLRDAOTest extends TestCase
|
|||||||
{
|
{
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
SOLRTest st = new SOLRTest100Nodes(txnHelper, fileFolderService, nodeService, rootNodeRef, "testGetNodeMetaData", true, true);
|
SOLRTest st = new SOLRTest100Nodes(txnHelper, fileFolderService, nodeDAO, nodeService, rootNodeRef, "testGetNodeMetaData", true, true);
|
||||||
st.buildTransactions();
|
st.buildTransactions();
|
||||||
|
|
||||||
List<Transaction> txns = solrDAO.getTransactions(null, startTime, 0);
|
List<Transaction> txns = solrDAO.getTransactions(null, startTime, 0);
|
||||||
@@ -204,7 +205,7 @@ public class SOLRDAOTest extends TestCase
|
|||||||
{
|
{
|
||||||
long fromCommitTime = System.currentTimeMillis();
|
long fromCommitTime = System.currentTimeMillis();
|
||||||
|
|
||||||
SOLRTest st = new SOLRTest4(txnHelper, fileFolderService, nodeService, rootNodeRef, "testNodeMetaDataManyNodes", true, false);
|
SOLRTest st = new SOLRTest4(txnHelper, fileFolderService, nodeDAO, nodeService, rootNodeRef, "testNodeMetaDataManyNodes", true, false);
|
||||||
st.buildTransactions();
|
st.buildTransactions();
|
||||||
|
|
||||||
List<Transaction> txns = solrDAO.getTransactions(null, fromCommitTime, 0);
|
List<Transaction> txns = solrDAO.getTransactions(null, fromCommitTime, 0);
|
||||||
@@ -257,11 +258,64 @@ public class SOLRDAOTest extends TestCase
|
|||||||
getNodeMetaData(nodeMetaDataParams, null, st);
|
getNodeMetaData(nodeMetaDataParams, null, st);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFilters()
|
public void testNodeMetaDataCache() throws Exception
|
||||||
|
{
|
||||||
|
long fromCommitTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
SOLRTest st = new SOLRTest4(txnHelper, fileFolderService, nodeDAO, nodeService, rootNodeRef, "testNodeMetaDataManyNodes", true, false);
|
||||||
|
st.buildTransactions();
|
||||||
|
|
||||||
|
List<Transaction> txns = solrDAO.getTransactions(null, fromCommitTime, 0);
|
||||||
|
|
||||||
|
int[] updates = new int[] {2001};
|
||||||
|
int[] deletes = new int[] {0};
|
||||||
|
List<Long> txnIds = checkTransactions(txns, 1, updates, deletes);
|
||||||
|
|
||||||
|
NodeParameters nodeParameters = new NodeParameters();
|
||||||
|
nodeParameters.setTransactionIds(txnIds);
|
||||||
|
getNodes(nodeParameters, st);
|
||||||
|
|
||||||
|
// clear out node caches
|
||||||
|
nodeDAO.clear();
|
||||||
|
|
||||||
|
System.out.println("Cold cache - explicit clear");
|
||||||
|
NodeMetaDataParameters nodeMetaDataParams = new NodeMetaDataParameters();
|
||||||
|
nodeMetaDataParams.setNodeIds(st.getNodeIds());
|
||||||
|
// nodeMetaDataParams.setMaxResults(1000);
|
||||||
|
MetaDataResultsFilter filter = new MetaDataResultsFilter();
|
||||||
|
filter.setIncludeAssociations(false);
|
||||||
|
//filter.setIncludePaths(false);
|
||||||
|
filter.setIncludeChildAssociations(false);
|
||||||
|
getNodeMetaData(nodeMetaDataParams, filter, st);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public void testNodeMetaDataNullPropertyValue() throws Exception
|
||||||
|
{
|
||||||
|
long fromCommitTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
SOLRTest st = new SOLRTest5(txnHelper, fileFolderService, nodeDAO, nodeService, rootNodeRef, "testNodeMetaDataNullPropertyValue", true, true);
|
||||||
|
st.buildTransactions();
|
||||||
|
|
||||||
|
List<Transaction> txns = solrDAO.getTransactions(null, fromCommitTime, 0);
|
||||||
|
|
||||||
|
int[] updates = new int[] {11};
|
||||||
|
int[] deletes = new int[] {0};
|
||||||
|
List<Long> txnIds = checkTransactions(txns, 1, updates, deletes);
|
||||||
|
|
||||||
|
NodeParameters nodeParameters = new NodeParameters();
|
||||||
|
nodeParameters.setTransactionIds(txnIds);
|
||||||
|
getNodes(nodeParameters, st);
|
||||||
|
|
||||||
|
NodeMetaDataParameters nodeMetaDataParams = new NodeMetaDataParameters();
|
||||||
|
nodeMetaDataParams.setNodeIds(st.getNodeIds());
|
||||||
|
getNodeMetaData(nodeMetaDataParams, null, st);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* public void testFilters()
|
||||||
{
|
{
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
SOLRTest st = new SOLRTest1(txnHelper, fileFolderService, nodeService, rootNodeRef, "testFilters", true, true);
|
SOLRTest st = new SOLRTest1(txnHelper, fileFolderService, nodeDAO, nodeService, rootNodeRef, "testFilters", true, true);
|
||||||
st.buildTransactions();
|
st.buildTransactions();
|
||||||
|
|
||||||
List<Transaction> txns = solrDAO.getTransactions(null, startTime, 0);
|
List<Transaction> txns = solrDAO.getTransactions(null, startTime, 0);
|
||||||
@@ -277,7 +331,7 @@ public class SOLRDAOTest extends TestCase
|
|||||||
NodeMetaDataParameters nodeMetaDataParams = new NodeMetaDataParameters();
|
NodeMetaDataParameters nodeMetaDataParams = new NodeMetaDataParameters();
|
||||||
nodeMetaDataParams.setNodeIds(st.getNodeIds());
|
nodeMetaDataParams.setNodeIds(st.getNodeIds());
|
||||||
getNodeMetaData(nodeMetaDataParams, null, st);
|
getNodeMetaData(nodeMetaDataParams, null, st);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
private static class NodeAssertions
|
private static class NodeAssertions
|
||||||
{
|
{
|
||||||
@@ -455,6 +509,7 @@ public class SOLRDAOTest extends TestCase
|
|||||||
protected RetryingTransactionHelper txnHelper;
|
protected RetryingTransactionHelper txnHelper;
|
||||||
protected NodeService nodeService;
|
protected NodeService nodeService;
|
||||||
protected NodeRef rootNodeRef;
|
protected NodeRef rootNodeRef;
|
||||||
|
protected NodeDAO nodeDAO;
|
||||||
|
|
||||||
protected String containerName;
|
protected String containerName;
|
||||||
protected Map<NodeRef, NodeAssertions> nodeAssertions;
|
protected Map<NodeRef, NodeAssertions> nodeAssertions;
|
||||||
@@ -473,13 +528,14 @@ public class SOLRDAOTest extends TestCase
|
|||||||
protected long actualNodeCount = 0;
|
protected long actualNodeCount = 0;
|
||||||
protected long actualNodeMetaDataCount = 0;
|
protected long actualNodeMetaDataCount = 0;
|
||||||
|
|
||||||
SOLRTest(RetryingTransactionHelper txnHelper, FileFolderService fileFolderService, NodeService nodeService,
|
SOLRTest(RetryingTransactionHelper txnHelper, FileFolderService fileFolderService, NodeDAO nodeDAO, NodeService nodeService,
|
||||||
NodeRef rootNodeRef, String containerName, boolean doNodeChecks, boolean doMetaDataChecks)
|
NodeRef rootNodeRef, String containerName, boolean doNodeChecks, boolean doMetaDataChecks)
|
||||||
{
|
{
|
||||||
this.txnHelper = txnHelper;
|
this.txnHelper = txnHelper;
|
||||||
this.nodeService = nodeService;
|
this.nodeService = nodeService;
|
||||||
this.rootNodeRef = rootNodeRef;
|
this.rootNodeRef = rootNodeRef;
|
||||||
this.fileFolderService = fileFolderService;
|
this.fileFolderService = fileFolderService;
|
||||||
|
this.nodeDAO = nodeDAO;
|
||||||
|
|
||||||
this.containerName = containerName;
|
this.containerName = containerName;
|
||||||
this.nodeAssertions = new HashMap<NodeRef, NodeAssertions>();
|
this.nodeAssertions = new HashMap<NodeRef, NodeAssertions>();
|
||||||
@@ -580,19 +636,6 @@ public class SOLRDAOTest extends TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// protected void addNode(NodeRef nodeRef, NodeAssertions nodeStatus)
|
|
||||||
// {
|
|
||||||
// if(nodeStatus.nodeStatus == NodeStatus.UPDATED)
|
|
||||||
// {
|
|
||||||
// expectedNumMetaDataNodes++;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(doNodeChecks || doMetaDataChecks)
|
|
||||||
// {
|
|
||||||
// nodeAssertions.put(nodeRef, nodeStatus);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
void buildTransactions()
|
void buildTransactions()
|
||||||
{
|
{
|
||||||
buildTransactionsInternal();
|
buildTransactionsInternal();
|
||||||
@@ -614,8 +657,6 @@ public class SOLRDAOTest extends TestCase
|
|||||||
throw new RuntimeException("Unexpected missing assertion for NodeRef " + nodeRef);
|
throw new RuntimeException("Unexpected missing assertion for NodeRef " + nodeRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
//System.out.println("Node: " + node.toString());
|
|
||||||
|
|
||||||
if((expectedStatus.getNodeStatus() == NodeStatus.DELETED && isDeleted) ||
|
if((expectedStatus.getNodeStatus() == NodeStatus.DELETED && isDeleted) ||
|
||||||
(expectedStatus.getNodeStatus() == NodeStatus.UPDATED && !isDeleted))
|
(expectedStatus.getNodeStatus() == NodeStatus.UPDATED && !isDeleted))
|
||||||
{
|
{
|
||||||
@@ -630,21 +671,82 @@ public class SOLRDAOTest extends TestCase
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* private boolean compareProperties(Map<QName, Serializable> properties1, Map<QName, Serializable> properties2)
|
||||||
|
{
|
||||||
|
boolean match = true;
|
||||||
|
|
||||||
|
if(properties1.size() != properties2.size())
|
||||||
|
{
|
||||||
|
match = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for(QName qname : properties1.keySet())
|
||||||
|
{
|
||||||
|
Serializable value1 = properties1.get(qname);
|
||||||
|
Serializable value2 = properties2.get(qname);
|
||||||
|
if(value1 instanceof MLText)
|
||||||
|
{
|
||||||
|
if(!(value2 instanceof MLText))
|
||||||
|
{
|
||||||
|
match = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
MLText ml1 = (MLText)value1;
|
||||||
|
MLText ml2 = (MLText)value2;
|
||||||
|
if(ml1.getDefaultValue().equals(ml2.getDefaultValue()))
|
||||||
|
{
|
||||||
|
match = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(value1 instanceof ContentDataWithId)
|
||||||
|
{
|
||||||
|
if(!(value2 instanceof ContentDataWithId))
|
||||||
|
{
|
||||||
|
match = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ContentDataWithId cd1 = (ContentDataWithId)value1;
|
||||||
|
ContentDataWithId cd2 = (ContentDataWithId)value2;
|
||||||
|
if(cd1.getDefaultValue().equals(ml2.getDefaultValue()))
|
||||||
|
{
|
||||||
|
match = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(!value1.equals(value2))
|
||||||
|
{
|
||||||
|
match = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return match;
|
||||||
|
}*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handleNodeMetaData(NodeMetaData nodeMetaData) {
|
public boolean handleNodeMetaData(NodeMetaData nodeMetaData) {
|
||||||
actualNodeMetaDataCount++;
|
actualNodeMetaDataCount++;
|
||||||
|
|
||||||
if(doMetaDataChecks)
|
if(doMetaDataChecks)
|
||||||
{
|
{
|
||||||
|
Long nodeId = nodeMetaData.getNodeId();
|
||||||
NodeRef nodeRef = nodeMetaData.getNodeRef();
|
NodeRef nodeRef = nodeMetaData.getNodeRef();
|
||||||
|
|
||||||
Set<QName> aspects = nodeMetaData.getAspects();
|
Set<QName> aspects = nodeMetaData.getAspects();
|
||||||
Set<QName> actualAspects = nodeService.getAspects(nodeRef);
|
Set<QName> actualAspects = nodeService.getAspects(nodeRef);
|
||||||
assertEquals("Aspects are incorrect", aspects, actualAspects);
|
assertEquals("Aspects are incorrect", actualAspects, aspects);
|
||||||
|
|
||||||
Map<QName, Serializable> properties = nodeMetaData.getProperties();
|
Map<QName, Serializable> properties = nodeMetaData.getProperties();
|
||||||
Map<QName, Serializable> actualProperties = nodeService.getProperties(nodeRef);
|
// NodeService converts properties so use nodeDAO to get unadulterated property value
|
||||||
assertEquals("Properties are incorrect", properties, actualProperties);
|
Map<QName, Serializable> actualProperties = nodeDAO.getNodeProperties(nodeId);
|
||||||
|
//assertTrue("Properties are incorrect", compareProperties(actualProperties, properties));
|
||||||
|
assertEquals("Properties are incorrect", actualProperties, properties);
|
||||||
|
|
||||||
NodeAssertions assertions = getNodeAssertions(nodeRef);
|
NodeAssertions assertions = getNodeAssertions(nodeRef);
|
||||||
// NodeAssertions assertions = nodes.get(nodeRef);
|
// NodeAssertions assertions = nodes.get(nodeRef);
|
||||||
@@ -669,10 +771,11 @@ public class SOLRDAOTest extends TestCase
|
|||||||
assertEquals("Incorrect property value", expectedPropValue, actualPropValue);
|
assertEquals("Incorrect property value", expectedPropValue, actualPropValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Path> actualPaths = nodeMetaData.getPaths();
|
// TODO complete path tests
|
||||||
List<Path> expectedPaths = nodeService.getPaths(nodeRef, false);
|
// List<Path> actualPaths = nodeMetaData.getPaths();
|
||||||
assertEquals("Paths are incorrect", expectedPaths, actualPaths);
|
// List<Path> expectedPaths = nodeService.getPaths(nodeRef, false);
|
||||||
|
// assertEquals("Paths are incorrect", expectedPaths, actualPaths);
|
||||||
|
|
||||||
boolean expectAspects = assertions.isExpectAspects();
|
boolean expectAspects = assertions.isExpectAspects();
|
||||||
if(expectAspects && nodeMetaData.getAspects() == null)
|
if(expectAspects && nodeMetaData.getAspects() == null)
|
||||||
@@ -772,10 +875,10 @@ public class SOLRDAOTest extends TestCase
|
|||||||
private NodeRef content1;
|
private NodeRef content1;
|
||||||
private NodeRef content2;
|
private NodeRef content2;
|
||||||
|
|
||||||
SOLRTest1(RetryingTransactionHelper txnHelper, FileFolderService fileFolderService, NodeService nodeService,
|
SOLRTest1(RetryingTransactionHelper txnHelper, FileFolderService fileFolderService, NodeDAO nodeDAO, NodeService nodeService,
|
||||||
NodeRef rootNodeRef, String containerName, boolean doNodeChecks, boolean doMetaDataChecks)
|
NodeRef rootNodeRef, String containerName, boolean doNodeChecks, boolean doMetaDataChecks)
|
||||||
{
|
{
|
||||||
super(txnHelper, fileFolderService, nodeService, rootNodeRef, containerName, doNodeChecks, doMetaDataChecks);
|
super(txnHelper, fileFolderService, nodeDAO, nodeService, rootNodeRef, containerName, doNodeChecks, doMetaDataChecks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getExpectedNumNodes()
|
public int getExpectedNumNodes()
|
||||||
@@ -830,10 +933,10 @@ public class SOLRDAOTest extends TestCase
|
|||||||
private NodeRef content1;
|
private NodeRef content1;
|
||||||
private NodeRef content2;
|
private NodeRef content2;
|
||||||
|
|
||||||
SOLRTest2(RetryingTransactionHelper txnHelper, FileFolderService fileFolderService, NodeService nodeService,
|
SOLRTest2(RetryingTransactionHelper txnHelper, FileFolderService fileFolderService, NodeDAO nodeDAO, NodeService nodeService,
|
||||||
NodeRef rootNodeRef, String containerName, boolean doNodeChecks, boolean doMetaDataChecks)
|
NodeRef rootNodeRef, String containerName, boolean doNodeChecks, boolean doMetaDataChecks)
|
||||||
{
|
{
|
||||||
super(txnHelper, fileFolderService, nodeService, rootNodeRef, containerName, doNodeChecks, doMetaDataChecks);
|
super(txnHelper, fileFolderService, nodeDAO, nodeService, rootNodeRef, containerName, doNodeChecks, doMetaDataChecks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getExpectedNumNodes()
|
public int getExpectedNumNodes()
|
||||||
@@ -888,10 +991,10 @@ public class SOLRDAOTest extends TestCase
|
|||||||
private NodeRef content1;
|
private NodeRef content1;
|
||||||
private NodeRef content2;
|
private NodeRef content2;
|
||||||
|
|
||||||
SOLRTest3(RetryingTransactionHelper txnHelper, FileFolderService fileFolderService, NodeService nodeService,
|
SOLRTest3(RetryingTransactionHelper txnHelper, FileFolderService fileFolderService, NodeDAO nodeDAO, NodeService nodeService,
|
||||||
NodeRef rootNodeRef, String containerName, boolean doNodeChecks, boolean doMetaDataChecks)
|
NodeRef rootNodeRef, String containerName, boolean doNodeChecks, boolean doMetaDataChecks)
|
||||||
{
|
{
|
||||||
super(txnHelper, fileFolderService, nodeService, rootNodeRef, containerName, doNodeChecks, doMetaDataChecks);
|
super(txnHelper, fileFolderService, nodeDAO, nodeService, rootNodeRef, containerName, doNodeChecks, doMetaDataChecks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getExpectedNumNodes()
|
public int getExpectedNumNodes()
|
||||||
@@ -947,10 +1050,10 @@ public class SOLRDAOTest extends TestCase
|
|||||||
|
|
||||||
private static class SOLRTest100Nodes extends SOLRTest
|
private static class SOLRTest100Nodes extends SOLRTest
|
||||||
{
|
{
|
||||||
SOLRTest100Nodes(RetryingTransactionHelper txnHelper, FileFolderService fileFolderService, NodeService nodeService,
|
SOLRTest100Nodes(RetryingTransactionHelper txnHelper, FileFolderService fileFolderService, NodeDAO nodeDAO, NodeService nodeService,
|
||||||
NodeRef rootNodeRef, String containerName, boolean doNodeChecks, boolean doMetaDataChecks)
|
NodeRef rootNodeRef, String containerName, boolean doNodeChecks, boolean doMetaDataChecks)
|
||||||
{
|
{
|
||||||
super(txnHelper, fileFolderService, nodeService, rootNodeRef, containerName, doNodeChecks, doMetaDataChecks);
|
super(txnHelper, fileFolderService, nodeDAO, nodeService, rootNodeRef, containerName, doNodeChecks, doMetaDataChecks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getExpectedNumNodes()
|
public int getExpectedNumNodes()
|
||||||
@@ -992,10 +1095,10 @@ public class SOLRDAOTest extends TestCase
|
|||||||
{
|
{
|
||||||
private int numContentNodes = 2000;
|
private int numContentNodes = 2000;
|
||||||
|
|
||||||
SOLRTest4(RetryingTransactionHelper txnHelper, FileFolderService fileFolderService, NodeService nodeService,
|
SOLRTest4(RetryingTransactionHelper txnHelper, FileFolderService fileFolderService, NodeDAO nodeDAO, NodeService nodeService,
|
||||||
NodeRef rootNodeRef, String containerName, boolean doNodeChecks, boolean doMetaDataChecks)
|
NodeRef rootNodeRef, String containerName, boolean doNodeChecks, boolean doMetaDataChecks)
|
||||||
{
|
{
|
||||||
super(txnHelper, fileFolderService, nodeService, rootNodeRef, containerName, doNodeChecks, doMetaDataChecks);
|
super(txnHelper, fileFolderService, nodeDAO, nodeService, rootNodeRef, containerName, doNodeChecks, doMetaDataChecks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getExpectedNumNodes()
|
public int getExpectedNumNodes()
|
||||||
@@ -1028,6 +1131,7 @@ public class SOLRDAOTest extends TestCase
|
|||||||
{
|
{
|
||||||
nodeService.addAspect(nodeRef, ContentModel.ASPECT_TEMPORARY, null);
|
nodeService.addAspect(nodeRef, ContentModel.ASPECT_TEMPORARY, null);
|
||||||
}
|
}
|
||||||
|
nodeService.setProperty(nodeRef, ContentModel.PROP_AUTHOR, null);
|
||||||
|
|
||||||
setExpectedNodeStatus(nodeRef, NodeStatus.UPDATED);
|
setExpectedNodeStatus(nodeRef, NodeStatus.UPDATED);
|
||||||
}
|
}
|
||||||
@@ -1038,4 +1142,65 @@ public class SOLRDAOTest extends TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class SOLRTest5 extends SOLRTest
|
||||||
|
{
|
||||||
|
private int numContentNodes = 10;
|
||||||
|
|
||||||
|
SOLRTest5(RetryingTransactionHelper txnHelper, FileFolderService fileFolderService, NodeDAO nodeDAO, NodeService nodeService,
|
||||||
|
NodeRef rootNodeRef, String containerName, boolean doNodeChecks, boolean doMetaDataChecks)
|
||||||
|
{
|
||||||
|
super(txnHelper, fileFolderService, nodeDAO, nodeService, rootNodeRef, containerName, doNodeChecks, doMetaDataChecks);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getExpectedNumNodes()
|
||||||
|
{
|
||||||
|
return numContentNodes + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void buildTransactionsInternal()
|
||||||
|
{
|
||||||
|
final String titles[] =
|
||||||
|
{
|
||||||
|
"caf\u00E9", "\u00E7edilla", "\u00E0\u00E1\u00E2\u00E3", "\u00EC\u00ED\u00EE\u00EF", "\u00F0\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6",
|
||||||
|
"caf\u00E9", "\u00E7edilla", "\u00E0\u00E1\u00E2\u00E3", "\u00EC\u00ED\u00EE\u00EF", "\u00F0\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6"
|
||||||
|
};
|
||||||
|
txnHelper.doInTransaction(new RetryingTransactionCallback<Void>()
|
||||||
|
{
|
||||||
|
public Void execute() throws Throwable
|
||||||
|
{
|
||||||
|
PropertyMap props = new PropertyMap();
|
||||||
|
props.put(ContentModel.PROP_NAME, containerName);
|
||||||
|
NodeRef container = nodeService.createNode(
|
||||||
|
rootNodeRef,
|
||||||
|
ContentModel.ASSOC_CHILDREN,
|
||||||
|
ContentModel.ASSOC_CHILDREN,
|
||||||
|
ContentModel.TYPE_FOLDER,
|
||||||
|
props).getChildRef();
|
||||||
|
setExpectedNodeStatus(container, NodeStatus.UPDATED);
|
||||||
|
|
||||||
|
for(int i = 0; i < numContentNodes; i++)
|
||||||
|
{
|
||||||
|
FileInfo contentInfo = fileFolderService.create(container, "Content" + i, ContentModel.TYPE_CONTENT);
|
||||||
|
NodeRef nodeRef = contentInfo.getNodeRef();
|
||||||
|
|
||||||
|
nodeService.addAspect(nodeRef, ContentModel.ASPECT_AUTHOR, null);
|
||||||
|
if(i % 5 == 1)
|
||||||
|
{
|
||||||
|
nodeService.setProperty(nodeRef, ContentModel.PROP_AUTHOR, null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nodeService.setProperty(nodeRef, ContentModel.PROP_AUTHOR, "author" + i);
|
||||||
|
}
|
||||||
|
|
||||||
|
nodeService.setProperty(nodeRef, ContentModel.PROP_TITLE, titles[i]);
|
||||||
|
|
||||||
|
setExpectedNodeStatus(nodeRef, NodeStatus.UPDATED);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,11 +20,14 @@ package org.alfresco.repo.domain.solr.ibatis;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.domain.node.Node;
|
import org.alfresco.repo.domain.node.Node;
|
||||||
import org.alfresco.repo.domain.node.NodeDAO;
|
import org.alfresco.repo.domain.node.NodeDAO;
|
||||||
import org.alfresco.repo.domain.node.NodeDAO.ChildAssocRefQueryCallback;
|
import org.alfresco.repo.domain.node.NodeDAO.ChildAssocRefQueryCallback;
|
||||||
@@ -38,10 +41,16 @@ import org.alfresco.repo.domain.solr.NodeParameters;
|
|||||||
import org.alfresco.repo.domain.solr.SOLRDAO;
|
import org.alfresco.repo.domain.solr.SOLRDAO;
|
||||||
import org.alfresco.repo.domain.solr.SOLRTransactionParameters;
|
import org.alfresco.repo.domain.solr.SOLRTransactionParameters;
|
||||||
import org.alfresco.repo.domain.solr.Transaction;
|
import org.alfresco.repo.domain.solr.Transaction;
|
||||||
|
import org.alfresco.repo.tenant.TenantService;
|
||||||
|
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
||||||
|
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
|
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
|
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.Path;
|
import org.alfresco.service.cmr.repository.Path;
|
||||||
|
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||||
import org.alfresco.service.cmr.security.OwnableService;
|
import org.alfresco.service.cmr.security.OwnableService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.util.Pair;
|
import org.alfresco.util.Pair;
|
||||||
@@ -70,9 +79,15 @@ public class SOLRDAOImpl implements SOLRDAO
|
|||||||
private NodeDAO nodeDAO;
|
private NodeDAO nodeDAO;
|
||||||
private QNameDAO qnameDAO;
|
private QNameDAO qnameDAO;
|
||||||
private OwnableService ownableService;
|
private OwnableService ownableService;
|
||||||
|
private TenantService tenantService;
|
||||||
|
|
||||||
private SqlSessionTemplate template;
|
private SqlSessionTemplate template;
|
||||||
|
|
||||||
|
public void setTenantService(TenantService tenantService)
|
||||||
|
{
|
||||||
|
this.tenantService = tenantService;
|
||||||
|
}
|
||||||
|
|
||||||
public void setOwnableService(OwnableService ownableService)
|
public void setOwnableService(OwnableService ownableService)
|
||||||
{
|
{
|
||||||
this.ownableService = ownableService;
|
this.ownableService = ownableService;
|
||||||
@@ -103,6 +118,8 @@ public class SOLRDAOImpl implements SOLRDAO
|
|||||||
*/
|
*/
|
||||||
public void init()
|
public void init()
|
||||||
{
|
{
|
||||||
|
PropertyCheck.mandatory(this, "ownableService", ownableService);
|
||||||
|
PropertyCheck.mandatory(this, "tenantService", tenantService);
|
||||||
PropertyCheck.mandatory(this, "dictionaryService", dictionaryService);
|
PropertyCheck.mandatory(this, "dictionaryService", dictionaryService);
|
||||||
PropertyCheck.mandatory(this, "nodeDAO", nodeDAO);
|
PropertyCheck.mandatory(this, "nodeDAO", nodeDAO);
|
||||||
PropertyCheck.mandatory(this, "qnameDAO", qnameDAO);
|
PropertyCheck.mandatory(this, "qnameDAO", qnameDAO);
|
||||||
@@ -190,46 +207,227 @@ public class SOLRDAOImpl implements SOLRDAO
|
|||||||
* A dumb iterator that iterates over longs in sequence.
|
* A dumb iterator that iterates over longs in sequence.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static class SequenceIterator implements Iterable<Long>
|
private static class SequenceIterator implements Iterable<Long>, Iterator<Long>
|
||||||
{
|
{
|
||||||
private long fromId;
|
private long fromId;
|
||||||
private long toId;
|
private long toId;
|
||||||
private long counter;
|
private long counter;
|
||||||
|
private int maxResults;
|
||||||
|
private boolean inUse = false;
|
||||||
|
|
||||||
SequenceIterator(Long fromId, Long toId)
|
SequenceIterator(Long fromId, Long toId, int maxResults)
|
||||||
{
|
{
|
||||||
this.fromId = (fromId == null ? 1 : fromId.longValue());
|
this.fromId = (fromId == null ? 1 : fromId.longValue());
|
||||||
this.toId = (toId == null ? Long.MAX_VALUE : toId.longValue());
|
this.toId = (toId == null ? Long.MAX_VALUE : toId.longValue());
|
||||||
|
this.maxResults = maxResults;
|
||||||
this.counter = this.fromId;
|
this.counter = this.fromId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Long> getList()
|
||||||
|
{
|
||||||
|
List<Long> ret = new ArrayList<Long>(100);
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
Iterator nodeIds = iterator();
|
||||||
|
while(nodeIds.hasNext())
|
||||||
|
{
|
||||||
|
ret.add((Long)nodeIds.next());
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterator<Long> iterator()
|
public Iterator<Long> iterator()
|
||||||
{
|
{
|
||||||
counter = this.fromId;
|
if(inUse)
|
||||||
return new Iterator<Long>() {
|
{
|
||||||
|
throw new IllegalStateException("Already in use");
|
||||||
|
}
|
||||||
|
this.counter = this.fromId;
|
||||||
|
this.inUse = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext()
|
public boolean hasNext()
|
||||||
{
|
{
|
||||||
return counter <= toId;
|
return ((counter - this.fromId) < maxResults) && counter <= toId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long next()
|
public Long next()
|
||||||
{
|
{
|
||||||
return counter++;
|
return counter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove()
|
public void remove()
|
||||||
{
|
{
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isCategorised(AspectDefinition aspDef)
|
||||||
|
{
|
||||||
|
if(aspDef == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
AspectDefinition current = aspDef;
|
||||||
|
while (current != null)
|
||||||
|
{
|
||||||
|
if (current.getName().equals(ContentModel.ASPECT_CLASSIFIABLE))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QName parentName = current.getParentName();
|
||||||
|
if (parentName == null)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
current = dictionaryService.getAspect(parentName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Collection<Pair<Path, QName>> getCategoryPaths(NodeRef nodeRef, Set<QName> aspects, Map<QName, Serializable> properties)
|
||||||
|
{
|
||||||
|
ArrayList<Pair<Path, QName>> categoryPaths = new ArrayList<Pair<Path, QName>>();
|
||||||
|
|
||||||
|
for (QName classRef : aspects)
|
||||||
|
{
|
||||||
|
AspectDefinition aspDef = dictionaryService.getAspect(classRef);
|
||||||
|
if (isCategorised(aspDef))
|
||||||
|
{
|
||||||
|
LinkedList<Pair<Path, QName>> aspectPaths = new LinkedList<Pair<Path, QName>>();
|
||||||
|
for (PropertyDefinition propDef : aspDef.getProperties().values())
|
||||||
|
{
|
||||||
|
if (propDef.getDataType().getName().equals(DataTypeDefinition.CATEGORY))
|
||||||
|
{
|
||||||
|
for (NodeRef catRef : DefaultTypeConverter.INSTANCE.getCollection(NodeRef.class, properties.get(propDef.getName())))
|
||||||
|
{
|
||||||
|
if (catRef != null)
|
||||||
|
{
|
||||||
|
// can be running in context of System user, hence use input nodeRef
|
||||||
|
catRef = tenantService.getName(nodeRef, catRef);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Pair<Long, NodeRef> pair = nodeDAO.getNodePair(catRef);
|
||||||
|
for (Path path : nodeDAO.getPaths(pair, false))
|
||||||
|
{
|
||||||
|
if ((path.size() > 1) && (path.get(1) instanceof Path.ChildAssocElement))
|
||||||
|
{
|
||||||
|
Path.ChildAssocElement cae = (Path.ChildAssocElement) path.get(1);
|
||||||
|
boolean isFakeRoot = true;
|
||||||
|
|
||||||
|
final List<ChildAssociationRef> results = new ArrayList<ChildAssociationRef>(10);
|
||||||
|
// We have a callback handler to filter results
|
||||||
|
ChildAssocRefQueryCallback callback = new ChildAssocRefQueryCallback()
|
||||||
|
{
|
||||||
|
public boolean preLoadNodes()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean handle(
|
||||||
|
Pair<Long, ChildAssociationRef> childAssocPair,
|
||||||
|
Pair<Long, NodeRef> parentNodePair,
|
||||||
|
Pair<Long, NodeRef> childNodePair)
|
||||||
|
{
|
||||||
|
results.add(childAssocPair.getSecond());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void done()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Pair<Long, NodeRef> caePair = nodeDAO.getNodePair(cae.getRef().getChildRef());
|
||||||
|
nodeDAO.getParentAssocs(caePair.getFirst(), null, null, false, callback);
|
||||||
|
for (ChildAssociationRef car : results)
|
||||||
|
{
|
||||||
|
if (cae.getRef().equals(car))
|
||||||
|
{
|
||||||
|
isFakeRoot = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isFakeRoot)
|
||||||
|
{
|
||||||
|
if (path.toString().indexOf(aspDef.getName().toString()) != -1)
|
||||||
|
{
|
||||||
|
aspectPaths.add(new Pair<Path, QName>(path, aspDef.getName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (InvalidNodeRefException e)
|
||||||
|
{
|
||||||
|
// If the category does not exists we move on the next
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
categoryPaths.addAll(aspectPaths);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Add member final element
|
||||||
|
for (Pair<Path, QName> pair : categoryPaths)
|
||||||
|
{
|
||||||
|
if (pair.getFirst().last() instanceof Path.ChildAssocElement)
|
||||||
|
{
|
||||||
|
Path.ChildAssocElement cae = (Path.ChildAssocElement) pair.getFirst().last();
|
||||||
|
ChildAssociationRef assocRef = cae.getRef();
|
||||||
|
pair.getFirst().append(new Path.ChildAssocElement(new ChildAssociationRef(assocRef.getTypeQName(), assocRef.getChildRef(), QName.createQName("member"), nodeRef)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return categoryPaths;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Long> preCacheNodes(NodeMetaDataParameters nodeMetaDataParameters)
|
||||||
|
{
|
||||||
|
int maxResults = nodeMetaDataParameters.getMaxResults();
|
||||||
|
boolean isLimitSet = (maxResults != 0 && maxResults != Integer.MAX_VALUE);
|
||||||
|
|
||||||
|
List<Long> nodeIds = null;
|
||||||
|
Iterable<Long> iterable = null;
|
||||||
|
List<Long> allNodeIds = nodeMetaDataParameters.getNodeIds();
|
||||||
|
if(allNodeIds != null)
|
||||||
|
{
|
||||||
|
int toIndex = (maxResults > allNodeIds.size() ? allNodeIds.size() : maxResults);
|
||||||
|
nodeIds = isLimitSet ? allNodeIds.subList(0, toIndex) : nodeMetaDataParameters.getNodeIds();
|
||||||
|
iterable = nodeMetaDataParameters.getNodeIds();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Long fromNodeId = nodeMetaDataParameters.getFromNodeId();
|
||||||
|
Long toNodeId = nodeMetaDataParameters.getToNodeId();
|
||||||
|
nodeIds = new ArrayList<Long>(isLimitSet ? maxResults : 100); // TODO better default here?
|
||||||
|
iterable = new SequenceIterator(fromNodeId, toNodeId, maxResults);
|
||||||
|
int counter = 1;
|
||||||
|
for(Long nodeId : iterable)
|
||||||
|
{
|
||||||
|
if(isLimitSet && counter++ > maxResults)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
nodeIds.add(nodeId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// pre-cache nodes
|
||||||
|
nodeDAO.cacheNodesById(nodeIds);
|
||||||
|
|
||||||
|
return nodeIds;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@@ -247,52 +445,40 @@ public class SOLRDAOImpl implements SOLRDAO
|
|||||||
boolean includeChildAssociations = (resultFilter == null ? true : resultFilter.getIncludeChildAssociations());
|
boolean includeChildAssociations = (resultFilter == null ? true : resultFilter.getIncludeChildAssociations());
|
||||||
boolean includeOwner = (resultFilter == null ? true : resultFilter.getIncludeOwner());
|
boolean includeOwner = (resultFilter == null ? true : resultFilter.getIncludeOwner());
|
||||||
|
|
||||||
Iterable<Long> iterable = null;
|
List<Long> nodeIds = preCacheNodes(nodeMetaDataParameters);
|
||||||
if(nodeMetaDataParameters.getNodeIds() != null)
|
|
||||||
{
|
|
||||||
iterable = nodeMetaDataParameters.getNodeIds();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
iterable = new SequenceIterator(nodeMetaDataParameters.getFromNodeId(), nodeMetaDataParameters.getToNodeId());
|
|
||||||
}
|
|
||||||
|
|
||||||
// pre-cache nodes?
|
//Iterable<Long> iterable = null;
|
||||||
// TODO does this cache acls, etc for the node?
|
// if(nodeMetaDataParameters.getNodeIds() != null)
|
||||||
List<NodeRef> nodeRefs = new ArrayList<NodeRef>(100);
|
// {
|
||||||
int i = 1;
|
// int toIndex = (maxResults > allNodeIds.size() ? allNodeIds.size() : maxResults);
|
||||||
for(Long nodeId : iterable)
|
// nodeIds = isLimitSet ? nodeMetaDataParameters.getNodeIds().subList(0, maxResults) : nodeMetaDataParameters.getNodeIds();
|
||||||
|
// //iterable = nodeMetaDataParameters.getNodeIds();
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// Long fromNodeId = nodeMetaDataParameters.getFromNodeId();
|
||||||
|
// Long toNodeId = nodeMetaDataParameters.getToNodeId();
|
||||||
|
// nodeIds = new ArrayList<Long>(isLimitSet ? maxResults : 100); // TODO better default here
|
||||||
|
// SequenceIterator si = new SequenceIterator(fromNodeId, toNodeId, maxResults);
|
||||||
|
// nodeIds = si.getList();
|
||||||
|
// //iterable = si;
|
||||||
|
// }
|
||||||
|
// pre-cache nodes
|
||||||
|
// nodeDAO.cacheNodesById(nodeIds);
|
||||||
|
|
||||||
|
//int i = 1;
|
||||||
|
for(Long nodeId : nodeIds)
|
||||||
{
|
{
|
||||||
if(isLimitSet && i++ > maxResults)
|
Map<QName, Serializable> props = null;
|
||||||
{
|
Set<QName> aspects = null;
|
||||||
break;
|
|
||||||
}
|
// if(isLimitSet && i++ > maxResults)
|
||||||
|
// {
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
|
||||||
if(!nodeDAO.exists(nodeId))
|
if(!nodeDAO.exists(nodeId))
|
||||||
{
|
{
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Pair<Long, NodeRef> pair = nodeDAO.getNodePair(nodeId);
|
|
||||||
nodeRefs.add(pair.getSecond());
|
|
||||||
}
|
|
||||||
if(logger.isDebugEnabled())
|
|
||||||
{
|
|
||||||
logger.debug("SOLRDAO caching " + nodeRefs.size() + " nodes");
|
|
||||||
}
|
|
||||||
nodeDAO.cacheNodes(nodeRefs);
|
|
||||||
|
|
||||||
i = 1;
|
|
||||||
for(Long nodeId : iterable)
|
|
||||||
{
|
|
||||||
if(isLimitSet && i++ > maxResults)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!nodeDAO.exists(nodeId))
|
|
||||||
{
|
|
||||||
// ignore deleted node?
|
|
||||||
// TODO nodeDAO doesn't cache anything for deleted nodes. Should we be ignoring delete node meta data?
|
// TODO nodeDAO doesn't cache anything for deleted nodes. Should we be ignoring delete node meta data?
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -311,22 +497,31 @@ public class SOLRDAOImpl implements SOLRDAO
|
|||||||
nodeMetaData.setNodeType(nodeType);
|
nodeMetaData.setNodeType(nodeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(includeProperties)
|
if(includePaths || includeProperties)
|
||||||
{
|
{
|
||||||
Map<QName, Serializable> props = nodeDAO.getNodeProperties(nodeId);
|
props = nodeDAO.getNodeProperties(nodeId);
|
||||||
nodeMetaData.setProperties(props);
|
|
||||||
}
|
}
|
||||||
|
nodeMetaData.setProperties(props);
|
||||||
|
|
||||||
if(includeAspects)
|
if(includePaths || includeAspects)
|
||||||
{
|
{
|
||||||
Set<QName> aspects = nodeDAO.getNodeAspects(nodeId);
|
aspects = nodeDAO.getNodeAspects(nodeId);
|
||||||
nodeMetaData.setAspects(aspects);
|
|
||||||
}
|
}
|
||||||
|
nodeMetaData.setAspects(aspects);
|
||||||
|
|
||||||
// paths may change during get i.e. node moved around in the graph
|
// TODO paths may change during get i.e. node moved around in the graph
|
||||||
if(includePaths)
|
if(includePaths)
|
||||||
{
|
{
|
||||||
List<Path> paths = nodeDAO.getPaths(pair, false);
|
Collection<Pair<Path, QName>> categoryPaths = getCategoryPaths(pair.getSecond(), aspects, props);
|
||||||
|
List<Path> directPaths = nodeDAO.getPaths(pair, false);
|
||||||
|
|
||||||
|
Collection<Pair<Path, QName>> paths = new ArrayList<Pair<Path, QName>>(directPaths.size() + categoryPaths.size());
|
||||||
|
for (Path path : directPaths)
|
||||||
|
{
|
||||||
|
paths.add(new Pair<Path, QName>(path, null));
|
||||||
|
}
|
||||||
|
paths.addAll(categoryPaths);
|
||||||
|
|
||||||
nodeMetaData.setPaths(paths);
|
nodeMetaData.setPaths(paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,12 +533,11 @@ public class SOLRDAOImpl implements SOLRDAO
|
|||||||
if(includeChildAssociations)
|
if(includeChildAssociations)
|
||||||
{
|
{
|
||||||
final List<ChildAssociationRef> childAssocs = new ArrayList<ChildAssociationRef>(100);
|
final List<ChildAssociationRef> childAssocs = new ArrayList<ChildAssociationRef>(100);
|
||||||
nodeDAO.getChildAssocs(nodeId, null, null, null, false, false, new ChildAssocRefQueryCallback()
|
nodeDAO.getChildAssocs(nodeId, null, null, null, null, null, new ChildAssocRefQueryCallback()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean preLoadNodes()
|
public boolean preLoadNodes()
|
||||||
{
|
{
|
||||||
// already cached above
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -365,6 +559,29 @@ public class SOLRDAOImpl implements SOLRDAO
|
|||||||
|
|
||||||
if(includeAssociations)
|
if(includeAssociations)
|
||||||
{
|
{
|
||||||
|
final List<ChildAssociationRef> parentAssocs = new ArrayList<ChildAssociationRef>(100);
|
||||||
|
nodeDAO.getParentAssocs(nodeId, null, null, null, new ChildAssocRefQueryCallback()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public boolean handle(Pair<Long, ChildAssociationRef> childAssocPair,
|
||||||
|
Pair<Long, NodeRef> parentNodePair, Pair<Long, NodeRef> childNodePair)
|
||||||
|
{
|
||||||
|
parentAssocs.add(childAssocPair.getSecond());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean preLoadNodes()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void done()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// TODO non-child associations
|
// TODO non-child associations
|
||||||
// Collection<Pair<Long, AssociationRef>> sourceAssocs = nodeDAO.getSourceNodeAssocs(nodeId);
|
// Collection<Pair<Long, AssociationRef>> sourceAssocs = nodeDAO.getSourceNodeAssocs(nodeId);
|
||||||
// Collection<Pair<Long, AssociationRef>> targetAssocs = nodeDAO.getTargetNodeAssocs(nodeId);
|
// Collection<Pair<Long, AssociationRef>> targetAssocs = nodeDAO.getTargetNodeAssocs(nodeId);
|
||||||
|
@@ -41,6 +41,15 @@ public interface NodeBulkLoader
|
|||||||
*/
|
*/
|
||||||
public void cacheNodes(List<NodeRef> nodeRefs);
|
public void cacheNodes(List<NodeRef> nodeRefs);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pre-cache data relevant to the given nodes. There is no need to split the collection
|
||||||
|
* up before calling this method; it is up to the implementations to ensure that batching
|
||||||
|
* is done where necessary.
|
||||||
|
*
|
||||||
|
* @param nodeIds the nodes that will be cached.
|
||||||
|
*/
|
||||||
|
public void cacheNodesById(List<Long> nodeIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <b>FOR TESTING ONLY: </b>Clears out node cache data
|
* <b>FOR TESTING ONLY: </b>Clears out node cache data
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user