This commit is contained in:
Lucio Lelii 2019-03-26 17:22:04 +00:00
parent 789f89e43a
commit 59b2fbdefc
1 changed files with 15 additions and 5 deletions

View File

@ -280,13 +280,23 @@ public class ItemsCreator {
try {
newNode = ses.getNode(org.gcube.common.storagehub.model.Paths.append(org.gcube.common.storagehub.model.Paths.getPath(destinationNode.getPath()), name).toPath());
authChecker.checkWriteAuthorizationControl(ses, newNode.getIdentifier(), false);
versionHandler.checkoutContentNode(newNode, ses);
log.trace("replacing content of class {}",item.getContent().getClass());
item2Node.replaceContent(newNode,item, ItemAction.UPDATED);
accountingHandler.createFileUpdated(item.getTitle(), ses, newNode, false);
ses.getWorkspace().getLockManager().lock(newNode.getPath(), true, true, 0,login);
try {
versionHandler.checkoutContentNode(newNode, ses);
log.trace("replacing content of class {}",item.getContent().getClass());
item2Node.replaceContent(newNode,item, ItemAction.UPDATED);
accountingHandler.createFileUpdated(item.getTitle(), ses, newNode, false);
}finally {
ses.getWorkspace().getLockManager().unlock(newNode.getPath());
}
}catch(PathNotFoundException pnf) {
authChecker.checkWriteAuthorizationControl(ses, destinationNode.getIdentifier(), true);
newNode = item2Node.getNode(destinationNode, item);
ses.getWorkspace().getLockManager().lock(destinationNode.getPath(), false, true, 0,login);
try {
newNode = item2Node.getNode(destinationNode, item);
}finally {
ses.getWorkspace().getLockManager().unlock(destinationNode.getPath());
}
versionHandler.makeVersionableContent(newNode, ses);
accountingHandler.createFolderAddObj(name, item.getClass().getSimpleName(), item.getContent().getMimeType(), ses, newNode, false);
}