diff --git a/.classpath b/.classpath
index a80540a..58e7037 100644
--- a/.classpath
+++ b/.classpath
@@ -31,8 +31,8 @@
-
+
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
index 26aef1a..90f7a5b 100644
--- a/.settings/org.eclipse.jdt.core.prefs
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -1,10 +1,7 @@
eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.processAnnotations=enabled
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 55af606..67db191 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,12 +3,16 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [v1-1-0-SNAPSHOT] - 2021-05-12
+
+Added some methods that were missing
+
## [v1-0-1-SNAPSHOT] - 2021-03-03
Improved JUnit Test
-## [v1-0-0] [r4-25-0] - 2020-07-15
+## [v1-0-0]- 2020-07-15
#### Enhancements
@@ -17,14 +21,14 @@ Improved JUnit Test
[#19668] add the method updateDescriptionForItem
-## [v0-7-1] [r4-23-0] - 2020-05-18
+## [v0-7-1] - 2020-05-18
#### Enhancements
[#19058] added the folder destination Id to restore operation
-## [v0-7-0] [r4-22-0] - 2020-04-16
+## [v0-7-0] - 2020-04-16
#### Enhancements
@@ -32,7 +36,7 @@ Improved JUnit Test
-## [v0-6-2] [r4-21-0] - 2020-03-11
+## [v0-6-2] - 2020-03-11
#### New features
diff --git a/pom.xml b/pom.xml
index 8cca62d..e90a90c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
org.gcube.common
storagehub-client-wrapper
- 1.0.1-SNAPSHOT
+ 1.1.0-SNAPSHOT
storagehub-client-wrapper
This is a wrapper of storagehub-client library. It allows to interact with storagehub in a simplified way by exposing several utilities. Moreover, It exposes by another inteface java beans as defined in (the old) HL interfaces
@@ -143,6 +143,24 @@
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+
+ -Xdoclint:none
+ -Xdoclint:none
+
+ 3.1.0
+
+
+ generate-doc
+ install
+
+ jar
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/org/gcube/common/storagehubwrapper/server/StorageHubClientService.java b/src/main/java/org/gcube/common/storagehubwrapper/server/StorageHubClientService.java
index d8dcb25..e9a0bf2 100644
--- a/src/main/java/org/gcube/common/storagehubwrapper/server/StorageHubClientService.java
+++ b/src/main/java/org/gcube/common/storagehubwrapper/server/StorageHubClientService.java
@@ -4,6 +4,7 @@ import java.io.InputStream;
import java.net.URL;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.apache.commons.lang.Validate;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
@@ -15,12 +16,14 @@ import org.gcube.common.storagehub.client.dsl.GenericItemContainer;
import org.gcube.common.storagehub.client.dsl.ItemContainer;
import org.gcube.common.storagehub.client.dsl.ListResolver;
import org.gcube.common.storagehub.client.dsl.ListResolverTyped;
+import org.gcube.common.storagehub.client.dsl.OpenResolver;
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.Metadata;
import org.gcube.common.storagehub.model.acls.ACL;
+import org.gcube.common.storagehub.model.acls.AccessType;
import org.gcube.common.storagehub.model.exceptions.StorageHubException;
import org.gcube.common.storagehub.model.items.AbstractFileItem;
import org.gcube.common.storagehub.model.items.ExternalLink;
@@ -32,7 +35,10 @@ 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.ImageContent;
import org.gcube.common.storagehub.model.service.Version;
+import org.gcube.common.storagehubwrapper.server.converter.HLMapper;
import org.gcube.common.storagehubwrapper.server.converter.ObjectMapper;
+import org.gcube.common.storagehubwrapper.shared.ACLType;
+import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.ItemNotFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -141,6 +147,34 @@ public class StorageHubClientService {
return theResolver.getItems();
}
+
+ /**
+ * Gets the children.
+ *
+ * @param id the id
+ * @param withAccounting the with accounting
+ * @param withMapProperties the with map properties
+ * @return the children
+ * @throws Exception the exception
+ */
+ public List extends Item> getChildren(String id, boolean withAccounting, boolean withMapProperties, boolean includeHidden) throws Exception{
+ setContextProviders(scope, authorizationToken);
+ logger.trace("Requesting getChildren for id: "+id+" [withAccounting: "+withAccounting+", withMapProperties: "+withMapProperties+"]");
+ if (!includeHidden) {
+ return getChildren(id, withAccounting, withMapProperties);
+ }
+
+ ListResolver theResolver = shClient.open(id).asFolder().list().includeHidden().withContent();
+
+ if(withAccounting)
+ theResolver = theResolver.withAccounting();
+
+ if(withMapProperties)
+ theResolver = theResolver.withMetadata();
+
+ return theResolver.getItems();
+
+ }
/**
@@ -194,6 +228,26 @@ public class StorageHubClientService {
return itemCont.get();
}
+ /**
+ *
+ * @param folderId
+ * @param relativePath
+ * @return
+ * @throws Exception
+ */
+ public Item getItemByPath(String folderId, String relativePath) throws Exception {
+ setContextProviders(scope, authorizationToken);
+ FolderContainer itemCont = shClient.open(folderId).asFolder();
+ FolderContainer attachmentFolder = null;
+ try {
+ OpenResolver oRes = itemCont.openByRelativePath(relativePath);
+ attachmentFolder = oRes.asFolder();
+ return (Item) attachmentFolder.get();
+ } catch (StorageHubException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
/**
* Gets the item.
@@ -879,7 +933,70 @@ public class StorageHubClientService {
shClient.open(itemId).asItem().setMetadata(new Metadata(mapProperties));
}
+
+ /**
+ * Sets the Folder As Hidden or visible .
+ *
+ * @param itemId the folder id
+ * @param hide true to set hide, false to set visible
+ * @throws Exception the exception
+ */
+ public void setFolderAsHidden(String folderId, boolean hide) throws Exception {
+ Validate.notNull(folderId, "Bad request to setFolderAsHidden the folderId is null");
+ setContextProviders(scope, authorizationToken);
+ FolderContainer folderContainer = shClient.open(folderId).asFolder();
+ if (hide)
+ folderContainer.setHidden(); //will not appear in the workspace GUI
+ else
+ folderContainer.setVisible(); //will appear in the workspace GUI
+ }
+
+ /**
+ *
+ * @param folderId the folder id to share
+ * @param users the users to share
+ * @param type the permission
+ */
+ public WorkspaceSharedFolder shareFolder(String folderId, Set users, ACLType type) throws Exception {
+ Validate.notNull(folderId, "Bad request to setFolderAsHidden the folderId is null");
+ setContextProviders(scope, authorizationToken);
+ AccessType acType;
+ switch (type) {
+ case READ_ONLY:
+ acType = AccessType.READ_ONLY;
+ break;
+ case ADMINISTRATOR:
+ acType = AccessType.ADMINISTRATOR;
+ break;
+ case WRITE_ALL:
+ acType = AccessType.WRITE_ALL;
+ break;
+ case WRITE_OWNER:
+ acType = AccessType.WRITE_OWNER;
+ break;
+ case NONE:
+ acType = null;
+ break;
+ default:
+ acType = AccessType.WRITE_OWNER;
+ break;
+ }
+ FolderContainer fContainer = shClient.open(folderId).asFolder().share(users, acType);
+ return HLMapper.toWorkspaceItem(fContainer.get());
+ }
+
+ /**
+ *
+ * @param folderId the folder id to share
+ * @param users the users to share
+ */
+ public WorkspaceSharedFolder unshareFolder(String folderId, Set users) throws Exception {
+ Validate.notNull(folderId, "Bad request to setFolderAsHidden the folderId is null");
+ setContextProviders(scope, authorizationToken);
+ FolderContainer fContainer = shClient.open(folderId).asFolder().unshare(users);
+ return HLMapper.toWorkspaceItem(fContainer.get());
+ }
/**
* Adds the URL.
diff --git a/src/main/java/org/gcube/common/storagehubwrapper/server/WorkspaceStorageHubClientService.java b/src/main/java/org/gcube/common/storagehubwrapper/server/WorkspaceStorageHubClientService.java
index 7a8c767..745151f 100644
--- a/src/main/java/org/gcube/common/storagehubwrapper/server/WorkspaceStorageHubClientService.java
+++ b/src/main/java/org/gcube/common/storagehubwrapper/server/WorkspaceStorageHubClientService.java
@@ -11,6 +11,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.apache.commons.lang.Validate;
import org.gcube.common.storagehub.client.StreamDescriptor;
@@ -25,7 +26,9 @@ import org.gcube.common.storagehub.model.items.nodes.accounting.AccountEntry;
import org.gcube.common.storagehub.model.service.Version;
import org.gcube.common.storagehubwrapper.server.converter.HLMapper;
import org.gcube.common.storagehubwrapper.server.tohl.Workspace;
+import org.gcube.common.storagehubwrapper.shared.ACLType;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
+import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
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;
@@ -345,6 +348,33 @@ public final class WorkspaceStorageHubClientService implements Workspace{
return toChildren;
}
+
+ /**
+ * Gets the children.
+ *
+ * @param id the id
+ * @return the children
+ * @throws Exception the exception
+ */
+ /* (non-Javadoc)
+ * @see org.gcube.portal.storagehubwrapper.shared.tohl.Workspace#getChildren(java.lang.String)
+ */
+ public List extends WorkspaceItem> getChildren(String id, boolean includeHidden)throws Exception{
+
+ LOGGER.debug("called get Children include hidden");
+ Validate.notNull(id,"The input id is null");
+ List extends Item> children = storageHubClientService.getChildren(id, withAccounting, withMapProperties, includeHidden);
+ List toChildren = new ArrayList(children.size());
+
+ for (Item item : children) {
+ WorkspaceItem child = HLMapper.toWorkspaceItem(item, withAccounting, withFileDetails, withMapProperties);
+ toChildren.add(child);
+ }
+
+ return toChildren;
+ }
+
+
/**
* Gets the filtered children.
*
@@ -523,6 +553,23 @@ public final class WorkspaceStorageHubClientService implements Workspace{
return workspaceItem;
}
+ @Override
+ public WorkspaceItem getItemByPath(String folderId, String relativePath) throws ItemNotFoundException, InternalErrorException, Exception {
+ LOGGER.debug("called get getItemByPath");
+ Validate.notNull(folderId,"The input folderId is null");
+ Item item;
+ try {
+ item = storageHubClientService.getItemByPath(folderId, relativePath);
+ }
+ catch (Exception e) {
+ LOGGER.error("Error during get item with id: "+folderId,e);
+ throw new InternalErrorException(e.getMessage());
+ }
+ WorkspaceItem workspaceItem = HLMapper.toWorkspaceItem(item, withAccounting, withFileDetails, withMapProperties);
+ setIsRoot((org.gcube.common.storagehubwrapper.shared.tohl.impl.WorkspaceItem) workspaceItem);
+ return workspaceItem;
+ }
+
/**
* Gets the item. This call is the same of {@link WorkspaceStorageHubClientService#getItem(String, boolean, boolean, boolean)}
* except to getRoot called inside (to check if an item is root or not). {@link WorkspaceItem#isRoot()} returns always false.
@@ -666,7 +713,6 @@ public final class WorkspaceStorageHubClientService implements Workspace{
public boolean exists(String name, String folderId)
throws InternalErrorException, ItemNotFoundException,
WrongItemTypeException {
-
LOGGER.debug("called exists");
List foundItems = find(name, folderId);
@@ -691,7 +737,7 @@ public final class WorkspaceStorageHubClientService implements Workspace{
throws InternalErrorException, ItemNotFoundException,
WrongItemTypeException {
- LOGGER.debug("called find");
+ LOGGER.debug("called find ");
Validate.notNull(folderId,"The input folderid is null");
try {
List extends Item> items = storageHubClientService.findByName(name, folderId);
@@ -1513,4 +1559,22 @@ public final class WorkspaceStorageHubClientService implements Workspace{
return updatedDescription;
}
+
+ @Override
+ public void setFolderAsHidden(String folderId, boolean hide) throws Exception {
+ storageHubClientService.setFolderAsHidden(folderId, hide);
+ }
+
+
+ @Override
+ public WorkspaceSharedFolder shareFolder(String folderId, Set users, ACLType type) throws Exception {
+ return storageHubClientService.shareFolder(folderId, users, type);
+ }
+
+
+ @Override
+ public WorkspaceSharedFolder unshareFolder(String folderId, Set users) throws Exception {
+ return storageHubClientService.unshareFolder(folderId, users);
+ }
+
}
diff --git a/src/main/java/org/gcube/common/storagehubwrapper/server/tohl/Workspace.java b/src/main/java/org/gcube/common/storagehubwrapper/server/tohl/Workspace.java
index 67e8760..ba35d98 100644
--- a/src/main/java/org/gcube/common/storagehubwrapper/server/tohl/Workspace.java
+++ b/src/main/java/org/gcube/common/storagehubwrapper/server/tohl/Workspace.java
@@ -7,12 +7,15 @@ import java.io.InputStream;
import java.net.URL;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.gcube.common.storagehub.model.items.Item;
import org.gcube.common.storagehub.model.items.nodes.accounting.AccountEntry;
import org.gcube.common.storagehubwrapper.server.WorkspaceStorageHubClientService;
+import org.gcube.common.storagehubwrapper.shared.ACLType;
import org.gcube.common.storagehubwrapper.shared.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.exceptions.InsufficientPrivilegesException;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.ItemAlreadyExistException;
@@ -55,13 +58,23 @@ public interface Workspace {
public WorkspaceFolder getRoot() throws InternalErrorException, Exception;
/**
- * Gets the children.
+ * Gets the children not including the ones marked as hidden.
*
* @param id the id
* @return the children
* @throws Exception the exception
*/
public List extends WorkspaceItem> getChildren(String id) throws Exception;
+
+ /**
+ * Gets the children including the ones marked as hidden if the bool param is true.
+ *
+ * @param id the id
+ * @param hidden true to return also the hidden ones
+ * @return the children
+ * @throws Exception the exception
+ */
+ public List extends WorkspaceItem> getChildren(String id, boolean includeHidden) throws Exception;
/**
* Gets the parents by id.
@@ -99,6 +112,19 @@ public interface Workspace {
public WorkspaceItem getItem(String itemId, boolean withAccounting, boolean withFileDetails,
boolean withMapProperties) throws ItemNotFoundException, InternalErrorException, Exception;
+ /**
+ *
+ * @param idFolder
+ * @param relativePath
+ * @return the item.
+ * @throws ItemNotFoundException if the item has not been found.
+ * @throws InternalErrorException the internal error exception
+ * @throws Exception the exception
+ */
+ public WorkspaceItem getItemByPath(String idFolder, String relativePath) throws ItemNotFoundException, InternalErrorException, Exception;
+
+
+
/**
* Create a new folder with specified name. The new folder is created into the
* specified folder.
@@ -591,5 +617,27 @@ public interface Workspace {
*/
public String updateDescriptionForItem(String itemId, String newDescription) throws Exception;
-
+ /**
+ * Sets the Folder As Hidden or visible .
+ *
+ * @param folderId the folder id to set as hidden
+ * @param hide true to set hide, false to set visible
+ * @throws Exception the exception
+ */
+ public void setFolderAsHidden(String folderId, boolean hide) throws Exception;
+ /**
+ *
+ * @param folderId the folder id to share
+ * @param users the Set of users to share
+ * @param type the permission
+ */
+ public WorkspaceSharedFolder shareFolder(String folderId, Set users, ACLType type) throws Exception;
+
+ /**
+ *
+ * @param folderId the folder id to share
+ * @param users the Set of users to share
+ * @param type the permission
+ */
+ public WorkspaceSharedFolder unshareFolder(String folderId, Set users) throws Exception;
}