allows moving shared item outside the shared folder

This commit is contained in:
Lucio Lelii 2020-04-14 18:46:44 +02:00
parent 487eae33e2
commit 458b8a72ea
1 changed files with 9 additions and 4 deletions

View File

@ -871,8 +871,10 @@ public class ItemsManager {
if (!(destinationItem instanceof FolderItem))
throw new InvalidItemException("destination item is not a folder");
if (item.isShared() && (!destinationItem.isShared() || !getSharedParentNode(nodeToMove).getIdentifier().equals(getSharedParentNode(destination).getIdentifier())))
throw new InvalidCallParameters("shared Item cannot be moved in a different shared folder or in a private folder");
boolean movingSharedItemOutside = item.isShared() && (!destinationItem.isShared() || !getSharedParentNode(nodeToMove).getIdentifier().equals(getSharedParentNode(destination).getIdentifier()));
try {
ses.getWorkspace().getLockManager().lock(destination.getPath(), false, true, 0,login);
@ -886,9 +888,12 @@ public class ItemsManager {
ses.getWorkspace().move(nodeToMove.getPath(), newPath);
Utils.setPropertyOnChangeNode(ses.getNode(newPath), login, ItemAction.MOVED);
String mimeTypeForAccounting = (item instanceof AbstractFileItem)? ((AbstractFileItem) item).getContent().getMimeType(): null;
if (movingSharedItemOutside)
item2Node.updateOwnerOnSubTree(nodeToMove, login);
accountingHandler.createFolderAddObj(uniqueName, item.getClass().getSimpleName(), mimeTypeForAccounting , ses, destination, false);
accountingHandler.createFolderRemoveObj(item.getTitle(), item.getClass().getSimpleName(), mimeTypeForAccounting, ses, originalParent, false);
ses.save();