diff --git a/src/main/java/org/gcube/data/access/storagehub/services/ItemSharing.java b/src/main/java/org/gcube/data/access/storagehub/services/ItemSharing.java index e39b39b..374fdfc 100644 --- a/src/main/java/org/gcube/data/access/storagehub/services/ItemSharing.java +++ b/src/main/java/org/gcube/data/access/storagehub/services/ItemSharing.java @@ -142,14 +142,14 @@ public class ItemSharing { ses.save(); toReturn = sharedFolderNode.getIdentifier(); - } finally { - ses.getWorkspace().getLockManager().unlock(sharedFolderNode.getPath()); + if (!ses.hasPendingChanges()) + ses.getWorkspace().getLockManager().unlock(sharedFolderNode.getPath()); } }catch(RepositoryException re){ log.error("jcr sharing", re); - GXOutboundErrorResponse.throwException(new BackendGenericError("jcr error extracting archive", re)); + GXOutboundErrorResponse.throwException(new BackendGenericError("jcr error sharing folder", re)); }catch(StorageHubException she ){ log.error(she.getErrorMessage(), she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));