Compare commits
28 Commits
16
.classpath
16
.classpath
|
@ -13,9 +13,10 @@
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</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>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="test" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||||
|
@ -24,21 +25,20 @@
|
||||||
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
|
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="src" path="target/generated-sources/annotations">
|
<classpathentry kind="src" path=".apt_generated">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="ignore_optional_problems" value="true"/>
|
|
||||||
<attribute name="optional" value="true"/>
|
<attribute name="optional" value="true"/>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
<attribute name="m2e-apt" value="true"/>
|
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
|
<classpathentry kind="src" output="target/test-classes" path=".apt_generated_tests">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="ignore_optional_problems" value="true"/>
|
|
||||||
<attribute name="test" value="true"/>
|
<attribute name="test" value="true"/>
|
||||||
<attribute name="optional" value="true"/>
|
<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"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
<attribute name="m2e-apt" value="true"/>
|
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="output" path="target/classes"/>
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
|
|
|
@ -1 +1,3 @@
|
||||||
/target/
|
/target/
|
||||||
|
/.apt_generated/
|
||||||
|
/.apt_generated_tests/
|
||||||
|
|
|
@ -6,7 +6,7 @@ org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
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.processAnnotations=enabled
|
||||||
org.eclipse.jdt.core.compiler.release=disabled
|
org.eclipse.jdt.core.compiler.release=disabled
|
||||||
org.eclipse.jdt.core.compiler.source=1.8
|
org.eclipse.jdt.core.compiler.source=1.8
|
||||||
|
|
|
@ -1,6 +1,31 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<wb-module deploy-name="storagehub-client-wrapper">
|
<wb-module deploy-name="storagehub-client-wrapper">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<wb-resource deploy-path="/" source-path="/src/main/java"/>
|
<wb-resource deploy-path="/" source-path="/src/main/java"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<wb-resource deploy-path="/" source-path="/src/main/resources"/>
|
<wb-resource deploy-path="/" source-path="/src/main/resources"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<wb-resource deploy-path="/" source-path="/.apt_generated"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</wb-module>
|
</wb-module>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</project-modules>
|
</project-modules>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<faceted-project>
|
<faceted-project>
|
||||||
<installed facet="java" version="1.8"/>
|
|
||||||
<installed facet="jst.utility" version="1.0"/>
|
<installed facet="jst.utility" version="1.0"/>
|
||||||
|
<installed facet="java" version="1.8"/>
|
||||||
</faceted-project>
|
</faceted-project>
|
||||||
|
|
|
@ -3,48 +3,79 @@
|
||||||
All notable changes to this project will be documented in this file.
|
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).
|
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
## [v0-7-1] [r4-23-0] - [2020-05-18]
|
## [v1.2.1] - 2023-04-04
|
||||||
|
|
||||||
** Enhancements **
|
- [#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
|
||||||
|
|
||||||
|
[#21412] Added some methods that were missing
|
||||||
|
|
||||||
|
|
||||||
|
## [v1-0-1-SNAPSHOT] - 2021-03-03
|
||||||
|
|
||||||
|
Improved JUnit Test
|
||||||
|
|
||||||
|
|
||||||
|
## [v1-0-0]- 2020-07-15
|
||||||
|
|
||||||
|
#### Enhancements
|
||||||
|
|
||||||
|
[#19317] component moved from 0.y.z to 1.y.z version
|
||||||
|
|
||||||
|
[#19668] add the method updateDescriptionForItem
|
||||||
|
|
||||||
|
|
||||||
|
## [v0-7-1] - 2020-05-18
|
||||||
|
|
||||||
|
#### Enhancements
|
||||||
|
|
||||||
[#19058] added the folder destination Id to restore operation
|
[#19058] added the folder destination Id to restore operation
|
||||||
|
|
||||||
|
|
||||||
## [v0-7-0] [r4-22-0] - [2020-04-16]
|
## [v0-7-0] - 2020-04-16
|
||||||
|
|
||||||
** Enhancements **
|
#### Enhancements
|
||||||
|
|
||||||
[Task #19087] provide a getItem (without getRoot inside) for Workspace-Explorer-App
|
[#19087] provide a getItem (without getRoot inside) for Workspace-Explorer-App
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [v0-6-2] [r4-21-0] - [2020-03-11]
|
## [v0-6-2] - 2020-03-11
|
||||||
|
|
||||||
** New features **
|
#### New features
|
||||||
|
|
||||||
[#18174] Moved to new search facility provided by SHUB
|
[#18174] Moved to new search facility provided by SHUB
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [0-6-1] - [2019-12-19]
|
## [v0-6-1] - 2019-12-19
|
||||||
|
|
||||||
Ported to Git and Jenkins
|
Ported to Git and Jenkins
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [0-6-0] - [2019-10-01]
|
## [v0-6-0] - 2019-10-01
|
||||||
|
|
||||||
[Task #16688] Integrating new method added into SHUB
|
[Task #16688] Integrating new method added into SHUB
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [0-5-0] - [2019-08-01]
|
## [v0-5-0] - 2019-08-01
|
||||||
|
|
||||||
Released due to exceptions thrown by SHUB
|
Released due to exceptions thrown by SHUB
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [0-4-0] - [2019-06-01]
|
## [v0-4-0] - 2019-06-01
|
||||||
|
|
||||||
Updated to new SHub interface
|
Updated to new SHub interface
|
||||||
|
|
||||||
|
@ -52,7 +83,7 @@ Added method getMetadata
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [0-3-0] - [2018-03-01]
|
## [v0-3-0] - 2018-03-01
|
||||||
|
|
||||||
[Task #12059] added delete item
|
[Task #12059] added delete item
|
||||||
|
|
||||||
|
@ -76,13 +107,13 @@ Added method getMetadata
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [0-2-0] - [2018-06-20]
|
## [v0-2-0] - 2018-06-20
|
||||||
|
|
||||||
minor fixes
|
minor fixes
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [0-1-0] - [2018-06-20]
|
## [v0-1-0] - 2018-06-20
|
||||||
|
|
||||||
[Task #12059] first release
|
[Task #12059] first release
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
<includes>
|
<includes>
|
||||||
<include>README.md</include>
|
<include>README.md</include>
|
||||||
<include>LICENSE.md</include>
|
<include>LICENSE.md</include>
|
||||||
<include>changelog.md</include>
|
|
||||||
<include>profile.xml</include>
|
<include>profile.xml</include>
|
||||||
|
<include>CHANGELOG.md</include>
|
||||||
</includes>
|
</includes>
|
||||||
<fileMode>755</fileMode>
|
<fileMode>755</fileMode>
|
||||||
<filtered>true</filtered>
|
<filtered>true</filtered>
|
||||||
|
|
44
pom.xml
44
pom.xml
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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">
|
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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
|
@ -10,7 +11,7 @@
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>org.gcube.common</groupId>
|
<groupId>org.gcube.common</groupId>
|
||||||
<artifactId>storagehub-client-wrapper</artifactId>
|
<artifactId>storagehub-client-wrapper</artifactId>
|
||||||
<version>0.7.1</version>
|
<version>1.2.1</version>
|
||||||
<name>storagehub-client-wrapper</name>
|
<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>
|
<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>
|
<scm>
|
||||||
|
@ -19,15 +20,18 @@
|
||||||
<url>https://code-repo.d4science.org/gCubeSystem/${project.artifactId}</url>
|
<url>https://code-repo.d4science.org/gCubeSystem/${project.artifactId}</url>
|
||||||
</scm>
|
</scm>
|
||||||
<properties>
|
<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>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<distroDirectory>distro</distroDirectory>
|
<distroDirectory>distro</distroDirectory>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.distribution</groupId>
|
<groupId>org.gcube.distribution</groupId>
|
||||||
<artifactId>gcube-bom</artifactId>
|
<artifactId>gcube-bom</artifactId>
|
||||||
<version>1.4.0</version>
|
<version>2.3.0</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@ -51,13 +55,21 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<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>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.common</groupId>
|
<groupId>org.gcube.common</groupId>
|
||||||
<artifactId>storagehub-client-library</artifactId>
|
<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>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
@ -89,6 +101,7 @@
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-log4j12</artifactId>
|
<artifactId>slf4j-log4j12</artifactId>
|
||||||
<version>1.6.4</version>
|
<version>1.6.4</version>
|
||||||
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -97,6 +110,7 @@
|
||||||
<version>4.12</version>
|
<version>4.12</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<resources>
|
<resources>
|
||||||
|
@ -143,6 +157,24 @@
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<additionalparam>-Xdoclint:none</additionalparam>
|
||||||
|
<additionalJOption>-Xdoclint:none</additionalJOption>
|
||||||
|
</configuration>
|
||||||
|
<version>3.1.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>generate-doc</id>
|
||||||
|
<phase>install</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>jar</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -11,6 +11,7 @@ import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.gcube.common.storagehub.client.StreamDescriptor;
|
import org.gcube.common.storagehub.client.StreamDescriptor;
|
||||||
|
@ -26,9 +27,9 @@ import org.gcube.common.storagehub.model.service.Version;
|
||||||
import org.gcube.common.storagehubwrapper.server.converter.HLMapper;
|
import org.gcube.common.storagehubwrapper.server.converter.HLMapper;
|
||||||
import org.gcube.common.storagehubwrapper.server.tohl.Workspace;
|
import org.gcube.common.storagehubwrapper.server.tohl.Workspace;
|
||||||
import org.gcube.common.storagehubwrapper.shared.ACLType;
|
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.WorkspaceItem;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceVREFolder;
|
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InsufficientPrivilegesException;
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InsufficientPrivilegesException;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.ItemAlreadyExistException;
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.ItemAlreadyExistException;
|
||||||
|
@ -348,6 +349,33 @@ public final class WorkspaceStorageHubClientService implements Workspace{
|
||||||
return toChildren;
|
return toChildren;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the children.
|
||||||
|
*
|
||||||
|
* @param id the id
|
||||||
|
* @return the children
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.gcube.portal.storagehubwrapper.shared.tohl.Workspace#getChildren(java.lang.String)
|
||||||
|
*/
|
||||||
|
public List<? extends WorkspaceItem> getChildren(String id, boolean includeHidden)throws Exception{
|
||||||
|
|
||||||
|
LOGGER.debug("called get Children include hidden");
|
||||||
|
Validate.notNull(id,"The input id is null");
|
||||||
|
List<? extends Item> children = storageHubClientService.getChildren(id, withAccounting, withMapProperties, includeHidden);
|
||||||
|
List<WorkspaceItem> toChildren = new ArrayList<WorkspaceItem>(children.size());
|
||||||
|
|
||||||
|
for (Item item : children) {
|
||||||
|
WorkspaceItem child = HLMapper.toWorkspaceItem(item, withAccounting, withFileDetails, withMapProperties);
|
||||||
|
toChildren.add(child);
|
||||||
|
}
|
||||||
|
|
||||||
|
return toChildren;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the filtered children.
|
* Gets the filtered children.
|
||||||
*
|
*
|
||||||
|
@ -526,6 +554,23 @@ public final class WorkspaceStorageHubClientService implements Workspace{
|
||||||
return workspaceItem;
|
return workspaceItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WorkspaceItem getItemByPath(String folderId, String relativePath) throws ItemNotFoundException, InternalErrorException, Exception {
|
||||||
|
LOGGER.debug("called get getItemByPath");
|
||||||
|
Validate.notNull(folderId,"The input folderId is null");
|
||||||
|
Item item;
|
||||||
|
try {
|
||||||
|
item = storageHubClientService.getItemByPath(folderId, relativePath);
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
LOGGER.error("Error during get item with id: "+folderId,e);
|
||||||
|
throw new InternalErrorException(e.getMessage());
|
||||||
|
}
|
||||||
|
WorkspaceItem workspaceItem = HLMapper.toWorkspaceItem(item, withAccounting, withFileDetails, withMapProperties);
|
||||||
|
setIsRoot((org.gcube.common.storagehubwrapper.shared.tohl.impl.WorkspaceItem) workspaceItem);
|
||||||
|
return workspaceItem;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the item. This call is the same of {@link WorkspaceStorageHubClientService#getItem(String, boolean, boolean, boolean)}
|
* Gets the item. This call is the same of {@link WorkspaceStorageHubClientService#getItem(String, boolean, boolean, boolean)}
|
||||||
* except to getRoot called inside (to check if an item is root or not). {@link WorkspaceItem#isRoot()} returns always false.
|
* except to getRoot called inside (to check if an item is root or not). {@link WorkspaceItem#isRoot()} returns always false.
|
||||||
|
@ -640,7 +685,7 @@ public final class WorkspaceStorageHubClientService implements Workspace{
|
||||||
* @see org.gcube.portal.storagehubwrapper.server.tohl.Workspace#getSharedFolderMembers(java.lang.String)
|
* @see org.gcube.portal.storagehubwrapper.server.tohl.Workspace#getSharedFolderMembers(java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<String> getSharedFolderMembers(String folderId) throws Exception {
|
public List<Member> getSharedFolderMembers(String folderId) throws Exception {
|
||||||
|
|
||||||
try{
|
try{
|
||||||
LOGGER.debug("called Shared Folder Members");
|
LOGGER.debug("called Shared Folder Members");
|
||||||
|
@ -669,7 +714,6 @@ public final class WorkspaceStorageHubClientService implements Workspace{
|
||||||
public boolean exists(String name, String folderId)
|
public boolean exists(String name, String folderId)
|
||||||
throws InternalErrorException, ItemNotFoundException,
|
throws InternalErrorException, ItemNotFoundException,
|
||||||
WrongItemTypeException {
|
WrongItemTypeException {
|
||||||
|
|
||||||
LOGGER.debug("called exists");
|
LOGGER.debug("called exists");
|
||||||
List<WorkspaceItem> foundItems = find(name, folderId);
|
List<WorkspaceItem> foundItems = find(name, folderId);
|
||||||
|
|
||||||
|
@ -694,7 +738,7 @@ public final class WorkspaceStorageHubClientService implements Workspace{
|
||||||
throws InternalErrorException, ItemNotFoundException,
|
throws InternalErrorException, ItemNotFoundException,
|
||||||
WrongItemTypeException {
|
WrongItemTypeException {
|
||||||
|
|
||||||
LOGGER.debug("called find");
|
LOGGER.debug("called find ");
|
||||||
Validate.notNull(folderId,"The input folderid is null");
|
Validate.notNull(folderId,"The input folderid is null");
|
||||||
try {
|
try {
|
||||||
List<? extends Item> items = storageHubClientService.findByName(name, folderId);
|
List<? extends Item> items = storageHubClientService.findByName(name, folderId);
|
||||||
|
@ -1500,356 +1544,38 @@ public final class WorkspaceStorageHubClientService implements Workspace{
|
||||||
throw new Exception("The item with id '"+folderId+"' is not a folder");
|
throw new Exception("The item with id '"+folderId+"' is not a folder");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* TODO
|
|
||||||
*
|
|
||||||
* FOLLOWING METHODS ARE NOT IMPLEMENTED;
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Change description.
|
|
||||||
*
|
|
||||||
* @param itemId the item id
|
|
||||||
* @param newDescription the new description
|
|
||||||
* @throws ItemNotFoundException the item not found exception
|
|
||||||
* @throws InternalErrorException the internal error exception
|
|
||||||
*/
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#changeDescription(java.lang.String, java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void changeDescription(String itemId, String newDescription)
|
public String updateDescriptionForItem(String itemId, String newDescription) throws Exception {
|
||||||
throws ItemNotFoundException, InternalErrorException {
|
|
||||||
|
String updatedDescription = null;
|
||||||
// TODO Auto-generated method stub
|
try{
|
||||||
|
updatedDescription = storageHubClientService.updateDescriptionForItem(itemId, newDescription);
|
||||||
|
}catch(Exception e){
|
||||||
|
String error = "Error on updating the description for item with id: "+itemId;
|
||||||
|
LOGGER.error(error, e);
|
||||||
|
throw new Exception(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return updatedDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Search by mime type.
|
|
||||||
*
|
|
||||||
* @param mimeType the mime type
|
|
||||||
* @return the list
|
|
||||||
* @throws InternalErrorException the internal error exception
|
|
||||||
*/
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#searchByMimeType(java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public List<WorkspaceItem> searchByMimeType(String mimeType)
|
public void setFolderAsHidden(String folderId, boolean hide) throws Exception {
|
||||||
throws InternalErrorException {
|
storageHubClientService.setFolderAsHidden(folderId, hide);
|
||||||
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates the shared folder.
|
|
||||||
*
|
|
||||||
* @param name the name
|
|
||||||
* @param description the description
|
|
||||||
* @param users the users
|
|
||||||
* @param destinationFolderId the destination folder id
|
|
||||||
* @return the workspace shared folder
|
|
||||||
* @throws InternalErrorException the internal error exception
|
|
||||||
* @throws InsufficientPrivilegesException the insufficient privileges exception
|
|
||||||
* @throws ItemAlreadyExistException the item already exist exception
|
|
||||||
* @throws WrongDestinationException the wrong destination exception
|
|
||||||
* @throws ItemNotFoundException the item not found exception
|
|
||||||
* @throws WorkspaceFolderNotFoundException the workspace folder not found exception
|
|
||||||
*/
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#createSharedFolder(java.lang.String, java.lang.String, java.util.List, java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public WorkspaceSharedFolder createSharedFolder(
|
|
||||||
String name, String description, List<String> users,
|
|
||||||
String destinationFolderId)
|
|
||||||
throws InternalErrorException, InsufficientPrivilegesException,
|
|
||||||
ItemAlreadyExistException, WrongDestinationException,
|
|
||||||
ItemNotFoundException, WorkspaceFolderNotFoundException {
|
|
||||||
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Share folder.
|
|
||||||
*
|
|
||||||
* @param users the users
|
|
||||||
* @param destinationFolderId the destination folder id
|
|
||||||
* @return the workspace shared folder
|
|
||||||
* @throws InternalErrorException the internal error exception
|
|
||||||
* @throws InsufficientPrivilegesException the insufficient privileges exception
|
|
||||||
* @throws ItemAlreadyExistException the item already exist exception
|
|
||||||
* @throws WrongDestinationException the wrong destination exception
|
|
||||||
* @throws ItemNotFoundException the item not found exception
|
|
||||||
* @throws WorkspaceFolderNotFoundException the workspace folder not found exception
|
|
||||||
*/
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#shareFolder(java.util.List, java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public WorkspaceSharedFolder shareFolder(
|
|
||||||
List<String> users, String destinationFolderId)
|
|
||||||
throws InternalErrorException, InsufficientPrivilegesException,
|
|
||||||
ItemAlreadyExistException, WrongDestinationException,
|
|
||||||
ItemNotFoundException, WorkspaceFolderNotFoundException {
|
|
||||||
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Share.
|
|
||||||
*
|
|
||||||
* @param users the users
|
|
||||||
* @param itemId the item id
|
|
||||||
* @return the workspace shared folder
|
|
||||||
* @throws InternalErrorException the internal error exception
|
|
||||||
* @throws InsufficientPrivilegesException the insufficient privileges exception
|
|
||||||
* @throws ItemAlreadyExistException the item already exist exception
|
|
||||||
* @throws WrongDestinationException the wrong destination exception
|
|
||||||
* @throws ItemNotFoundException the item not found exception
|
|
||||||
* @throws WorkspaceFolderNotFoundException the workspace folder not found exception
|
|
||||||
*/
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#share(java.util.List, java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public WorkspaceSharedFolder share(List<String> users, String itemId)
|
|
||||||
throws InternalErrorException, InsufficientPrivilegesException,
|
|
||||||
ItemAlreadyExistException, WrongDestinationException,
|
|
||||||
ItemNotFoundException, WorkspaceFolderNotFoundException {
|
|
||||||
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates the gcube item.
|
|
||||||
*
|
|
||||||
* @param name the name
|
|
||||||
* @param description the description
|
|
||||||
* @param scopes the scopes
|
|
||||||
* @param creator the creator
|
|
||||||
* @param itemType the item type
|
|
||||||
* @param properties the properties
|
|
||||||
* @param destinationFolderId the destination folder id
|
|
||||||
* @return the workspace item
|
|
||||||
* @throws InsufficientPrivilegesException the insufficient privileges exception
|
|
||||||
* @throws WorkspaceFolderNotFoundException the workspace folder not found exception
|
|
||||||
* @throws InternalErrorException the internal error exception
|
|
||||||
* @throws ItemAlreadyExistException the item already exist exception
|
|
||||||
* @throws WrongDestinationException the wrong destination exception
|
|
||||||
* @throws ItemNotFoundException the item not found exception
|
|
||||||
*/
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#createGcubeItem(java.lang.String, java.lang.String, java.util.List, java.lang.String, java.lang.String, java.util.Map, java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public WorkspaceItem createGcubeItem(
|
|
||||||
String name, String description, List<String> scopes, String creator,
|
|
||||||
String itemType, Map<String, String> properties,
|
|
||||||
String destinationFolderId)
|
|
||||||
throws InsufficientPrivilegesException,
|
|
||||||
WorkspaceFolderNotFoundException, InternalErrorException,
|
|
||||||
ItemAlreadyExistException, WrongDestinationException,
|
|
||||||
ItemNotFoundException {
|
|
||||||
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unshare.
|
|
||||||
*
|
|
||||||
* @param itemId the item id
|
|
||||||
* @return the workspace item
|
|
||||||
* @throws InternalErrorException the internal error exception
|
|
||||||
* @throws ItemNotFoundException the item not found exception
|
|
||||||
*/
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#unshare(java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public WorkspaceItem unshare(String itemId)
|
|
||||||
throws InternalErrorException, ItemNotFoundException {
|
|
||||||
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the my special folders.
|
|
||||||
*
|
|
||||||
* @return the my special folders
|
|
||||||
* @throws InternalErrorException the internal error exception
|
|
||||||
* @throws ItemNotFoundException the item not found exception
|
|
||||||
*/
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#getMySpecialFolders()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public WorkspaceFolder getMySpecialFolders()
|
public WorkspaceSharedFolder shareFolder(String folderId, Set<String> users, ACLType type) throws Exception {
|
||||||
throws InternalErrorException, ItemNotFoundException {
|
return storageHubClientService.shareFolder(folderId, users, type);
|
||||||
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Search by properties.
|
|
||||||
*
|
|
||||||
* @param properties the properties
|
|
||||||
* @return the list
|
|
||||||
* @throws InternalErrorException the internal error exception
|
|
||||||
*/
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#searchByProperties(java.util.List)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<WorkspaceItem> searchByProperties(List<String> properties)
|
|
||||||
throws InternalErrorException {
|
|
||||||
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates the VRE folder.
|
|
||||||
*
|
|
||||||
* @param scope the scope
|
|
||||||
* @param description the description
|
|
||||||
* @param displayName the display name
|
|
||||||
* @param privilege the privilege
|
|
||||||
* @return the workspace VRE folder
|
|
||||||
* @throws InternalErrorException the internal error exception
|
|
||||||
* @throws InsufficientPrivilegesException the insufficient privileges exception
|
|
||||||
* @throws ItemAlreadyExistException the item already exist exception
|
|
||||||
* @throws WrongDestinationException the wrong destination exception
|
|
||||||
* @throws ItemNotFoundException the item not found exception
|
|
||||||
* @throws WorkspaceFolderNotFoundException the workspace folder not found exception
|
|
||||||
*/
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#createVREFolder(java.lang.String, java.lang.String, java.lang.String, org.gcube.portal.storagehubwrapper.shared.ACLType)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public WorkspaceVREFolder createVREFolder(
|
|
||||||
String scope, String description, String displayName, ACLType privilege)
|
|
||||||
throws InternalErrorException, InsufficientPrivilegesException,
|
|
||||||
ItemAlreadyExistException, WrongDestinationException,
|
|
||||||
ItemNotFoundException, WorkspaceFolderNotFoundException {
|
|
||||||
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the public folders.
|
|
||||||
*
|
|
||||||
* @return the public folders
|
|
||||||
* @throws InternalErrorException the internal error exception
|
|
||||||
*/
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#getPublicFolders()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public List<WorkspaceItem> getPublicFolders()
|
public WorkspaceSharedFolder unshareFolder(String folderId, Set<String> users) throws Exception {
|
||||||
throws InternalErrorException {
|
return storageHubClientService.unshareFolder(folderId, users);
|
||||||
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,9 +12,13 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* The Class WrapperUtility.
|
||||||
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Oct 17, 2018
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Oct 17, 2018
|
||||||
*/
|
*/
|
||||||
public class WrapperUtility {
|
public class WrapperUtility {
|
||||||
|
|
||||||
|
public static final String SCOPE_SEPARATOR = "/";
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(WrapperUtility.class);
|
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,30 +39,16 @@ import org.gcube.common.storagehubwrapper.shared.tohl.items.FileItemType;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class HLMapper.
|
* The Class HLMapper.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
* Jun 20, 2018
|
* Jun 20, 2018
|
||||||
*/
|
*/
|
||||||
public class HLMapper {
|
public class HLMapper {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(HLMapper.class);
|
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.
|
* To URL file.
|
||||||
*
|
*
|
||||||
|
@ -74,232 +60,227 @@ public class HLMapper {
|
||||||
return (URLFile) toWorkspaceItem(extLink, false, false, false);
|
return (URLFile) toWorkspaceItem(extLink, false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To workspace item.
|
* To workspace item.
|
||||||
*
|
*
|
||||||
* @param <T> the generic type
|
* @param <T> the generic type
|
||||||
* @param item the item
|
* @param item the item
|
||||||
* @return the t
|
* @return the t
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
public static<T extends WorkspaceItem> T toWorkspaceItem(Item item) throws Exception{
|
public static <T extends WorkspaceItem> T toWorkspaceItem(Item item) throws Exception {
|
||||||
|
|
||||||
return toWorkspaceItem(item, false, false, false);
|
return toWorkspaceItem(item, false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To accounting entries.
|
* To accounting entries.
|
||||||
*
|
*
|
||||||
* @param item the item
|
* @param item the item
|
||||||
* @return the list
|
* @return the list
|
||||||
*/
|
*/
|
||||||
public static List<AccountEntry> toAccountingEntries(Item item){
|
public static List<AccountEntry> toAccountingEntries(Item item) {
|
||||||
|
|
||||||
List<AccountEntry> accountingEntries = null;
|
List<AccountEntry> accountingEntries = null;
|
||||||
|
|
||||||
Accounting accounting = item.getAccounting();
|
Accounting accounting = item.getAccounting();
|
||||||
if(accounting!=null){
|
if (accounting != null) {
|
||||||
accountingEntries = accounting.getEntries();
|
accountingEntries = accounting.getEntries();
|
||||||
// for (AccountEntry ae : accounting.getEntries()) {
|
}
|
||||||
// accountingEntries.add(toAccountingEntry.apply(ae));
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
return accountingEntries;
|
return accountingEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To property map.
|
* To property map.
|
||||||
*
|
*
|
||||||
* @param metadata the metadata
|
* @param metadata the metadata
|
||||||
* @return the property map
|
* @return the property map
|
||||||
*/
|
*/
|
||||||
public static PropertyMap toPropertyMap(Metadata metadata){
|
public static PropertyMap toPropertyMap(Metadata metadata) {
|
||||||
|
|
||||||
PropertyMap pm = null;
|
PropertyMap pm = null;
|
||||||
if(metadata!=null)
|
if (metadata != null)
|
||||||
pm = new PropertyMap(metadata.getMap());
|
pm = new PropertyMap(metadata.getMap());
|
||||||
|
|
||||||
//IN CASE OF EMPTY MAP RETURNS NULL
|
// IN CASE OF EMPTY MAP RETURNS NULL
|
||||||
if(pm!=null && pm.getValues()!=null && pm.getValues().isEmpty())
|
if (pm != null && pm.getValues() != null && pm.getValues().isEmpty())
|
||||||
pm = null;
|
pm = null;
|
||||||
|
|
||||||
return pm;
|
return pm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To workspace file version.
|
* To workspace file version.
|
||||||
*
|
*
|
||||||
* @param fileVersion the file version
|
* @param fileVersion the file version
|
||||||
* @return the workspace file version
|
* @return the workspace file version
|
||||||
*/
|
*/
|
||||||
public static WorkspaceFileVersion toWorkspaceFileVersion(Version fileVersion){
|
public static WorkspaceFileVersion toWorkspaceFileVersion(Version fileVersion) {
|
||||||
WorkspaceFileVersion wsFileVersion = new WorkspaceFileVersion();
|
WorkspaceFileVersion wsFileVersion = new WorkspaceFileVersion();
|
||||||
wsFileVersion.setId(fileVersion.getId());
|
wsFileVersion.setId(fileVersion.getId());
|
||||||
wsFileVersion.setName(fileVersion.getName());
|
wsFileVersion.setName(fileVersion.getName());
|
||||||
wsFileVersion.setCreated(fileVersion.getCreated());
|
wsFileVersion.setCreated(fileVersion.getCreated());
|
||||||
wsFileVersion.setCurrentVersion(fileVersion.isCurrent());
|
wsFileVersion.setCurrentVersion(fileVersion.isCurrent());
|
||||||
//TODO MUST BE TERMINATED
|
// TODO MUST BE TERMINATED
|
||||||
return wsFileVersion;
|
return wsFileVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To workspace item.
|
* To workspace item.
|
||||||
*
|
*
|
||||||
* @param <T> the generic type
|
* @param <T> the generic type
|
||||||
* @param item the item
|
* @param item the item
|
||||||
* @param withAccounting the with accounting
|
* @param withAccounting the with accounting
|
||||||
* @param withFileDetails the with file details
|
* @param withFileDetails the with file details
|
||||||
* @param withMapProperties the with map properties
|
* @param withMapProperties the with map properties
|
||||||
* @return the t
|
* @return the t
|
||||||
* @throws Exception the exception
|
* @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{
|
try {
|
||||||
List<AccountEntry> accountingEntries = null;
|
List<AccountEntry> accountingEntries = null;
|
||||||
|
|
||||||
if(withAccounting)
|
if (withAccounting)
|
||||||
accountingEntries = toAccountingEntries(item);
|
accountingEntries = toAccountingEntries(item);
|
||||||
|
|
||||||
org.gcube.common.storagehubwrapper.shared.tohl.impl.WorkspaceItem theItem = null;
|
org.gcube.common.storagehubwrapper.shared.tohl.impl.WorkspaceItem theItem = null;
|
||||||
WorkspaceItemType type = null;
|
WorkspaceItemType type = null;
|
||||||
Boolean isFolder = false;
|
Boolean isFolder = false;
|
||||||
|
|
||||||
String itemName = item.getName();
|
String itemName = item.getName();
|
||||||
boolean isRoot = false;
|
boolean isRoot = false;
|
||||||
|
|
||||||
logger.trace("The item: "+item);
|
logger.trace("The item: " + item);
|
||||||
logger.trace("Converting Item: "+item.getName() + " with id: "+item.getId());
|
logger.trace("Converting Item: " + item.getName() + " with id: " + item.getId());
|
||||||
|
|
||||||
//THE ITEM IS A KIND OF FOLDER
|
// THE ITEM IS A KIND OF FOLDER
|
||||||
if (item instanceof FolderItem){
|
if (item instanceof FolderItem) {
|
||||||
isFolder = true;
|
isFolder = true;
|
||||||
FolderItem folderItem = (FolderItem) item; //??
|
FolderItem folderItem = (FolderItem) item; // ??
|
||||||
theItem = new WorkspaceFolder();
|
theItem = new WorkspaceFolder();
|
||||||
type = WorkspaceItemType.FOLDER;
|
type = WorkspaceItemType.FOLDER;
|
||||||
if (item instanceof SharedFolder || item instanceof VreFolder) {
|
if (item instanceof SharedFolder || item instanceof VreFolder) {
|
||||||
SharedFolder sharedfolder = (SharedFolder) item; //??
|
SharedFolder sharedfolder = (SharedFolder) item; // ??
|
||||||
theItem = new WorkspaceSharedFolder();
|
theItem = new WorkspaceSharedFolder();
|
||||||
type = WorkspaceItemType.SHARED_FOLDER;
|
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()){
|
if (sharedfolder.isVreFolder()) {
|
||||||
//logger.debug("Converting shared folder: "+theItem.getClass());
|
// logger.debug("Converting shared folder: "+theItem.getClass());
|
||||||
//VreFolder vreFolder = (VreFolder) item;
|
// 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
|
||||||
itemName = sharedfolder.getDisplayName(); //IN CASE OF VRE FOLDER I'M USING THE DISPLAYNAME
|
// 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);
|
((WorkspaceSharedFolder) theItem).setVreFolder(true);
|
||||||
type = WorkspaceItemType.VRE_FOLDER;
|
type = WorkspaceItemType.VRE_FOLDER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isPublicItem = folderItem.isPublicItem();
|
boolean isPublicItem = folderItem.isPublicItem();
|
||||||
//((WorkspaceFolder) theItem).setPublicFolder(folderItem.isPublicItem());
|
// ((WorkspaceFolder) theItem).setPublicFolder(folderItem.isPublicItem());
|
||||||
//logger.debug("Wrapped as Folder");
|
// 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
|
||||||
if(!isPublicItem){
|
// "<boolean>true</boolean>" by HL
|
||||||
try{
|
if (!isPublicItem) {
|
||||||
//Map<String, Object> map = item.getPropertyMap().getValues();
|
try {
|
||||||
|
// Map<String, Object> map = item.getPropertyMap().getValues();
|
||||||
// logger.debug("Property Map size: "+map.size());
|
// logger.debug("Property Map size: "+map.size());
|
||||||
// for (String key : map.keySet()) {
|
// for (String key : map.keySet()) {
|
||||||
// logger.debug("Key: "+key+ "value: "+map.get(key));
|
// logger.debug("Key: "+key+ "value: "+map.get(key));
|
||||||
// }
|
// }
|
||||||
String isPublic = (String) item.getMetadata().getMap().get("isPublic");
|
String isPublic = (String) item.getMetadata().getMap().get("isPublic");
|
||||||
logger.debug("The item name: "+item.getName()+ " has isPublic property like: "+isPublic);
|
logger.debug("The item name: " + item.getName() + " has isPublic property like: " + isPublic);
|
||||||
isPublicItem = isPublic!=null?isPublic.toLowerCase().contains("true"):false;
|
isPublicItem = isPublic != null ? isPublic.toLowerCase().contains("true") : false;
|
||||||
}catch(Exception e){
|
} catch (Exception e) {
|
||||||
//silent
|
// silent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
((WorkspaceFolder) theItem).setPublicFolder(isPublicItem);
|
((WorkspaceFolder) theItem).setPublicFolder(isPublicItem);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//THE ITEM IS A KIND OF FILE
|
// THE ITEM IS A KIND OF FILE
|
||||||
if(item instanceof AbstractFileItem){
|
if (item instanceof AbstractFileItem) {
|
||||||
theItem = new FileItem();
|
theItem = new FileItem();
|
||||||
type = WorkspaceItemType.FILE_ITEM;
|
type = WorkspaceItemType.FILE_ITEM;
|
||||||
FileItemType fileItemType = null;
|
FileItemType fileItemType = null;
|
||||||
if(item instanceof ExternalURL){
|
if (item instanceof ExternalURL) {
|
||||||
theItem = new URLFileItem();
|
theItem = new URLFileItem();
|
||||||
fileItemType = FileItemType.URL_DOCUMENT;
|
fileItemType = FileItemType.URL_DOCUMENT;
|
||||||
}else if(item instanceof GenericFileItem){
|
} else if (item instanceof GenericFileItem) {
|
||||||
GenericFileItem gFI = (GenericFileItem) item; //??
|
GenericFileItem gFI = (GenericFileItem) item; // ??
|
||||||
fileItemType = FileItemType.DOCUMENT;
|
fileItemType = FileItemType.DOCUMENT;
|
||||||
}else if(item instanceof PDFFileItem){
|
} else if (item instanceof PDFFileItem) {
|
||||||
theItem = new PDFFile();
|
theItem = new PDFFile();
|
||||||
fileItemType = FileItemType.PDF_DOCUMENT;
|
fileItemType = FileItemType.PDF_DOCUMENT;
|
||||||
if(withFileDetails){
|
if (withFileDetails) {
|
||||||
PDFFileItem pdfFI = (PDFFileItem) item;
|
PDFFileItem pdfFI = (PDFFileItem) item;
|
||||||
PDFContent pdfContent = pdfFI.getContent();
|
PDFContent pdfContent = pdfFI.getContent();
|
||||||
PDFFile thePDFFileItem = (PDFFile) theItem;
|
PDFFile thePDFFileItem = (PDFFile) theItem;
|
||||||
thePDFFileItem.setNumberOfPages(pdfContent.getNumberOfPages());
|
thePDFFileItem.setNumberOfPages(pdfContent.getNumberOfPages());
|
||||||
thePDFFileItem.setProducer(pdfContent.getProducer());
|
thePDFFileItem.setProducer(pdfContent.getProducer());
|
||||||
thePDFFileItem.setVersion(pdfContent.getVersion());
|
thePDFFileItem.setVersion(pdfContent.getVersion());
|
||||||
thePDFFileItem.setTitle(pdfContent.getTitle());
|
thePDFFileItem.setTitle(pdfContent.getTitle());
|
||||||
thePDFFileItem.setAuthor(pdfContent.getAuthor());
|
thePDFFileItem.setAuthor(pdfContent.getAuthor());
|
||||||
}
|
}
|
||||||
}else if(item instanceof org.gcube.common.storagehub.model.items.ImageFile){
|
} else if (item instanceof org.gcube.common.storagehub.model.items.ImageFile) {
|
||||||
theItem = new ImageFile();
|
theItem = new ImageFile();
|
||||||
fileItemType = FileItemType.IMAGE_DOCUMENT;
|
fileItemType = FileItemType.IMAGE_DOCUMENT;
|
||||||
if(withFileDetails){
|
if (withFileDetails) {
|
||||||
org.gcube.common.storagehub.model.items.ImageFile imgFI = (org.gcube.common.storagehub.model.items.ImageFile) item; //??
|
org.gcube.common.storagehub.model.items.ImageFile imgFI = (org.gcube.common.storagehub.model.items.ImageFile) item; // ??
|
||||||
ImageFile theImageFileItem = (ImageFile) theItem;
|
ImageFile theImageFileItem = (ImageFile) theItem;
|
||||||
ImageContent content = imgFI.getContent();
|
ImageContent content = imgFI.getContent();
|
||||||
theImageFileItem.setHeight(content.getHeight());
|
theImageFileItem.setHeight(content.getHeight());
|
||||||
theImageFileItem.setWidth(content.getWidth());
|
theImageFileItem.setWidth(content.getWidth());
|
||||||
theImageFileItem.setThumbnailWidth(content.getThumbnailHeight());
|
theImageFileItem.setThumbnailWidth(content.getThumbnailHeight());
|
||||||
theImageFileItem.setThumbnailHeight(content.getThumbnailHeight());
|
theImageFileItem.setThumbnailHeight(content.getThumbnailHeight());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractFileItem itemAb = (AbstractFileItem) item;
|
AbstractFileItem itemAb = (AbstractFileItem) item;
|
||||||
Content aC = itemAb.getContent();
|
Content aC = itemAb.getContent();
|
||||||
FileItem theFileItem = (FileItem) theItem;
|
FileItem theFileItem = (FileItem) theItem;
|
||||||
theFileItem.setFileItemType(fileItemType);
|
theFileItem.setFileItemType(fileItemType);
|
||||||
|
|
||||||
if(aC!=null){
|
if (aC != null) {
|
||||||
logger.debug("The content is not null for item: "+itemAb.getId());
|
logger.debug("The content is not null for item: " + itemAb.getId());
|
||||||
theFileItem.setMimeType(aC.getMimeType());
|
theFileItem.setMimeType(aC.getMimeType());
|
||||||
theFileItem.setSize(aC.getSize());
|
theFileItem.setSize(aC.getSize());
|
||||||
}else
|
} else
|
||||||
logger.warn("The content is null for item: "+itemAb.getId());
|
logger.warn("The content is null for item: " + itemAb.getId());
|
||||||
|
|
||||||
//TODO ADD VERSION NAME
|
// TODO ADD VERSION NAME
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//ADDING (GCUBE) PROPERTIES
|
|
||||||
PropertyMap pm = null;
|
|
||||||
if(withMapProperties || isFolder){
|
|
||||||
//System.out.println("Setting map: "+item.getPropertyMap().getValues());
|
|
||||||
pm = toPropertyMap(item.getMetadata());
|
|
||||||
}
|
|
||||||
|
|
||||||
//CONVERTING EXTERNALLINK
|
|
||||||
if(item instanceof ExternalLink) {
|
|
||||||
logger.trace("FOUND an ExternalLink...");
|
|
||||||
type = WorkspaceItemType.URL_ITEM;
|
|
||||||
ExternalLink extLink = (ExternalLink) item;
|
|
||||||
theItem = new URLFile();
|
|
||||||
URLFile theURLFile = (URLFile) theItem;
|
|
||||||
theURLFile.setValue(extLink.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
//CONVERTING TRASH ITEM
|
// ADDING (GCUBE) PROPERTIES
|
||||||
if(item.isTrashed() && item instanceof TrashItem){
|
PropertyMap pm = null;
|
||||||
|
if (withMapProperties || isFolder) {
|
||||||
|
// System.out.println("Setting map: "+item.getPropertyMap().getValues());
|
||||||
|
pm = toPropertyMap(item.getMetadata());
|
||||||
|
}
|
||||||
|
|
||||||
|
// CONVERTING EXTERNALLINK
|
||||||
|
if (item instanceof ExternalLink) {
|
||||||
|
logger.trace("FOUND an ExternalLink...");
|
||||||
|
type = WorkspaceItemType.URL_ITEM;
|
||||||
|
ExternalLink extLink = (ExternalLink) item;
|
||||||
|
theItem = new URLFile();
|
||||||
|
URLFile theURLFile = (URLFile) theItem;
|
||||||
|
theURLFile.setValue(extLink.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
// CONVERTING TRASH ITEM
|
||||||
|
if (item.isTrashed() && item instanceof TrashItem) {
|
||||||
type = WorkspaceItemType.TRASH_ITEM;
|
type = WorkspaceItemType.TRASH_ITEM;
|
||||||
TrashItem trashItem = (TrashItem) item;
|
TrashItem trashItem = (TrashItem) item;
|
||||||
itemName = trashItem.getTitle(); //IN CASE OF TRASHED ITEM THE NAME IS THE ID, SO I'M USING THE TITLE
|
itemName = trashItem.getTitle(); // IN CASE OF TRASHED ITEM THE NAME IS THE ID, SO I'M USING THE TITLE
|
||||||
theItem = new org.gcube.common.storagehubwrapper.shared.tohl.impl.TrashItem();
|
theItem = new org.gcube.common.storagehubwrapper.shared.tohl.impl.TrashItem();
|
||||||
org.gcube.common.storagehubwrapper.shared.tohl.impl.TrashItem theTrashItem = (org.gcube.common.storagehubwrapper.shared.tohl.impl.TrashItem) theItem;
|
org.gcube.common.storagehubwrapper.shared.tohl.impl.TrashItem theTrashItem = (org.gcube.common.storagehubwrapper.shared.tohl.impl.TrashItem) theItem;
|
||||||
theTrashItem.setDeletedBy(trashItem.getDeletedBy());
|
theTrashItem.setDeletedBy(trashItem.getDeletedBy());
|
||||||
|
@ -309,16 +290,16 @@ public class HLMapper {
|
||||||
theTrashItem.setLenght(trashItem.getLenght());
|
theTrashItem.setLenght(trashItem.getLenght());
|
||||||
theTrashItem.setMimeType(trashItem.getMimeType());
|
theTrashItem.setMimeType(trashItem.getMimeType());
|
||||||
|
|
||||||
isFolder = trashItem.isFolder(); //DO NOT MOVE THIS SET
|
isFolder = trashItem.isFolder(); // DO NOT MOVE THIS SET
|
||||||
if(isFolder) //Avoiding null exception on
|
if (isFolder) // Avoiding null exception on
|
||||||
type = WorkspaceItemType.TRASH_FOLDER;
|
type = WorkspaceItemType.TRASH_FOLDER;
|
||||||
|
|
||||||
logger.debug("Wrapped as TrashItem");
|
logger.debug("Wrapped as TrashItem");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(item instanceof GCubeItem){
|
if (item instanceof GCubeItem) {
|
||||||
type = WorkspaceItemType.FILE_ITEM;
|
type = WorkspaceItemType.FILE_ITEM;
|
||||||
GCubeItem gcubeItem = (GCubeItem) item; //??
|
GCubeItem gcubeItem = (GCubeItem) item; // ??
|
||||||
theItem = new GcubeItem();
|
theItem = new GcubeItem();
|
||||||
GcubeItem theGcubeItem = (GcubeItem) theItem;
|
GcubeItem theGcubeItem = (GcubeItem) theItem;
|
||||||
theGcubeItem.setFileItemType(FileItemType.GCUBE_ITEM);
|
theGcubeItem.setFileItemType(FileItemType.GCUBE_ITEM);
|
||||||
|
@ -326,7 +307,7 @@ public class HLMapper {
|
||||||
theGcubeItem.setCreator(gcubeItem.getCreator());
|
theGcubeItem.setCreator(gcubeItem.getCreator());
|
||||||
theGcubeItem.setItemType(gcubeItem.getItemType());
|
theGcubeItem.setItemType(gcubeItem.getItemType());
|
||||||
theGcubeItem.setShared(gcubeItem.isShared());
|
theGcubeItem.setShared(gcubeItem.isShared());
|
||||||
if(withMapProperties){
|
if (withMapProperties) {
|
||||||
PropertyMap property = toPropertyMap(gcubeItem.getProperty());
|
PropertyMap property = toPropertyMap(gcubeItem.getProperty());
|
||||||
theGcubeItem.setProperty(property);
|
theGcubeItem.setProperty(property);
|
||||||
}
|
}
|
||||||
|
@ -334,12 +315,12 @@ public class HLMapper {
|
||||||
logger.debug("Wrapped as GcubeItem");
|
logger.debug("Wrapped as GcubeItem");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(theItem==null){
|
if (theItem == null) {
|
||||||
logger.info("Mapping unknown object as simple FileItem");
|
logger.info("Mapping unknown object as simple FileItem");
|
||||||
theItem = new FileItem();
|
theItem = new FileItem();
|
||||||
type = WorkspaceItemType.FILE_ITEM;
|
type = WorkspaceItemType.FILE_ITEM;
|
||||||
FileItem theFileItem = (FileItem) theItem;
|
FileItem theFileItem = (FileItem) theItem;
|
||||||
theFileItem.setFileItemType(FileItemType.DOCUMENT);
|
theFileItem.setFileItemType(FileItemType.DOCUMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
theItem.setId(item.getId());
|
theItem.setId(item.getId());
|
||||||
|
@ -359,23 +340,19 @@ public class HLMapper {
|
||||||
theItem.setAccounting(accountingEntries);
|
theItem.setAccounting(accountingEntries);
|
||||||
theItem.setType(type);
|
theItem.setType(type);
|
||||||
theItem.setFolder(isFolder);
|
theItem.setFolder(isFolder);
|
||||||
theItem.setRoot(isRoot); //THIS IS ALWAYS FALSE. SHUB DOES NOT RETURN THIS INFORMATION
|
theItem.setRoot(isRoot); // THIS IS ALWAYS FALSE. SHUB DOES NOT RETURN THIS INFORMATION
|
||||||
theItem.setPropertyMap(pm);
|
theItem.setPropertyMap(pm);
|
||||||
|
|
||||||
logger.debug("Wrapped WsItem: "+theItem);
|
logger.debug("Wrapped WsItem: " + theItem);
|
||||||
logger.debug("Wrapped WsItem has type: "+theItem.getClass().getName());
|
logger.debug("Wrapped WsItem has type: " + theItem.getClass().getName());
|
||||||
|
|
||||||
return (T) theItem;
|
return (T) theItem;
|
||||||
|
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
logger.error("Error on converting the item with id: "+item.getId(), e);
|
logger.error("Error on converting the item with id: " + item.getId(), e);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,32 +12,29 @@ import org.gcube.common.storagehub.model.items.SharedFolder;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class ObjectMapper.
|
* The Class ObjectMapper.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
* Jun 26, 2018
|
* Jun 26, 2018
|
||||||
*/
|
*/
|
||||||
public class ObjectMapper {
|
public class ObjectMapper {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(ObjectMapper.class);
|
private static Logger logger = LoggerFactory.getLogger(ObjectMapper.class);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To list logins.
|
* To list logins.
|
||||||
*
|
*
|
||||||
* @param sharedfolder the sharedfolder
|
* @param sharedfolder the sharedfolder
|
||||||
* @return the list
|
* @return the list
|
||||||
*/
|
*/
|
||||||
public static List<String> toListLogins(SharedFolder sharedfolder){
|
@Deprecated
|
||||||
|
public static List<String> toListLogins(SharedFolder sharedfolder) {
|
||||||
Metadata users = sharedfolder.getUsers();
|
Metadata users = sharedfolder.getUsers();
|
||||||
Map<String, Object> mapMember = users.getMap();
|
Map<String, Object> mapMember = users.getMap();
|
||||||
List<String> listUsers = new ArrayList<String>(mapMember.size());
|
List<String> listUsers = new ArrayList<String>(mapMember.size());
|
||||||
listUsers.addAll(mapMember.keySet());
|
listUsers.addAll(mapMember.keySet());
|
||||||
logger.debug("Returning "+listUsers.size()+" member/s for sharedFolder with id: "+sharedfolder.getId());
|
logger.debug("Returning " + listUsers.size() + " member/s for sharedFolder with id: " + sharedfolder.getId());
|
||||||
return listUsers;
|
return listUsers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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.List;
|
||||||
import java.util.Map;
|
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.StorageHubWrapper;
|
||||||
import org.gcube.common.storagehubwrapper.server.WorkspaceStorageHubClientService;
|
import org.gcube.common.storagehubwrapper.server.WorkspaceStorageHubClientService;
|
||||||
import org.gcube.common.storagehubwrapper.server.tohl.Workspace;
|
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.WorkspaceFolder;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
|
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.FileItem;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.impl.ImageFile;
|
import org.gcube.common.storagehubwrapper.shared.tohl.impl.ImageFile;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.impl.PDFFile;
|
import org.gcube.common.storagehubwrapper.shared.tohl.impl.PDFFile;
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Jun 20, 2018
|
||||||
* Jun 20, 2018
|
|
||||||
*/
|
*/
|
||||||
public class WorkspaceInstance {
|
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 SCOPE = "/d4science.research-infrastructures.eu";
|
||||||
|
|
||||||
|
// public static String USERNAME = "massimiliano.assante";
|
||||||
//public static String USERNAME = "massimiliano.assante";
|
|
||||||
public static String USERNAME = "francesco.mangiacrapa";
|
public static String USERNAME = "francesco.mangiacrapa";
|
||||||
|
|
||||||
public static String TOKEN; //YOU MUST SET THIS AS VM PARAMETER
|
//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 FIND_FILE_NAME = "francesco";
|
||||||
public static String rootId = null;
|
public static String rootId = null;
|
||||||
|
@ -44,18 +46,23 @@ public class WorkspaceInstance {
|
||||||
|
|
||||||
private WorkspaceStorageHubClientService workspace;
|
private WorkspaceStorageHubClientService workspace;
|
||||||
|
|
||||||
@Before
|
//@Before
|
||||||
public void init(){
|
public void init() {
|
||||||
|
|
||||||
TOKEN = System.getProperty("token");
|
if (TOKEN == null) {
|
||||||
|
System.err.println("You must set the token as Environment variable");
|
||||||
|
}
|
||||||
|
|
||||||
System.out.println("Read TOKEN: "+TOKEN);
|
System.out.println("Read TOKEN_gcube: " + TOKEN);
|
||||||
|
|
||||||
|
ScopeProvider.instance.set(SCOPE);
|
||||||
|
SecurityTokenProvider.instance.set(TOKEN);
|
||||||
|
|
||||||
//METHOD 1
|
// METHOD 1
|
||||||
storageHubWrapper = new StorageHubWrapper(SCOPE, TOKEN, false, false, true);
|
storageHubWrapper = new StorageHubWrapper(SCOPE, TOKEN, false, false, true);
|
||||||
//workspace = storageHubWrapper.getWorkspace();
|
// workspace = storageHubWrapper.getWorkspace();
|
||||||
|
|
||||||
//METHOD 2
|
// METHOD 2
|
||||||
// StorageHubClientService storageHubClientService = new StorageHubClientService(SCOPE, TOKEN);
|
// StorageHubClientService storageHubClientService = new StorageHubClientService(SCOPE, TOKEN);
|
||||||
// workspace = new WorkspaceStorageHubClientService.WorkspaceStorageHubClientServiceBuilder(storageHubClientService).
|
// workspace = new WorkspaceStorageHubClientService.WorkspaceStorageHubClientServiceBuilder(storageHubClientService).
|
||||||
// withAccounting(false).
|
// withAccounting(false).
|
||||||
|
@ -63,66 +70,82 @@ public class WorkspaceInstance {
|
||||||
// build();
|
// build();
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Test
|
// @Test
|
||||||
public void getRoot() {
|
public void getRoot() {
|
||||||
System.out.println("Get Root test");
|
System.out.println("Get Root test");
|
||||||
WorkspaceFolder root;
|
WorkspaceFolder root;
|
||||||
try {
|
try {
|
||||||
root = storageHubWrapper.getWorkspace().getRoot();
|
root = storageHubWrapper.getWorkspace().getRoot();
|
||||||
rootId = root.getId();
|
rootId = root.getId();
|
||||||
System.out.println("The root is:"+root);
|
System.out.println("The root is:" + root);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
// @Test
|
||||||
public void getChildren() throws Exception{
|
public void getChildren() throws Exception {
|
||||||
System.out.println("Get children test");
|
System.out.println("Get children test");
|
||||||
|
|
||||||
WorkspaceFolder root = storageHubWrapper.getWorkspace().getRoot();
|
WorkspaceFolder root = storageHubWrapper.getWorkspace().getRoot();
|
||||||
List<? extends WorkspaceItem> children = storageHubWrapper.getWorkspace().getChildren(root.getId());
|
List<? extends WorkspaceItem> children = storageHubWrapper.getWorkspace().getChildren(root.getId());
|
||||||
|
|
||||||
//WorkspaceFolder root = workspace.getRoot();
|
// WorkspaceFolder root = workspace.getRoot();
|
||||||
//List<? extends WorkspaceItem> children = workspace.getChildren(root.getId());
|
// List<? extends WorkspaceItem> children = workspace.getChildren(root.getId());
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (WorkspaceItem workspaceItem : children) {
|
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: "
|
||||||
//System.out.println(workspaceItem.getType() +" "+workspaceItem.getClass());
|
+ workspaceItem.getType() + " class: " + workspaceItem.getClass());
|
||||||
|
|
||||||
|
|
||||||
// System.out.println(++i+")");
|
|
||||||
// if(workspaceItem.isFolder()){
|
|
||||||
// WorkspaceFolder folder = (WorkspaceFolder) workspaceItem;
|
|
||||||
// System.out.println("is public? "+folder.isPublicFolder());
|
|
||||||
// }
|
|
||||||
|
|
||||||
//printMap(workspaceItem);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Test
|
||||||
|
public void getPathOnShared() throws Exception {
|
||||||
|
System.out.println("Get Path on Shared");
|
||||||
|
|
||||||
|
WorkspaceFolder root = storageHubWrapper.getWorkspace().getRoot();
|
||||||
|
List<? extends WorkspaceItem> children = storageHubWrapper.getWorkspace().getChildren(root.getId());
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
for (WorkspaceItem workspaceItem : children) {
|
||||||
|
if (workspaceItem.isShared()) {
|
||||||
|
System.out.println(++i + ")" + workspaceItem.getId() + " name: " + workspaceItem.getName() + " type: "
|
||||||
|
+ workspaceItem.getPath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//@Test
|
//@Test
|
||||||
public void getFilteredChildren() throws Exception{
|
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 {
|
||||||
System.out.println("Get children test");
|
System.out.println("Get children test");
|
||||||
|
|
||||||
WorkspaceFolder root = storageHubWrapper.getWorkspace().getRoot();
|
WorkspaceFolder root = storageHubWrapper.getWorkspace().getRoot();
|
||||||
Class filterClass = org.gcube.common.storagehub.model.items.FolderItem.class;
|
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();
|
// WorkspaceFolder root = workspace.getRoot();
|
||||||
//List<? extends WorkspaceItem> children = workspace.getChildren(root.getId());
|
// List<? extends WorkspaceItem> children = workspace.getChildren(root.getId());
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (WorkspaceItem workspaceItem : children) {
|
for (WorkspaceItem workspaceItem : children) {
|
||||||
System.out.println(++i+")"+workspaceItem);
|
System.out.println(++i + ")" + workspaceItem);
|
||||||
System.out.println(workspaceItem.getType() +" "+workspaceItem.getClass());
|
System.out.println(workspaceItem.getType() + " " + workspaceItem.getClass());
|
||||||
|
|
||||||
|
|
||||||
// System.out.println(++i+")");
|
// System.out.println(++i+")");
|
||||||
// if(workspaceItem.isFolder()){
|
// if(workspaceItem.isFolder()){
|
||||||
|
@ -136,33 +159,61 @@ public class WorkspaceInstance {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void printMap(WorkspaceItem workspaceItem){
|
public static void printMap(WorkspaceItem workspaceItem) {
|
||||||
if(workspaceItem.getPropertyMap()!=null){
|
if (workspaceItem.getPropertyMap() != null) {
|
||||||
System.out.println(workspaceItem.getId() + " name: "+workspaceItem.getName() + " isFolder: "+workspaceItem.isFolder());
|
System.out.println(workspaceItem.getId() + " name: " + workspaceItem.getName() + " isFolder: "
|
||||||
System.out.println("Property Map: "+workspaceItem.getPropertyMap().getValues().toString());
|
+ workspaceItem.isFolder());
|
||||||
|
System.out.println("Property Map: " + workspaceItem.getPropertyMap().getValues().toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Test
|
// @Test
|
||||||
public void getWorkspaceId() {
|
public void getWorkspaceId() {
|
||||||
System.out.println("Getting the workspaceId test");
|
System.out.println("Getting the workspaceId test");
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Workspace ws = storageHubWrapper.getWorkspace();
|
Workspace ws = storageHubWrapper.getWorkspace();
|
||||||
|
|
||||||
//Workspace ws = workspace;
|
// Workspace ws = workspace;
|
||||||
|
|
||||||
if(ws!=null){
|
if (ws != null) {
|
||||||
WorkspaceFolder root = ws.getRoot();
|
WorkspaceFolder root = ws.getRoot();
|
||||||
System.out.println("Retrieve the root "+root.getId()+" correctly");
|
System.out.println("Retrieve the root " + root.getId() + " correctly");
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Test
|
@Test
|
||||||
public void getChildrenPerWorkspaceItem() throws InternalErrorException{
|
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");
|
System.out.println("Get children test per workspace item");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -174,11 +225,11 @@ public class WorkspaceInstance {
|
||||||
// List<? extends WorkspaceItem> children = workspace.getChildren(root.getId());
|
// List<? extends WorkspaceItem> children = workspace.getChildren(root.getId());
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
Map<String, List<WorkspaceItem>> map = new HashMap<String,List<WorkspaceItem>>();
|
Map<String, List<WorkspaceItem>> map = new HashMap<String, List<WorkspaceItem>>();
|
||||||
for (WorkspaceItem workspaceItem : children) {
|
for (WorkspaceItem workspaceItem : children) {
|
||||||
String key = workspaceItem.getType().name();
|
String key = workspaceItem.getType().name();
|
||||||
List<WorkspaceItem> list = map.get(key);
|
List<WorkspaceItem> list = map.get(key);
|
||||||
if(list==null){
|
if (list == null) {
|
||||||
list = new ArrayList<WorkspaceItem>();
|
list = new ArrayList<WorkspaceItem>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,20 +246,20 @@ public class WorkspaceInstance {
|
||||||
switch (fileItem.getFileItemType()) {
|
switch (fileItem.getFileItemType()) {
|
||||||
case PDF_DOCUMENT:
|
case PDF_DOCUMENT:
|
||||||
PDFFile pdfFile = (PDFFile) fileItem;
|
PDFFile pdfFile = (PDFFile) fileItem;
|
||||||
System.out.println("PDF_DOCUMENT "+pdfFile);
|
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);
|
System.out.println(completeItem);
|
||||||
break;
|
break;
|
||||||
case IMAGE_DOCUMENT:
|
case IMAGE_DOCUMENT:
|
||||||
ImageFile imageFile = (ImageFile) fileItem;
|
ImageFile imageFile = (ImageFile) fileItem;
|
||||||
System.out.println("IMAGE_DOCUMENT "+imageFile);
|
System.out.println("IMAGE_DOCUMENT " + imageFile);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println(fileItem.getFileItemType() +" "+workspaceItem.getClass());
|
System.out.println(fileItem.getFileItemType() + " " + workspaceItem.getClass());
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -216,33 +267,32 @@ public class WorkspaceInstance {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Test
|
// @Test
|
||||||
public void findFileName() throws InternalErrorException{
|
public void findFileName() throws InternalErrorException {
|
||||||
System.out.println("Find file name test");
|
System.out.println("Find file name test");
|
||||||
getRoot();
|
getRoot();
|
||||||
try {
|
try {
|
||||||
//List<WorkspaceItem> foundItems = storageHubWrapper.getWorkspace().find(FIND_FILE_NAME,rootId);
|
// List<WorkspaceItem> foundItems =
|
||||||
List<? extends WorkspaceItem> foundItems = workspace.find(FIND_FILE_NAME,rootId);
|
// storageHubWrapper.getWorkspace().find(FIND_FILE_NAME,rootId);
|
||||||
|
List<? extends WorkspaceItem> foundItems = workspace.find(FIND_FILE_NAME, rootId);
|
||||||
|
|
||||||
if(foundItems==null || foundItems.size()==0){
|
if (foundItems == null || foundItems.size() == 0) {
|
||||||
System.out.println("No Items found with name: "+FIND_FILE_NAME+ " in the parent: "+rootId);
|
System.out.println("No Items found with name: " + FIND_FILE_NAME + " in the parent: " + rootId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Items found with name: "+FIND_FILE_NAME+ " in the parent: "+rootId +" are:");
|
System.out.println("Items found with name: " + FIND_FILE_NAME + " in the parent: " + rootId + " are:");
|
||||||
for (WorkspaceItem workspaceItem : foundItems) {
|
for (WorkspaceItem workspaceItem : foundItems) {
|
||||||
System.out.println(workspaceItem);
|
System.out.println(workspaceItem);
|
||||||
}
|
}
|
||||||
}
|
} catch (ItemNotFoundException | WrongItemTypeException e) {
|
||||||
catch (ItemNotFoundException | WrongItemTypeException e) {
|
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue