Initial import.

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/storagehub-client-wrapper@169443 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2018-06-26 12:58:41 +00:00
parent 7ee02a6c3a
commit 9a7ac83e67
59 changed files with 4484 additions and 0 deletions

36
.classpath Normal file
View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<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">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

23
.project Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>storagehub-client-wrapper</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,6 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8

View File

@ -0,0 +1,5 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.8

View File

@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1

1
distro/LICENSE Normal file
View File

@ -0,0 +1 @@
${gcube.license}

60
distro/README Normal file
View File

@ -0,0 +1,60 @@
The gCube System - ${name}
--------------------------------------------------
${description}
${gcube.description}
${gcube.funding}
Version
--------------------------------------------------
${version} (${buildDate})
Please see the file named "changelog.xml" in this directory for the release notes.
Authors
--------------------------------------------------
* Francesco Mangiacrapa (francesco.mangiacrapa-AT-isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy).
Maintainers
-----------
* Francesco Mangiacrapa (francesco.mangiacrapa-AT-isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy).
Download information
--------------------------------------------------
Source code is available from SVN:
${scm.url}
Binaries can be downloaded from the gCube website:
${gcube.website}
Installation
--------------------------------------------------
Documentation
--------------------------------------------------
Documentation is available on-line in the gCube Wiki:
${gcube.wikiRoot}
Support
--------------------------------------------------
Bugs and support requests can be reported in the gCube issue tracking tool:
${gcube.issueTracking}
Licensing
--------------------------------------------------
This software is licensed under the terms you may find in the file named "LICENSE" in this directory.

6
distro/changelog.xml Normal file
View File

@ -0,0 +1,6 @@
<ReleaseNotes>
<Changeset component="org.gcube.common.storagehubwrapper.0-1-0"
date="2018-06-20">
<Change>first release</Change>
</Changeset>
</ReleaseNotes>

32
distro/descriptor.xml Normal file
View File

@ -0,0 +1,32 @@
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>servicearchive</id>
<formats>
<format>tar.gz</format>
</formats>
<baseDirectory>/</baseDirectory>
<fileSets>
<fileSet>
<directory>${distroDirectory}</directory>
<outputDirectory>/</outputDirectory>
<useDefaultExcludes>true</useDefaultExcludes>
<includes>
<include>README</include>
<include>LICENSE</include>
<include>changelog.xml</include>
<include>profile.xml</include>
</includes>
<fileMode>755</fileMode>
<filtered>true</filtered>
</fileSet>
</fileSets>
<files>
<file>
<source>target/${build.finalName}.${project.packaging}</source>
<outputDirectory>/${artifactId}</outputDirectory>
</file>
</files>
</assembly>

25
distro/profile.xml Normal file
View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<Resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ID></ID>
<Type>Library</Type>
<Profile>
<Description>${description}</Description>
<Class>Common</Class>
<Name>${artifactId}</Name>
<Version>1.0.0</Version>
<Packages>
<Software>
<Name>${artifactId}</Name>
<Version>${version}</Version>
<MavenCoordinates>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
</MavenCoordinates>
<Files>
<File>${build.finalName}.jar</File>
</Files>
</Software>
</Packages>
</Profile>
</Resource>

195
pom.xml Normal file
View File

@ -0,0 +1,195 @@
<?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"
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>
<artifactId>maven-parent</artifactId>
<groupId>org.gcube.tools</groupId>
<version>1.0.0</version>
<relativePath />
</parent>
<groupId>org.gcube.common</groupId>
<artifactId>storagehub-client-wrapper</artifactId>
<version>0.1.0-SNAPSHOT</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 object as defined in (the old) HL interfaces</description>
<scm>
<connection>scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/common/${project.artifactId}</connection>
<developerConnection>scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/common/${project.artifactId}</developerConnection>
<url>http://svn.d4science.research-infrastructures.eu/gcube/trunk/common/${project.artifactId}</url>
</scm>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<distroDirectory>distro</distroDirectory>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId>
<version>LATEST</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.14.8</version>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>storagehub-client-library</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.portal</groupId>
<artifactId>storagehub-icons-library</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-encryption</artifactId>
<scope>provided</scope>
</dependency>
<!-- FWS -->
<dependency>
<groupId>org.gcube.resources.discovery</groupId>
<artifactId>ic-client</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-scope-maps</artifactId>
<scope>compile</scope>
</dependency>
<!-- END FWS -->
<!-- <dependency> -->
<!-- <groupId>org.gcube.common.portal</groupId> -->
<!-- <artifactId>portal-manager</artifactId> -->
<!-- <scope>provided</scope> -->
<!-- </dependency> -->
<!-- <dependency> -->
<!-- <groupId>org.gcube.dvos</groupId> -->
<!-- <artifactId>usermanagement-core</artifactId> -->
<!-- <scope>provided</scope> -->
<!-- </dependency> -->
<!-- <dependency> -->
<!-- <groupId>com.liferay.portal</groupId> -->
<!-- <artifactId>portal-service</artifactId> -->
<!-- <scope>provided</scope> -->
<!-- </dependency> -->
<!-- LOGGER -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
</resources>
<finalName>${artifactId}</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>copy-profile</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>target</outputDirectory>
<resources>
<resource>
<directory>${distroDirectory}</directory>
<filtering>true</filtering>
<includes>
<include>profile.xml</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>${distroDirectory}/descriptor.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>servicearchive</id>
<phase>install</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='storagehubwrapper'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' />
<!-- Specify the paths for translatable code -->
<source path='client' />
<source path='shared' />
</module>

View File

@ -0,0 +1,263 @@
package org.gcube.common.storagehubwrapper.server;
import java.io.InputStream;
import java.util.List;
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.storagehub.client.dsl.FileContainer;
import org.gcube.common.storagehub.client.dsl.FolderContainer;
import org.gcube.common.storagehub.client.dsl.ItemContainer;
import org.gcube.common.storagehub.client.dsl.StorageHubClient;
import org.gcube.common.storagehub.client.plugins.AbstractPlugin;
import org.gcube.common.storagehub.client.proxies.ItemManagerClient;
import org.gcube.common.storagehub.client.proxies.WorkspaceManagerClient;
import org.gcube.common.storagehub.model.acls.ACL;
import org.gcube.common.storagehub.model.items.FolderItem;
import org.gcube.common.storagehub.model.items.Item;
import org.gcube.common.storagehub.model.items.SharedFolder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class StorageHubClientService.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 20, 2018
*/
public class StorageHubClientService {
private static Logger logger = LoggerFactory.getLogger(StorageHubClientService.class);
public static final String ACCOUNTING_HL_NODE_NAME = "hl:accounting";
private String scope;
private String authorizationToken;
private StorageHubClient shcClient;
/**
* Instantiates a new storage hub service util.
*
* @param scope the scope
* @param authorizationToken the authorization token
*/
public StorageHubClientService(String scope, String authorizationToken) {
Validate.notNull(scope, "The scope is null");
Validate.notNull(authorizationToken, "The authorizationToken is null");
this.scope = scope;
this.authorizationToken = authorizationToken;
setContextProviders(scope, authorizationToken);
shcClient = new StorageHubClient();
logger.info("Instancied the "+StorageHubClientService.class.getSimpleName()+" as: "+this.toString());
}
/**
* Sets the context providers.
*
* @param scope the scope
* @param authorizationToken the authorization token
*/
private void setContextProviders(String scope, String authorizationToken){
ScopeProvider.instance.set(scope);
SecurityTokenProvider.instance.set(authorizationToken);
logger.debug("Saved the contexts [scope: "+scope+", token: "+authorizationToken+"]");
}
/**
* Gets the root.
*
* @return the root
* @throws Exception
*/
public FolderItem getRoot() throws Exception {
setContextProviders(scope, authorizationToken);
// WorkspaceManagerClient client = AbstractPlugin.workspace().build();
// Item itemRoot = client.getWorkspace(ACCOUNTING_HL_NODE_NAME);
FolderContainer root = shcClient.getWSRoot();
return root.get();
}
/**
* Gets the root.
*
* @return the root
*/
public Item getTrash() {
setContextProviders(scope, authorizationToken);
WorkspaceManagerClient client = AbstractPlugin.workspace().build();
Item trash = client.getTrashFolder();
return trash;
}
/**
* Gets the children.
*
* @param id the id
* @param excludeNodes the exclude nodes
* @return the children
*/
public List<? extends Item> getChildren(String id){
setContextProviders(scope, authorizationToken);
return shcClient.open(id).asFolder().list().withContent().getItems();
}
/**
* Gets the item.
*
* @param itemId the item id
* @return the item
* @throws Exception
*/
public Item getItem(String itemId) throws Exception{
setContextProviders(scope, authorizationToken);
ItemContainer<Item> itemCont = shcClient.open(itemId).asItem();//TODO
return itemCont.get();
}
/**
* Gets the parents.
*
* @param itemId the item id
* @return the parents
*/
public List<? extends Item> getParents(String itemId) {
setContextProviders(scope, authorizationToken);
List<? extends Item> toReturn = shcClient.open(itemId).asItem().getAnchestors();
return toReturn;
}
/**
* Creates the folder.
*
* @param parentId the parent id
* @param folderName the folder name
* @param folderDescription the folder description
* @return the item
* @throws Exception
*/
public Item createFolder(String parentId, String folderName, String folderDescription) throws Exception {
setContextProviders(scope, authorizationToken);
FolderContainer folderContainer = shcClient.open(parentId).asFolder().newFolder(folderName, folderDescription);
return getItem(folderContainer.get().getId());
}
/**
* Gets the VRE folders id.
*
* @return the VRE folders id
*/
public String getVREFoldersId() {
setContextProviders(scope, authorizationToken);
String toReturn = "";
try {
WorkspaceManagerClient wsclient = AbstractPlugin.workspace().build();
try {
List<? extends Item> list = wsclient.getVreFolders(ACCOUNTING_HL_NODE_NAME);
toReturn =list.iterator().next().getParentId();
} catch (Exception e) {
logger.info("This user has no VRE Folders", e);
return null;
}
}catch (Exception e) {
e.printStackTrace();
}
return toReturn;
}
/**
* Gets the user acl for folder id.
*
* @param request the request
* @param folderId the folder id
* @return the user acl for folder id
* @throws Exception
*/
public String getUserACLForFolderId(String infrastructureName, String userName, String folderId) throws Exception {
setContextProviders(scope, authorizationToken);
Item theFolder = getItem(folderId);
if (!theFolder.isShared()) {
return "OWNER";
} else {
ItemManagerClient client = AbstractPlugin.item().build();
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.
for (ACL acl : acls) {
if (acl.getPricipal().compareTo(userName) == 0) {
found = true;
return acl.getAccessTypes().get(0).toString();
}
}
if (!found && sharedFolder.isVreFolder()) {
for (ACL acl : acls) {
if (acl.getPricipal().startsWith(infrastructureName));
return acl.getAccessTypes().get(0).toString();
}
}
}
return "UNDEFINED";
}
/**
* Gets the item children count.
*
* @param itemId the item id
* @return the item children count
*/
public int getItemChildrenCount(String itemId) {
setContextProviders(scope, authorizationToken);
ItemManagerClient client = AbstractPlugin.item().build();
return client.childrenCount(itemId);
}
/**
* Upload file.
*
* @param folderId the folder id
* @param is the is
* @param fileName the file name
* @param fileDescription the file description
* @return the item
* @throws Exception the exception
*/
public Item uploadFile(String folderId, InputStream is, String fileName, String fileDescription) throws Exception{
try {
FileContainer fileCont = shcClient.open(folderId).asFolder().uploadFile(is, fileName, fileDescription);
return fileCont.get();
} catch (Exception e) {
logger.error("Error during uploading the file: "+fileName+" in the folderId: "+folderId, e);
throw new Exception("Error during uploading the file: "+fileName+". Try again");
}
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("StorageHubClientService [scope=");
builder.append(scope);
builder.append(", authorizationToken=");
builder.append(authorizationToken.substring(0, authorizationToken.length()-5)+"XXXXX");
builder.append(", itemManagerClient=");
builder.append(shcClient);
builder.append("]");
return builder.toString();
}
}

View File

@ -0,0 +1,62 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.server;
import org.gcube.common.storagehubwrapper.server.tohl.Workspace;
/**
* The Class StorageHubWrapper.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 26, 2018
*/
public class StorageHubWrapper {
private StorageHubClientService storageHubClientService;
public Object lock = new Object(); //Thread safety
private Workspace workspace = null;
/**
* Instantiates a new storage hub wrapper.
*
* @param scope the scope
* @param authorizationToken the authorization token
*/
public StorageHubWrapper(String scope, String authorizationToken) {
this.storageHubClientService = new StorageHubClientService(scope, authorizationToken);
}
/**
* Gets the storage hub client service.
*
* @return the storageHubClientService
*/
public StorageHubClientService getStorageHubClientService() {
return storageHubClientService;
}
/**
* Gets the workspace.
*
* @return the workspace
*/
public Workspace getWorkspace(){
synchronized (lock) {
if(workspace==null){
workspace = new WorkspaceStorageHubClientService.WorkspaceStorageHubClientServiceBuilder(storageHubClientService).build();
}
return workspace;
}
}
}

View File

@ -0,0 +1,868 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.server;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.Validate;
import org.gcube.common.storagehub.model.items.FolderItem;
import org.gcube.common.storagehub.model.items.Item;
import org.gcube.common.storagehub.model.items.SharedFolder;
import org.gcube.common.storagehub.model.types.GenericItemType;
import org.gcube.common.storagehubwrapper.server.converter.HLMapper;
import org.gcube.common.storagehubwrapper.server.converter.PortalMapper;
import org.gcube.common.storagehubwrapper.server.tohl.Workspace;
import org.gcube.common.storagehubwrapper.shared.ACLType;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
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.InternalErrorException;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.ItemAlreadyExistException;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.ItemNotFoundException;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.WorkspaceFolderNotFoundException;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.WrongDestinationException;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.WrongItemTypeException;
import org.gcube.common.storagehubwrapper.shared.tohl.folder.items.URLFileItem;
import org.gcube.common.storagehubwrapper.shared.tohl.impl.WorkspaceFolder;
import org.gcube.common.storagehubwrapper.shared.tohl.trash.WorkspaceTrashItem;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class WorkspaceStorageHubClientService.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 20, 2018
*/
public final class WorkspaceStorageHubClientService implements Workspace{
//public static final String ACCOUNTING_HL_NODE_NAME = "hl:accounting";
private static Logger logger = LoggerFactory.getLogger(WorkspaceStorageHubClientService.class);
private StorageHubClientService storageHubClientService;
private boolean withAccounting;
private boolean withFileDetails;
private boolean withMapProperties;
/**
* Gets the storage hub client service.
*
* @return the storageHubClientService
*/
public StorageHubClientService getStorageHubClientService() {
return storageHubClientService;
}
/**
* @return the withAccounting
*/
public boolean isWithAccounting() {
return withAccounting;
}
/**
* @return the withFileDetails
*/
public boolean isWithFileDetails() {
return withFileDetails;
}
/**
* @return the withMapProperties
*/
public boolean isWithMapProperties() {
return withMapProperties;
}
/**
* Instantiates a new workspace storage hub client service.
*
* @param storageHubClientService the storage hub client service
*/
private WorkspaceStorageHubClientService(StorageHubClientService storageHubClientService) {
this.storageHubClientService = storageHubClientService;
}
/**
* Instantiates a new workspace storage hub client service.
*
* @param storageHubClientService the storage hub client service
* @param withAccounting the with accounting
* @param withFileDetails the with file details
* @param withMapProperties the with map properties
*/
private WorkspaceStorageHubClientService(
StorageHubClientService storageHubClientService,
boolean withAccounting, boolean withFileDetails,
boolean withMapProperties) {
super();
this.storageHubClientService = storageHubClientService;
this.withAccounting = withAccounting;
this.withFileDetails = withFileDetails;
this.withMapProperties = withMapProperties;
}
/**
* The Class WorkspaceStorageHubClientServiceBuilder.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 22, 2018
*/
public static class WorkspaceStorageHubClientServiceBuilder{
private StorageHubClientService storageHubClientService;
private boolean withAccounting;
private boolean withFileDetails;
private boolean withMapProperties;
/**
* Instantiates a new workspace storage hub client service builder.
*
* @param storageHubClientService the storage hub client service
* @param withAccounting the with accounting
* @param withFileDetails the with file details
* @param withMapProperties the with map properties
*/
public WorkspaceStorageHubClientServiceBuilder(
final StorageHubClientService storageHubClientService,
final boolean withAccounting, final boolean withFileDetails,
final boolean withMapProperties) {
this.storageHubClientService = storageHubClientService;
this.withAccounting = withAccounting;
this.withFileDetails = withFileDetails;
this.withMapProperties = withMapProperties;
}
/**
* Instantiates a new workspace storage hub client service builder.
*
* @param storageHubClientService the storage hub client service
* @param withAccounting the with accounting
* @param withFileDetails the with file details
* @param withMapProperties the with map properties
*/
public WorkspaceStorageHubClientServiceBuilder(
final StorageHubClientService storageHubClientService) {
this.storageHubClientService = storageHubClientService;
this.withAccounting = false;
this.withFileDetails = false;
this.withMapProperties = false;
}
/**
* Sets the with accounting.
*
* @param withAccounting the withAccounting to set
* @return the workspace storage hub client service builder
*/
public WorkspaceStorageHubClientServiceBuilder withAccounting(final boolean withAccounting) {
this.withAccounting = withAccounting;
return this;
}
/**
* Sets the with file details.
*
* @param withFileDetails the withFileDetails to set
* @return the workspace storage hub client service builder
*/
public WorkspaceStorageHubClientServiceBuilder withFileDetails(final boolean withFileDetails) {
this.withFileDetails = withFileDetails;
return this;
}
/**
* Sets the with map properties.
*
* @param withMapProperties the withMapProperties to set
* @return the workspace storage hub client service builder
*/
public WorkspaceStorageHubClientServiceBuilder withMapProperties(final boolean withMapProperties) {
this.withMapProperties = withMapProperties;
return this;
}
/**
* Builds the WorkspaceStorageHubClientService
*
* @return the workspace storage hub client service
*/
public WorkspaceStorageHubClientService build(){
return new WorkspaceStorageHubClientService(storageHubClientService,
withAccounting,
withFileDetails,
withMapProperties);
}
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#getOwner()
*/
@Override
public String getOwner()
throws InternalErrorException {
WorkspaceFolder root = getRoot();
return root.getOwner();
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#getRoot()
*/
@Override
public WorkspaceFolder getRoot() throws InternalErrorException{
logger.debug("Getting root");
FolderItem root;
try {
root = storageHubClientService.getRoot();
}
catch (Exception e) {
logger.error("Error on getting root: ", e);
throw new InternalErrorException("Sorry an error occurred when getting the workspace root. Refresh and try again");
}
WorkspaceFolder workspaceFolder = (WorkspaceFolder) HLMapper.toWorkspaceItem(root);
workspaceFolder.setRoot(true);
return workspaceFolder;
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.tohl.Workspace#getChildren(java.lang.String)
*/
public List<? extends WorkspaceItem> getChildren(String id){
Validate.notNull(id,"The input id is null");
List<? extends Item> children = storageHubClientService.getChildren(id);
List<WorkspaceItem> toChildren = new ArrayList<WorkspaceItem>(children.size());
for (Item item : children) {
WorkspaceItem child = HLMapper.toWorkspaceItem(item);
toChildren.add(child);
}
return toChildren;
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#getParentsById(java.lang.String)
*/
@Override
public List<? extends WorkspaceItem> getParentsById(String id)
throws InternalErrorException {
Validate.notNull(id,"The input id is null");
List<? extends Item> parents = storageHubClientService.getParents(id);
List<WorkspaceItem> toParents = new ArrayList<WorkspaceItem>(parents.size());
for (Item item : parents) {
WorkspaceItem child = HLMapper.toWorkspaceItem(item);
toParents.add(child);
}
return toParents;
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#createFolder(java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public WorkspaceFolder createFolder(
String name, String description, String destinationFolderId)
throws InternalErrorException, InsufficientPrivilegesException,
ItemAlreadyExistException, WrongDestinationException,
ItemNotFoundException, WorkspaceFolderNotFoundException {
Validate.notNull(destinationFolderId,"The destinationFolderId id is null");
Validate.notNull(name,"The folderName is null");
Item item;
try {
item = storageHubClientService.createFolder(destinationFolderId, name, description);
return (WorkspaceFolder) HLMapper.toWorkspaceItem(item);
}
catch (Exception e) {
logger.error("Error on creting the folde: ",e);
throw new InternalErrorException(e.getMessage());
}
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#getItem(java.lang.String)
*/
@Override
public WorkspaceItem getItem(String itemId) throws ItemNotFoundException, InternalErrorException {
/*Validate.notNull(itemId,"The input itemId is null");
Item item;
try {
item = storageHubClientService.getItem(itemId);
}
catch (Exception e) {
logger.error("Error during get item with id: "+itemId,e);
throw new InternalErrorException(e.getMessage());
}
return HLMapper.toWorkspaceItem(item, withAccounting, withFileDetails, withMapProperties);*/
return getItem(itemId, withAccounting, withFileDetails, withMapProperties);
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.server.tohl.Workspace#getItem(java.lang.String, boolean, boolean, boolean)
*/
@Override
public WorkspaceItem getItem(
String itemId, boolean withAccounting, boolean withFileDetails,
boolean withMapProperties)
throws ItemNotFoundException, InternalErrorException {
Validate.notNull(itemId,"The input itemId is null");
Item item;
try {
item = storageHubClientService.getItem(itemId);
}
catch (Exception e) {
logger.error("Error during get item with id: "+itemId,e);
throw new InternalErrorException(e.getMessage());
}
return HLMapper.toWorkspaceItem(item, withAccounting, withFileDetails, withMapProperties);
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#createFolder(java.lang.String, java.lang.String, java.lang.String, java.util.Map)
*/
@Override
public WorkspaceFolder createFolder(
String name, String description, String destinationFolderId,
Map<String, String> properties)
throws InternalErrorException, InsufficientPrivilegesException,
ItemAlreadyExistException, WrongDestinationException,
ItemNotFoundException, WorkspaceFolderNotFoundException {
WorkspaceFolder folder = createFolder(name, description, destinationFolderId);
//TODO set gcube properties
return folder;
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.server.tohl.Workspace#uploadFile(java.lang.String, java.io.InputStream, java.lang.String, java.lang.String)
*/
@Override
public WorkspaceItem uploadFile(
String folderId, InputStream is, String fileName, String fileDescription)
throws InsufficientPrivilegesException,
WorkspaceFolderNotFoundException, InternalErrorException,
ItemAlreadyExistException, WrongDestinationException {
WorkspaceItem wsItem = null;
try {
Item item = storageHubClientService.uploadFile(folderId, is, fileName, fileDescription);
wsItem = HLMapper.toWorkspaceItem(item);
}
catch (Exception e) {
logger.error("Error during upload file ",e);
throw new InternalErrorException(e.getMessage());
}
return wsItem;
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.server.tohl.Workspace#getSharedFolderMembers(java.lang.String)
*/
@Override
public List<String> getSharedFolderMembers(String folderId) throws Exception {
Validate.notNull(folderId,"The input folderid is null");
Item item;
try {
item = storageHubClientService.getItem(folderId);
}catch (Exception e) {
logger.error("Error during get item with id: "+folderId,e);
throw new ItemNotFoundException(e.getMessage());
}
Validate.notNull(item, "The item with id "+folderId+" was not found");
if(item instanceof SharedFolder){
return PortalMapper.toWorkspaceSharedFolderMembers((SharedFolder)item);
}else
throw new Exception("The item with "+folderId+ " is not a Shared Folder");
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#createExternalUrl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public URLFileItem createExternalUrl(
String name, String description, String url, String destinationFolderId)
throws InsufficientPrivilegesException,
WorkspaceFolderNotFoundException, InternalErrorException,
ItemAlreadyExistException, WrongDestinationException, IOException {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#createExternalUrl(java.lang.String, java.lang.String, java.io.InputStream, java.lang.String)
*/
@Override
public URLFileItem createExternalUrl(
String name, String description, InputStream url,
String destinationfolderId)
throws InsufficientPrivilegesException, InternalErrorException,
ItemAlreadyExistException, WrongDestinationException,
WorkspaceFolderNotFoundException, IOException {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#removeItem(java.lang.String)
*/
@Override
public void removeItem(String itemId)
throws ItemNotFoundException, InternalErrorException,
InsufficientPrivilegesException {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#moveItem(java.lang.String, java.lang.String)
*/
@Override
public WorkspaceItem moveItem(String itemId, String destinationFolderId)
throws ItemNotFoundException, WrongDestinationException,
InsufficientPrivilegesException, InternalErrorException,
ItemAlreadyExistException, WorkspaceFolderNotFoundException {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#renameItem(java.lang.String, java.lang.String)
*/
@Override
public void renameItem(String itemId, String newName)
throws ItemNotFoundException, InternalErrorException,
ItemAlreadyExistException, InsufficientPrivilegesException {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#changeDescription(java.lang.String, java.lang.String)
*/
@Override
public void changeDescription(String itemId, String newDescription)
throws ItemNotFoundException, InternalErrorException {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#getItemByPath(java.lang.String)
*/
@Override
public WorkspaceItem getItemByPath(String path)
throws ItemNotFoundException {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#remove(java.lang.String, java.lang.String)
*/
@Override
public void remove(String itemName, String folderId)
throws ItemNotFoundException, InternalErrorException,
InsufficientPrivilegesException, WrongItemTypeException {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#copy(java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public WorkspaceItem copy(
String itemId, String newName, String destinationFolderId)
throws ItemNotFoundException, WrongDestinationException,
InternalErrorException, ItemAlreadyExistException,
InsufficientPrivilegesException, WorkspaceFolderNotFoundException {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#copy(java.lang.String, java.lang.String)
*/
@Override
public WorkspaceItem copy(String itemId, String destinationFolderId)
throws ItemNotFoundException, WrongDestinationException,
InternalErrorException, ItemAlreadyExistException,
InsufficientPrivilegesException, WorkspaceFolderNotFoundException {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#exists(java.lang.String, java.lang.String)
*/
@Override
public boolean exists(String name, String folderId)
throws InternalErrorException, ItemNotFoundException,
WrongItemTypeException {
// TODO Auto-generated method stub
return false;
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#exists(java.lang.String)
*/
@Override
public boolean exists(String itemId)
throws InternalErrorException {
// TODO Auto-generated method stub
return false;
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#find(java.lang.String, java.lang.String)
*/
@Override
public WorkspaceItem find(String name, String folderId)
throws InternalErrorException, ItemNotFoundException,
WrongItemTypeException {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#find(java.lang.String)
*/
@Override
public WorkspaceItem find(String path)
throws InternalErrorException {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#searchByName(java.lang.String, java.lang.String)
*/
@Override
public List<WorkspaceItem> searchByName(String name, String folderId)
throws InternalErrorException {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#searchByMimeType(java.lang.String)
*/
@Override
public List<WorkspaceItem> searchByMimeType(String mimeType)
throws InternalErrorException {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#getFolderItems(org.gcube.common.storagehub.model.types.GenericItemType)
*/
@Override
public List<WorkspaceItem> getFolderItems(GenericItemType type)
throws InternalErrorException {
// TODO Auto-generated method stub
return null;
}
/* (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;
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#createSharedFolder(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean)
*/
@Override
public WorkspaceSharedFolder createSharedFolder(
String name, String description, String groupId,
String destinationFolderId, String displayName, boolean isVREFolder)
throws InternalErrorException, InsufficientPrivilegesException,
ItemAlreadyExistException, WrongDestinationException,
ItemNotFoundException, WorkspaceFolderNotFoundException {
// TODO Auto-generated method stub
return null;
}
/* (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;
}
/* (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;
}
/* (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;
}
/* (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;
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#getTrash()
*/
@Override
public WorkspaceTrashItem getTrash()
throws InternalErrorException, ItemNotFoundException {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#getMySpecialFolders()
*/
@Override
public WorkspaceFolder getMySpecialFolders()
throws InternalErrorException, ItemNotFoundException {
// TODO Auto-generated method stub
return null;
}
/* (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;
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#getVREFolderByScope(java.lang.String)
*/
@Override
public WorkspaceSharedFolder getVREFolderByScope(String scope)
throws ItemNotFoundException, InternalErrorException {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#getDiskUsage()
*/
@Override
public long getDiskUsage()
throws InternalErrorException {
// TODO Auto-generated method stub
return 0;
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#getTotalItems()
*/
@Override
public int getTotalItems()
throws InternalErrorException {
// TODO Auto-generated method stub
return 0;
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#removeItems(java.lang.String[])
*/
@Override
public Map<String, String> removeItems(String... id)
throws ItemNotFoundException, InternalErrorException,
InsufficientPrivilegesException {
// TODO Auto-generated method stub
return null;
}
/* (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;
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#getGroup(java.lang.String)
*/
@Override
public String getGroup(String groupId)
throws InternalErrorException {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#isGroup(java.lang.String)
*/
@Override
public boolean isGroup(String groupId)
throws InternalErrorException {
// TODO Auto-generated method stub
return false;
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#getPublicFolders()
*/
@Override
public List<WorkspaceItem> getPublicFolders()
throws InternalErrorException {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -0,0 +1,269 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.server.converter;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import org.gcube.common.storagehub.model.Metadata;
import org.gcube.common.storagehub.model.items.AbstractFileItem;
import org.gcube.common.storagehub.model.items.ExternalURL;
import org.gcube.common.storagehub.model.items.FolderItem;
import org.gcube.common.storagehub.model.items.GenericFileItem;
import org.gcube.common.storagehub.model.items.Item;
import org.gcube.common.storagehub.model.items.PDFFileItem;
import org.gcube.common.storagehub.model.items.SharedFolder;
import org.gcube.common.storagehub.model.items.VreFolder;
import org.gcube.common.storagehub.model.items.nodes.Accounting;
import org.gcube.common.storagehub.model.items.nodes.Content;
import org.gcube.common.storagehub.model.items.nodes.ImageContent;
import org.gcube.common.storagehub.model.items.nodes.PDFContent;
import org.gcube.common.storagehub.model.items.nodes.accounting.AccountEntry;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItemType;
import org.gcube.common.storagehubwrapper.shared.tohl.folder.items.FileItemType;
import org.gcube.common.storagehubwrapper.shared.tohl.impl.AccountingEntry;
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.gcube.common.storagehubwrapper.shared.tohl.impl.PropertyMap;
import org.gcube.common.storagehubwrapper.shared.tohl.impl.URLFile;
import org.gcube.common.storagehubwrapper.shared.tohl.impl.WorkspaceFolder;
import org.gcube.common.storagehubwrapper.shared.tohl.impl.WorkspaceSharedFolder;
import org.gcube.common.storagehubwrapper.shared.tohl.impl.WorkspaceVREFolder;
/**
* The Class HLMapper.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 20, 2018
*/
public class HLMapper {
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().name(),
accountingEntry.getVersion(),
accountingEntry.getPrimaryType());
}
};
/**
* To workspace item.
*
* @param <T> the generic type
* @param item the item
* @return the t
*/
public static<T extends WorkspaceItem> T toWorkspaceItem(Item item){
return toWorkspaceItem(item, false, false, false);
}
/**
* To workspace item.
*
* @param <T> the generic type
* @param item the item
* @return the t
*/
public static<T extends WorkspaceItem> T toWorkspaceItem(Item item, boolean withAccounting, boolean withFileDetails, boolean withMapProperties){
List<org.gcube.common.storagehubwrapper.shared.tohl.AccountingEntry> accountingEntries = null;
if(withAccounting){
Accounting accounting = item.getAccounting();
if(accounting!=null && accounting.getEntries().size()>0){
accountingEntries = new ArrayList<org.gcube.common.storagehubwrapper.shared.tohl.AccountingEntry>(accounting.getEntries().size());
for (AccountEntry ae : accounting.getEntries()) {
accountingEntries.add(toAccountingEntry.apply(ae));
}
}
}
org.gcube.common.storagehubwrapper.shared.tohl.impl.WorkspaceItem theItem = null;
WorkspaceItemType type = null;
boolean isFolder = false;
//THE ITEM IS A KIND OF FOLDER
if (item instanceof FolderItem){
isFolder = true;
FolderItem folderItem = (FolderItem) item; //??
theItem = new WorkspaceFolder();
type = WorkspaceItemType.FOLDER;
if (item instanceof SharedFolder || item instanceof VreFolder) {
SharedFolder sharedfolder = (SharedFolder) item; //??
theItem = new WorkspaceSharedFolder();
type = WorkspaceItemType.SHARED_FOLDER;
if (sharedfolder.isVreFolder()){
VreFolder vreFolder = (VreFolder) item;
theItem = new WorkspaceVREFolder();
((WorkspaceSharedFolder) theItem).setVreFolder(true);
type = WorkspaceItemType.VRE_FOLDER;
}
}
}
//THE ITEM IS A KIND OF FILE
if(item instanceof AbstractFileItem){
theItem = new FileItem();
type = WorkspaceItemType.FILE_ITEM;
FileItemType fileItemType = null;
if(item instanceof ExternalURL){
ExternalURL eURL = (ExternalURL) item; //??
theItem = new URLFile();
fileItemType = FileItemType.URL_DOCUMENT;
}else if(item instanceof GenericFileItem){
GenericFileItem gFI = (GenericFileItem) item; //??
fileItemType = FileItemType.DOCUMENT;
}else if(item instanceof PDFFileItem){
theItem = new PDFFile();
fileItemType = FileItemType.PDF_DOCUMENT;
if(withFileDetails){
PDFFileItem pdfFI = (PDFFileItem) item;
PDFContent pdfContent = pdfFI.getContent();
PDFFile thePDFFileItem = (PDFFile) theItem;
thePDFFileItem.setNumberOfPages(pdfContent.getNumberOfPages());
thePDFFileItem.setProducer(pdfContent.getProducer());
thePDFFileItem.setVersion(pdfContent.getVersion());
thePDFFileItem.setTitle(pdfContent.getTitle());
thePDFFileItem.setAuthor(pdfContent.getAuthor());
}
}else if(item instanceof org.gcube.common.storagehub.model.items.ImageFile){
theItem = new ImageFile();
fileItemType = FileItemType.IMAGE_DOCUMENT;
if(withFileDetails){
org.gcube.common.storagehub.model.items.ImageFile imgFI = (org.gcube.common.storagehub.model.items.ImageFile) item; //??
ImageFile theImageFileItem = (ImageFile) theItem;
ImageContent content = imgFI.getContent();
theImageFileItem.setHeight(content.getHeight());
theImageFileItem.setWidth(content.getWidth());
theImageFileItem.setThumbnailWidth(content.getThumbnailHeight());
theImageFileItem.setThumbnailHeight(content.getThumbnailHeight());
}
}
AbstractFileItem itemAb = (AbstractFileItem) item;
Content aC = itemAb.getContent();
FileItem theFileItem = (FileItem) theItem;
theFileItem.setMimeType(aC.getMimeType());
theFileItem.setSize(aC.getSize());
theFileItem.setFileItemType(fileItemType);
//TODO ADD VERSION NAME
}
//ADDING (GCUBE) PROPERTIES
PropertyMap pm = null;
if(withMapProperties){
Metadata metadata = item.getPropertyMap();
if(metadata!=null){
pm = new PropertyMap(metadata.getValues());
}
}
//TRASH //TODO
if(theItem.isTrashed())
type = WorkspaceItemType.TRASH_ITEM;
theItem.setId(item.getId());
theItem.setName(item.getName());
theItem.setPath(item.getPath());
theItem.setParentId(item.getParentId());
theItem.setTrashed(item.isTrashed());
theItem.setShared(item.isShared());
theItem.setLocked(item.isLocked());
theItem.setTitle(item.getTitle());
theItem.setDescription(item.getDescription());
theItem.setLastModifiedBy(item.getLastModifiedBy());
theItem.setLastModificationTime(item.getLastModificationTime());
theItem.setCreationTime(item.getCreationTime());
theItem.setOwner(item.getOwner());
theItem.setHidden(item.isHidden());
theItem.setAccounting(accountingEntries);
theItem.setType(type);
theItem.setFolder(isFolder);
theItem.setRoot(false);
theItem.setPropertyMap(pm);
return (T) theItem;
}
/*public static Function<Item, ? extends WorkspaceItem> toWorkspaceItem = new Function<Item, WorkspaceItem>() {
public WorkspaceItem apply(Item item) {
Accounting accounting = item.getAccounting();
List<AccountingEntry> accountingEntries = null;
if(accounting!=null && accounting.getEntries().size()>0){
accountingEntries = new ArrayList<AccountingEntry>(accounting.getEntries().size());
for (AccountEntry ae : accounting.getEntries()) {
//TODO
accountingEntries.add(toAccountingEntry.apply(ae));
}
}
WorkspaceItemImpl theItem = null;
WorkspaceItemType type = null;
boolean isFolder = false;
//IS THE ITEM A FOLDER TYPE?
if (item instanceof FolderItem){
isFolder = true;
FolderItem folderItem = (FolderItem) item; //??
theItem = new WorkspaceFolderImpl();
type = org.gcube.portal.storagehubwrapper.shared.tohl.WorkspaceItemType.FOLDER_ITEM;
if (item instanceof SharedFolder || item instanceof VreFolder) {
SharedFolder sharedfolder = (SharedFolder) item; //??
theItem = new WorkspaceSharedFolderImpl();
type = org.gcube.portal.storagehubwrapper.shared.tohl.WorkspaceItemType.SHARED_FOLDER;
if (sharedfolder.isVreFolder()){
VreFolder vreFolder = (VreFolder) item;
theItem = new WorkspaceVREFolderImpl();
type = org.gcube.portal.storagehubwrapper.shared.tohl.WorkspaceItemType.VRE_FOLDER;
}
}
}
if(theItem.isTrashed())
type = org.gcube.portal.storagehubwrapper.shared.tohl.WorkspaceItemType.TRASH_ITEM;
theItem.setId(item.getId());
theItem.setName(item.getName());
theItem.setPath(item.getPath());
theItem.setParentId(item.getParentId());
theItem.setTrashed(item.isTrashed());
theItem.setShared(item.isShared());
theItem.setLocked(item.isLocked());
theItem.setTitle(item.getTitle());
theItem.setDescription(item.getDescription());
theItem.setLastModifiedBy(item.getLastModifiedBy());
theItem.setLastModificationTime(item.getLastModificationTime());
theItem.setCreationTime(item.getCreationTime());
theItem.setOwner(item.getOwner());
theItem.setHidden(item.isHidden());
theItem.setAccounting(accountingEntries);
theItem.setType(type);
theItem.setFolder(isFolder);
theItem.setRoot(false);
return theItem;
}
};*/
}

View File

@ -0,0 +1,41 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.server.converter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.gcube.common.storagehub.model.Metadata;
import org.gcube.common.storagehub.model.items.SharedFolder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class PortalMapper.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 26, 2018
*/
public class PortalMapper {
private static Logger logger = LoggerFactory.getLogger(PortalMapper.class);
/**
* To workspace shared folder members.
*
* @param sharedfolder the sharedfolder
* @return the list
*/
public static List<String> toWorkspaceSharedFolderMembers(SharedFolder sharedfolder){
Metadata users = sharedfolder.getUsers();
Map<String, Object> mapMember = users.getValues();
List<String> listUsers = new ArrayList<String>(mapMember.size());
listUsers.addAll(mapMember.keySet());
logger.debug("Returning "+listUsers.size()+" member/s for sharedFolder with id: "+sharedfolder.getId());
return listUsers;
}
}

View File

@ -0,0 +1,625 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.server.tohl;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
import org.gcube.common.storagehub.model.types.GenericItemType;
import org.gcube.common.storagehubwrapper.shared.ACLType;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
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.InternalErrorException;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.ItemAlreadyExistException;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.ItemNotFoundException;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.WorkspaceFolderNotFoundException;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.WrongDestinationException;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.WrongItemTypeException;
import org.gcube.common.storagehubwrapper.shared.tohl.folder.items.URLFileItem;
import org.gcube.common.storagehubwrapper.shared.tohl.trash.WorkspaceTrashItem;
/**
* The Interface Workspace.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 15, 2018
*
* Represents a HL user workspace.
*/
public interface Workspace{
/**
* Gets the owner.
*
* @return the owner
* @throws InternalErrorException the internal error exception
*/
//OK
public String getOwner() throws InternalErrorException;
/**
* Returns the workspace root.
*
* @return the root.
* @throws InternalErrorException the internal error exception
*/
//OK
public WorkspaceFolder getRoot() throws InternalErrorException;
/**
* Gets the children.
*
* @param id the id
* @return the children
*/
//OK
public List<? extends WorkspaceItem> getChildren(String id);
/**
* Gets the parents by id.
*
* @param id the id
* @return the parents by id
* @throws InternalErrorException the internal error exception
*/
//OK
public List<? extends WorkspaceItem> getParentsById(String id) throws InternalErrorException;
/**
* Return the item with the specified id.
*
* @param itemId the item id.
* @return the item.
* @throws ItemNotFoundException if the item has not been found.
* @throws InternalErrorException the internal error exception
*/
//OK
public WorkspaceItem getItem(String itemId) throws ItemNotFoundException, InternalErrorException;
/**
* Return the item with the specified id.
*
* @param itemId the item id.
* @param withAccounting the with accounting
* @param withFileDetails the with file details
* @param withMapProperties the with map properties
* @return the item.
* @throws ItemNotFoundException if the item has not been found.
* @throws InternalErrorException the internal error exception
*/
//OK
public WorkspaceItem getItem(String itemId, boolean withAccounting, boolean withFileDetails, boolean withMapProperties) throws ItemNotFoundException, InternalErrorException;
/**
* Create a new folder with specified name.
* The new folder is created into the specified folder.
*
* @param name the folder name.
* @param description the folder description.
* @param destinationFolderId the destination folder.
* @return the new folder.
* @throws InternalErrorException if an internal error occurs.
* @throws InsufficientPrivilegesException if the user don't have sufficient privileges to perform this operation.
* @throws ItemAlreadyExistException if an item with the same exist in the destination folder.
* @throws WrongDestinationException if the destination item is not a folder.
* @throws ItemNotFoundException if the destination folder has not been found.
* @throws WorkspaceFolderNotFoundException if the destination folder has not been found.
* @throws Exception the exception
*/
public WorkspaceFolder createFolder(String name, String description, String destinationFolderId) throws InternalErrorException, InsufficientPrivilegesException, ItemAlreadyExistException, WrongDestinationException, ItemNotFoundException, WorkspaceFolderNotFoundException, Exception;
/**
* Create a new folder with properties.
*
* @param name the name
* @param description the description
* @param destinationFolderId the destination folder id
* @param properties the properties
* @return the new 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
*/
public WorkspaceFolder createFolder(String name, String description, String destinationFolderId, Map<String, String> properties) throws InternalErrorException, InsufficientPrivilegesException, ItemAlreadyExistException, WrongDestinationException, ItemNotFoundException, WorkspaceFolderNotFoundException;
/**
* Upload file.
*
* @param folderId the folder id
* @param inputStream the input stream
* @param fileName the file name
* @param fileDescription the file description
* @return the 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
*/
public WorkspaceItem uploadFile(String folderId, InputStream inputStream, String fileName, String fileDescription) throws InsufficientPrivilegesException, WorkspaceFolderNotFoundException, InternalErrorException, ItemAlreadyExistException, WrongDestinationException;
/**
* Gets the shared folder members.
*
* @param folderid the folderid
* @return the shared folder members
* @throws Exception the exception
*/
public List<String> getSharedFolderMembers(String folderid) throws Exception;
/**
* Create a new External URL into a folder.
*
* @param name the external URL name.
* @param description the external URL description.
* @param url the external URL value.
* @param destinationFolderId the destination folder.
* @return the new external URL.
* @throws InsufficientPrivilegesException if the user don't have sufficient privileges to perform this operation.
* @throws WorkspaceFolderNotFoundException if the destination folder has not been found.
* @throws InternalErrorException if an internal error occurs.
* @throws ItemAlreadyExistException if a folder item with same name already exist.
* @throws WrongDestinationException if the destination type is not a folder.
* @throws IOException Signals that an I/O exception has occurred.
*/
public URLFileItem createExternalUrl(String name, String description, String url, String destinationFolderId) throws InsufficientPrivilegesException, WorkspaceFolderNotFoundException, InternalErrorException, ItemAlreadyExistException, WrongDestinationException, IOException;
/**
* Add a Bookmark.
*
* @param name the name
* @param description the description
* @param url the url
* @param destinationfolderId the destinationfolder id
* @return the external url
* @throws InsufficientPrivilegesException the insufficient privileges exception
* @throws InternalErrorException the internal error exception
* @throws ItemAlreadyExistException the item already exist exception
* @throws WrongDestinationException the wrong destination exception
* @throws WorkspaceFolderNotFoundException the workspace folder not found exception
* @throws IOException Signals that an I/O exception has occurred.
*/
/**
* Create a new External URL into a folder.
* @param name the external URL name.
* @param description the external URL description.
* @param url the external URL.
* @param destinationfolderId the destination folder.
* @return the new external URL.
* @throws InsufficientPrivilegesException if the user don't have sufficient privileges to perform this operation.
* @throws WorkspaceFolderNotFoundException if the destination folder has not been found.
* @throws InternalErrorException if an internal error occurs.
* @throws ItemAlreadyExistException if a folder item with same name already exist.
* @throws WrongDestinationException if the destination type is not a folder.
* @throws IOException
*/
public URLFileItem createExternalUrl(String name, String description, InputStream url, String destinationfolderId) throws InsufficientPrivilegesException, InternalErrorException, ItemAlreadyExistException, WrongDestinationException, WorkspaceFolderNotFoundException, IOException;
/**
* Remove an item.
* @param itemId the item to remove.
* @throws ItemNotFoundException if the item has not been found.
* @throws InternalErrorException if an internal error occurs.
* @throws InsufficientPrivilegesException if the user don't have sufficient privileges to perform this operation.
*/
public void removeItem(String itemId) throws ItemNotFoundException, InternalErrorException, InsufficientPrivilegesException;
/**
* Move a workspaceItem to a specified destination.
* @param itemId the item to move.
* @param destinationFolderId the destination folder.
* @return the moved workspaceItem
* @throws ItemNotFoundException if the specified item has not been found.
* @throws WrongDestinationException if the specified destination has not been found.
* @throws InsufficientPrivilegesException if the user don't have sufficient privileges to perform this operation.
* @throws InternalErrorException if an internal error occurs.
* @throws ItemAlreadyExistException if the destination folder have a children with same name.
* @throws WorkspaceFolderNotFoundException if the destination folder is not found.
*/
public WorkspaceItem moveItem(String itemId, String destinationFolderId) throws ItemNotFoundException, WrongDestinationException, InsufficientPrivilegesException, InternalErrorException, ItemAlreadyExistException, WorkspaceFolderNotFoundException;
/**
* Rename an item.
*
* @param itemId the item id.
* @param newName the new name.
* @throws ItemNotFoundException if the item has not been found.
* @throws InternalErrorException if an internal error occurs.
* @throws ItemAlreadyExistException if the user don't have sufficient privileges to perform this operation.
* @throws InsufficientPrivilegesException the insufficient privileges exception
*/
public void renameItem(String itemId, String newName) throws ItemNotFoundException, InternalErrorException, ItemAlreadyExistException, InsufficientPrivilegesException;
/**
* Change an item description.
* @param itemId the item to update.
* @param newDescription the new item description.
* @throws ItemNotFoundException if the item has not been found.
* @throws InternalErrorException if an internal error occurs.
*/
public void changeDescription(String itemId, String newDescription) throws ItemNotFoundException, InternalErrorException;
/**
* Return the item with the specified path.
*
* @param path the item path.
* @return the item.
* @throws ItemNotFoundException if the item has not been found.
*/
public WorkspaceItem getItemByPath(String path) throws ItemNotFoundException;
/**
* Remove an item from a folder.
* @param itemName the item name.
* @param folderId the folder id.
* @throws ItemNotFoundException if the folder has not been found.
* @throws InternalErrorException if an internal error occurs.
* @throws InsufficientPrivilegesException if the user don't have sufficient privileges to perform this operation.
* @throws WrongItemTypeException if the specified folder is neither a workspace nor a folder.
*/
public void remove(String itemName, String folderId) throws ItemNotFoundException, InternalErrorException, InsufficientPrivilegesException, WrongItemTypeException;
/**
* Copy an item from a folder to another folder.
*
* @param itemId the item to copy.
* @param newName the item new name.
* @param destinationFolderId the destination folder id.
* @return the item copy.
* @throws ItemNotFoundException if the item has not been found.
* @throws WrongDestinationException if the destination have a wrong type.
* @throws InternalErrorException if an internal error occurs.
* @throws ItemAlreadyExistException if an item with same name already exist in the destination folder.
* @throws InsufficientPrivilegesException if the user don't have sufficient privileges to perform this operation.
* @throws WorkspaceFolderNotFoundException if the destination folder has not been found.
*/
public WorkspaceItem copy(String itemId, String newName, String destinationFolderId) throws ItemNotFoundException, WrongDestinationException, InternalErrorException, ItemAlreadyExistException, InsufficientPrivilegesException, WorkspaceFolderNotFoundException;
/**
* Copy an item from a folder to another folder. The item copy have the same name of the original.
*
* @param itemId the item to copy.
* @param destinationFolderId the destination folder id, can't be the same of the item (can't have the same name).
* @return the item copy.
* @throws ItemNotFoundException if the item has not been found.
* @throws WrongDestinationException if the destination have a wrong type.
* @throws InternalErrorException if an internal error occurs.
* @throws ItemAlreadyExistException if an item with same name already exist in the destination folder.
* @throws InsufficientPrivilegesException if the user don't have sufficient privileges to perform this operation.
* @throws WorkspaceFolderNotFoundException if the destination folder has not been found.
*/
public WorkspaceItem copy(String itemId, String destinationFolderId) throws ItemNotFoundException, WrongDestinationException, InternalErrorException, ItemAlreadyExistException, InsufficientPrivilegesException, WorkspaceFolderNotFoundException;
/**
* Check if an item with the specified name exists in the specified folder.
* @param name the name to check.
* @param folderId the folder where to search the item.
* @return <code>true</code> if the item exists, <code>false</code> otherwise.
* @throws InternalErrorException if an error occurs.
* @throws ItemNotFoundException if the folder has not been found.
* @throws WrongItemTypeException if the folderId referrer to an item with type different from Workspace or folder.
*/
public boolean exists(String name, String folderId) throws InternalErrorException, ItemNotFoundException, WrongItemTypeException;
/**
* Check if an item with the specified id exists.
* @param itemId the item id to check.
* @return <code>true</code> if the item exists, <code>false</code> otherwise.
* @throws InternalErrorException if an error occurs.
*/
public boolean exists(String itemId) throws InternalErrorException;
/**
* Get an item with the specified name in the specified folder.
* @param name the item name to find.
* @param folderId the folder where to search the item.
* @return the item if the item is found, <code>null</code> otherwise.
* @throws InternalErrorException if an error occurs.
* @throws ItemNotFoundException if the folder has not been found.
* @throws WrongItemTypeException if the folderId referrer to an item with type different from Workspace or folder.
*/
public WorkspaceItem find(String name, String folderId) throws InternalErrorException, ItemNotFoundException, WrongItemTypeException;
/**
* Find an item using the specified path.
*
* @param path the item path.
* @return the item if the item is found, <code>null</code> otherwise.
* @throws InternalErrorException if an error occurs.
*/
public WorkspaceItem find(String path) throws InternalErrorException;
/**
* Search by Name.
*
* @param name the name
* @param folderId the folder id
* @return a list of SearchItem
* @throws InternalErrorException the internal error exception
*/
public List<WorkspaceItem> searchByName(String name, String folderId) throws InternalErrorException;
/**
* Search By MimeType.
*
* @param mimeType the mime type
* @return a list of SearchFolderItem
* @throws InternalErrorException the internal error exception
*/
public List<WorkspaceItem> searchByMimeType(String mimeType)
throws InternalErrorException;
/**
* Get items by type.
*
* @param type the type
* @return a list of SearchItem
* @throws InternalErrorException the internal error exception
*/
public List<WorkspaceItem> getFolderItems(GenericItemType type) throws InternalErrorException;
/**
* Create a shared folder with a list of users.
*
* @param name the name
* @param description the description
* @param users A list of portal logins
* @param destinationFolderId the destination folder id
* @return the 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
*/
public WorkspaceSharedFolder createSharedFolder(String name, String description,
List<String> users, String destinationFolderId)
throws InternalErrorException, InsufficientPrivilegesException,
ItemAlreadyExistException, WrongDestinationException,
ItemNotFoundException, WorkspaceFolderNotFoundException;
/**
* Create a shared folder associated with a groupId.
*
* @param name the name of the folder
* @param description the description
* @param groupId an existing groupId to associate with the folder
* @param destinationFolderId the destination folder id
* @param displayName a friendly name for the folder
* @param isVREFolder a flag to indicate the folder is a VRE Folder
* @return the 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
*/
public WorkspaceSharedFolder createSharedFolder(String name, String description,
String groupId, String destinationFolderId, String displayName, boolean isVREFolder)
throws InternalErrorException, InsufficientPrivilegesException,
ItemAlreadyExistException, WrongDestinationException,
ItemNotFoundException, WorkspaceFolderNotFoundException;
/**
* Shared an exist {@link WorkspaceFolder} with a list of users.
*
* @param users A list of portal logins.
* @param destinationFolderId the destination folder id
* @return the 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
*/
public WorkspaceSharedFolder shareFolder(List<String> users, String destinationFolderId)
throws InternalErrorException, InsufficientPrivilegesException,
ItemAlreadyExistException, WrongDestinationException,
ItemNotFoundException, WorkspaceFolderNotFoundException;
/**
* Shared an exist {@link WorkspaceFolder} with a list of users.
*
* @param users A list of portal logins.
* @param itemId the item id
* @return the 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
*/
public WorkspaceSharedFolder share(List<String> users, String itemId)
throws InternalErrorException, InsufficientPrivilegesException,
ItemAlreadyExistException, WrongDestinationException,
ItemNotFoundException, WorkspaceFolderNotFoundException;
/**
* Create a GCubeItem.
*
* @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 a GCubeItem
* @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
*/
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;
/**
* Unshare a shared item.
*
* @param itemId the item id
* @return the workspace item
* @throws InternalErrorException the internal error exception
* @throws ItemNotFoundException the item not found exception
*/
public WorkspaceItem unshare(String itemId) throws InternalErrorException, ItemNotFoundException;
/**
* Get Trash Folder.
*
* @return the trash folder
* @throws InternalErrorException the internal error exception
* @throws ItemNotFoundException the item not found exception
*/
public WorkspaceTrashItem getTrash() throws InternalErrorException, ItemNotFoundException;
/**
* Get MySpecialFolders.
*
* @return my special folders
* @throws InternalErrorException the internal error exception
* @throws ItemNotFoundException the item not found exception
*/
public WorkspaceFolder getMySpecialFolders() throws InternalErrorException, ItemNotFoundException;
/**
* Search By Properties.
*
* @param properties the properties
* @return a list of WorkspaceItem
* @throws InternalErrorException the internal error exception
*/
public List<WorkspaceItem> searchByProperties(List<String> properties)
throws InternalErrorException;
/**
* Get VRE Folder By Scope.
*
* @param scope the scope
* @return the VRE folder associated to such scope
* @throws ItemNotFoundException the item not found exception
* @throws InternalErrorException the internal error exception
*/
public WorkspaceSharedFolder getVREFolderByScope(String scope) throws ItemNotFoundException, InternalErrorException;
/**
* Get the disk usage of a worskpace.
*
* @return the disk usage
* @throws InternalErrorException the internal error exception
*/
public long getDiskUsage() throws InternalErrorException;
/**
* Get the total number of items in a workspace.
*
* @return the numer of total Items
* @throws InternalErrorException the internal error exception
*/
public int getTotalItems() throws InternalErrorException;
/**
* Remove a list of items identified by ids.
*
* @param id the id
* @return a map of errors: Map<id, error>
* @throws ItemNotFoundException the item not found exception
* @throws InternalErrorException the internal error exception
* @throws InsufficientPrivilegesException the insufficient privileges exception
*/
public Map<String, String> removeItems(String... id) throws ItemNotFoundException,
InternalErrorException, InsufficientPrivilegesException;
/**
* Create a VRE folder.
*
* @param scope the scope
* @param description the description
* @param displayName the display name
* @param privilege the privilege
* @return a new 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
*/
public WorkspaceVREFolder createVREFolder(String scope, String description,
String displayName, ACLType privilege) throws InternalErrorException,
InsufficientPrivilegesException, ItemAlreadyExistException,
WrongDestinationException, ItemNotFoundException,
WorkspaceFolderNotFoundException;
/**
* Get group name by group id.
*
* @param groupId the group id
* @return the group name
* @throws InternalErrorException the internal error exception
*/
String getGroup(String groupId) throws InternalErrorException;
/**
* Check if a user is a group.
*
* @param groupId the group id
* @return true if the user is a group, false otherwise
* @throws InternalErrorException the internal error exception
*/
boolean isGroup(String groupId) throws InternalErrorException;
/**
* Get public folders.
*
* @return a list of public folder
* @throws InternalErrorException the internal error exception
*/
List<WorkspaceItem> getPublicFolders() throws InternalErrorException;
}

View File

@ -0,0 +1,37 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared;
/**
* The Enum ACLType.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 15, 2018
*/
public enum ACLType {
/**
* Access denied to user.
*/
NONE,
/**
* Allow users to only read files.
*/
READ_ONLY,
/**
* Allow users to create, edit and delete their own files.
*/
WRITE_OWNER,
/**
* Allow users to create, edit and delete files of everyone in the share.
*/
WRITE_ALL,
/**
* All privileges.
*/
ADMINISTRATOR;
}

View File

@ -0,0 +1,43 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl;
import java.util.Calendar;
/**
* The Interface AccountingEntry.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 15, 2018
*/
public interface AccountingEntry {
/**
* Gets the user.
*
* @return the user
*/
String getUser();
/**
* Gets the date.
*
* @return the date
*/
Calendar getDate();
/**
* Gets the entry type.
*
* @return the entry type
*/
String getEntryType();
/**
* Gets the version.
*
* @return the version
*/
String getVersion();
}

View File

@ -0,0 +1,67 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl;
import java.util.Map;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
/**
* The Interface Properties.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 15, 2018
*/
public interface Properties {
/**
* Get ID.
*
* @return the properties id.
* @throws InternalErrorException if an internal error occurs.
*/
public String getId() throws InternalErrorException;
/**
* Get property value.
*
* @param propertyName the property name.
* @return the property value.
* @throws InternalErrorException the internal error exception
*/
public String getPropertyValue(String propertyName) throws InternalErrorException;
/**
* Get Properties.
*
* @return the properties map.
* @throws InternalErrorException the internal error exception
*/
public Map<String, String> getProperties() throws InternalErrorException;
// /**
// * Add properties to item.
// *
// * @param properties a map of properties
// * @throws InternalErrorException the internal error exception
// */
// public void addProperties(Map<String, String> properties) throws InternalErrorException;
//
// /**
// * Save modified properties.
// *
// * @throws InternalErrorException the internal error exception
// */
// public void update() throws InternalErrorException;
//
// /**
// * Check if the item has a given property.
// *
// * @param property the property
// * @return true, if successful
// * @throws InternalErrorException the internal error exception
// */
// public boolean hasProperty(String property) throws InternalErrorException;
}

View File

@ -0,0 +1,16 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl;
/**
* The Interface WorkspaceFolder.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 15, 2018
*/
public interface WorkspaceFolder extends WorkspaceItem {
}

View File

@ -0,0 +1,179 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl;
import java.util.Calendar;
import java.util.List;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
import org.gcube.common.storagehubwrapper.shared.tohl.folder.items.PropertyMap;
/**
* The Interface WorkspaceItem. Define a Workspace item like folder or
* folder-item.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 15, 2018
*/
public interface WorkspaceItem {
/**
* This item id.
*
* @return the id.
* @throws InternalErrorException
* if an internal error occurs.
*/
public String getId()
throws InternalErrorException;
/**
* This item name.
*
* @return the name.
* @throws InternalErrorException
* if an internal error occurs.
*/
public String getName()
throws InternalErrorException;
/**
* This item description.
*
* @return the description.
* @throws InternalErrorException
* if an internal error occurs.
*/
public String getDescription()
throws InternalErrorException;
/**
* This item creation time.
*
* @return the creation time.
* @throws InternalErrorException
* if an internal error occurs.
*/
public Calendar getCreationTime()
throws InternalErrorException;
/**
* This item last modification time.
*
* @return the last modification time.
* @throws InternalErrorException
* if an internal error occurs.
*/
public Calendar getLastModificationTime()
throws InternalErrorException;
/**
* Gets the last modified by.
*
* @return the last modified by
* @throws InternalErrorException the internal error exception
*/
public String getLastModifiedBy()
throws InternalErrorException;
/**
* This item owner.
*
* @return the owner.
* @throws InternalErrorException
* if an internal error occurs.
*/
public String getOwner()
throws InternalErrorException;
/**
* Gets the map property.
*
* @return the map property
*/
public PropertyMap getPropertyMap();
/**
* Gets the accounting.
*
* @return the accounting
*/
public List<AccountingEntry> getAccounting();
/**
* Gets the path.
*
* @return the path
*/
public String getPath();
/**
* Gets the parent id.
*
* @return the parent id
*/
public String getParentId();
/**
* Return this item type.
*
* @return the type.
*/
public WorkspaceItemType getType();
/**
* Says if this item is a root element.
*
* @return <code>true</code> if this element is a root, <code>false</code>
* otherwise.
* @throws InternalErrorException
* if an internal error occurs.
*/
public boolean isRoot()
throws InternalErrorException;
/**
* Return a flag indicating whether the element is hidden.
*
* @return <code>true</code> if the element is hidden, <code>false</code> if
* the element is visible.
* @throws InternalErrorException
* the internal error exception
*/
public boolean isHidden()
throws InternalErrorException;
/**
* Return a flag indicating whether the element is shared.
*
* @return <code>true</code> if the element is shared, <code>false</code>
* otherwise.
* @throws InternalErrorException
* the internal error exception
*/
public boolean isShared()
throws InternalErrorException;
/**
* Check if the item is in the trash.
*
* @return true if the item has been trashed
* @throws InternalErrorException
* the internal error exception
*/
public boolean isTrashed()
throws InternalErrorException;
/**
* Check if the item is a folder.
*
* @return true if the item is a folder
* @throws InternalErrorException
* the internal error exception
*/
public boolean isFolder()
throws InternalErrorException;
}

View File

@ -0,0 +1,50 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl;
/**
* The Enum WorkspaceItemType.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 19, 2018
*/
public enum WorkspaceItemType {
/**
* A folder.
*/
FOLDER,
/**
* A shared folder
*/
SHARED_FOLDER,
/**
* A smart folder
*/
SMART_FOLDER,
/**
* A folder item.
*/
FILE_ITEM,
/**
* A trash folder.
*/
TRASH_FOLDER,
/**
* A trash item.
*/
TRASH_ITEM,
VRE_FOLDER;
}

View File

@ -0,0 +1,16 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl;
/**
* The Interface WorkspaceSharedFolder.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 15, 2018
*/
public interface WorkspaceSharedFolder extends WorkspaceFolder{
}

View File

@ -0,0 +1,19 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl;
/**
* The Interface WorkspaceVREFolder.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 19, 2018
*/
public interface WorkspaceVREFolder extends WorkspaceSharedFolder {
}

View File

@ -0,0 +1,42 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.exceptions;
/**
* The Class InsufficientPrivilegesException.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 15, 2018
*/
public class InsufficientPrivilegesException extends WorkspaceException {
private static final long serialVersionUID = 2423742342338757212L;
/**
* Create a new internal error exception.
* @param cause the exception cause.
*/
public InsufficientPrivilegesException(Throwable cause) {
super(cause);
}
/**
* Create a new internal error exception.
* @param message the exception message.
*/
public InsufficientPrivilegesException(String message) {
super(message);
}
/**
* Create a new internal error exception.
* @param message the exception message.
* @param cause the exception cause.
*/
public InsufficientPrivilegesException(String message, Throwable cause) {
super(message, cause);
}
}

View File

@ -0,0 +1,39 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.exceptions;
/**
* The Class InternalErrorException.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 15, 2018
*/
public class InternalErrorException extends Exception {
/**
*
*/
private static final long serialVersionUID = -8885298303989967692L;
/**
* Instantiates a new internal error exception.
*
* @param arg0 the arg0
*/
public InternalErrorException(String arg0) {
super(arg0);
}
/* (non-Javadoc)
* @see java.lang.Throwable#toString()
*/
@Override
public String toString() {
// TODO Auto-generated method stub
return super.toString();
}
}

View File

@ -0,0 +1,26 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.exceptions;
/**
* The Class ItemAlreadyExistException.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 15, 2018
*/
public class ItemAlreadyExistException extends WorkspaceException {
private static final long serialVersionUID = -2884454770219837164L;
/**
* Instantiates a new item already exist exception.
*
* @param message the exception message.
*/
public ItemAlreadyExistException(String message) {
super(message);
}
}

View File

@ -0,0 +1,26 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.exceptions;
/**
* The Class ItemNotFoundException.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 15, 2018
*/
public class ItemNotFoundException extends WorkspaceException {
private static final long serialVersionUID = -553175277581696583L;
/**
* Instantiates a new item not found exception.
*
* @param message the exception message.
*/
public ItemNotFoundException(String message) {
super(message);
}
}

View File

@ -0,0 +1,52 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.exceptions;
/**
* A super class for all the workspace exceptions.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 15, 2018
*/
public class WorkspaceException extends Exception{
/**
*
*/
private static final long serialVersionUID = -5657714325026850145L;
/**
*
*/
public WorkspaceException() {
}
/**
* Create a new workspace exception.
* @param message the exception message.
* @param cause the exception cause.
*/
public WorkspaceException(String message, Throwable cause) {
super(message, cause);
}
/**
* Create a new workspace exception.
* @param message the exception message.
*/
public WorkspaceException(String message) {
super(message);
}
/**
* Create a new workspace exception.
* @param cause the exception cause.
*/
public WorkspaceException(Throwable cause) {
super(cause);
}
}

View File

@ -0,0 +1,25 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.exceptions;
/**
* The Class WorkspaceFolderAlreadyExistException.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 15, 2018
*/
public class WorkspaceFolderAlreadyExistException extends WorkspaceException {
private static final long serialVersionUID = -6285161417298571997L;
/**
* Instantiates a new workspace folder already exist exception.
*
* @param message the exception message.
*/
public WorkspaceFolderAlreadyExistException(String message) {
super(message);
}
}

View File

@ -0,0 +1,25 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.exceptions;
/**
* The Class WorkspaceFolderNotFoundException.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 15, 2018
*/
public class WorkspaceFolderNotFoundException extends WorkspaceException {
private static final long serialVersionUID = -729077599735921718L;
/**
* Instantiates a new workspace folder not found exception.
*
* @param msg the exception message.
*/
public WorkspaceFolderNotFoundException(String msg) {
super(msg);
}
}

View File

@ -0,0 +1,27 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.exceptions;
/**
* The Class WrongDestinationException.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 15, 2018
*/
public class WrongDestinationException extends WorkspaceException {
private static final long serialVersionUID = -1765035358366830708L;
/**
* Instantiates a new wrong destination exception.
*
* @param message the exception message.
*/
public WrongDestinationException(String message) {
super(message);
}
}

View File

@ -0,0 +1,24 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.exceptions;
/**
* The Class WrongItemTypeException.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 15, 2018
*/
public class WrongItemTypeException extends WorkspaceException {
private static final long serialVersionUID = -5013356582135921634L;
/**
* Instantiates a new wrong item type exception.
*
* @param message the exception message.
*/
public WrongItemTypeException(String message) {
super(message);
}
}

View File

@ -0,0 +1,27 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.exceptions;
/**
* The Class WrongParentTypeException.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 15, 2018
*/
public class WrongParentTypeException extends WorkspaceException {
private static final long serialVersionUID = -6202770939428067425L;
/**
* Instantiates a new wrong parent type exception.
*
* @param message the exception message.
*/
public WrongParentTypeException(String message) {
super(message);
}
}

View File

@ -0,0 +1,42 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.folder.items;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
/**
* The Interface File.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 15, 2018
*/
public interface File {
/**
* Gets the folder item type.
*
* @return the folder item type
*/
public FileItemType getFileItemType();
/**
* Gets the size.
*
* @return the size
* @throws InternalErrorException the internal error exception
*/
public Long getSize() throws InternalErrorException;
/**
* The folder myme type.
*
* @return the myme type
* @throws InternalErrorException the internal error exception
*/
public String getMimeType() throws InternalErrorException;
}

View File

@ -0,0 +1,27 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.folder.items;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
/**
* The Interface FolderItem.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 15, 2018
*/
public interface FileItem extends WorkspaceItem, File {
/**
* Get Current version.
*
* @return the current version
* @throws InternalErrorException the internal error exception
*/
public WorkspaceVersion getCurrentVersion() throws InternalErrorException;
}

View File

@ -0,0 +1,52 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.folder.items;
import org.gcube.common.storagehub.model.types.GenericItemType;
/**
* The Enum FileItemType.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 21, 2018
*/
public enum FileItemType implements GenericItemType{
/**
* Document.
*/
DOCUMENT,
/**
* Image document.
*/
IMAGE_DOCUMENT,
/**
* PDF document.
*/
PDF_DOCUMENT,
/**
* Url document.
*/
URL_DOCUMENT,
/**
* Metadata.
*/
METADATA,
/**
* Trash item
*/
TRASH_ITEM,
/**
* A gCube item.
*/
GCUBE_ITEM
}

View File

@ -0,0 +1,61 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.folder.items;
import java.io.InputStream;
import java.util.List;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
/**
* The Interface GCubeItem.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 15, 2018
*/
public interface GCubeItem extends FileItem {
/**
* Gets the scopes.
*
* @return the scopes
* @throws InternalErrorException the internal error exception
*/
public List<String> getScopes() throws InternalErrorException;
/**
* Gets the item type.
*
* @return the item type
*/
public String getItemType();
/**
* Gets the creator.
*
* @return the creator
*/
public String getCreator();
/**
* Share.
*
* @param users the users
* @return the workspace shared folder
* @throws InternalErrorException the internal error exception
*/
public WorkspaceSharedFolder share(List<String> users) throws InternalErrorException;
/**
* Gets the data.
*
* @return the data
* @throws InternalErrorException the internal error exception
*/
public InputStream getData() throws InternalErrorException;
}

View File

@ -0,0 +1,51 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.folder.items;
import java.io.InputStream;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
/**
* The Interface Image.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 15, 2018
*/
public interface Image extends File {
/**
* The image width.
* @return the width.
*/
public Long getWidth();
/**
* The image height.
* @return the height.
*/
public Long getHeight();
/**
* The image thumbnail.
* @return the thumbnail.
* @throws InternalErrorException if an internal error occurs.
*/
public InputStream getThumbnail() throws InternalErrorException;
/**
* The image thumbanil width.
* @return the thumbnail width.
*/
public Long getThumbnailWidth();
/**
* The image thumbnail height.
* @return the thumbnail height.
*/
public Long getThumbnailHeight();
}

View File

@ -0,0 +1,15 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.folder.items;
/**
* The Interface FileItemImage.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 21, 2018
*/
public interface ImageFileItem extends FileItem, Image {
}

View File

@ -0,0 +1,55 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.folder.items;
/**
* The Interface FileItemPDF.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 21, 2018
*/
public interface PDFFileItem extends FileItem{
/**
* Gets the number of pages.
*
* @return the numberOfPages
*/
public Long getNumberOfPages();
/**
* Gets the version.
*
* @return the version
*/
public String getVersion();
/**
* Gets the author.
*
* @return the author
*/
public String getAuthor();
/**
* Gets the title.
*
* @return the title
*/
public String getTitle();
/**
* Gets the producer.
*
* @return the producer
*/
public String getProducer();
}

View File

@ -0,0 +1,23 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.folder.items;
import java.util.Map;
/**
* The Interface PropertyMap.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 22, 2018
*/
public interface PropertyMap {
/**
* Gets the values.
*
* @return the values
*/
public Map<String, Object> getValues();
}

View File

@ -0,0 +1,16 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.folder.items;
/**
* The Interface FileItemURL.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 21, 2018
*/
public interface URLFileItem extends FileItem{
}

View File

@ -0,0 +1,60 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.folder.items;
import java.util.Calendar;
/**
* The Interface WorkspaceVersion.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 15, 2018
*/
public interface WorkspaceVersion {
/**
* Gets the name.
*
* @return the name
*/
public String getName();
/**
* Gets the created.
*
* @return the created
*/
public Calendar getCreated();
/**
* Gets the user.
*
* @return the user
*/
public String getUser();
/**
* Gets the remote path.
*
* @return the remote path
*/
public String getRemotePath();
/**
* Gets the size.
*
* @return the size
*/
public long getSize();
/**
* Checks if is current version.
*
* @return true, if is current version
*/
public boolean isCurrentVersion();
}

View File

@ -0,0 +1,35 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.impl;
import java.io.Serializable;
import java.util.Calendar;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jun 15, 2018
*/
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class AccountingEntry implements org.gcube.common.storagehubwrapper.shared.tohl.AccountingEntry, Serializable{
/**
*
*/
private static final long serialVersionUID = 2880510084929441352L;
String user;
Calendar date;
String entryType;
String version;
String primaryType;
}

View File

@ -0,0 +1,85 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.impl;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
import org.gcube.common.storagehubwrapper.shared.tohl.folder.items.FileItemType;
import org.gcube.common.storagehubwrapper.shared.tohl.folder.items.WorkspaceVersion;
/**
* The Class FileItem.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 21, 2018
*/
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
public class FileItem extends WorkspaceItem implements org.gcube.common.storagehubwrapper.shared.tohl.folder.items.FileItem {
/**
*
*/
private static final long serialVersionUID = -4149282274165182444L;
private FileItemType fileItemType;
private Long size;
private String mimeType;
private WorkspaceVersion currentVersion;
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.tohl.folder.items.File#getFolderItemType()
*/
@Override
public FileItemType getFileItemType() {
// TODO Auto-generated method stub
return fileItemType;
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.tohl.folder.items.File#getSize()
*/
@Override
public Long getSize()
throws InternalErrorException {
// TODO Auto-generated method stub
return size;
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.tohl.folder.items.File#getMimeType()
*/
@Override
public String getMimeType()
throws InternalErrorException {
// TODO Auto-generated method stub
return mimeType;
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.tohl.folder.items.FileItem#getCurrentVersion()
*/
@Override
public WorkspaceVersion getCurrentVersion()
throws InternalErrorException {
// TODO Auto-generated method stub
return currentVersion;
}
}

View File

@ -0,0 +1,88 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.impl;
import java.io.InputStream;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jun 21, 2018
*/
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@ToString(callSuper=false)
public class ImageFile extends FileItem implements org.gcube.common.storagehubwrapper.shared.tohl.folder.items.ImageFileItem{
/**
*
*/
private static final long serialVersionUID = 7586826417080458164L;
private Long width;
private Long height;
private Long thumbnailWidth;
private Long thumbnailHeight;
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.tohl.folder.items.Image#getWidth()
*/
@Override
public Long getWidth() {
// TODO Auto-generated method stub
return width;
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.tohl.folder.items.Image#getHeight()
*/
@Override
public Long getHeight() {
// TODO Auto-generated method stub
return height;
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.tohl.folder.items.Image#getThumbnail()
*/
@Override
public InputStream getThumbnail()
throws InternalErrorException {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.tohl.folder.items.Image#getThumbnailWidth()
*/
@Override
public Long getThumbnailWidth() {
// TODO Auto-generated method stub
return thumbnailWidth;
}
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.tohl.folder.items.Image#getThumbnailHeight()
*/
@Override
public Long getThumbnailHeight() {
// TODO Auto-generated method stub
return thumbnailHeight;
}
}

View File

@ -0,0 +1,43 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.impl;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
/**
* The Interface FileItemURL.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 21, 2018
*/
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@ToString(callSuper=false)
public class PDFFile extends FileItem implements org.gcube.common.storagehubwrapper.shared.tohl.folder.items.PDFFileItem{
/**
*
*/
private static final long serialVersionUID = 1367372682598677200L;
Long numberOfPages;
String version;
String author;
String title;
String producer;
}

View File

@ -0,0 +1,27 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.impl;
import java.util.HashMap;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jun 22, 2018
*/
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class PropertyMap implements org.gcube.common.storagehubwrapper.shared.tohl.folder.items.PropertyMap{
Map<String, Object> values = new HashMap<String, Object>();
}

View File

@ -0,0 +1,18 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.impl;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jun 21, 2018
*/
public class URLFile extends FileItem implements org.gcube.common.storagehubwrapper.shared.tohl.folder.items.URLFileItem{
/**
*
*/
private static final long serialVersionUID = 7586826417080458164L;
}

View File

@ -0,0 +1,33 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.impl;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;
/**
* The Class WorkspaceFolder.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 20, 2018
*/
/**
* Instantiates a new workspace folder.
*/
@Getter
@NoArgsConstructor
@ToString(callSuper=true)
public class WorkspaceFolder extends WorkspaceItem implements org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder{
/*
*
*/
private static final long serialVersionUID = -3767943529796942863L;
}

View File

@ -0,0 +1,96 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.impl;
import java.io.Serializable;
import java.util.Calendar;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.gcube.common.storagehubwrapper.shared.tohl.AccountingEntry;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItemType;
import org.gcube.common.storagehubwrapper.shared.tohl.folder.items.PropertyMap;
/**
* The Class WorkspaceItemImpl.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Jun 15, 2018
*/
/* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.tohl.WorkspaceItem#isHidden()
*/
@Getter
/**
* Sets the folder.
*
* @param isFolder the new folder
*/
@Setter
/**
* Instantiates a new workspace item.
*/
@NoArgsConstructor
/**
* Instantiates a new workspace item.
*
* @param id the id
* @param name the name
* @param path the path
* @param parentId the parent id
* @param trashed the trashed
* @param shared the shared
* @param locked the locked
* @param title the title
* @param description the description
* @param lastModifiedBy the last modified by
* @param lastModificationTime the last modification time
* @param creationTime the creation time
* @param owner the owner
* @param hidden the hidden
* @param accounting the accounting
* @param type the type
* @param isFolder the is folder
* @param isRoot the is root
*/
@AllArgsConstructor
@ToString
public class WorkspaceItem implements org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem, Serializable {
/**
*
*/
private static final long serialVersionUID = 5444534091783292538L;
private String id;
private String name;
private String path;
private String parentId;
//private String primaryType;
private boolean trashed;
private boolean shared;
private boolean locked;
private String title;
private String description;
private String lastModifiedBy;
private Calendar lastModificationTime;
private Calendar creationTime;
private String owner;
//private ItemAction lastAction;
private boolean hidden;
private List<AccountingEntry> accounting;
private WorkspaceItemType type;
private boolean isFolder;
boolean isRoot;
private PropertyMap propertyMap;
}

View File

@ -0,0 +1,32 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.impl;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
/**
* The Class WorkspaceFolderImpl.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jun 15, 2018
*/
@Getter
/**
* Instantiates a new workspace folder impl.
*/
@NoArgsConstructor
@Setter
@ToString(callSuper=true)
public class WorkspaceSharedFolder extends WorkspaceFolder implements org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder{
private static final long serialVersionUID = -6493111521916500793L;
private boolean isVreFolder;
}

View File

@ -0,0 +1,23 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.impl;
import lombok.NoArgsConstructor;
import lombok.ToString;
/**
* The Class WorkspaceVREFolder.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 20, 2018
*/
@NoArgsConstructor
@ToString(callSuper=true)
public class WorkspaceVREFolder extends WorkspaceFolder implements org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceVREFolder{
/**
*
*/
private static final long serialVersionUID = 1984917908193397527L;
}

View File

@ -0,0 +1,78 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.trash;
import java.util.List;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.ItemNotFoundException;
/**
* The Interface WorkspaceTrashFolder.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 26, 2018
*/
public interface WorkspaceTrashFolder extends WorkspaceFolder {
/**
* Empty Trash.
*
* @return a list of WorkspaceItem ids not removed; the list is null if every item has been removed
* @throws InternalErrorException the internal error exception
*/
public List<String> emptyTrash() throws InternalErrorException;
/**
* Delete permanently a specific item.
*
* @param id item to delete
* @throws InternalErrorException the internal error exception
*/
public void deletePermanentlyById(String id) throws InternalErrorException;
/**
* Restore all item in Trash.
*
* @return a list of WorkspaceItem ids not restored; the list is null if every item has been restored
* @throws InternalErrorException the internal error exception
*/
public List<String> restoreAll() throws InternalErrorException;
/**
* Restore a specific item.
*
* @param id item to restore
* @throws InternalErrorException the internal error exception
*/
public void restoreById(String id) throws InternalErrorException;
/**
* Get trashed items.
*
* @return the list of trashed items
* @throws InternalErrorException the internal error exception
* @throws ItemNotFoundException the item not found exception
* @deprecated use {@link #getChildren()} instead
*/
@Deprecated
public List<WorkspaceTrashItem> listTrashItems() throws InternalErrorException, ItemNotFoundException;
/**
* Get Trash Item by Id.
*
* @param id of a trashed item
* @return a trashed item
* @throws InternalErrorException the internal error exception
* @deprecated use {@link org.gcube.portal.storagehubwrapper.server.tohl.homelibrary.home.workspace.Workspace#getItem(String itemId)} instead
*/
@Deprecated
public WorkspaceTrashItem getTrashItemById(String id) throws InternalErrorException;
}

View File

@ -0,0 +1,91 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.trash;
import java.util.Calendar;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItemType;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
/**
* The Interface WorkspaceTrashItem.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 15, 2018
*/
public interface WorkspaceTrashItem extends WorkspaceFolder {
/**
* Get original parent Id to restore the item.
*
* @return the original parent Id to restore the item
*/
String getOriginalParentId();
/**
* Get the path where the item was deleted.
*
* @return the path where the item was deleted
*/
String getDeletedFrom();
/**
* Get the user who deleted the item.
*
* @return the user who deleted the item
*/
String getDeletedBy();
/**
* Get the date when the item was deleted.
*
* @return the date when the item was deleted
*/
Calendar getDeletedTime();
/**
* Return true if the trash item was a folder.
*
* @return true if the trash item was a folder, false otherwise
*/
boolean isFolder();
/**
* Get mime type.
*
* @return the mime type of the trashed item
* @throws InternalErrorException the internal error exception
*/
String getMimeType() throws InternalErrorException;
/**
* Get the name of the trashed item.
*
* @return the name of the trashed item
* @throws InternalErrorException the internal error exception
*/
String getName() throws InternalErrorException;
/**
* Return this item type.
* @return the type.
*/
WorkspaceItemType getType();
/**
* Delete Permanently an item in the trash folder.
*
* @throws InternalErrorException the internal error exception
*/
void deletePermanently() throws InternalErrorException;
/**
* Restore an item in the trash folder.
*
* @throws InternalErrorException the internal error exception
*/
void restore() throws InternalErrorException;
}

View File

@ -0,0 +1,162 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.gcube.common.storagehubwrapper.server.StorageHubWrapper;
import org.gcube.common.storagehubwrapper.server.tohl.Workspace;
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;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.ItemNotFoundException;
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
*/
public class WorkspaceInstance {
public static String USERNAME = "francesco.mangiacrapa";
public static String SCOPE = "/gcube";
public static String TOKEN = "0e2c7963-8d3e-4ea6-a56d-ffda530dd0fa-98187548";
StorageHubWrapper storageHubWrapper = null;
//Workspace workspace = null;
@Before
public void init(){
//METHOD 1
storageHubWrapper = new StorageHubWrapper(SCOPE, TOKEN);
//workspace = storageHubWrapper.getWorkspace();
//METHOD 2
// StorageHubClientService storageHubClientService = new StorageHubClientService(SCOPE, TOKEN);
// workspace = new WorkspaceStorageHubClientService.WorkspaceStorageHubClientServiceBuilder(storageHubClientService).
// withAccounting(true).
// withMapProperties(true).
// build();
}
@Test
public void getRoot() {
System.out.println("Get Root test");
WorkspaceFolder root;
try {
root = storageHubWrapper.getWorkspace().getRoot();
System.out.println(root);
}
catch (InternalErrorException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//@Test
public void getChildren() throws InternalErrorException{
System.out.println("Get children test");
WorkspaceFolder root = storageHubWrapper.getWorkspace().getRoot();
try {
List<? extends WorkspaceItem> children = storageHubWrapper.getWorkspace().getChildren(root.getId());
int i = 0;
for (WorkspaceItem workspaceItem : children) {
System.out.println(++i+")"+workspaceItem);
System.out.println(workspaceItem.getType() +" "+workspaceItem.getClass());
}
}
catch (InternalErrorException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Test
public void getWorkspaceId() {
System.out.println("Getting the workspaceId");
try {
Workspace workspace = storageHubWrapper.getWorkspace();
if(workspace!=null){
WorkspaceFolder root = workspace.getRoot();
System.out.println("Retrieve the root "+root.getId()+" correctly");
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void getChildrenPerWorkspaceItem() throws InternalErrorException{
System.out.println("Get children test per workspace item");
WorkspaceFolder root = storageHubWrapper.getWorkspace().getRoot();
try {
List<? extends WorkspaceItem> children = storageHubWrapper.getWorkspace().getChildren(root.getId());
int i = 0;
Map<String, List<WorkspaceItem>> map = new HashMap<String,List<WorkspaceItem>>();
for (WorkspaceItem workspaceItem : children) {
String key = workspaceItem.getType().name();
List<WorkspaceItem> list = map.get(key);
if(list==null){
list = new ArrayList<WorkspaceItem>();
}
list.add(workspaceItem);
map.put(key, list);
}
for (String key : map.keySet()) {
List<WorkspaceItem> list = map.get(key);
for (WorkspaceItem workspaceItem : list) {
switch (workspaceItem.getType()) {
case FILE_ITEM:
FileItem fileItem = (FileItem) workspaceItem;
switch (fileItem.getFileItemType()) {
case PDF_DOCUMENT:
PDFFile pdfFile = (PDFFile) fileItem;
System.out.println("PDF_DOCUMENT "+pdfFile);
PDFFile completeItem = (PDFFile) storageHubWrapper.getWorkspace().getItem(fileItem.getId(), true, true, true);
System.out.println(completeItem);
break;
case IMAGE_DOCUMENT:
ImageFile imageFile = (ImageFile) fileItem;
System.out.println("IMAGE_DOCUMENT "+imageFile);
break;
default:
break;
}
System.out.println(fileItem.getFileItemType() +" "+workspaceItem.getClass());
break;
default:
break;
}
}
}
}
catch (InternalErrorException | ItemNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}