complete remove of file on user and group deletion
This commit is contained in:
parent
6c9aaa9489
commit
868eadfdaa
|
@ -78,7 +78,7 @@ public class TrashHandler {
|
|||
|
||||
log.debug("content ids to remove are {}",contentIdsToDelete);
|
||||
|
||||
String user = AuthorizationProvider.instance.get().getClient().getId();
|
||||
//String user = AuthorizationProvider.instance.get().getClient().getId();
|
||||
Runnable deleteFromStorageRunnable = AuthorizedTasks.bind(new Runnable() {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -49,6 +49,7 @@ import org.gcube.common.storagehub.model.exceptions.InvalidCallParameters;
|
|||
import org.gcube.common.storagehub.model.exceptions.InvalidItemException;
|
||||
import org.gcube.common.storagehub.model.exceptions.StorageHubException;
|
||||
import org.gcube.common.storagehub.model.exceptions.UserNotAuthorizedException;
|
||||
import org.gcube.common.storagehub.model.items.Item;
|
||||
import org.gcube.common.storagehub.model.types.NodeProperty;
|
||||
import org.gcube.common.storagehub.model.types.PrimaryNodeType;
|
||||
import org.gcube.data.access.storagehub.AuthorizationChecker;
|
||||
|
@ -57,9 +58,9 @@ 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.handlers.Node2ItemConverter;
|
||||
import org.gcube.data.access.storagehub.handlers.TrashHandler;
|
||||
import org.gcube.data.access.storagehub.handlers.VRE;
|
||||
import org.gcube.data.access.storagehub.handlers.VREManager;
|
||||
import org.gcube.smartgears.context.application.ApplicationContext;
|
||||
import org.gcube.smartgears.utils.InnerMethodName;
|
||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -70,6 +71,8 @@ public class GroupManager {
|
|||
|
||||
@Context ServletContext context;
|
||||
|
||||
@Inject
|
||||
TrashHandler trashHandler;
|
||||
|
||||
private static final String VREMANAGER_ROLE = "VRE-Manager";
|
||||
private static final String INFRASTRUCTURE_MANAGER_ROLE = "Infrastructure-Manager";
|
||||
|
@ -187,6 +190,8 @@ public class GroupManager {
|
|||
|
||||
try {
|
||||
Node node = getVreFolderNode(session, group);
|
||||
List<Item> workspaceItems = Utils.getItemList(node, Excludes.GET_ONLY_CONTENT, null, true, null);
|
||||
trashHandler.removeNodes(session, workspaceItems);
|
||||
node.removeSharedSet();
|
||||
}catch (Exception e) {
|
||||
log.warn("vreFolder {} not found, removing only the group", group);
|
||||
|
|
|
@ -31,16 +31,17 @@ import org.apache.jackrabbit.api.security.user.QueryBuilder;
|
|||
import org.apache.jackrabbit.api.security.user.User;
|
||||
import org.apache.jackrabbit.core.security.principal.PrincipalImpl;
|
||||
import org.gcube.common.authorization.control.annotations.AuthorizationControl;
|
||||
import org.gcube.common.authorization.library.provider.AuthorizationProvider;
|
||||
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.exceptions.UserNotAuthorizedException;
|
||||
import org.gcube.common.storagehub.model.items.Item;
|
||||
import org.gcube.common.storagehub.model.types.NodeProperty;
|
||||
import org.gcube.data.access.storagehub.Constants;
|
||||
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.handlers.TrashHandler;
|
||||
import org.gcube.data.access.storagehub.handlers.UnshareHandler;
|
||||
import org.gcube.smartgears.utils.InnerMethodName;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -61,6 +62,9 @@ public class UserManager {
|
|||
@Inject
|
||||
UnshareHandler unshareHandler;
|
||||
|
||||
@Inject
|
||||
TrashHandler trashHandler;
|
||||
|
||||
@GET
|
||||
@Path("")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
|
@ -182,8 +186,14 @@ public class UserManager {
|
|||
} else log.warn("the user {} was already deleted", user);
|
||||
|
||||
org.gcube.common.storagehub.model.Path homePath = Utils.getHome(user);
|
||||
org.gcube.common.storagehub.model.Path workspacePath = Utils.getWorkspacePath(user);
|
||||
|
||||
try {
|
||||
session.getNode(homePath.toPath()).remove();
|
||||
Node workspaceNode = session.getNode(workspacePath.toPath());
|
||||
Node homeNode = session.getNode(homePath.toPath());
|
||||
List<Item> workspaceItems = Utils.getItemList(workspaceNode, Excludes.GET_ONLY_CONTENT, null, true, null);
|
||||
trashHandler.removeNodes(session, workspaceItems);
|
||||
homeNode.remove();
|
||||
} catch (PathNotFoundException e) {
|
||||
log.warn("{} home dir was already deleted", user);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue