Ported code to new APIs

This commit is contained in:
Luca Frosini 2022-02-28 14:33:48 +01:00
parent 017f8648b4
commit c2835d00d5
2 changed files with 11 additions and 8 deletions

View File

@ -6,6 +6,7 @@ import java.net.URL;
import java.util.List;
import org.gcube.common.authorization.utils.manager.SecretManager;
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
import org.gcube.common.scope.impl.ScopeBean;
import org.gcube.common.scope.impl.ScopeBean.Type;
import org.gcube.common.storagehub.client.dsl.ContainerType;
@ -106,7 +107,7 @@ public class StorageHubManagement {
protected FolderContainer getContextFolder() throws Exception {
FolderContainer destinationFolder = getWorkspaceRoot();
String currentContext = SecretManager.instance.get().getContext();
String currentContext = SecretManagerProvider.instance.get().getContext();
ScopeBean scopeBean = new ScopeBean(currentContext);
switch(scopeBean.type()) {
case INFRASTRUCTURE:
@ -128,10 +129,11 @@ public class StorageHubManagement {
public FolderContainer getApplicationFolder() throws Exception {
FolderContainer destinationFolder = getContextFolder();
String currentContext = SecretManager.instance.get().getContext();
SecretManager secretManager = SecretManagerProvider.instance.get();
String currentContext = secretManager.getContext();
ScopeBean scopeBean = new ScopeBean(currentContext);
if(scopeBean.is(Type.VRE)) {
String username = SecretManager.instance.get().getUser().getUsername();
String username = secretManager.getUser().getUsername();
destinationFolder = getOrCreateFolder(destinationFolder, username, "Folder Created for user/application", true);
}
return destinationFolder;

View File

@ -4,6 +4,7 @@ import java.util.List;
import java.util.Map;
import org.gcube.common.authorization.utils.manager.SecretManager;
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
import org.gcube.common.authorization.utils.secret.GCubeSecret;
import org.gcube.common.storagehub.client.dsl.ContainerType;
import org.gcube.common.storagehub.client.dsl.FileContainer;
@ -25,7 +26,7 @@ public class StorageHubManagementTest extends ContextTest {
@Test
public void myTest() throws Exception {
SecretManager secretManager = SecretManager.instance.get();
SecretManager secretManager = SecretManagerProvider.instance.get();
GCubeSecret gCubeSecret = new GCubeSecret(ContextTest.properties.getProperty(DEFAULT_TEST_SCOPE_NAME));
secretManager.startSession(gCubeSecret);
StorageHubManagement storageHubManagement = new StorageHubManagement();
@ -36,7 +37,7 @@ public class StorageHubManagementTest extends ContextTest {
@Test
public void test() throws Exception {
SecretManager secretManager = SecretManager.instance.get();
SecretManager secretManager = SecretManagerProvider.instance.get();
GCubeSecret gCubeSecret = new GCubeSecret(ContextTest.properties.getProperty(DEFAULT_TEST_SCOPE_NAME));
secretManager.startSession(gCubeSecret);
StorageHubManagement storageHubManagement = new StorageHubManagement();
@ -54,7 +55,7 @@ public class StorageHubManagementTest extends ContextTest {
@Test
public void listFolders() throws Exception {
SecretManager secretManager = SecretManager.instance.get();
SecretManager secretManager = SecretManagerProvider.instance.get();
GCubeSecret gCubeSecret = new GCubeSecret(ContextTest.properties.getProperty(DEFAULT_TEST_SCOPE_NAME));
secretManager.startSession(gCubeSecret);
StorageHubManagement storageHubManagement = new StorageHubManagement();
@ -80,7 +81,7 @@ public class StorageHubManagementTest extends ContextTest {
@Test
public void getFileInfo() throws Exception {
SecretManager secretManager = SecretManager.instance.get();
SecretManager secretManager = SecretManagerProvider.instance.get();
GCubeSecret gCubeSecret = new GCubeSecret(ContextTest.properties.getProperty(DEFAULT_TEST_SCOPE_NAME));
secretManager.startSession(gCubeSecret);
StorageHubManagement storageHubManagement = new StorageHubManagement();
@ -110,7 +111,7 @@ public class StorageHubManagementTest extends ContextTest {
@Test
public void getFileInfoViaDirectoryListing() throws Exception {
SecretManager secretManager = SecretManager.instance.get();
SecretManager secretManager = SecretManagerProvider.instance.get();
GCubeSecret gCubeSecret = new GCubeSecret(ContextTest.properties.getProperty(DEFAULT_TEST_SCOPE_NAME));
secretManager.startSession(gCubeSecret);
StorageHubManagement storageHubManagement = new StorageHubManagement();