/** * @see CheckOutCheckInService#getWorkingCopy(NodeRef) * @see CheckOutCheckInService#getCheckedOut(NodeRef) */ public void testBidirectionalReferences() { final NodeRef origNodeRef = nodeService .createNode( this.rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("test2"), ContentModel.TYPE_CONTENT) .getChildRef(); NodeRef wk1 = cociService.getWorkingCopy(origNodeRef); assertNull(wk1); // Check the document out final NodeRef workingCopy = cociService.checkout(origNodeRef); assertTrue( "Expect cm:workingcopy aspect", nodeService.hasAspect(workingCopy, ContentModel.ASPECT_WORKING_COPY)); assertTrue( "Expect cm:checkedOut aspect", nodeService.hasAspect(origNodeRef, ContentModel.ASPECT_CHECKED_OUT)); List<AssociationRef> targetAssocs = nodeService.getTargetAssocs(origNodeRef, ContentModel.ASSOC_WORKING_COPY_LINK); assertEquals("Expect a 1:1 relationship", 1, targetAssocs.size()); List<AssociationRef> sourceAssocs = nodeService.getSourceAssocs(workingCopy, ContentModel.ASSOC_WORKING_COPY_LINK); assertEquals("Expect a 1:1 relationship", 1, sourceAssocs.size()); // Need to commit the transaction in order to get the indexer to run setComplete(); endTransaction(); final NodeRef finalNodeRef = origNodeRef; this.transactionService .getRetryingTransactionHelper() .doInTransaction( new RetryingTransactionCallback<Object>() { public Object execute() { NodeRef wk2 = cociService.getWorkingCopy(finalNodeRef); assertNotNull(wk2); assertEquals(workingCopy, wk2); NodeRef orig2 = cociService.getCheckedOut(wk2); assertNotNull(orig2); assertEquals(origNodeRef, orig2); cociService.cancelCheckout(workingCopy); return null; } }); NodeRef wk3 = cociService.getWorkingCopy(this.nodeRef); assertNull(wk3); }
public DownloadRequest getDownloadRequest(NodeRef downloadNodeRef) { validateNode(downloadNodeRef); Map<QName, Serializable> properties = nodeService.getProperties(downloadNodeRef); List<AssociationRef> requestedNodes = nodeService.getTargetAssocs(downloadNodeRef, DownloadModel.ASSOC_REQUESTED_NODES); return new DownloadRequest( (Boolean) properties.get(DownloadModel.PROP_RECURSIVE), requestedNodes, (String) properties.get(ContentModel.PROP_CREATOR)); }