public void start() {
try {
H2HSession session = networkManager.getSession();
String randomPID = UUID.randomUUID().toString();
UserProfileManager profileManager = session.getProfileManager();
UserProfile userProfile = profileManager.getUserProfile(randomPID, true);
// get and check the file nodes to be rearranged
FolderIndex oldParent = (FolderIndex) userProfile.getFileById(oldParentKey);
if (oldParent == null) {
logger.error("Could not find the old parent.");
return;
} else if (!oldParent.canWrite(sender)) {
logger.error("User was not allowed to change the source directory.");
return;
}
Index child = oldParent.getChildByName(sourceFileName);
if (child == null) {
logger.error("File node that should be moved not found.");
return;
}
FolderIndex newParent = (FolderIndex) userProfile.getFileById(newParentKey);
if (newParent == null) {
logger.error("Could not find the new parent.");
return;
} else if (!newParent.canWrite(sender)) {
logger.error("User was not allowed to change the destination directory.");