mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
transfer service : ALF-4128 alien nodes.
- unit test of multiple invasion - unit test move alien node via transfer. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@21685 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -968,75 +968,7 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
|
||||
log.debug("on create child association to transferred node");
|
||||
|
||||
final String localRepositoryId = descriptorService.getCurrentRepositoryDescriptor().getId();
|
||||
alienProcessor.onCreateChild(childAssocRef, localRepositoryId);
|
||||
//
|
||||
// ChildAssociationRef currentAssoc = childAssocRef;
|
||||
//
|
||||
// final String localRepositoryId = descriptorService.getCurrentRepositoryDescriptor().getId();
|
||||
//
|
||||
// // TODO Needs to check assoc is a cm:contains or subtype
|
||||
// if(childAssocRef.isPrimary())
|
||||
// {
|
||||
// NodeRef parentNodeRef = currentAssoc.getParentRef();
|
||||
// NodeRef childNodeRef = currentAssoc.getChildRef();
|
||||
//
|
||||
// /**
|
||||
// * Make the new child node ref an alien node
|
||||
// */
|
||||
// setAlien(childNodeRef, localRepositoryId);
|
||||
//
|
||||
// /**
|
||||
// * Now deal with the parents of this alien node
|
||||
// */
|
||||
// while(currentAssoc != null)
|
||||
// {
|
||||
// parentNodeRef = currentAssoc.getParentRef();
|
||||
// childNodeRef = currentAssoc.getChildRef();
|
||||
//
|
||||
// if(nodeService.hasAspect(parentNodeRef, TransferModel.ASPECT_TRANSFERRED) || nodeService.hasAspect(parentNodeRef, TransferModel.ASPECT_ALIEN))
|
||||
// {
|
||||
// if (!isInvaded(parentNodeRef, localRepositoryId))
|
||||
// {
|
||||
// if(log.isDebugEnabled())
|
||||
// {
|
||||
// log.debug("alien invades parent node:" + parentNodeRef + ", repositoryId:" + localRepositoryId);
|
||||
// }
|
||||
//
|
||||
// final NodeRef newAlien = parentNodeRef;
|
||||
//
|
||||
// /**
|
||||
// * Parent may be locked or not be editable by the current user
|
||||
// * turn off auditing and lock service for this transaction and
|
||||
// * run as admin.
|
||||
// */
|
||||
// RunAsWork<Void> actionRunAs = new RunAsWork<Void>()
|
||||
// {
|
||||
// public Void doWork() throws Exception
|
||||
// {
|
||||
// behaviourFilter.disableBehaviour(newAlien, ContentModel.ASPECT_AUDITABLE);
|
||||
// behaviourFilter.disableBehaviour(newAlien, ContentModel.ASPECT_LOCKABLE);
|
||||
// setAlien(newAlien, localRepositoryId);
|
||||
// return null;
|
||||
// }
|
||||
// };
|
||||
// AuthenticationUtil.runAs(actionRunAs, AuthenticationUtil.getSystemUserName());
|
||||
//
|
||||
// // Yes the parent has been invaded so step up to the parent's parent
|
||||
// currentAssoc = nodeService.getPrimaryParent(parentNodeRef);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// log.debug("parent node is already invaded");
|
||||
// currentAssoc = null;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// log.debug("parent is not a transferred node");
|
||||
// currentAssoc = null;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
alienProcessor.onCreateChild(childAssocRef, localRepositoryId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1048,175 +980,8 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
|
||||
{
|
||||
log.debug("on delete node - need to check for transferred node");
|
||||
alienProcessor.beforeDeleteAlien(deletedNodeRef);
|
||||
//
|
||||
// List<String>stuff = (List<String>)nodeService.getProperty(deletedNodeRef, TransferModel.PROP_INVADED_BY);
|
||||
//
|
||||
// Vector<String> exInvaders = new Vector<String>(stuff);
|
||||
//
|
||||
// ChildAssociationRef currentAssoc = nodeService.getPrimaryParent(deletedNodeRef);
|
||||
//
|
||||
// while(currentAssoc != null && exInvaders != null && exInvaders.size() > 0)
|
||||
// {
|
||||
// NodeRef parentNodeRef = currentAssoc.getParentRef();
|
||||
// NodeRef currentNodeRef = currentAssoc.getChildRef();
|
||||
//
|
||||
// /**
|
||||
// * Does the parent have alien invaders ?
|
||||
// */
|
||||
// if(nodeService.hasAspect(parentNodeRef, TransferModel.ASPECT_ALIEN))
|
||||
// {
|
||||
// log.debug("parent node is alien - check siblings");
|
||||
//
|
||||
// /**
|
||||
// * For each invader of the deletedNode
|
||||
// */
|
||||
// Iterator<String> i = exInvaders.listIterator();
|
||||
// while(i.hasNext())
|
||||
// {
|
||||
// String exInvader = i.next();
|
||||
// log.debug("Checking exInvader:" + exInvader);
|
||||
//
|
||||
// /**
|
||||
// * Check the siblings of this node to see whether there are any other alien nodes for this invader.
|
||||
// */
|
||||
// //TODO replace with a more efficient query
|
||||
// List<ChildAssociationRef> refs = nodeService.getChildAssocs(parentNodeRef);
|
||||
//
|
||||
// for(ChildAssociationRef ref : refs)
|
||||
// {
|
||||
// NodeRef childRef = ref.getChildRef();
|
||||
// List<String>invadedBy = (List<String>)nodeService.getProperty(childRef, TransferModel.PROP_INVADED_BY);
|
||||
//
|
||||
// if(childRef.equals(currentNodeRef))
|
||||
// {
|
||||
// // do nothing - this is the node we are working with.
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if(invadedBy != null && invadedBy.contains(exInvader))
|
||||
// {
|
||||
// // There is a sibling so remove this from the list of ex invaders.
|
||||
// log.debug("yes there is a sibling so it remains an invader");
|
||||
// i.remove();
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// } // for each child assoc
|
||||
//
|
||||
// } // for each invader
|
||||
//
|
||||
// log.debug("end of checking siblings");
|
||||
//
|
||||
// if(exInvaders.size() > 0)
|
||||
// {
|
||||
// log.debug("removing invaders from parent node:" + parentNodeRef);
|
||||
// List<String> parentInvaders = (List<String>)nodeService.getProperty(parentNodeRef, TransferModel.PROP_INVADED_BY);
|
||||
//
|
||||
// final List<String> newInvaders = new ArrayList<String>(10);
|
||||
// for(String invader : parentInvaders)
|
||||
// {
|
||||
// if(exInvaders.contains(invader))
|
||||
// {
|
||||
// log.debug("removing invader:" + invader);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// newInvaders.add(invader);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// final NodeRef oldAlien = parentNodeRef;
|
||||
//
|
||||
// /**
|
||||
// * Parent may be locked or not be editable by the current user
|
||||
// * turn off auditing and lock service for this transaction and
|
||||
// * run as admin.
|
||||
// */
|
||||
// RunAsWork<Void> actionRunAs = new RunAsWork<Void>()
|
||||
// {
|
||||
// public Void doWork() throws Exception
|
||||
// {
|
||||
// behaviourFilter.disableBehaviour(oldAlien, ContentModel.ASPECT_AUDITABLE);
|
||||
// behaviourFilter.disableBehaviour(oldAlien, ContentModel.ASPECT_LOCKABLE);
|
||||
// if(newInvaders.size() > 0)
|
||||
// {
|
||||
// nodeService.setProperty(oldAlien, TransferModel.PROP_INVADED_BY, (Serializable)newInvaders);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// log.debug("parent node no is no longer alien");
|
||||
// nodeService.removeAspect(oldAlien, TransferModel.ASPECT_ALIEN);
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
// };
|
||||
// AuthenticationUtil.runAs(actionRunAs, AuthenticationUtil.getSystemUserName());
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Now step up to the parent's parent
|
||||
// */
|
||||
// currentAssoc = nodeService.getPrimaryParent(parentNodeRef);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// log.debug("parent is not an alien node");
|
||||
// currentAssoc = null;
|
||||
// }
|
||||
// } // end of while
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Is this node invaded ?
|
||||
// * @param nodeRef
|
||||
// * @param invader
|
||||
// * @return true, this node has been invaded by the invader
|
||||
// */
|
||||
// private boolean isInvaded(NodeRef nodeRef, String invader)
|
||||
// {
|
||||
// List<String>invadedBy = (List<String>)nodeService.getProperty(nodeRef, TransferModel.PROP_INVADED_BY);
|
||||
//
|
||||
// if(invadedBy == null)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// return invadedBy.contains(invader);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Mark the specified node as an alien node, invadedby the invader.
|
||||
// * @param newAlien
|
||||
// * @param invader
|
||||
// */
|
||||
// private void setAlien(NodeRef newAlien, String invader)
|
||||
// {
|
||||
// // Introduce a Multi-valued property
|
||||
// List<String> invadedBy = (List<String>)nodeService.getProperty(newAlien,
|
||||
// TransferModel.PROP_INVADED_BY);
|
||||
//
|
||||
// if(invadedBy == null)
|
||||
// {
|
||||
// nodeService.setProperty(newAlien, TransferModel.PROP_ALIEN, Boolean.TRUE);
|
||||
// invadedBy = new ArrayList<String>(1);
|
||||
// }
|
||||
// invadedBy.add(invader);
|
||||
//
|
||||
// /**
|
||||
// * Set the invaded by property
|
||||
// */
|
||||
// nodeService.setProperty(newAlien, TransferModel.PROP_INVADED_BY, (Serializable) invadedBy);
|
||||
//
|
||||
// /**
|
||||
// * Experiment with a residual property
|
||||
// */
|
||||
// nodeService.setProperty(newAlien, QName.createQName(TransferModel.TRANSFER_MODEL_1_0_URI,
|
||||
// "invader" + invader), Boolean.TRUE);
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
public void setDescriptorService(DescriptorService descriptorService)
|
||||
{
|
||||
this.descriptorService = descriptorService;
|
||||
|
Reference in New Issue
Block a user