From 2fc02e6411c05fd2768a368cc965a9ea19c0e047 Mon Sep 17 00:00:00 2001 From: Fabio Sinibaldi Date: Fri, 28 Jan 2022 17:12:32 +0100 Subject: [PATCH] Move WS Folder Utility --- .../service/ws/DescribeWSFolder.java | 11 +++---- .../geoportal/service/ws/MoveWSFolder.java | 31 +++++++++++++++++++ 2 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 geoportal-service/src/test/java/org/gcube/application/geoportal/service/ws/MoveWSFolder.java diff --git a/geoportal-service/src/test/java/org/gcube/application/geoportal/service/ws/DescribeWSFolder.java b/geoportal-service/src/test/java/org/gcube/application/geoportal/service/ws/DescribeWSFolder.java index d23b88e..662b450 100644 --- a/geoportal-service/src/test/java/org/gcube/application/geoportal/service/ws/DescribeWSFolder.java +++ b/geoportal-service/src/test/java/org/gcube/application/geoportal/service/ws/DescribeWSFolder.java @@ -17,17 +17,16 @@ public class DescribeWSFolder { static StorageHubClient shc =null; public static void main(String[] args) throws StorageHubException { -// String context="/gcube/devsec/devVRE"; - String context="/d4science.research-infrastructures.eu/D4OS/GeoNA-Prototype"; - String folderID="46b376db-32d7-4411-ad04-ca3dadab5f5b"; - Boolean recursive = true; + String context="/gcube/devsec/devVRE"; + String folderID="..."; + Boolean recursive = false; TokenSetter.set(context); shc= new StorageHubClient(); shc.openVREFolder().get().getDescription(); -// FolderContainer folder=shc.open(folderID).asFolder(); - FolderContainer folder = WorkspaceManager.getApplicationBaseFolder(shc); + FolderContainer folder=shc.open(folderID).asFolder(); + // FolderContainer folder = WorkspaceManager.getApplicationBaseFolder(shc); FolderItem item=folder.get(); System.out.print("PATH : "+item.getPath()+"\tHIDDEN : "+item.isHidden()+"\tDescription : "+item.getDescription()); diff --git a/geoportal-service/src/test/java/org/gcube/application/geoportal/service/ws/MoveWSFolder.java b/geoportal-service/src/test/java/org/gcube/application/geoportal/service/ws/MoveWSFolder.java new file mode 100644 index 0000000..3e582af --- /dev/null +++ b/geoportal-service/src/test/java/org/gcube/application/geoportal/service/ws/MoveWSFolder.java @@ -0,0 +1,31 @@ +package org.gcube.application.geoportal.service.ws; + +import org.gcube.application.cms.tests.TokenSetter; +import org.gcube.application.geoportal.service.engine.WorkspaceManager; +import org.gcube.common.storagehub.client.dsl.FolderContainer; +import org.gcube.common.storagehub.client.dsl.StorageHubClient; +import org.gcube.common.storagehub.model.exceptions.StorageHubException; + +public class MoveWSFolder { + + public static void main(String[] args) throws StorageHubException { + // Get original folder id + // Set original VRE token + + TokenSetter.set("..."); + + // Get appBaseFolder ID + StorageHubClient shc = new StorageHubClient(); + FolderContainer toMoveFolder= WorkspaceManager.getApplicationBaseFolder(shc); + + System.out.println("TO MOVE FOLDR ID IS "+toMoveFolder.getId()); + // Set token for target VRE + // MV + String destinationFolderID = "..."; + FolderContainer destinationFolder = shc.open(destinationFolderID).asFolder(); + + System.out.println("MOVING NOW .."); + toMoveFolder.move(destinationFolder); + System.out.println("DONE"); + } +}