diff --git a/src/main/java/org/gcube/data/access/storagehub/handlers/items/ItemHandler.java b/src/main/java/org/gcube/data/access/storagehub/handlers/items/ItemHandler.java index 9b1c82d..8ccac16 100644 --- a/src/main/java/org/gcube/data/access/storagehub/handlers/items/ItemHandler.java +++ b/src/main/java/org/gcube/data/access/storagehub/handlers/items/ItemHandler.java @@ -141,7 +141,7 @@ public class ItemHandler { } private Node create(FileCreationParameters params, Node destination) throws Exception{ - Node newNode = createFileItemInternally(params.getSession(), destination, params.getStream(), params.getName(), params.getDescription(), params.getUser(), true); + Node newNode = createFileItemInternally(params.getSession(), destination, params.getStream(), params.getName(), params.getDescription(), params.getUser(), true, false); params.getSession().save(); versionHandler.checkinContentNode(newNode); log.info("file with id {} correctly created",newNode.getIdentifier()); @@ -190,13 +190,13 @@ public class ItemHandler { log.debug("creating file with entire path {}, name {}, parentPath {} ", entirePath, name, parentPath); Node fileNode = null; if (parentPath.isEmpty()) - fileNode = createFileItemInternally(params.getSession(), parentDirectoryNode, input, name, "", params.getUser(), false); + fileNode = createFileItemInternally(params.getSession(), parentDirectoryNode, input, name, "", params.getUser(), false, true); else { Node parentNode = directoryNodeMap.get(parentPath); if (parentNode ==null) parentNode = createPath(parentPath, directoryNodeMap, parentDirectoryNode, params.getSession(), params.getUser()); - fileNode = createFileItemInternally(params.getSession(), parentNode, input, name, "", params.getUser(), false); + fileNode = createFileItemInternally(params.getSession(), parentNode, input, name, "", params.getUser(), false, true); } fileNodes.add(fileNode); }catch(Exception e) { @@ -246,7 +246,7 @@ public class ItemHandler { return newNode; } - private Node createFileItemInternally(Session ses, Node destinationNode, InputStream stream, String name, String description, String login, boolean withLock) throws RepositoryException, StorageHubException{ + private Node createFileItemInternally(Session ses, Node destinationNode, InputStream stream, String name, String description, String login, boolean withLock, boolean isBulk) throws RepositoryException, StorageHubException{ Node newNode; FolderItem destinationItem = node2Item.getItem(destinationNode, Excludes.ALL); @@ -281,7 +281,7 @@ public class ItemHandler { log.trace("replacing content of class {}",item.getContent().getClass()); item2Node.replaceContent(newNode,item, ItemAction.UPDATED); accountingHandler.createFileUpdated(item.getTitle(), ses, newNode, login, false); - ses.save(); + if (!isBulk) ses.save(); }finally { if (withLock) ses.getWorkspace().getLockManager().unlock(newNode.getPath()); } @@ -300,7 +300,7 @@ public class ItemHandler { try { newNode = item2Node.getNode(destinationNode, item); accountingHandler.createEntryCreate(item.getTitle(), ses, newNode, login, false); - ses.save(); + if (!isBulk) ses.save(); }finally { if (withLock) ses.getWorkspace().getLockManager().unlock(destinationNode.getPath()); }