enabled renaming of SharedFodler
This commit is contained in:
parent
2012500de8
commit
7019740af7
|
@ -876,18 +876,18 @@ public class ItemsManager extends Impersonable{
|
||||||
ses = repository.getRepository().login(CredentialHandler.getAdminCredentials(context));
|
ses = repository.getRepository().login(CredentialHandler.getAdminCredentials(context));
|
||||||
|
|
||||||
authChecker.checkMoveOpsForProtectedFolders(ses, id);
|
authChecker.checkMoveOpsForProtectedFolders(ses, id);
|
||||||
authChecker.checkWriteAuthorizationControl(ses, currentUser, id, false);
|
|
||||||
|
|
||||||
final Node nodeToMove = ses.getNodeByIdentifier(id);
|
final Node nodeToMove = ses.getNodeByIdentifier(id);
|
||||||
|
|
||||||
final Item item = node2Item.getItem(nodeToMove, null);
|
final Item item = node2Item.getItem(nodeToMove, null);
|
||||||
|
|
||||||
if (item instanceof SharedFolder)
|
/*if (item instanceof SharedFolder)
|
||||||
throw new InvalidItemException("shared folder");
|
throw new InvalidItemException("shared folder");*/
|
||||||
|
|
||||||
if (Constants.FOLDERS_TO_EXLUDE.contains(item.getTitle()))
|
if (Constants.FOLDERS_TO_EXLUDE.contains(item.getTitle()))
|
||||||
throw new InvalidItemException("protected folder cannot be renamed");
|
throw new InvalidItemException("protected folder cannot be renamed");
|
||||||
|
|
||||||
|
String uniqueName = Utils.checkExistanceAndGetUniqueName(ses, nodeToMove.getParent(), newName);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ses.getWorkspace().getLockManager().lock(nodeToMove.getPath(), true, true, 0,currentUser);
|
ses.getWorkspace().getLockManager().lock(nodeToMove.getPath(), true, true, 0,currentUser);
|
||||||
|
@ -895,17 +895,23 @@ public class ItemsManager extends Impersonable{
|
||||||
}catch (LockException e) {
|
}catch (LockException e) {
|
||||||
throw new ItemLockedException(e);
|
throw new ItemLockedException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String uniqueName = Utils.checkExistanceAndGetUniqueName(ses, nodeToMove.getParent(), newName);
|
if (item instanceof SharedFolder) {
|
||||||
|
authChecker.checkAdministratorControl(ses, currentUser, (SharedFolder)item);
|
||||||
|
nodeToMove.setProperty(NodeProperty.TITLE.toString(), uniqueName);
|
||||||
|
Utils.setPropertyOnChangeNode(nodeToMove, currentUser, ItemAction.RENAMED);
|
||||||
|
accountingHandler.createRename(item.getTitle(), uniqueName, nodeToMove, currentUser, ses, false);
|
||||||
|
} else {
|
||||||
|
authChecker.checkWriteAuthorizationControl(ses, currentUser, id, false);
|
||||||
|
String newPath = String.format("%s/%s", nodeToMove.getParent().getPath(), uniqueName);
|
||||||
|
nodeToMove.setProperty(NodeProperty.TITLE.toString(), uniqueName);
|
||||||
|
Utils.setPropertyOnChangeNode(nodeToMove, currentUser, ItemAction.RENAMED);
|
||||||
|
accountingHandler.createRename(item.getTitle(), uniqueName, ses.getNode(newPath), currentUser, ses, false);
|
||||||
|
ses.move(nodeToMove.getPath(), newPath);
|
||||||
|
}
|
||||||
|
|
||||||
String newPath = String.format("%s/%s", nodeToMove.getParent().getPath(), uniqueName);
|
|
||||||
nodeToMove.setProperty(NodeProperty.TITLE.toString(), uniqueName);
|
|
||||||
Utils.setPropertyOnChangeNode(nodeToMove, currentUser, ItemAction.RENAMED);
|
|
||||||
ses.move(nodeToMove.getPath(), newPath);
|
|
||||||
|
|
||||||
accountingHandler.createRename(item.getTitle(), uniqueName, ses.getNode(newPath), currentUser, ses, false);
|
|
||||||
ses.save();
|
ses.save();
|
||||||
|
|
||||||
}finally {
|
}finally {
|
||||||
ses.getWorkspace().getLockManager().unlock(nodeToMove.getPath());
|
ses.getWorkspace().getLockManager().unlock(nodeToMove.getPath());
|
||||||
ses.getWorkspace().getLockManager().unlock(nodeToMove.getParent().getPath());
|
ses.getWorkspace().getLockManager().unlock(nodeToMove.getParent().getPath());
|
||||||
|
|
Loading…
Reference in New Issue