();
nodes.add(A1NodeRef);
nodes.add(A3NodeRef);
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists and has similar properties to the source
NodeRef A1destNodeRef = testNodeFactory.getMappedNodeRef(A1NodeRef);
NodeRef A2destNodeRef = testNodeFactory.getMappedNodeRef(A2NodeRef);
NodeRef A3destNodeRef = testNodeFactory.getMappedNodeRef(A3NodeRef);
NodeRef A4destNodeRef = testNodeFactory.getMappedNodeRef(A4NodeRef);
NodeRef A5destNodeRef = testNodeFactory.getMappedNodeRef(A5NodeRef);
NodeRef A6destNodeRef = testNodeFactory.getMappedNodeRef(A6NodeRef);
NodeRef A7destNodeRef = testNodeFactory.getMappedNodeRef(A7NodeRef);
NodeRef A8destNodeRef = testNodeFactory.getMappedNodeRef(A8NodeRef);
assertTrue("node A1 not alien", (Boolean)nodeService.hasAspect(A1destNodeRef, TransferModel.ASPECT_ALIEN));
assertTrue("node A2 not alien", (Boolean)nodeService.hasAspect(A2destNodeRef, TransferModel.ASPECT_ALIEN));
assertTrue("node A4 not alien", (Boolean)nodeService.hasAspect(A4destNodeRef, TransferModel.ASPECT_ALIEN));
assertTrue("node B11 does not exist", nodeService.exists(B11NodeRef));
assertTrue("node A3 deleted", nodeService.exists(A3destNodeRef));
assertFalse("node A5 not deleted", nodeService.exists(A5destNodeRef));
assertFalse("node A6 not deleted", nodeService.exists(A6destNodeRef));
assertFalse("node A7 not deleted", nodeService.exists(A7destNodeRef));
assertFalse("node A8 not deleted", nodeService.exists(A8destNodeRef));
}
finally
{
endTransaction();
}
}
/**
* Test the transfer method with regard to permissions on a node.
*
* Step 1:
* Create a node with a single permission
* Inherit:false
* Read, Admin, Allow
* Transfer
*
* Step 2:
* Update it to have several permissions
* Inherit:false
* Read, Everyone, DENY
* Read, Admin, Allow
*
* Step 3:
* Remove a permission
* Inherit:false
* Read, Admin, Allow
*
* Step 4:
* Revert to inherit all permissions
* Inherit:true
*
* This is a unit test so it does some shenanigans to send to the same instance of alfresco.
*/
public void testTransferWithPermissions() throws Exception
{
setDefaultRollback(false);
String CONTENT_TITLE = "ContentTitle";
String CONTENT_TITLE_UPDATED = "ContentTitleUpdated";
Locale CONTENT_LOCALE = Locale.GERMAN;
String CONTENT_STRING = "Hello";
/**
* For unit test
* - replace the HTTP transport with the in-process transport
* - replace the node factory with one that will map node refs, paths etc.
*/
TransferTransmitter transmitter = new UnitTestInProcessTransmitterImpl(receiver, contentService, transactionService);
transferServiceImpl.setTransmitter(transmitter);
UnitTestTransferManifestNodeFactory testNodeFactory = new UnitTestTransferManifestNodeFactory(this.transferManifestNodeFactory);
transferServiceImpl.setTransferManifestNodeFactory(testNodeFactory);
List> pathMap = testNodeFactory.getPathMap();
// Map company_home/guest_home to company_home so tranferred nodes and moved "up" one level.
pathMap.add(new Pair(PathHelper.stringToPath(GUEST_HOME_XPATH_QUERY), PathHelper.stringToPath(COMPANY_HOME_XPATH_QUERY)));
DescriptorService mockedDescriptorService = getMockDescriptorService(REPO_ID_A);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
/**
* Now go ahead and create our transfer target
*/
String targetName = "testTransferWithPermissions";
TransferTarget transferMe;
NodeRef contentNodeRef;
NodeRef destNodeRef;
startNewTransaction();
try
{
/**
* Get guest home
*/
String guestHomeQuery = "/app:company_home/app:guest_home";
ResultSet guestHomeResult = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH, guestHomeQuery);
assertEquals("", 1, guestHomeResult.length());
NodeRef guestHome = guestHomeResult.getNodeRef(0);
/**
* Create a test node that we will read and write
*/
String name = GUID.generate();
ChildAssociationRef child = nodeService.createNode(guestHome, ContentModel.ASSOC_CONTAINS, QName.createQName(name), ContentModel.TYPE_CONTENT);
contentNodeRef = child.getChildRef();
nodeService.setProperty(contentNodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(contentNodeRef, ContentModel.PROP_NAME, name);
ContentWriter writer = contentService.getWriter(contentNodeRef, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
permissionService.setInheritParentPermissions(contentNodeRef, false);
permissionService.setPermission(contentNodeRef, "admin", PermissionService.READ, true);
if(!transferService.targetExists(targetName))
{
transferMe = createTransferTarget(targetName);
}
else
{
transferMe = transferService.getTransferTarget(targetName);
}
}
finally
{
endTransaction();
}
/**
* Step 1
*/
logger.debug("First transfer - create new node with inheritParent permission off");
startNewTransaction();
try
{
/**
* Transfer our transfer target node
*/
{
TransferDefinition definition = new TransferDefinition();
Setnodes = new HashSet();
nodes.add(contentNodeRef);
definition.setNodes(nodes);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists with the correct permissions
destNodeRef = testNodeFactory.getMappedNodeRef(contentNodeRef);
assertFalse("unit test stuffed up - comparing with self", destNodeRef.equals(transferMe.getNodeRef()));
assertTrue("dest node ref does not exist", nodeService.exists(destNodeRef));
assertEquals("title is wrong", (String)nodeService.getProperty(destNodeRef, ContentModel.PROP_TITLE), CONTENT_TITLE);
assertEquals("type is wrong", nodeService.getType(contentNodeRef), nodeService.getType(destNodeRef));
// Check ACL of destination node
boolean srcInherit = permissionService.getInheritParentPermissions(contentNodeRef);
Set srcPerm = permissionService.getAllSetPermissions(contentNodeRef);
boolean destInherit = permissionService.getInheritParentPermissions(destNodeRef);
Set destPerm = permissionService.getAllSetPermissions(destNodeRef);
assertFalse("inherit parent permissions (src) flag is incorrect", srcInherit);
assertFalse("inherit parent permissions (dest) flag is incorrect", destInherit);
// Check destination has the source's permissions
for (AccessPermission p : srcPerm)
{
logger.debug("checking permission :" + p);
assertTrue("permission is missing", destPerm.contains(p));
}
}
finally
{
endTransaction();
}
/**
* Step 2
* Update it to have several permissions
* Inherit:false
* Read, Everyone, DENY
* Read, Admin, Allow
*/
startNewTransaction();
try
{
permissionService.setPermission(contentNodeRef, "EVERYONE", PermissionService.READ, false);
permissionService.setPermission(contentNodeRef, "admin", PermissionService.FULL_CONTROL, true);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
/**
* Transfer our transfer target node
*/
{
TransferDefinition definition = new TransferDefinition();
Setnodes = new HashSet();
nodes.add(contentNodeRef);
definition.setNodes(nodes);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists with the correct permissions
destNodeRef = testNodeFactory.getMappedNodeRef(contentNodeRef);
// Check ACL of destination node
boolean srcInherit = permissionService.getInheritParentPermissions(contentNodeRef);
Set srcPerm = permissionService.getAllSetPermissions(contentNodeRef);
boolean destInherit = permissionService.getInheritParentPermissions(destNodeRef);
Set destPerm = permissionService.getAllSetPermissions(destNodeRef);
assertFalse("inherit parent permissions (src) flag is incorrect", srcInherit);
assertFalse("inherit parent permissions (dest) flag is incorrect", destInherit);
// Check destination has the source's permissions
for (AccessPermission p : srcPerm)
{
logger.debug("checking permission :" + p);
assertTrue("Step2, permission is missing", destPerm.contains(p));
}
}
finally
{
endTransaction();
}
/**
* Step 3 Remove a permission
*/
startNewTransaction();
try
{
permissionService.deletePermission(contentNodeRef, "admin", PermissionService.FULL_CONTROL);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
/**
* Transfer our transfer target node
*/
{
TransferDefinition definition = new TransferDefinition();
Setnodes = new HashSet();
nodes.add(contentNodeRef);
definition.setNodes(nodes);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists with the correct permissions
destNodeRef = testNodeFactory.getMappedNodeRef(contentNodeRef);
// Check ACL of destination node
boolean srcInherit = permissionService.getInheritParentPermissions(contentNodeRef);
Set srcPerm = permissionService.getAllSetPermissions(contentNodeRef);
boolean destInherit = permissionService.getInheritParentPermissions(destNodeRef);
Set destPerm = permissionService.getAllSetPermissions(destNodeRef);
assertFalse("inherit parent permissions (src) flag is incorrect", srcInherit);
assertFalse("inherit parent permissions (dest) flag is incorrect", destInherit);
// Check destination has the source's permissions
for (AccessPermission p : srcPerm)
{
logger.debug("checking permission :" + p);
assertTrue("permission is missing", destPerm.contains(p));
}
}
finally
{
endTransaction();
}
/**
* Step 4
* Revert to inherit all permissions
*/
startNewTransaction();
try
{
permissionService.setInheritParentPermissions(contentNodeRef, true);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
/**
* Transfer our transfer target node
*/
{
TransferDefinition definition = new TransferDefinition();
Setnodes = new HashSet();
nodes.add(contentNodeRef);
definition.setNodes(nodes);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Now validate that the target node exists with the correct permissions
destNodeRef = testNodeFactory.getMappedNodeRef(contentNodeRef);
assertFalse("unit test stuffed up - comparing with self", destNodeRef.equals(transferMe.getNodeRef()));
assertTrue("dest node ref does not exist", nodeService.exists(destNodeRef));
assertEquals("title is wrong", (String)nodeService.getProperty(destNodeRef, ContentModel.PROP_TITLE), CONTENT_TITLE);
assertEquals("type is wrong", nodeService.getType(contentNodeRef), nodeService.getType(destNodeRef));
// Check ACL of destination node
boolean srcInherit = permissionService.getInheritParentPermissions(contentNodeRef);
Set srcPerm = permissionService.getAllSetPermissions(contentNodeRef);
boolean destInherit = permissionService.getInheritParentPermissions(destNodeRef);
Set destPerm = permissionService.getAllSetPermissions(destNodeRef);
assertTrue("inherit parent permissions (src) flag is incorrect", srcInherit);
assertTrue("inherit parent permissions (dest) flag is incorrect", destInherit);
// Check destination has the source's permissions
for (AccessPermission p : srcPerm)
{
if(p.isSetDirectly())
{
logger.debug("checking permission :" + p);
assertTrue("permission is missing:" + p, destPerm.contains(p));
}
}
}
finally
{
endTransaction();
}
}
/**
* Transfer with read only flag
*
* Node tree for this test
*
* A (Folder)
* | |
* B (Content) C (Folder)
* |
* D (Content)
*
* Step 1
* transfer Nodes ABCD with read only flag set - content should all be locked on destination
*
* Step 2
* lock B (Content node) as user fred
* transfer (read only) - destination lock should change to Admin
*
* Step 3
* lock C (Folder) as user fred
* transfer (read only) - destination lock should change to Admin
*
* Step 4
* transfer without read only flag - locks should revert from Admin to Fred.
*
* Step 5
* remove locks on A and B - transfer without read only flag - content should all be unlocked.
*/
public void testReadOnlyFlag() throws Exception
{
setDefaultRollback(false);
String CONTENT_TITLE = "ContentTitle";
String CONTENT_TITLE_UPDATED = "ContentTitleUpdated";
String CONTENT_NAME = "Demo Node 1";
Locale CONTENT_LOCALE = Locale.GERMAN;
String CONTENT_STRING = "The quick brown fox";
Setnodes = new HashSet();
String USER_ONE = "TransferServiceImplTest";
String PASSWORD = "Password";
String targetName = "testReadOnlyFlag";
NodeRef nodeA;
NodeRef nodeB;
NodeRef nodeC;
NodeRef nodeD;
ChildAssociationRef child;
/**
* For unit test
* - replace the HTTP transport with the in-process transport
* - replace the node factory with one that will map node refs, paths etc.
*/
TransferTransmitter transmitter = new UnitTestInProcessTransmitterImpl(this.receiver, this.contentService, transactionService);
transferServiceImpl.setTransmitter(transmitter);
UnitTestTransferManifestNodeFactory testNodeFactory = new UnitTestTransferManifestNodeFactory(this.transferManifestNodeFactory);
transferServiceImpl.setTransferManifestNodeFactory(testNodeFactory);
List> pathMap = testNodeFactory.getPathMap();
// Map company_home/guest_home to company_home so tranferred nodes and moved "up" one level.
pathMap.add(new Pair(PathHelper.stringToPath(GUEST_HOME_XPATH_QUERY), PathHelper.stringToPath(COMPANY_HOME_XPATH_QUERY)));
DescriptorService mockedDescriptorService = getMockDescriptorService(REPO_ID_A);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
TransferTarget transferMe;
startNewTransaction();
try
{
/**
* Get guest home
*/
String guestHomeQuery = "/app:company_home/app:guest_home";
ResultSet guestHomeResult = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH, guestHomeQuery);
assertEquals("", 1, guestHomeResult.length());
NodeRef guestHome = guestHomeResult.getNodeRef(0);
/**
* Create a test node that we will read and write
*/
String guid = GUID.generate();
child = nodeService.createNode(guestHome, ContentModel.ASSOC_CONTAINS, QName.createQName(guid), ContentModel.TYPE_FOLDER);
nodeA = child.getChildRef();
nodeService.setProperty(nodeA , ContentModel.PROP_TITLE, guid);
nodeService.setProperty(nodeA , ContentModel.PROP_NAME, guid);
nodes.add(nodeA);
child = nodeService.createNode(nodeA, ContentModel.ASSOC_CONTAINS, QName.createQName("testNodeB"), ContentModel.TYPE_CONTENT);
nodeB = child.getChildRef();
nodeService.setProperty(nodeB , ContentModel.PROP_TITLE, CONTENT_TITLE + "B");
nodeService.setProperty(nodeB , ContentModel.PROP_NAME, "DemoNodeB");
{
ContentWriter writer = contentService.getWriter(nodeB , ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
nodes.add(nodeB);
}
child = nodeService.createNode(nodeA, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,"testNodeC"), ContentModel.TYPE_FOLDER);
nodeC = child.getChildRef();
nodeService.setProperty(nodeC , ContentModel.PROP_TITLE, "TestNodeC");
nodeService.setProperty(nodeC , ContentModel.PROP_NAME, "TestNodeC");
nodes.add(nodeC);
child = nodeService.createNode(nodeC, ContentModel.ASSOC_CONTAINS, QName.createQName("testNodeD"), ContentModel.TYPE_CONTENT);
nodeD = child.getChildRef();
nodeService.setProperty(nodeD , ContentModel.PROP_TITLE, CONTENT_TITLE + "D");
nodeService.setProperty(nodeD , ContentModel.PROP_NAME, "DemoNodeD");
{
ContentWriter writer = contentService.getWriter(nodeD , ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
nodes.add(nodeD);
}
// Create users
createUser(USER_ONE, PASSWORD);
/**
* Now go ahead and create our first transfer target
*/
if(!transferService.targetExists(targetName))
{
transferMe = createTransferTarget(targetName);
}
else
{
transferMe = transferService.getTransferTarget(targetName);
}
}
finally
{
endTransaction();
}
/**
* Step 1.
* transfer Nodes ABCD with read only flag set - content should all be locked on destination
*/
logger.debug("transfer read only - step 1");
startNewTransaction();
try
{
/**
* Transfer our transfer target nodes
*/
{
TransferDefinition definition = new TransferDefinition();
definition.setNodes(nodes);
definition.setReadOnly(true);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Check destination nodes are locked.
assertTrue("dest node A does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeA)));
assertTrue("dest node B does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeB)));
assertTrue("dest node C does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeC)));
assertTrue("dest node D does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeD)));
assertTrue("dest node A not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeA), ContentModel.ASPECT_LOCKABLE));
assertTrue("dest node B not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeB), ContentModel.ASPECT_LOCKABLE));
assertTrue("dest node C not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeC), ContentModel.ASPECT_LOCKABLE));
assertTrue("dest node D not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeD), ContentModel.ASPECT_LOCKABLE));
}
finally
{
endTransaction();
}
/**
* Step 2
* lock B (Content node) as user ONE
* transfer (read only) - destination lock should change user to "Admin"
*/
startNewTransaction();
try
{
AuthenticationUtil.pushAuthentication();
AuthenticationUtil.setFullyAuthenticatedUser(USER_ONE);
lockService.lock(nodeB, LockType.READ_ONLY_LOCK);
}
finally
{
assertEquals("test error: dest node B lock ownership", nodeService.getProperty(nodeB, ContentModel.PROP_LOCK_OWNER), USER_ONE);
AuthenticationUtil.popAuthentication();
endTransaction();
}
logger.debug("transfer read only - step 2");
startNewTransaction();
try
{
/**
* Transfer our transfer target nodes
*/
{
TransferDefinition definition = new TransferDefinition();
definition.setNodes(nodes);
definition.setReadOnly(true);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Check destination nodes are locked.
assertTrue("dest node A does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeA)));
assertTrue("dest node B does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeB)));
assertTrue("dest node C does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeC)));
assertTrue("dest node D does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeD)));
assertTrue("dest node A not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeA), ContentModel.ASPECT_LOCKABLE));
assertTrue("dest node B not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeB), ContentModel.ASPECT_LOCKABLE));
assertTrue("dest node C not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeC), ContentModel.ASPECT_LOCKABLE));
assertTrue("dest node D not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeD), ContentModel.ASPECT_LOCKABLE));
// check that the lock owner is no longer USER_ONE
assertTrue("lock owner not changed", !USER_ONE.equalsIgnoreCase((String)nodeService.getProperty(testNodeFactory.getMappedNodeRef(nodeB), ContentModel.PROP_LOCK_OWNER)));
}
finally
{
endTransaction();
}
/**
* Step 3
* lock C (Folder node) as user ONE
* transfer (read only) - destination lock should change to Admin
*/
startNewTransaction();
try
{
AuthenticationUtil.pushAuthentication();
AuthenticationUtil.setFullyAuthenticatedUser(USER_ONE);
lockService.lock(nodeC, LockType.READ_ONLY_LOCK);
}
finally
{
assertEquals("test error: dest node C lock ownership", nodeService.getProperty(nodeC, ContentModel.PROP_LOCK_OWNER), USER_ONE);
AuthenticationUtil.popAuthentication();
endTransaction();
}
logger.debug("transfer read only - step 3");
startNewTransaction();
try
{
/**
* Transfer our transfer target nodes
*/
{
TransferDefinition definition = new TransferDefinition();
definition.setNodes(nodes);
definition.setReadOnly(true);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Check destination nodes are locked.
assertTrue("dest node A does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeA)));
assertTrue("dest node B does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeB)));
assertTrue("dest node C does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeC)));
assertTrue("dest node D does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeD)));
assertTrue("dest node A not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeA), ContentModel.ASPECT_LOCKABLE));
assertTrue("dest node B not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeB), ContentModel.ASPECT_LOCKABLE));
assertTrue("dest node C not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeC), ContentModel.ASPECT_LOCKABLE));
assertTrue("dest node D not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeD), ContentModel.ASPECT_LOCKABLE));
// check that the lock owner is no longer USER_ONE for content node B and folder node C
assertTrue("lock owner not changed", !USER_ONE.equalsIgnoreCase((String)nodeService.getProperty(testNodeFactory.getMappedNodeRef(nodeB), ContentModel.PROP_LOCK_OWNER)));
assertTrue("lock owner not changed", !USER_ONE.equalsIgnoreCase((String)nodeService.getProperty(testNodeFactory.getMappedNodeRef(nodeC), ContentModel.PROP_LOCK_OWNER)));
}
finally
{
endTransaction();
}
/**
* Step 4
* transfer without read only flag - locks should revert from Admin to USER_ONE.
*/
logger.debug("transfer read only - step 4");
startNewTransaction();
try
{
/**
* Transfer our transfer target nodes
*/
{
TransferDefinition definition = new TransferDefinition();
definition.setNodes(nodes);
definition.setReadOnly(false); // turn off read-only
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Check destination nodes are not locked.
assertTrue("dest node A does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeA)));
assertTrue("dest node B does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeB)));
assertTrue("dest node C does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeC)));
assertTrue("dest node D does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeD)));
assertFalse("dest node A not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeA), ContentModel.ASPECT_LOCKABLE));
assertTrue("dest node B not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeB), ContentModel.ASPECT_LOCKABLE));
assertTrue("dest node C not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeC), ContentModel.ASPECT_LOCKABLE));
assertFalse("dest node D not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeD), ContentModel.ASPECT_LOCKABLE));
assertEquals("dest node B lock ownership", nodeService.getProperty(testNodeFactory.getMappedNodeRef(nodeB), ContentModel.PROP_LOCK_OWNER), USER_ONE);
assertEquals("dest node C lock ownership", nodeService.getProperty(testNodeFactory.getMappedNodeRef(nodeC), ContentModel.PROP_LOCK_OWNER), USER_ONE);
}
finally
{
endTransaction();
}
/**
* Step 5
* remove locks on A and B - transfer without read only flag - content should all be unlocked.
*/
logger.debug("transfer read only - step 5");
startNewTransaction();
try
{
lockService.unlock(nodeB);
lockService.unlock(nodeC);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
/**
* Transfer our transfer target nodes
*/
{
TransferDefinition definition = new TransferDefinition();
definition.setNodes(nodes);
definition.setReadOnly(false); // turn off read-only
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Check destination nodes are not locked.
assertTrue("dest node A does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeA)));
assertTrue("dest node B does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeB)));
assertTrue("dest node C does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeC)));
assertTrue("dest node D does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(nodeD)));
assertFalse("test fail: dest node B is still locked", nodeService.hasAspect(nodeB, ContentModel.ASPECT_LOCKABLE));
assertFalse("test fail: dest node C is still locked", nodeService.hasAspect(nodeC, ContentModel.ASPECT_LOCKABLE));
assertFalse("dest node A not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeA), ContentModel.ASPECT_LOCKABLE));
assertFalse("dest node B not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeB), ContentModel.ASPECT_LOCKABLE));
assertFalse("dest node C not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeC), ContentModel.ASPECT_LOCKABLE));
assertFalse("dest node D not locked", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(nodeD), ContentModel.ASPECT_LOCKABLE));
}
finally
{
endTransaction();
}
} // end test read only flag
/**
* Transfer sync from multiple repos.
*
* This is a unit test so does lots of shenanigans to fake transfer from three repositories on a single repo.
*
* Multi-repo sync depends upon the following pieces of functionality
* a) transferred nodes are tagged with a trx:transferred aspect containing the originating repository
* id and the from repository id
* b) to support hub and spoke - when syncing don't imply delete nodes that are not "from" the transferring system
*
* * Tree of nodes
* A1
* | |
* A2 A3 (Content Node) B6 (Content Node)
* |
* A4 A5 B7
*
* Step 1
* Hub and Spoke Sync
* create Tree A1...A5
* transfer (sync)
* check the transfered aspects on destination
* create node B6. Fake its transfered aspect to be from Repo B.
* transfer (sync)
*
* Step 2
* Chain Sync
* Create Node A7 "from repo B".
* Change Nodes A1 ... A5 source to be received "from repo B"
* transfer
*
* //TO BE INVESTIGATED - Not yet implemented
* //c) when syncing don't accept updates to nodes that are not "from" the transferring system.
* //Step 3.
* //Multiple repo update of the same node
* //Change the transferred aspect for A5 destination to be "from" repo B
* //Update A5
* //Transfer (sync)
* //
* //Step 4.
* //Change the transferred aspect for A5 destination to be "from" repo B
* //Update A5
* //Transfer A5 (normal) - should update
*/
public void testTwoRepoSync() throws Exception
{
/**
* Step 1
* create Tree A1...A6
* transfer (sync)
* check the transfered aspect
* create node B6. Fake its transfered aspect to be from Repo B, Non Alien.
* transfer (sync)
*/
setDefaultRollback(false);
String CONTENT_TITLE = "ContentTitle";
String CONTENT_TITLE_UPDATED = "ContentTitleUpdated";
Locale CONTENT_LOCALE = Locale.GERMAN;
String CONTENT_STRING = "Hello";
/**
* For unit test
* - replace the HTTP transport with the in-process transport
* - replace the node factory with one that will map node refs, paths etc.
*/
TransferTransmitter transmitter = new UnitTestInProcessTransmitterImpl(receiver, contentService, transactionService);
transferServiceImpl.setTransmitter(transmitter);
UnitTestTransferManifestNodeFactory testNodeFactory = new UnitTestTransferManifestNodeFactory(this.transferManifestNodeFactory);
transferServiceImpl.setTransferManifestNodeFactory(testNodeFactory);
List> pathMap = testNodeFactory.getPathMap();
// Map company_home/guest_home to company_home so tranferred nodes and moved "up" one level.
pathMap.add(new Pair(PathHelper.stringToPath(GUEST_HOME_XPATH_QUERY), PathHelper.stringToPath(COMPANY_HOME_XPATH_QUERY)));
DescriptorService mockedDescriptorService = getMockDescriptorService(REPO_ID_A);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
String repositoryId = REPO_ID_A;
/**
* Now go ahead and create our first transfer target
*/
String targetName = "testTransferSyncNodes";
TransferTarget transferMe;
NodeRef A1NodeRef;
NodeRef A2NodeRef;
NodeRef A3NodeRef;
NodeRef A4NodeRef;
NodeRef A5NodeRef;
NodeRef B6NodeRef;
NodeRef A7NodeRef;
startNewTransaction();
try
{
/**
* Get guest home
*/
String guestHomeQuery = "/app:company_home/app:guest_home";
ResultSet guestHomeResult = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH, guestHomeQuery);
assertEquals("", 1, guestHomeResult.length());
NodeRef guestHome = guestHomeResult.getNodeRef(0);
/**
* Create a test nodes A1 through A5 that we will read and write
*/
{
// Node A1
String name = GUID.generate();
ChildAssociationRef child = nodeService.createNode(guestHome, ContentModel.ASSOC_CONTAINS, QName.createQName(name), ContentModel.TYPE_FOLDER);
A1NodeRef = child.getChildRef();
nodeService.setProperty(A1NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(A1NodeRef, ContentModel.PROP_NAME, name);
}
{
// Node A2
ChildAssociationRef child = nodeService.createNode(A1NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A2"), ContentModel.TYPE_FOLDER);
A2NodeRef = child.getChildRef();
nodeService.setProperty(A2NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(A2NodeRef, ContentModel.PROP_NAME, "A2");
}
{
// Node A3
ChildAssociationRef child = nodeService.createNode(A1NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A3"), ContentModel.TYPE_CONTENT);
A3NodeRef = child.getChildRef();
nodeService.setProperty(A3NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(A3NodeRef, ContentModel.PROP_NAME, "A3");
ContentWriter writer = contentService.getWriter(A3NodeRef, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
}
{
// Node A4
ChildAssociationRef child = nodeService.createNode(A2NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A4"), ContentModel.TYPE_CONTENT);
A4NodeRef = child.getChildRef();
nodeService.setProperty(A4NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(A4NodeRef, ContentModel.PROP_NAME, "A4");
ContentWriter writer = contentService.getWriter(A4NodeRef, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
}
{
// Node A5
ChildAssociationRef child = nodeService.createNode(A2NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A5"), ContentModel.TYPE_CONTENT);
A5NodeRef = child.getChildRef();
nodeService.setProperty(A5NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(A5NodeRef, ContentModel.PROP_NAME, "A5");
ContentWriter writer = contentService.getWriter(A5NodeRef, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
}
// Create the transfer target if it does not already exist
if(!transferService.targetExists(targetName))
{
transferMe = createTransferTarget(targetName);
}
else
{
transferMe = transferService.getTransferTarget(targetName);
}
}
finally
{
endTransaction();
}
Setnodes = new HashSet();
nodes.add(A1NodeRef);
nodes.add(A2NodeRef);
nodes.add(A3NodeRef);
nodes.add(A4NodeRef);
nodes.add(A5NodeRef);
/**
* transfer (sync)
* check the transfered aspect
* create node B6. Fake its transfered aspect to be from Repo B, Non Alien.
* transfer (sync)
*/
startNewTransaction();
try
{
{
TransferDefinition definition = new TransferDefinition();
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Node B6 - faked transfer from repository B. Child of Destination node A1
NodeRef a1Dest = testNodeFactory.getMappedNodeRef(A1NodeRef);
assertTrue("dest node A does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A1NodeRef)));
assertEquals("dest node A1 From RepositoryId", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A1NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), repositoryId);
assertEquals("dest node A1 Repository Id", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A1NodeRef), TransferModel.PROP_REPOSITORY_ID), repositoryId);
assertEquals("dest node A2 From RepositoryId", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A2NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), repositoryId);
assertEquals("dest node A2 Repository Id", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A2NodeRef), TransferModel.PROP_REPOSITORY_ID), repositoryId);
assertEquals("dest node A3 From RepositoryId", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A3NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), repositoryId);
assertEquals("dest node A3 Repository Id", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A3NodeRef), TransferModel.PROP_REPOSITORY_ID), repositoryId);
assertEquals("dest node A4 From RepositoryId", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A4NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), repositoryId);
assertEquals("dest node A4 Repository Id", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A4NodeRef), TransferModel.PROP_REPOSITORY_ID), repositoryId);
assertEquals("dest node A5 From RepositoryId", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A5NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), repositoryId);
assertEquals("dest node A5 Repository Id", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A5NodeRef), TransferModel.PROP_REPOSITORY_ID), repositoryId);
ChildAssociationRef child = nodeService.createNode(a1Dest, ContentModel.ASSOC_CONTAINS, QName.createQName("B6"), ContentModel.TYPE_CONTENT);
B6NodeRef = child.getChildRef();
nodeService.setProperty(B6NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(B6NodeRef, ContentModel.PROP_NAME, "B6");
/**
* The first tranfer was mocked to repository A - this is repository B.
*/
// This is repository B so there's no need to fake it
// nodeService.setProperty(B6NodeRef, TransferModel.PROP_FROM_REPOSITORY_ID, REPO_ID_B);
// nodeService.setProperty(B6NodeRef, TransferModel.PROP_REPOSITORY_ID, REPO_ID_B);
ContentWriter writer = contentService.getWriter(B6NodeRef, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
TransferDefinition definition = new TransferDefinition();
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
// Does node B6 still exist ?
assertTrue("dest node B6 does not exist", nodeService.exists(B6NodeRef));
assertTrue("B6 not alien", nodeService.hasAspect(B6NodeRef, TransferModel.ASPECT_ALIEN));
}
finally
{
endTransaction();
}
/** Step 2
* Chain Sync
* Change Nodes A1 ... A5 source to be received "from repo B"
* Create Node A7 - Fake it to be received "from repo B"
* transfer
*/
String NEW_TITLE="Chain sync";
startNewTransaction();
try
{
nodeService.setProperty(A1NodeRef, ContentModel.PROP_TITLE, NEW_TITLE);
nodeService.setProperty(A1NodeRef, TransferModel.PROP_FROM_REPOSITORY_ID, REPO_ID_B);
nodeService.setProperty(A1NodeRef, TransferModel.PROP_REPOSITORY_ID, REPO_ID_B);
nodeService.setProperty(A2NodeRef, ContentModel.PROP_TITLE, NEW_TITLE);
nodeService.setProperty(A2NodeRef, TransferModel.PROP_FROM_REPOSITORY_ID, REPO_ID_B);
nodeService.setProperty(A2NodeRef, TransferModel.PROP_REPOSITORY_ID, REPO_ID_B);
nodeService.setProperty(A3NodeRef, ContentModel.PROP_TITLE, NEW_TITLE);
nodeService.setProperty(A3NodeRef, TransferModel.PROP_FROM_REPOSITORY_ID, REPO_ID_B);
nodeService.setProperty(A3NodeRef, TransferModel.PROP_REPOSITORY_ID, REPO_ID_B);
/**
* The repository was mocked to repoistory A. This is repository B
*/
ChildAssociationRef child = nodeService.createNode(A2NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A7"), ContentModel.TYPE_CONTENT);
A7NodeRef = child.getChildRef();
nodeService.setProperty(A7NodeRef, ContentModel.PROP_TITLE, NEW_TITLE);
nodeService.setProperty(A7NodeRef, ContentModel.PROP_NAME, "A7");
nodeService.setProperty(A7NodeRef, ContentModel.PROP_TITLE, NEW_TITLE);
nodeService.setProperty(A7NodeRef, TransferModel.PROP_FROM_REPOSITORY_ID, REPO_ID_B);
nodeService.setProperty(A7NodeRef, TransferModel.PROP_REPOSITORY_ID, REPO_ID_B);
ContentWriter writer = contentService.getWriter(A3NodeRef, ContentModel.PROP_CONTENT, true);
writer.setLocale(CONTENT_LOCALE);
writer.putContent(CONTENT_STRING);
}
finally
{
endTransaction();
}
nodes.add(A7NodeRef);
startNewTransaction();
try
{
TransferDefinition definition = new TransferDefinition();
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
finally
{
endTransaction();
}
try
{
assertTrue("dest node A7 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A7NodeRef)));
assertEquals("dest node A1 Title", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A1NodeRef), ContentModel.PROP_TITLE), NEW_TITLE);
assertEquals("dest node A1 Repository Id", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A1NodeRef), TransferModel.PROP_REPOSITORY_ID), REPO_ID_B);
assertEquals("dest node A1 Repository Id", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A1NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), repositoryId);
assertEquals("dest node A2 Title", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A2NodeRef), ContentModel.PROP_TITLE), NEW_TITLE);
assertEquals("dest node A2 Repository Id", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A2NodeRef), TransferModel.PROP_REPOSITORY_ID), REPO_ID_B);
assertEquals("dest node A2 Repository Id", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A2NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), repositoryId);
assertEquals("dest node A3 Title", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A3NodeRef), ContentModel.PROP_TITLE), NEW_TITLE);
assertEquals("dest node A3 Repository Id", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A3NodeRef), TransferModel.PROP_REPOSITORY_ID), REPO_ID_B);
assertEquals("dest node A3 Repository Id", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A3NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), repositoryId);
}
finally
{
endTransaction();
}
} // test two repo sync
/**
* Transfer sync from multiple repos.
*
* This is a unit test so does lots of shenanigans to fake transfer from three repositories on a single repo.
*
* Trees of nodes
*
* A1 B1 C1
* | |
* A2/images A2 Dummy/images
* | |
* A3 C3
*
* Destination
* B1
* |
* A2/images
* | |
* C3 A3
* |
* C4
*
* Step 1. Transfer from A to B.
* Step 2. Transfer from C to B (crossing over on A2Dest)
* Step 3. Invade A3Dest via C
* Step 4. Delete C4. Sync from C
* Step 5. Delete C3 - A2 dest images folder uninvaded.
*/
public void testMultiRepoTransfer() throws Exception
{
setDefaultRollback(false);
String CONTENT_TITLE = "ContentTitle";
String CONTENT_TITLE_UPDATED = "ContentTitleUpdated";
Locale CONTENT_LOCALE = Locale.GERMAN;
String CONTENT_STRING = "Hello";
String targetName = "testMultiRepoTransfer";
TransferTarget transferMe;
NodeRef S0NodeRef;
NodeRef A1NodeRef;
NodeRef A2NodeRef;
NodeRef A3NodeRef;
NodeRef B1NodeRef;
NodeRef C1NodeRef;
NodeRef C2NodeRef;
NodeRef C3NodeRef;
NodeRef C4NodeRef;
NodeRef A3Dummy;
startNewTransaction();
try
{
/**
* Get guest home
*/
String guestHomeQuery = "/app:company_home/app:guest_home";
ResultSet guestHomeResult = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH, guestHomeQuery);
assertEquals("", 1, guestHomeResult.length());
NodeRef guestHome = guestHomeResult.getNodeRef(0);
{
/**
* Node Source - located under guest home
*/
String name = GUID.generate();
ChildAssociationRef child = nodeService.createNode(guestHome, ContentModel.ASSOC_CONTAINS, QName.createQName(name), ContentModel.TYPE_FOLDER);
S0NodeRef = child.getChildRef();
nodeService.setProperty(S0NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(S0NodeRef, ContentModel.PROP_NAME, name);
}
{
// Node A1
ChildAssociationRef child = nodeService.createNode(S0NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A1"), ContentModel.TYPE_FOLDER);
A1NodeRef = child.getChildRef();
nodeService.setProperty(A1NodeRef, ContentModel.PROP_TITLE, "A1");
nodeService.setProperty(A1NodeRef, ContentModel.PROP_NAME, "A1");
}
{
// Node A2
ChildAssociationRef child = nodeService.createNode(A1NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("images"), ContentModel.TYPE_FOLDER);
A2NodeRef = child.getChildRef();
nodeService.setProperty(A2NodeRef, ContentModel.PROP_TITLE, "images");
nodeService.setProperty(A2NodeRef, ContentModel.PROP_NAME, "images");
}
{
// Node A3
ChildAssociationRef child = nodeService.createNode(A2NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A3"), ContentModel.TYPE_FOLDER);
A3NodeRef = child.getChildRef();
nodeService.setProperty(A3NodeRef, ContentModel.PROP_TITLE, "A3");
nodeService.setProperty(A3NodeRef, ContentModel.PROP_NAME, "A3");
}
{
// Node B1
ChildAssociationRef child = nodeService.createNode(S0NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("B1"), ContentModel.TYPE_FOLDER);
B1NodeRef = child.getChildRef();
nodeService.setProperty(B1NodeRef, ContentModel.PROP_TITLE, "B1");
nodeService.setProperty(B1NodeRef, ContentModel.PROP_NAME, "B1");
}
{
// Node C1
ChildAssociationRef child = nodeService.createNode(S0NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("C1"), ContentModel.TYPE_FOLDER);
C1NodeRef = child.getChildRef();
nodeService.setProperty(C1NodeRef, ContentModel.PROP_TITLE, "C1");
nodeService.setProperty(C1NodeRef, ContentModel.PROP_NAME, "C1");
}
{
// Node C2/images
ChildAssociationRef child = nodeService.createNode(C1NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("images"), ContentModel.TYPE_FOLDER);
C2NodeRef = child.getChildRef();
nodeService.setProperty(C2NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(C2NodeRef, ContentModel.PROP_NAME, "images");
}
{
// Node C3
ChildAssociationRef child = nodeService.createNode(C2NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("C3"), ContentModel.TYPE_FOLDER);
C3NodeRef = child.getChildRef();
nodeService.setProperty(C3NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(C3NodeRef, ContentModel.PROP_NAME, "C3");
}
{
// Node A3 (Dummy)
ChildAssociationRef child = nodeService.createNode(C2NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A3"), ContentModel.TYPE_FOLDER);
A3Dummy = child.getChildRef();
nodeService.setProperty(A3Dummy, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(A3Dummy, ContentModel.PROP_NAME, "A3 Dummy");
}
{
// Node C4
ChildAssociationRef child = nodeService.createNode(A3Dummy, ContentModel.ASSOC_CONTAINS, QName.createQName("C4"), ContentModel.TYPE_FOLDER);
C4NodeRef = child.getChildRef();
nodeService.setProperty(C4NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(C4NodeRef, ContentModel.PROP_NAME, "C4");
}
// Create the transfer target if it does not already exist
if(!transferService.targetExists(targetName))
{
transferMe = createTransferTarget(targetName);
}
else
{
transferMe = transferService.getTransferTarget(targetName);
}
}
finally
{
endTransaction();
}
/**
* For unit test
* - replace the HTTP transport with the in-process transport
* - Map path from A1 to B1 (So transfer will transfer by path)
* - Map path from C1 to B1
*/
TransferTransmitter transmitter = new UnitTestInProcessTransmitterImpl(receiver, contentService, transactionService);
transferServiceImpl.setTransmitter(transmitter);
UnitTestTransferManifestNodeFactory testNodeFactory = new UnitTestTransferManifestNodeFactory(this.transferManifestNodeFactory);
transferServiceImpl.setTransferManifestNodeFactory(testNodeFactory);
List> pathMap = testNodeFactory.getPathMap();
// Map Project A/images to Project B/images
// Map Project C/images to Project A/images
nodeService.getPath(A2NodeRef);
pathMap.add(new Pair(nodeService.getPath(A1NodeRef), nodeService.getPath(B1NodeRef)));
pathMap.add(new Pair(nodeService.getPath(C1NodeRef), nodeService.getPath(B1NodeRef)));
DescriptorService mockedDescriptorService = getMockDescriptorService(REPO_ID_A);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
/**
* Step 1
* Now transfer in A's nodes to Repo B
*/
startNewTransaction();
try
{
TransferDefinition definition = new TransferDefinition();
Collection nodes = new ArrayList();
nodes.add(A1NodeRef);
nodes.add(A2NodeRef);
nodes.add(A3NodeRef);
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
assertTrue("dest node A2 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A2NodeRef)));
assertTrue("dest node A3 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A3NodeRef)));
// Check that A3 dest is a child of A2Dest which is a child of B1
ChildAssociationRef A3Ref = nodeService.getPrimaryParent(testNodeFactory.getMappedNodeRef(A3NodeRef));
assertEquals("A3 dest is connected to the wrong node", A3Ref.getParentRef(), testNodeFactory.getMappedNodeRef(A2NodeRef));
ChildAssociationRef A2Ref = nodeService.getPrimaryParent(testNodeFactory.getMappedNodeRef(A2NodeRef));
assertEquals("A2 dest is connected to the wrong node", A2Ref.getParentRef(), B1NodeRef);
assertEquals("A2 dest owned by wrong repo", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A2NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), REPO_ID_A);
assertEquals("A3 dest owned by wrong repo", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A3NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), REPO_ID_A);
}
finally
{
endTransaction();
}
/**
* Step 2
* Now transfer in C's nodes
* B2 (Owned by A) gets invaded by C
*/
startNewTransaction();
try
{
mockedDescriptorService = getMockDescriptorService(REPO_ID_C);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
TransferDefinition definition = new TransferDefinition();
Collection nodes = new ArrayList();
nodes.add(C1NodeRef);
nodes.add(C2NodeRef);
nodes.add(C3NodeRef);
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
assertTrue("dest node A3 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A3NodeRef)));
assertTrue("dest node C3 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(C3NodeRef)));
// Check that A3 dest is a child of A2Dest which is a child of B1
// Check that C3 dest is a child of A2Dest
ChildAssociationRef A3Ref = nodeService.getPrimaryParent(testNodeFactory.getMappedNodeRef(A3NodeRef));
assertEquals("A3 dest is connected to the wrong node", A3Ref.getParentRef(), testNodeFactory.getMappedNodeRef(A2NodeRef));
ChildAssociationRef C3Ref = nodeService.getPrimaryParent(testNodeFactory.getMappedNodeRef(A3NodeRef));
assertEquals("C3 dest is connected to the wrong node", C3Ref.getParentRef(), testNodeFactory.getMappedNodeRef(A2NodeRef));
ChildAssociationRef A2Ref = nodeService.getPrimaryParent(testNodeFactory.getMappedNodeRef(A2NodeRef));
assertEquals("A2 dest is connected to the wrong node", A2Ref.getParentRef(), B1NodeRef);
assertTrue("A2 dest is not invaded", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(A2NodeRef), TransferModel.ASPECT_ALIEN));
assertTrue("C3 dest is not invaded", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(C3NodeRef), TransferModel.ASPECT_ALIEN));
assertFalse("A3 dest is invaded", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(A3NodeRef), TransferModel.ASPECT_ALIEN));
assertEquals("A2 dest owned by wrong repo", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A2NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), REPO_ID_A);
assertEquals("A3 dest owned by wrong repo", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A3NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), REPO_ID_A);
assertEquals("C3 dest owned by wrong repo", nodeService.getProperty(testNodeFactory.getMappedNodeRef(C3NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), REPO_ID_C);
}
finally
{
endTransaction();
}
/**
* Step 3
* Invade A3Dest via transfer of C4 from C
*/
startNewTransaction();
try
{
mockedDescriptorService = getMockDescriptorService(REPO_ID_C);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
TransferDefinition definition = new TransferDefinition();
Collection nodes = new ArrayList();
nodes.add(C4NodeRef);
definition.setNodes(nodes);
definition.setSync(false);
transferService.transfer(targetName, definition);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
assertTrue("dest node A3 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A3NodeRef)));
assertTrue("dest node C3 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(C3NodeRef)));
assertTrue("dest node C4 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(C4NodeRef)));
assertTrue("C4 is not an invader", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(C4NodeRef), TransferModel.ASPECT_ALIEN));
assertTrue("A3 is not an invader", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(A3NodeRef), TransferModel.ASPECT_ALIEN));
assertEquals("A2 dest owned by wrong repo", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A2NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), REPO_ID_A);
assertEquals("A3 dest owned by wrong repo", nodeService.getProperty(testNodeFactory.getMappedNodeRef(A3NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), REPO_ID_A);
assertEquals("C3 dest owned by wrong repo", nodeService.getProperty(testNodeFactory.getMappedNodeRef(C3NodeRef), TransferModel.PROP_FROM_REPOSITORY_ID), REPO_ID_C);
}
finally
{
endTransaction();
}
/**
* Step 4
* Uninvade A3 from C by deleting C4
* Via Sync of A3Dummy (which has the same destination path as A3).
*/
startNewTransaction();
try
{
nodeService.deleteNode(C4NodeRef);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
mockedDescriptorService = getMockDescriptorService(REPO_ID_C);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
TransferDefinition definition = new TransferDefinition();
Collection nodes = new ArrayList();
nodes.add(A3Dummy);
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
assertTrue("dest node A3 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A3NodeRef)));
assertTrue("dest node C3 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(C3NodeRef)));
assertFalse("dest node C4 not deleted", nodeService.exists(testNodeFactory.getMappedNodeRef(C4NodeRef)));
logger.debug("A3 Dest is " + testNodeFactory.getMappedNodeRef(A3NodeRef));
assertFalse("A3 Dest still invaded by C4", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(A3NodeRef), TransferModel.ASPECT_ALIEN));
}
finally
{
endTransaction();
}
/**
* Step 5 - repeat the above test with transfer(non sync) rather than transfer(sync)
* Uninvade by deleting C3.
*/
startNewTransaction();
try
{
nodeService.deleteNode(C3NodeRef);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
mockedDescriptorService = getMockDescriptorService(REPO_ID_C);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
TransferDefinition definition = new TransferDefinition();
Collection nodes = new ArrayList();
NodeRef C3Deleted = new NodeRef(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE, C3NodeRef.getId());
nodes.add(C3Deleted);
definition.setNodes(nodes);
definition.setSync(false);
transferService.transfer(targetName, definition);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
assertTrue("dest node A3 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A3NodeRef)));
assertFalse("dest node C3 not deleted", nodeService.exists(testNodeFactory.getMappedNodeRef(C3NodeRef)));
assertFalse("dest node C4 not deleted", nodeService.exists(testNodeFactory.getMappedNodeRef(C4NodeRef)));
assertFalse("A3 still invaded", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(A3NodeRef), TransferModel.ASPECT_ALIEN));
assertFalse("A2 still invaded", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(A2NodeRef), TransferModel.ASPECT_ALIEN));
}
finally
{
endTransaction();
}
} // test multi repo sync
// Utility methods below.
private TransferTarget createTransferTarget(String name)
{
String title = "title";
String description = "description";
String endpointProtocol = "http";
String endpointHost = "MARKR02";
int endpointPort = 7080;
String endpointPath = "/alfresco/service/api/transfer";
String username = "admin";
char[] password = "admin".toCharArray();
/**
* Now go ahead and create our first transfer target
*/
TransferTarget target = transferService.createAndSaveTransferTarget(name, title, description, endpointProtocol, endpointHost, endpointPort, endpointPath, username, password);
return target;
}
/**
* Test the transfer method behaviour with respect to move and alien nodes.
*
* So we have Repository A transferring content and Repository B is the local repo that we
* move alien nodes in and out.
*
* Tree
*
* B1
* | |
* C2(p1) C3(p2)
* |
* A4
*
*
* Setup tree above. Validate that A1 is child of C2.
*
* Step 1. Move A4 fron C2 to C3 via transfer.
* C2Dest should stop being invaded C3Dest should be invaded.
*/
public void testMultiRepoTransferMove() throws Exception
{
setDefaultRollback(false);
String CONTENT_TITLE = "ContentTitle";
String CONTENT_TITLE_UPDATED = "ContentTitleUpdated";
Locale CONTENT_LOCALE = Locale.GERMAN;
String CONTENT_STRING = "Hello";
String targetName = "testMultiRepoTransferMove";
TransferTarget transferMe;
NodeRef S0NodeRef;
NodeRef A1NodeRef;
NodeRef B1NodeRef;
NodeRef C1NodeRef;
NodeRef C2NodeRef;
NodeRef C3NodeRef;
NodeRef A4NodeRef;
NodeRef C2DummyNodeRef;
NodeRef C3DummyNodeRef;
QName C2Path = QName.createQName("p2");
QName C3Path= QName.createQName("p3");
startNewTransaction();
try
{
/**
* Get guest home
*/
String guestHomeQuery = "/app:company_home/app:guest_home";
ResultSet guestHomeResult = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH, guestHomeQuery);
assertEquals("", 1, guestHomeResult.length());
NodeRef guestHome = guestHomeResult.getNodeRef(0);
{
/**
* Node Source - located under guest home
*/
String name = GUID.generate();
ChildAssociationRef child = nodeService.createNode(guestHome, ContentModel.ASSOC_CONTAINS, QName.createQName(name), ContentModel.TYPE_FOLDER);
S0NodeRef = child.getChildRef();
nodeService.setProperty(S0NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(S0NodeRef, ContentModel.PROP_NAME, name);
}
{
// Node A1
ChildAssociationRef child = nodeService.createNode(S0NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A1"), ContentModel.TYPE_FOLDER);
A1NodeRef = child.getChildRef();
nodeService.setProperty(A1NodeRef, ContentModel.PROP_TITLE, "A1");
nodeService.setProperty(A1NodeRef, ContentModel.PROP_NAME, "A1");
}
{
// Node B1
ChildAssociationRef child = nodeService.createNode(S0NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("B1"), ContentModel.TYPE_FOLDER);
B1NodeRef = child.getChildRef();
nodeService.setProperty(B1NodeRef, ContentModel.PROP_TITLE, "B1");
nodeService.setProperty(B1NodeRef, ContentModel.PROP_NAME, "B1");
}
{
// Node C1
ChildAssociationRef child = nodeService.createNode(S0NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("C1"), ContentModel.TYPE_FOLDER);
C1NodeRef = child.getChildRef();
nodeService.setProperty(C1NodeRef, ContentModel.PROP_TITLE, "C1");
nodeService.setProperty(C1NodeRef, ContentModel.PROP_NAME, "C1");
}
{
// Node C2
ChildAssociationRef child = nodeService.createNode(C1NodeRef, ContentModel.ASSOC_CONTAINS, C2Path, ContentModel.TYPE_FOLDER);
C2NodeRef = child.getChildRef();
nodeService.setProperty(C2NodeRef, ContentModel.PROP_TITLE, "C2");
nodeService.setProperty(C2NodeRef, ContentModel.PROP_NAME, "C2");
}
{
// Node C3
ChildAssociationRef child = nodeService.createNode(C1NodeRef, ContentModel.ASSOC_CONTAINS, C3Path, ContentModel.TYPE_FOLDER);
C3NodeRef = child.getChildRef();
nodeService.setProperty(C3NodeRef, ContentModel.PROP_TITLE, "C3");
nodeService.setProperty(C3NodeRef, ContentModel.PROP_NAME, "C3");
}
{
// Node C2 (Dummy)
ChildAssociationRef child = nodeService.createNode(A1NodeRef, ContentModel.ASSOC_CONTAINS, C2Path, ContentModel.TYPE_FOLDER);
C2DummyNodeRef = child.getChildRef();
nodeService.setProperty(C2DummyNodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(C2DummyNodeRef, ContentModel.PROP_NAME, "C2 Dummy");
}
{
// Node C3 (Dummy)
ChildAssociationRef child = nodeService.createNode(A1NodeRef, ContentModel.ASSOC_CONTAINS, C3Path, ContentModel.TYPE_FOLDER);
C3DummyNodeRef = child.getChildRef();
nodeService.setProperty(C3DummyNodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE);
nodeService.setProperty(C3DummyNodeRef, ContentModel.PROP_NAME, "C3 Dummy");
}
{
// Node A4
ChildAssociationRef child = nodeService.createNode(C2DummyNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("C4"), ContentModel.TYPE_FOLDER);
A4NodeRef = child.getChildRef();
nodeService.setProperty(A4NodeRef, ContentModel.PROP_TITLE, "C4");
nodeService.setProperty(A4NodeRef, ContentModel.PROP_NAME, "C4");
}
// Create the transfer target if it does not already exist
if(!transferService.targetExists(targetName))
{
transferMe = createTransferTarget(targetName);
}
else
{
transferMe = transferService.getTransferTarget(targetName);
}
}
finally
{
endTransaction();
}
/**
* For unit test
* - replace the HTTP transport with the in-process transport
* - Map path from A1 to B1 (So transfer will transfer by path)
* - Map path from C1 to B1
*/
TransferTransmitter transmitter = new UnitTestInProcessTransmitterImpl(receiver, contentService, transactionService);
transferServiceImpl.setTransmitter(transmitter);
UnitTestTransferManifestNodeFactory testNodeFactory = new UnitTestTransferManifestNodeFactory(this.transferManifestNodeFactory);
transferServiceImpl.setTransferManifestNodeFactory(testNodeFactory);
List> pathMap = testNodeFactory.getPathMap();
// Map Project A to Project B
// Map Project C to Project B
pathMap.add(new Pair(nodeService.getPath(A1NodeRef), nodeService.getPath(B1NodeRef)));
pathMap.add(new Pair(nodeService.getPath(C1NodeRef), nodeService.getPath(B1NodeRef)));
DescriptorService mockedDescriptorService = getMockDescriptorService(REPO_ID_C);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
/**
* Step 1
* Now transfer in C's nodes to Repo B
*/
startNewTransaction();
try
{
TransferDefinition definition = new TransferDefinition();
Collection nodes = new ArrayList();
nodes.add(C1NodeRef);
nodes.add(C2NodeRef);
nodes.add(C3NodeRef);
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
assertTrue("dest node C2 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(C2NodeRef)));
assertTrue("dest node C3 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(C3NodeRef)));
// Check that C3 dest is a child of B1
ChildAssociationRef C3Ref = nodeService.getPrimaryParent(testNodeFactory.getMappedNodeRef(C3NodeRef));
assertEquals("A3 dest is connected to the wrong node", C3Ref.getParentRef(), B1NodeRef);
ChildAssociationRef C2Ref = nodeService.getPrimaryParent(testNodeFactory.getMappedNodeRef(C2NodeRef));
assertEquals("A2 dest is connected to the wrong node", C2Ref.getParentRef(), B1NodeRef);
}
finally
{
endTransaction();
}
mockedDescriptorService = getMockDescriptorService(REPO_ID_A);
transferServiceImpl.setDescriptorService(mockedDescriptorService);
/**
* Step 2
* Now transfer in A's nodes
* C2 (Dest) gets invaded by A4
*/
startNewTransaction();
try
{
TransferDefinition definition = new TransferDefinition();
Collection nodes = new ArrayList();
nodes.add(A4NodeRef);
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
assertTrue("dest node A4 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A4NodeRef)));
assertTrue("dest node C3 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(C3NodeRef)));
assertTrue("dest node C2 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(C2NodeRef)));
// Check that A4 dest is a child of C2Dest which is a child of B1
ChildAssociationRef A4Ref = nodeService.getPrimaryParent(testNodeFactory.getMappedNodeRef(A4NodeRef));
assertEquals("A4 dest is connected to the wrong node", A4Ref.getParentRef(), testNodeFactory.getMappedNodeRef(C2NodeRef));
assertTrue("C2 dest is not invaded", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(C2NodeRef), TransferModel.ASPECT_ALIEN));
assertFalse("C3 dest is not invaded", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(C3NodeRef), TransferModel.ASPECT_ALIEN));
}
finally
{
endTransaction();
}
/**
* Step 3
* Now move A3
* C2 (Dest) gets invaded by A4
*/
startNewTransaction();
try
{
nodeService.moveNode(A4NodeRef, C3DummyNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("C4"));
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
TransferDefinition definition = new TransferDefinition();
Collection nodes = new ArrayList();
nodes.add(A4NodeRef);
definition.setNodes(nodes);
definition.setSync(true);
transferService.transfer(targetName, definition);
}
finally
{
endTransaction();
}
startNewTransaction();
try
{
assertTrue("dest node A4 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(A4NodeRef)));
assertTrue("dest node C3 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(C3NodeRef)));
assertTrue("dest node C2 does not exist", nodeService.exists(testNodeFactory.getMappedNodeRef(C2NodeRef)));
// Check that A4 dest is a child of C3Dest which is a child of B1
ChildAssociationRef A4Ref = nodeService.getPrimaryParent(testNodeFactory.getMappedNodeRef(A4NodeRef));
assertEquals("A4 dest is connected to the wrong node", A4Ref.getParentRef(), testNodeFactory.getMappedNodeRef(C3NodeRef));
assertTrue("A4 dest is not invaded", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(A4NodeRef), TransferModel.ASPECT_ALIEN));
assertTrue("C3 dest is not invaded", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(C3NodeRef), TransferModel.ASPECT_ALIEN));
assertFalse("C2 dest is still invaded", nodeService.hasAspect(testNodeFactory.getMappedNodeRef(C2NodeRef), TransferModel.ASPECT_ALIEN));
}
finally
{
endTransaction();
}
}
/**
* transfer should only be able to update and delete nodes that are "from" the transferring system
*/
public void testFromRepo()
{
assertTrue("not yet implemented", false);
}
private void createUser(String userName, String password)
{
if (this.authenticationService.authenticationExists(userName) == false)
{
this.authenticationService.createAuthentication(userName, password.toCharArray());
PropertyMap ppOne = new PropertyMap(4);
ppOne.put(ContentModel.PROP_USERNAME, userName);
ppOne.put(ContentModel.PROP_FIRSTNAME, "firstName");
ppOne.put(ContentModel.PROP_LASTNAME, "lastName");
ppOne.put(ContentModel.PROP_EMAIL, "email@email.com");
ppOne.put(ContentModel.PROP_JOBTITLE, "jobTitle");
this.personService.createPerson(ppOne);
}
}
private DescriptorService getMockDescriptorService(String repositoryId)
{
DescriptorService descriptorService = mock(DescriptorService.class);
Descriptor descriptor = mock(Descriptor.class);
when(descriptor.getId()).thenReturn(repositoryId);
when(descriptorService.getCurrentRepositoryDescriptor()).thenReturn(descriptor);
return descriptorService;
}
}