Compare commits
17 Commits
|
@ -13,9 +13,10 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
|
@ -35,5 +36,10 @@
|
|||
<attribute name="optional" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.processAnnotations=enabled
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
|
|
|
@ -1,7 +1,31 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-module deploy-name="storagehub-client-wrapper">
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/src/main/java"/>
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/src/main/resources"/>
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/.apt_generated"/>
|
||||
|
||||
|
||||
|
||||
|
||||
</wb-module>
|
||||
|
||||
|
||||
|
||||
|
||||
</project-modules>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<faceted-project>
|
||||
<installed facet="java" version="1.8"/>
|
||||
<installed facet="jst.utility" version="1.0"/>
|
||||
<installed facet="java" version="1.8"/>
|
||||
</faceted-project>
|
||||
|
|
10
CHANGELOG.md
10
CHANGELOG.md
|
@ -3,6 +3,16 @@
|
|||
All notable changes to this project will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [v1.2.1] - 2023-04-04
|
||||
|
||||
- [#24597] Fixed no notification sent for items updated in the VRE Folder with score char in the name
|
||||
|
||||
## [v1.2.0] - 2022-05-02
|
||||
|
||||
#### Enhancements
|
||||
|
||||
- [#23225] Updated the method to read the members of (VRE or Simple) shared folders
|
||||
|
||||
## [v1-1-0] - 2021-05-12
|
||||
|
||||
#### Enhancements
|
||||
|
|
24
pom.xml
24
pom.xml
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
|
@ -10,7 +11,7 @@
|
|||
</parent>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>storagehub-client-wrapper</artifactId>
|
||||
<version>1.1.0</version>
|
||||
<version>1.2.1</version>
|
||||
<name>storagehub-client-wrapper</name>
|
||||
<description>This is a wrapper of storagehub-client library. It allows to interact with storagehub in a simplified way by exposing several utilities. Moreover, It exposes by another inteface java beans as defined in (the old) HL interfaces</description>
|
||||
<scm>
|
||||
|
@ -19,15 +20,18 @@
|
|||
<url>https://code-repo.d4science.org/gCubeSystem/${project.artifactId}</url>
|
||||
</scm>
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<distroDirectory>distro</distroDirectory>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.gcube.distribution</groupId>
|
||||
<artifactId>gcube-bom</artifactId>
|
||||
<version>2.0.1</version>
|
||||
<version>2.3.0</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
@ -51,13 +55,21 @@
|
|||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.14.8</version>
|
||||
<version>1.18.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>storagehub-model</artifactId>
|
||||
<!--<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version> -->
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>storagehub-client-library</artifactId>
|
||||
<version>[1.0.0,2.0.0-SNAPSHOT)</version>
|
||||
<!--<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version> -->
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
|
@ -89,6 +101,7 @@
|
|||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>1.6.4</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@ -97,6 +110,7 @@
|
|||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<build>
|
||||
<resources>
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.gcube.common.storagehubwrapper.server;
|
|||
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -9,6 +10,7 @@ import java.util.Set;
|
|||
import org.apache.commons.lang.Validate;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.common.scope.impl.ScopeBean;
|
||||
import org.gcube.common.storagehub.client.StreamDescriptor;
|
||||
import org.gcube.common.storagehub.client.dsl.FileContainer;
|
||||
import org.gcube.common.storagehub.client.dsl.FolderContainer;
|
||||
|
@ -36,14 +38,14 @@ import org.gcube.common.storagehub.model.items.nodes.Accounting;
|
|||
import org.gcube.common.storagehub.model.items.nodes.ImageContent;
|
||||
import org.gcube.common.storagehub.model.service.Version;
|
||||
import org.gcube.common.storagehubwrapper.server.converter.HLMapper;
|
||||
import org.gcube.common.storagehubwrapper.server.converter.ObjectMapper;
|
||||
import org.gcube.common.storagehubwrapper.shared.ACLType;
|
||||
import org.gcube.common.storagehubwrapper.shared.Member;
|
||||
import org.gcube.common.storagehubwrapper.shared.Member.TYPE;
|
||||
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
|
||||
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.ItemNotFoundException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class StorageHubClientService.
|
||||
|
@ -53,7 +55,6 @@ import org.slf4j.LoggerFactory;
|
|||
*/
|
||||
public class StorageHubClientService {
|
||||
|
||||
|
||||
/** The logger. */
|
||||
private static Logger logger = LoggerFactory.getLogger(StorageHubClientService.class);
|
||||
|
||||
|
@ -66,10 +67,8 @@ public class StorageHubClientService {
|
|||
/** The authorization token. */
|
||||
private String authorizationToken;
|
||||
|
||||
|
||||
private StorageHubClient shClient;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new storage hub service util.
|
||||
*
|
||||
|
@ -95,7 +94,8 @@ public class StorageHubClientService {
|
|||
private void setContextProviders(String scope, String authorizationToken) {
|
||||
ScopeProvider.instance.set(scope);
|
||||
SecurityTokenProvider.instance.set(authorizationToken);
|
||||
logger.debug("Saved the contexts [scope: "+scope+", token: "+authorizationToken.substring(0,15)+"-MASKED]");
|
||||
logger.debug(
|
||||
"Saved the contexts [scope: " + scope + ", token: " + authorizationToken.substring(0, 15) + "-MASKED]");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -122,7 +122,6 @@ public class StorageHubClientService {
|
|||
return trash;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the children.
|
||||
*
|
||||
|
@ -132,9 +131,11 @@ public class StorageHubClientService {
|
|||
* @return the children
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public List<? extends Item> getChildren(String id, boolean withAccounting, boolean withMapProperties) throws Exception{
|
||||
public List<? extends Item> getChildren(String id, boolean withAccounting, boolean withMapProperties)
|
||||
throws Exception {
|
||||
setContextProviders(scope, authorizationToken);
|
||||
logger.trace("Requesting getChildren for id: "+id+" [withAccounting: "+withAccounting+", withMapProperties: "+withMapProperties+"]");
|
||||
logger.trace("Requesting getChildren for id: " + id + " [withAccounting: " + withAccounting
|
||||
+ ", withMapProperties: " + withMapProperties + "]");
|
||||
ListResolverTyped resolverTyped = shClient.open(id).asFolder().list();
|
||||
ListResolver theResolver = resolverTyped.withContent();
|
||||
|
||||
|
@ -154,12 +155,15 @@ public class StorageHubClientService {
|
|||
* @param id the id
|
||||
* @param withAccounting the with accounting
|
||||
* @param withMapProperties the with map properties
|
||||
* @param includeHidden the include hidden
|
||||
* @return the children
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public List<? extends Item> getChildren(String id, boolean withAccounting, boolean withMapProperties, boolean includeHidden) throws Exception{
|
||||
public List<? extends Item> getChildren(String id, boolean withAccounting, boolean withMapProperties,
|
||||
boolean includeHidden) throws Exception {
|
||||
setContextProviders(scope, authorizationToken);
|
||||
logger.trace("Requesting getChildren for id: "+id+" [withAccounting: "+withAccounting+", withMapProperties: "+withMapProperties+"]");
|
||||
logger.trace("Requesting getChildren for id: " + id + " [withAccounting: " + withAccounting
|
||||
+ ", withMapProperties: " + withMapProperties + "]");
|
||||
if (!includeHidden) {
|
||||
return getChildren(id, withAccounting, withMapProperties);
|
||||
}
|
||||
|
@ -176,7 +180,6 @@ public class StorageHubClientService {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the filtered children.
|
||||
*
|
||||
|
@ -187,7 +190,8 @@ public class StorageHubClientService {
|
|||
* @return the filtered children
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public List<? extends Item> getFilteredChildren(String id, Class<? extends Item> aType, boolean withAccounting, boolean withMapProperties) throws Exception{
|
||||
public List<? extends Item> getFilteredChildren(String id, Class<? extends Item> aType, boolean withAccounting,
|
||||
boolean withMapProperties) throws Exception {
|
||||
setContextProviders(scope, authorizationToken);
|
||||
|
||||
ListResolver resolverTyped = shClient.open(id).asFolder().list().ofType(aType);
|
||||
|
@ -202,7 +206,6 @@ public class StorageHubClientService {
|
|||
return theResolver.getItems();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the item.
|
||||
*
|
||||
|
@ -221,19 +224,20 @@ public class StorageHubClientService {
|
|||
itemCont = shClient.open(itemId).asItem(); // TODO
|
||||
} else if (withAccounting) {
|
||||
itemCont = shClient.open(itemId).asItem(); // TODO
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
itemCont = shClient.open(itemId).asItem();
|
||||
}
|
||||
|
||||
return itemCont.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item by path.
|
||||
*
|
||||
* @param folderId
|
||||
* @param relativePath
|
||||
* @return
|
||||
* @throws Exception
|
||||
* @param folderId the folder id
|
||||
* @param relativePath the relative path
|
||||
* @return the item by path
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public Item getItemByPath(String folderId, String relativePath) throws Exception {
|
||||
setContextProviders(scope, authorizationToken);
|
||||
|
@ -260,8 +264,6 @@ public class StorageHubClientService {
|
|||
return getItem(itemId, false, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Sets the metadata and returns the Item with metadata updated.
|
||||
*
|
||||
|
@ -277,8 +279,6 @@ public class StorageHubClientService {
|
|||
return itemCont.get();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the metadata.
|
||||
*
|
||||
|
@ -296,7 +296,6 @@ public class StorageHubClientService {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the folder container.
|
||||
*
|
||||
|
@ -309,7 +308,6 @@ public class StorageHubClientService {
|
|||
return shClient.open(itemId).asFolder();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the parents.
|
||||
*
|
||||
|
@ -329,7 +327,6 @@ public class StorageHubClientService {
|
|||
|
||||
// TODO MAP OF SHARED ROOT ID
|
||||
|
||||
|
||||
/**
|
||||
* Gets the id shared folder.
|
||||
*
|
||||
|
@ -342,7 +339,6 @@ public class StorageHubClientService {
|
|||
return getRootSharedFolder(itemId).getId();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the root shared folder.
|
||||
*
|
||||
|
@ -356,7 +352,6 @@ public class StorageHubClientService {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if is item shared.
|
||||
*
|
||||
|
@ -370,7 +365,6 @@ public class StorageHubClientService {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Can write.
|
||||
*
|
||||
|
@ -383,7 +377,6 @@ public class StorageHubClientService {
|
|||
return shClient.open(folderContainerId).asFolder().canWrite();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the root shared folder.
|
||||
*
|
||||
|
@ -400,7 +393,8 @@ public class StorageHubClientService {
|
|||
} else
|
||||
throw new Exception("The item with id: " + item.getId() + " is not shared");
|
||||
|
||||
Validate.notNull(rootSharedFolder, "The root shared folder with children id "+item.getId()+" does not exist");
|
||||
Validate.notNull(rootSharedFolder,
|
||||
"The root shared folder with children id " + item.getId() + " does not exist");
|
||||
return rootSharedFolder.get();
|
||||
}
|
||||
|
||||
|
@ -419,7 +413,6 @@ public class StorageHubClientService {
|
|||
return getItem(folderContainer.get().getId(), false, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the VRE folders id.
|
||||
*
|
||||
|
@ -445,9 +438,6 @@ public class StorageHubClientService {
|
|||
return toReturn;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the user acl for folder id.
|
||||
*
|
||||
|
@ -468,7 +458,8 @@ public class StorageHubClientService {
|
|||
List<ACL> acls = client.getACL(folderId);
|
||||
SharedFolder sharedFolder = (SharedFolder) theFolder;
|
||||
|
||||
boolean found = false; //this is needed because in case o VRE Foder the permission is assigned to the group and not to the user.
|
||||
boolean found = false; // this is needed because in case o VRE Foder the permission is assigned to the
|
||||
// group and not to the user.
|
||||
for (ACL acl : acls) {
|
||||
if (acl.getPricipal().compareTo(userName) == 0) {
|
||||
found = true;
|
||||
|
@ -477,7 +468,8 @@ public class StorageHubClientService {
|
|||
}
|
||||
if (!found && sharedFolder.isVreFolder()) {
|
||||
for (ACL acl : acls) {
|
||||
if (acl.getPricipal().startsWith(infrastructureName));
|
||||
if (acl.getPricipal().startsWith(infrastructureName))
|
||||
;
|
||||
return acl.getAccessTypes().get(0).toString();
|
||||
}
|
||||
}
|
||||
|
@ -485,7 +477,6 @@ public class StorageHubClientService {
|
|||
return "UNDEFINED";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the item children count.
|
||||
*
|
||||
|
@ -517,18 +508,18 @@ public class StorageHubClientService {
|
|||
return fileCont.get();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Download file.
|
||||
*
|
||||
* @param itemId the item id
|
||||
* @param versionName the version name. If is null or empty returns the latest version of file
|
||||
* @param versionName the version name. If is null or empty returns the
|
||||
* latest version of file
|
||||
* @param nodeIdsToExclude the node ids to exclude
|
||||
* @return the stream descriptor
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public StreamDescriptor downloadFile(String itemId, String versionName, String... nodeIdsToExclude) throws Exception{
|
||||
public StreamDescriptor downloadFile(String itemId, String versionName, String... nodeIdsToExclude)
|
||||
throws Exception {
|
||||
|
||||
setContextProviders(scope, authorizationToken);
|
||||
StreamDescriptor streamDesc;
|
||||
|
@ -537,11 +528,11 @@ public class StorageHubClientService {
|
|||
} else {
|
||||
streamDesc = shClient.open(itemId).asFile().download(nodeIdsToExclude);
|
||||
}
|
||||
return new StreamDescriptor(streamDesc.getStream(), streamDesc.getFileName(), streamDesc.getContentType(), streamDesc.getContentLenght());
|
||||
return new StreamDescriptor(streamDesc.getStream(), streamDesc.getFileName(), streamDesc.getContentType(),
|
||||
streamDesc.getContentLenght());
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Download folder.
|
||||
*
|
||||
|
@ -554,12 +545,11 @@ public class StorageHubClientService {
|
|||
|
||||
setContextProviders(scope, authorizationToken);
|
||||
StreamDescriptor streamDesc = shClient.open(folderId).asFolder().download(nodeIdsToExclude);
|
||||
return new StreamDescriptor(streamDesc.getStream(), streamDesc.getFileName(), streamDesc.getContentType(), streamDesc.getContentLenght());
|
||||
return new StreamDescriptor(streamDesc.getStream(), streamDesc.getFileName(), streamDesc.getContentType(),
|
||||
streamDesc.getContentLenght());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Upload archive.
|
||||
*
|
||||
|
@ -576,8 +566,6 @@ public class StorageHubClientService {
|
|||
return folderCont.get();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the shared folder members.
|
||||
*
|
||||
|
@ -585,17 +573,144 @@ public class StorageHubClientService {
|
|||
* @return the shared folder members
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public List<String> getSharedFolderMembers(String folderId) throws Exception {
|
||||
public List<Member> getSharedFolderMembers(String folderId) throws Exception {
|
||||
|
||||
setContextProviders(scope, authorizationToken);
|
||||
Item item = getItem(folderId, false, true);
|
||||
List<Member> members = new ArrayList<Member>();
|
||||
|
||||
if (item instanceof SharedFolder) {
|
||||
return ObjectMapper.toListLogins((SharedFolder)item);
|
||||
}else
|
||||
SharedFolder sharedfolder = (SharedFolder) item;
|
||||
|
||||
String vreName = null;
|
||||
if (sharedfolder.isVreFolder()) {
|
||||
vreName = sharedfolder.getDisplayName(); // the displayName should matching the VRE Name
|
||||
// this class is used?
|
||||
if (sharedfolder instanceof VreFolder) {
|
||||
VreFolder vreFolder = (VreFolder) sharedfolder;
|
||||
vreName = vreFolder.getDisplayName(); // the displayName should matching the VRE Name
|
||||
}
|
||||
}
|
||||
|
||||
String infra = WrapperUtility.getInfrastructureNameFromScope(scope);
|
||||
logger.debug("Infrastructure is: " + infra);
|
||||
logger.debug("vreName is: " + vreName);
|
||||
List<ACL> listACL = shClient.open(folderId).asFolder().getAcls();
|
||||
logger.info("Reading users from ACLs");
|
||||
for (ACL acl : listACL) {
|
||||
logger.info("acl principal is: " + acl.getPricipal());
|
||||
Member member = new Member(acl.getPricipal(), acl.getPricipal(), Member.TYPE.USER);
|
||||
boolean isAGroup = isGroupName(acl.getPricipal(), infra, vreName);
|
||||
if (isAGroup) {
|
||||
member.setMemberType(TYPE.GROUP);
|
||||
// gcube-devsec-devVRE -> devVRE that is the groupName
|
||||
// the VRE Name should be the group name
|
||||
member.setName(vreName);
|
||||
logger.info("pricipal: " + acl.getPricipal() + " is "+member.getMemberType()+": "+member.getName());
|
||||
}
|
||||
members.add(member);
|
||||
logger.debug("added member: " + member);
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new Exception("The item with " + folderId + " is not a Shared Folder");
|
||||
}
|
||||
|
||||
logger.info("Returning " + members.size() + " member/s");
|
||||
return members;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is group name.
|
||||
*
|
||||
* @param pricipal the pricipal
|
||||
* @param infrastructureName the infrastructur name
|
||||
* @param vreName the vre name
|
||||
* @return true, if is group name E.g. with the input 'gcube-devNext-NextNext'
|
||||
* returns true
|
||||
*/
|
||||
private boolean isGroupName(String pricipal, String infrastructureName, String vreName) {
|
||||
|
||||
if (pricipal == null || pricipal.isEmpty())
|
||||
return false;
|
||||
|
||||
if (vreName == null || vreName.isEmpty())
|
||||
return false;
|
||||
|
||||
ScopeBean scope = null;
|
||||
|
||||
//Removing the first / from the infrastructure name. E.g /gcube -> gcube
|
||||
infrastructureName = infrastructureName.replace(WrapperUtility.SCOPE_SEPARATOR, "");
|
||||
if (principalContainsScopes(pricipal, infrastructureName, vreName)) {
|
||||
String theScope = getScopeFromVREGroupName(pricipal, infrastructureName, vreName);
|
||||
|
||||
try {
|
||||
//Just to be sure of the format /RootVO/VO/VRE
|
||||
scope = new ScopeBean(theScope);
|
||||
logger.info("pricipal '" + pricipal + "' remapping as "+theScope+" should be a valid scope");
|
||||
} catch (IllegalArgumentException e) {
|
||||
logger.trace("principal '" + pricipal + "' is not a scope");
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return scope != null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Principal contains scopes.
|
||||
*
|
||||
* @param principal the principal
|
||||
* @param infrastructurName the infrastructur name
|
||||
* @param vreName the vre name
|
||||
* @return true, if principal (as string) contains the RootVO and the VRE name.
|
||||
*/
|
||||
private static boolean principalContainsScopes(String principal, String infrastructurName, String vreName) {
|
||||
|
||||
if (principal.contains(infrastructurName)) {
|
||||
if (principal.contains(vreName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public static String getScopeFromVREGroupName(String context, String infrastructurName, String vreName) {
|
||||
|
||||
if (vreName == null)
|
||||
vreName = "";
|
||||
|
||||
logger.debug("vreName: " + vreName);
|
||||
|
||||
if (infrastructurName.startsWith("/"))
|
||||
infrastructurName = infrastructurName.substring(1, infrastructurName.length());
|
||||
|
||||
logger.debug("infrastructurName: " + infrastructurName);
|
||||
|
||||
String voGroup = context.replaceAll(infrastructurName, "");
|
||||
if (vreName != null) {
|
||||
voGroup = voGroup.replaceAll(vreName, "").replaceAll("-", "");
|
||||
}
|
||||
String voName = voGroup.replaceAll("-", "");
|
||||
logger.debug("voName: " + voName);
|
||||
|
||||
StringBuilder theScopeBuilder = new StringBuilder();
|
||||
theScopeBuilder.append("/" + infrastructurName);
|
||||
if (voName != null && !voName.isEmpty()) {
|
||||
theScopeBuilder.append(WrapperUtility.SCOPE_SEPARATOR + voName);
|
||||
}
|
||||
if (vreName != null && !vreName.isEmpty()) {
|
||||
theScopeBuilder.append(WrapperUtility.SCOPE_SEPARATOR + vreName);
|
||||
}
|
||||
String theScope = theScopeBuilder.toString();
|
||||
logger.debug("Built scope: " + theScope);
|
||||
return theScope;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find by name.
|
||||
|
@ -621,8 +736,6 @@ public class StorageHubClientService {
|
|||
throw new Exception("The input folder id is not a folder");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Search for text.
|
||||
*
|
||||
|
@ -648,8 +761,6 @@ public class StorageHubClientService {
|
|||
throw new Exception("The input folder id is not a folder");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Delete item by id.
|
||||
*
|
||||
|
@ -664,8 +775,6 @@ public class StorageHubClientService {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Open trash.
|
||||
*
|
||||
|
@ -679,8 +788,6 @@ public class StorageHubClientService {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Empty trash.
|
||||
*
|
||||
|
@ -693,7 +800,6 @@ public class StorageHubClientService {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Restore thrash item.
|
||||
*
|
||||
|
@ -724,7 +830,6 @@ public class StorageHubClientService {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Move item.
|
||||
*
|
||||
|
@ -743,7 +848,6 @@ public class StorageHubClientService {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Copy item.
|
||||
*
|
||||
|
@ -753,18 +857,19 @@ public class StorageHubClientService {
|
|||
* @return the abstract file item
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public AbstractFileItem copyFileItem(String fileItemId, FolderContainer destFolderContainer, String newFileName) throws Exception{
|
||||
public AbstractFileItem copyFileItem(String fileItemId, FolderContainer destFolderContainer, String newFileName)
|
||||
throws Exception {
|
||||
|
||||
Validate.notNull(fileItemId, "Bad request to copyFileItem, the fileItemId is null");
|
||||
Validate.notNull(destFolderContainer, "Bad request to copyFileItem, the destFolderContainer is null");
|
||||
setContextProviders(scope, authorizationToken);
|
||||
FileContainer copyingItem = shClient.open(fileItemId).asFile();
|
||||
String newName = newFileName!=null && !newFileName.isEmpty()?newFileName:"Copy of "+copyingItem.get().getName();
|
||||
String newName = newFileName != null && !newFileName.isEmpty() ? newFileName
|
||||
: "Copy of " + copyingItem.get().getName();
|
||||
FileContainer newItem = copyingItem.copy(destFolderContainer, newName);
|
||||
return newItem.get();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Rename item.
|
||||
*
|
||||
|
@ -782,7 +887,6 @@ public class StorageHubClientService {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the file public link.
|
||||
*
|
||||
|
@ -798,7 +902,6 @@ public class StorageHubClientService {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the public link for file version.
|
||||
*
|
||||
|
@ -817,7 +920,6 @@ public class StorageHubClientService {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the list versions.
|
||||
*
|
||||
|
@ -853,7 +955,6 @@ public class StorageHubClientService {
|
|||
throw new Exception("Thumbnail Data is not available for type: " + item.getClass().getSimpleName());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the total items.
|
||||
*
|
||||
|
@ -866,7 +967,6 @@ public class StorageHubClientService {
|
|||
return shClient.getTotalItemCount();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the disk usage.
|
||||
*
|
||||
|
@ -894,7 +994,6 @@ public class StorageHubClientService {
|
|||
return item.getAccounting();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the gcube item properties.
|
||||
*
|
||||
|
@ -912,11 +1011,10 @@ public class StorageHubClientService {
|
|||
GCubeItem theGcubeItem = (GCubeItem) item;
|
||||
return theGcubeItem.getMetadata();
|
||||
} else
|
||||
throw new Exception("The item with id "+gcubeItemId+" is not an istance of "+GCubeItem.class.getSimpleName());
|
||||
throw new Exception(
|
||||
"The item with id " + gcubeItemId + " is not an istance of " + GCubeItem.class.getSimpleName());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Sets the metadata.
|
||||
*
|
||||
|
@ -933,11 +1031,10 @@ public class StorageHubClientService {
|
|||
shClient.open(itemId).asItem().setMetadata(new Metadata(mapProperties));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the Folder As Hidden or visible .
|
||||
*
|
||||
* @param itemId the folder id
|
||||
* @param folderId the folder id
|
||||
* @param hide true to set hide, false to set visible
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
|
@ -951,12 +1048,14 @@ public class StorageHubClientService {
|
|||
folderContainer.setVisible(); // will appear in the workspace GUI
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Share folder.
|
||||
*
|
||||
* @param folderId the folder id to share
|
||||
* @param users the users to share
|
||||
* @param type the permission
|
||||
* @return the workspace shared folder
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public WorkspaceSharedFolder shareFolder(String folderId, Set<String> users, ACLType type) throws Exception {
|
||||
Validate.notNull(folderId, "Bad request to setFolderAsHidden the folderId is null");
|
||||
|
@ -987,9 +1086,12 @@ public class StorageHubClientService {
|
|||
}
|
||||
|
||||
/**
|
||||
* Unshare folder.
|
||||
*
|
||||
* @param folderId the folder id to share
|
||||
* @param users the users to share
|
||||
* @return the workspace shared folder
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public WorkspaceSharedFolder unshareFolder(String folderId, Set<String> users) throws Exception {
|
||||
Validate.notNull(folderId, "Bad request to setFolderAsHidden the folderId is null");
|
||||
|
@ -1016,7 +1118,6 @@ public class StorageHubClientService {
|
|||
return folder.addUrl(URL, name, description).get();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the folder as public.
|
||||
*
|
||||
|
@ -1041,7 +1142,6 @@ public class StorageHubClientService {
|
|||
return shClient.open(folderId).asFolder().get().isPublicItem();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update description for item.
|
||||
*
|
||||
|
@ -1059,13 +1159,14 @@ public class StorageHubClientService {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* To string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
|
@ -1075,13 +1176,11 @@ public class StorageHubClientService {
|
|||
builder.append("StorageHubClientService [scope=");
|
||||
builder.append(scope);
|
||||
builder.append(", authorizationToken=");
|
||||
builder.append(authorizationToken.substring(0, authorizationToken.length()-5)+"XXXXX");
|
||||
builder.append(authorizationToken.substring(0, authorizationToken.length() - 8) + "XXXXXXXX");
|
||||
builder.append(", itemManagerClient=");
|
||||
builder.append(shClient);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.gcube.common.storagehub.model.service.Version;
|
|||
import org.gcube.common.storagehubwrapper.server.converter.HLMapper;
|
||||
import org.gcube.common.storagehubwrapper.server.tohl.Workspace;
|
||||
import org.gcube.common.storagehubwrapper.shared.ACLType;
|
||||
import org.gcube.common.storagehubwrapper.shared.Member;
|
||||
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
||||
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
|
||||
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InsufficientPrivilegesException;
|
||||
|
@ -684,7 +685,7 @@ public final class WorkspaceStorageHubClientService implements Workspace{
|
|||
* @see org.gcube.portal.storagehubwrapper.server.tohl.Workspace#getSharedFolderMembers(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public List<String> getSharedFolderMembers(String folderId) throws Exception {
|
||||
public List<Member> getSharedFolderMembers(String folderId) throws Exception {
|
||||
|
||||
try{
|
||||
LOGGER.debug("called Shared Folder Members");
|
||||
|
|
|
@ -12,10 +12,14 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* The Class WrapperUtility.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Oct 17, 2018
|
||||
*/
|
||||
public class WrapperUtility {
|
||||
|
||||
public static final String SCOPE_SEPARATOR = "/";
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(WrapperUtility.class);
|
||||
|
||||
/**
|
||||
|
@ -47,4 +51,35 @@ public class WrapperUtility {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the infrastructure name from scope.
|
||||
*
|
||||
* @param scope the scope
|
||||
* @return the infrastructure name from scope
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static String getInfrastructureNameFromScope(String scope) throws Exception{
|
||||
|
||||
if(scope==null || scope.isEmpty()){
|
||||
throw new Exception("Scope is null or empty");
|
||||
}
|
||||
|
||||
if(!scope.startsWith(SCOPE_SEPARATOR)){
|
||||
logger.warn("Input scope: "+scope+" not have / is a really scope?");
|
||||
scope = SCOPE_SEPARATOR+scope;
|
||||
logger.warn("Tentative as scope: "+scope);
|
||||
}
|
||||
|
||||
String[] splitScope = scope.split(SCOPE_SEPARATOR);
|
||||
|
||||
String rootScope = SCOPE_SEPARATOR + splitScope[1];
|
||||
|
||||
if(rootScope.length()<2){
|
||||
throw new Exception("Infrastructure name not found in "+scope);
|
||||
}
|
||||
|
||||
return rootScope;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ import org.gcube.common.storagehubwrapper.shared.tohl.items.FileItemType;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
/**
|
||||
* The Class HLMapper.
|
||||
*
|
||||
|
@ -50,19 +49,6 @@ public class HLMapper {
|
|||
|
||||
private static Logger logger = LoggerFactory.getLogger(HLMapper.class);
|
||||
|
||||
// public static Function<org.gcube.common.storagehub.model.items.nodes.accounting.AccountEntry, AccountingEntry> toAccountingEntry = new Function<org.gcube.common.storagehub.model.items.nodes.accounting.AccountEntry, AccountingEntry>() {
|
||||
//
|
||||
// public AccountingEntry apply(org.gcube.common.storagehub.model.items.nodes.accounting.AccountEntry accountingEntry) {
|
||||
//
|
||||
// return new AccountingEntry(
|
||||
// accountingEntry.getUser(),
|
||||
// accountingEntry.getDate(),
|
||||
// accountingEntry.getType(),
|
||||
// accountingEntry.getVersion(),
|
||||
// accountingEntry.getPrimaryType());
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* To URL file.
|
||||
*
|
||||
|
@ -74,7 +60,6 @@ public class HLMapper {
|
|||
return (URLFile) toWorkspaceItem(extLink, false, false, false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* To workspace item.
|
||||
*
|
||||
|
@ -88,8 +73,6 @@ public class HLMapper {
|
|||
return toWorkspaceItem(item, false, false, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* To accounting entries.
|
||||
*
|
||||
|
@ -103,16 +86,11 @@ public class HLMapper {
|
|||
Accounting accounting = item.getAccounting();
|
||||
if (accounting != null) {
|
||||
accountingEntries = accounting.getEntries();
|
||||
// for (AccountEntry ae : accounting.getEntries()) {
|
||||
// accountingEntries.add(toAccountingEntry.apply(ae));
|
||||
// }
|
||||
}
|
||||
|
||||
return accountingEntries;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* To property map.
|
||||
*
|
||||
|
@ -132,7 +110,6 @@ public class HLMapper {
|
|||
return pm;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* To workspace file version.
|
||||
*
|
||||
|
@ -160,7 +137,8 @@ public class HLMapper {
|
|||
* @return the t
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static<T extends WorkspaceItem> T toWorkspaceItem(Item item, boolean withAccounting, boolean withFileDetails, boolean withMapProperties) throws Exception{
|
||||
public static <T extends WorkspaceItem> T toWorkspaceItem(Item item, boolean withAccounting,
|
||||
boolean withFileDetails, boolean withMapProperties) throws Exception {
|
||||
|
||||
try {
|
||||
List<AccountEntry> accountingEntries = null;
|
||||
|
@ -188,12 +166,14 @@ public class HLMapper {
|
|||
SharedFolder sharedfolder = (SharedFolder) item; // ??
|
||||
theItem = new WorkspaceSharedFolder();
|
||||
type = WorkspaceItemType.SHARED_FOLDER;
|
||||
itemName = sharedfolder.getTitle(); //IN CASE OF SHARED FOLDER THE NAME IS AN UUID, I'M USING THE TITLE
|
||||
itemName = sharedfolder.getTitle(); // IN CASE OF SHARED FOLDER THE NAME IS AN UUID, I'M USING THE
|
||||
// TITLE
|
||||
|
||||
if (sharedfolder.isVreFolder()) {
|
||||
// logger.debug("Converting shared folder: "+theItem.getClass());
|
||||
// VreFolder vreFolder = (VreFolder) item;
|
||||
//theItem = new WorkspaceVREFolder(); //NEVER INSTANCE THE WorkspaceVREFolder because VreFolder is never used by HL/StorageHub
|
||||
// theItem = new WorkspaceVREFolder(); //NEVER INSTANCE THE WorkspaceVREFolder
|
||||
// because VreFolder is never used by HL/StorageHub
|
||||
itemName = sharedfolder.getDisplayName(); // IN CASE OF VRE FOLDER I'M USING THE DISPLAYNAME
|
||||
((WorkspaceSharedFolder) theItem).setVreFolder(true);
|
||||
type = WorkspaceItemType.VRE_FOLDER;
|
||||
|
@ -204,7 +184,8 @@ public class HLMapper {
|
|||
// ((WorkspaceFolder) theItem).setPublicFolder(folderItem.isPublicItem());
|
||||
// logger.debug("Wrapped as Folder");
|
||||
|
||||
//TODO THIS MUST BE REMOVED. Checking the old property isPublic added as "<boolean>true</boolean>" by HL
|
||||
// TODO THIS MUST BE REMOVED. Checking the old property isPublic added as
|
||||
// "<boolean>true</boolean>" by HL
|
||||
if (!isPublicItem) {
|
||||
try {
|
||||
// Map<String, Object> map = item.getPropertyMap().getValues();
|
||||
|
@ -372,10 +353,6 @@ public class HLMapper {
|
|||
throw e;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -12,8 +12,6 @@ import org.gcube.common.storagehub.model.items.SharedFolder;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The Class ObjectMapper.
|
||||
*
|
||||
|
@ -24,15 +22,14 @@ public class ObjectMapper {
|
|||
|
||||
private static Logger logger = LoggerFactory.getLogger(ObjectMapper.class);
|
||||
|
||||
|
||||
/**
|
||||
* To list logins.
|
||||
*
|
||||
* @param sharedfolder the sharedfolder
|
||||
* @return the list
|
||||
*/
|
||||
@Deprecated
|
||||
public static List<String> toListLogins(SharedFolder sharedfolder) {
|
||||
|
||||
Metadata users = sharedfolder.getUsers();
|
||||
Map<String, Object> mapMember = users.getMap();
|
||||
List<String> listUsers = new ArrayList<String>(mapMember.size());
|
||||
|
|
|
@ -13,6 +13,7 @@ import org.gcube.common.storagehub.model.items.Item;
|
|||
import org.gcube.common.storagehub.model.items.nodes.accounting.AccountEntry;
|
||||
import org.gcube.common.storagehubwrapper.server.WorkspaceStorageHubClientService;
|
||||
import org.gcube.common.storagehubwrapper.shared.ACLType;
|
||||
import org.gcube.common.storagehubwrapper.shared.Member;
|
||||
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder;
|
||||
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
||||
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
|
||||
|
@ -193,7 +194,7 @@ public interface Workspace {
|
|||
* @return the shared folder members
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public List<String> getSharedFolderMembers(String folderid) throws Exception;
|
||||
public List<Member> getSharedFolderMembers(String folderid) throws Exception;
|
||||
|
||||
/**
|
||||
* Check if an item with the specified name exists in the specified folder.
|
||||
|
|
|
@ -0,0 +1,125 @@
|
|||
package org.gcube.common.storagehubwrapper.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* The Class Member.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Apr 29, 2022
|
||||
*/
|
||||
public class Member implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1454948336452658186L;
|
||||
|
||||
/**
|
||||
* The Enum TYPE.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Apr 29, 2022
|
||||
*/
|
||||
public static enum TYPE {
|
||||
USER, GROUP
|
||||
}
|
||||
|
||||
private String identity;
|
||||
private String name;
|
||||
private TYPE memberType = TYPE.USER;
|
||||
|
||||
/**
|
||||
* Instantiates a new member.
|
||||
*/
|
||||
public Member() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new member.
|
||||
*
|
||||
* @param identity the identity is the username of a User or the name of a
|
||||
* Group. In general is key to identify he/she/it in the in
|
||||
* the infrastructure
|
||||
* @param name the name is the name of a User or the name of a Group
|
||||
* @param memberType the member type
|
||||
*/
|
||||
public Member(String identity, String name, TYPE memberType) {
|
||||
super();
|
||||
this.identity = identity;
|
||||
this.name = name;
|
||||
this.memberType = memberType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the identity.
|
||||
*
|
||||
* @return the login in case of user and the groupName stored in SHUB (e.g.
|
||||
* gcube-devsec-devVRE) in case of group
|
||||
*/
|
||||
public String getIdentity() {
|
||||
return identity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name.
|
||||
*
|
||||
* @return the login in case of user and the groupName in case of group
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the member type.
|
||||
*
|
||||
* @return the member type
|
||||
*/
|
||||
public TYPE getMemberType() {
|
||||
return memberType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the identity.
|
||||
*
|
||||
* @param identity the new identity
|
||||
*/
|
||||
public void setIdentity(String identity) {
|
||||
this.identity = identity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name.
|
||||
*
|
||||
* @param name the new name
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the member type.
|
||||
*
|
||||
* @param memberType the new member type
|
||||
*/
|
||||
public void setMemberType(TYPE memberType) {
|
||||
this.memberType = memberType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("Member [identity=");
|
||||
builder.append(identity);
|
||||
builder.append(", name=");
|
||||
builder.append(name);
|
||||
builder.append(", memberType=");
|
||||
builder.append(memberType);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
/resources/
|
|
@ -3,9 +3,14 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.common.storagehub.client.dsl.FolderContainer;
|
||||
import org.gcube.common.storagehub.client.dsl.StorageHubClient;
|
||||
import org.gcube.common.storagehubwrapper.server.StorageHubWrapper;
|
||||
import org.gcube.common.storagehubwrapper.server.WorkspaceStorageHubClientService;
|
||||
import org.gcube.common.storagehubwrapper.server.tohl.Workspace;
|
||||
import org.gcube.common.storagehubwrapper.shared.Member;
|
||||
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder;
|
||||
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
||||
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
|
||||
|
@ -14,29 +19,26 @@ import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.WrongItemTypeEx
|
|||
import org.gcube.common.storagehubwrapper.shared.tohl.impl.FileItem;
|
||||
import org.gcube.common.storagehubwrapper.shared.tohl.impl.ImageFile;
|
||||
import org.gcube.common.storagehubwrapper.shared.tohl.impl.PDFFile;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Jun 20, 2018
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Jun 20, 2018
|
||||
*/
|
||||
public class WorkspaceInstance {
|
||||
|
||||
public static String SCOPE = "/gcube";
|
||||
public static String SCOPE = "/gcube/devsec/devVRE";
|
||||
//public static String SCOPE = "/d4science.research-infrastructures.eu";
|
||||
|
||||
|
||||
// public static String USERNAME = "massimiliano.assante";
|
||||
public static String USERNAME = "francesco.mangiacrapa";
|
||||
|
||||
public static String TOKEN = System.getenv("TOKEN_gcube"); //YOU MUST SET THIS AS Environment variable
|
||||
//public static String TOKEN = System.getenv("TOKEN_gcube"); // YOU MUST SET THIS AS Environment variable
|
||||
|
||||
public static String TOKEN = "";
|
||||
|
||||
public static String FIND_FILE_NAME = "francesco";
|
||||
public static String rootId = null;
|
||||
|
@ -49,11 +51,13 @@ public class WorkspaceInstance {
|
|||
|
||||
if (TOKEN == null) {
|
||||
System.err.println("You must set the token as Environment variable");
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.println("Read TOKEN_gcube: " + TOKEN);
|
||||
|
||||
ScopeProvider.instance.set(SCOPE);
|
||||
SecurityTokenProvider.instance.set(TOKEN);
|
||||
|
||||
// METHOD 1
|
||||
storageHubWrapper = new StorageHubWrapper(SCOPE, TOKEN, false, false, true);
|
||||
// workspace = storageHubWrapper.getWorkspace();
|
||||
|
@ -74,8 +78,7 @@ public class WorkspaceInstance {
|
|||
root = storageHubWrapper.getWorkspace().getRoot();
|
||||
rootId = root.getId();
|
||||
System.out.println("The root is:" + root);
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -94,7 +97,8 @@ public class WorkspaceInstance {
|
|||
|
||||
int i = 0;
|
||||
for (WorkspaceItem workspaceItem : children) {
|
||||
System.out.println(++i+")"+workspaceItem.getId() + " name: "+workspaceItem.getName() + " type: "+workspaceItem.getType() +" class: "+workspaceItem.getClass());
|
||||
System.out.println(++i + ")" + workspaceItem.getId() + " name: " + workspaceItem.getName() + " type: "
|
||||
+ workspaceItem.getType() + " class: " + workspaceItem.getClass());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -109,12 +113,22 @@ public class WorkspaceInstance {
|
|||
int i = 0;
|
||||
for (WorkspaceItem workspaceItem : children) {
|
||||
if (workspaceItem.isShared()) {
|
||||
System.out.println(++i+")"+workspaceItem.getId() + " name: "+workspaceItem.getName() + " type: "+workspaceItem.getPath());
|
||||
System.out.println(++i + ")" + workspaceItem.getId() + " name: " + workspaceItem.getName() + " type: "
|
||||
+ workspaceItem.getPath());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//@Test
|
||||
public void getVREFolder() throws Exception {
|
||||
System.out.println("Get VRE Folder");
|
||||
|
||||
StorageHubClient shClient = new StorageHubClient();
|
||||
FolderContainer vre= shClient.openVREFolder();
|
||||
System.out.println("VRE folder: "+vre.getId() + " ACLs: "+vre.getAcls());
|
||||
}
|
||||
|
||||
|
||||
// @Test
|
||||
public void getFilteredChildren() throws Exception {
|
||||
|
@ -122,7 +136,8 @@ public class WorkspaceInstance {
|
|||
|
||||
WorkspaceFolder root = storageHubWrapper.getWorkspace().getRoot();
|
||||
Class filterClass = org.gcube.common.storagehub.model.items.FolderItem.class;
|
||||
List<? extends WorkspaceItem> children = storageHubWrapper.getWorkspace().getFilteredChildren(root.getId(), filterClass);
|
||||
List<? extends WorkspaceItem> children = storageHubWrapper.getWorkspace().getFilteredChildren(root.getId(),
|
||||
filterClass);
|
||||
|
||||
// WorkspaceFolder root = workspace.getRoot();
|
||||
// List<? extends WorkspaceItem> children = workspace.getChildren(root.getId());
|
||||
|
@ -132,7 +147,6 @@ public class WorkspaceInstance {
|
|||
System.out.println(++i + ")" + workspaceItem);
|
||||
System.out.println(workspaceItem.getType() + " " + workspaceItem.getClass());
|
||||
|
||||
|
||||
// System.out.println(++i+")");
|
||||
// if(workspaceItem.isFolder()){
|
||||
// WorkspaceFolder folder = (WorkspaceFolder) workspaceItem;
|
||||
|
@ -147,7 +161,8 @@ public class WorkspaceInstance {
|
|||
|
||||
public static void printMap(WorkspaceItem workspaceItem) {
|
||||
if (workspaceItem.getPropertyMap() != null) {
|
||||
System.out.println(workspaceItem.getId() + " name: "+workspaceItem.getName() + " isFolder: "+workspaceItem.isFolder());
|
||||
System.out.println(workspaceItem.getId() + " name: " + workspaceItem.getName() + " isFolder: "
|
||||
+ workspaceItem.isFolder());
|
||||
System.out.println("Property Map: " + workspaceItem.getPropertyMap().getValues().toString());
|
||||
}
|
||||
}
|
||||
|
@ -170,6 +185,33 @@ public class WorkspaceInstance {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSharedFolderMembers() {
|
||||
System.out.println("Getting getSharedFolderMembers");
|
||||
try {
|
||||
|
||||
//String sharedFolderId = "7e3c6636-927c-4139-9fcc-64986ea70cbf"; // devVRE (VRE Folder)
|
||||
String sharedFolderId = "f8275521-5da1-4501-8385-bb9c79055aa6"; // PROD - d4science.research-infrastructures.eu-D4OS-Blue-Cloud2026Project (VRE Folder)
|
||||
//String sharedFolderId = "4d6f1fe9-8f04-45c9-a87e-ee6093553d77"; // PROD - AriadnePlus-LiDAR Dataset (simple Shared Folder)
|
||||
//String sharedFolderId = "a4837a77-c1d0-4ea4-9f9d-c4bd5cf07e9a"; // PROD - Sample Reports and Templates (private Folder)
|
||||
//sharedFolderId = "c141d53d-4cae-4bfc-a6f7-9b8bbd8c0e2b"; //NextNext
|
||||
SCOPE = "/gcube";
|
||||
SCOPE = "/d4science.research-infrastructures.eu";
|
||||
TOKEN = "";
|
||||
storageHubWrapper = new StorageHubWrapper(SCOPE, TOKEN);
|
||||
List<Member> listMembers = storageHubWrapper.getWorkspace().getSharedFolderMembers(sharedFolderId);
|
||||
|
||||
System.out.println("Foud " + listMembers.size() + " member/s");
|
||||
|
||||
for (Member member : listMembers) {
|
||||
System.out.println(member);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// @Test
|
||||
public void getChildrenPerWorkspaceItem() throws InternalErrorException {
|
||||
System.out.println("Get children test per workspace item");
|
||||
|
@ -205,7 +247,8 @@ public class WorkspaceInstance {
|
|||
case PDF_DOCUMENT:
|
||||
PDFFile pdfFile = (PDFFile) fileItem;
|
||||
System.out.println("PDF_DOCUMENT " + pdfFile);
|
||||
PDFFile completeItem = (PDFFile) storageHubWrapper.getWorkspace().getItem(fileItem.getId(), true, true, true);
|
||||
PDFFile completeItem = (PDFFile) storageHubWrapper.getWorkspace().getItem(fileItem.getId(),
|
||||
true, true, true);
|
||||
System.out.println(completeItem);
|
||||
break;
|
||||
case IMAGE_DOCUMENT:
|
||||
|
@ -218,15 +261,13 @@ public class WorkspaceInstance {
|
|||
|
||||
System.out.println(fileItem.getFileItemType() + " " + workspaceItem.getClass());
|
||||
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -238,7 +279,8 @@ public class WorkspaceInstance {
|
|||
System.out.println("Find file name test");
|
||||
getRoot();
|
||||
try {
|
||||
//List<WorkspaceItem> foundItems = storageHubWrapper.getWorkspace().find(FIND_FILE_NAME,rootId);
|
||||
// List<WorkspaceItem> foundItems =
|
||||
// storageHubWrapper.getWorkspace().find(FIND_FILE_NAME,rootId);
|
||||
List<? extends WorkspaceItem> foundItems = workspace.find(FIND_FILE_NAME, rootId);
|
||||
|
||||
if (foundItems == null || foundItems.size() == 0) {
|
||||
|
@ -250,8 +292,7 @@ public class WorkspaceInstance {
|
|||
for (WorkspaceItem workspaceItem : foundItems) {
|
||||
System.out.println(workspaceItem);
|
||||
}
|
||||
}
|
||||
catch (ItemNotFoundException | WrongItemTypeException e) {
|
||||
} catch (ItemNotFoundException | WrongItemTypeException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue