From 7566a3cf9fc0ad24734d67eca7ccdae72c448f72 Mon Sep 17 00:00:00 2001 From: "lucio.lelii" Date: Tue, 16 Mar 2021 13:03:27 +0100 Subject: [PATCH] issue on home folder removal fixed --- .../storagehub/services/UserManager.java | 20 ++++++++++++++----- .../services/admin/NodeManagerAdmin.java | 8 -------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/gcube/data/access/storagehub/services/UserManager.java b/src/main/java/org/gcube/data/access/storagehub/services/UserManager.java index 3a6b0c7..49202c1 100644 --- a/src/main/java/org/gcube/data/access/storagehub/services/UserManager.java +++ b/src/main/java/org/gcube/data/access/storagehub/services/UserManager.java @@ -321,15 +321,25 @@ public class UserManager { try { Node workspaceNode = session.getNode(workspacePath.toPath()); - Node homeNode = session.getNode(homePath.toPath()); - Node trashNode = session.getNode(trashPath.toPath()); List workspaceItems = Utils.getItemList(workspaceNode, Excludes.GET_ONLY_CONTENT, null, true, null).stream().filter(i -> !i.isShared()).collect(Collectors.toList()); trashHandler.removeOnlyNodesContent(session, workspaceItems); - List itemsToDelete = Utils.getItemList(trashNode, Excludes.ALL, null, true, null); - trashHandler.removeOnlyNodesContent(session, itemsToDelete); + } catch (PathNotFoundException e) { + log.warn("{} workspace dir {} was already deleted", user, homePath.toPath()); + } + + try { + Node trashNode = session.getNode(trashPath.toPath()); + List trashItems = Utils.getItemList(trashNode, Excludes.ALL, null, true, null); + trashHandler.removeOnlyNodesContent(session, trashItems); + } catch (PathNotFoundException e) { + log.warn("{} trash dir {} was already deleted", user, homePath.toPath()); + } + + try { + Node homeNode = session.getNode(homePath.toPath()); homeNode.remove(); } catch (PathNotFoundException e) { - log.warn("{} home dir was already deleted", user); + log.warn("{} home dir {} was already deleted", user, homePath.toPath()); } } diff --git a/src/main/java/org/gcube/data/access/storagehub/services/admin/NodeManagerAdmin.java b/src/main/java/org/gcube/data/access/storagehub/services/admin/NodeManagerAdmin.java index afc20b8..b614913 100644 --- a/src/main/java/org/gcube/data/access/storagehub/services/admin/NodeManagerAdmin.java +++ b/src/main/java/org/gcube/data/access/storagehub/services/admin/NodeManagerAdmin.java @@ -8,8 +8,6 @@ import java.util.List; import javax.enterprise.context.RequestScoped; import javax.jcr.Node; import javax.jcr.NodeIterator; -import javax.jcr.Property; -import javax.jcr.PropertyIterator; import javax.jcr.RepositoryException; import javax.jcr.Session; import javax.servlet.ServletContext; @@ -20,18 +18,12 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; import org.apache.jackrabbit.api.JackrabbitSession; import org.gcube.common.authorization.control.annotations.AuthorizationControl; import org.gcube.common.gxrest.response.outbound.GXOutboundErrorResponse; -import org.gcube.common.storagehub.model.Excludes; import org.gcube.common.storagehub.model.exceptions.BackendGenericError; -import org.gcube.common.storagehub.model.exceptions.StorageHubException; -import org.gcube.common.storagehub.model.items.Item; -import org.gcube.common.storagehub.model.service.ItemList; import org.gcube.data.access.storagehub.StorageHubAppllicationManager; -import org.gcube.data.access.storagehub.Utils; import org.gcube.data.access.storagehub.exception.MyAuthException; import org.gcube.data.access.storagehub.handlers.CredentialHandler; import org.gcube.data.access.storagehub.services.RepositoryInitializer;