// - file moved from other source to root
// - file moved from other source to other destination
// Additionally, the file can be renamed (within any directory)
try {
UserProfileManager profileManager = networkManager.getSession().getProfileManager();
UserProfile userProfile = profileManager.getUserProfile(getID(), true);
logger.debug("Start relinking the moved file in the user profile.");
Index movedNode = userProfile.getFileById(context.getFileNodeKeys().getPublic());
// consider renaming
movedNode.setName(context.getDestination().getName());
FolderIndex oldParent = movedNode.getParent();
oldParentKey = oldParent.getFileKeys().getPublic();
// source's parent needs to be updated, no matter if it's root or not
oldParent.removeChild(movedNode);
// add to the new parent
FolderIndex newParent = (FolderIndex) userProfile.getFileByPath(context.getDestination()
.getParentFile(), networkManager.getSession().getRoot());
movedNode.setParent(newParent);
newParent.addChild(movedNode);
// validate