Class FolderContainer

java.lang.Object
org.gcube.common.storagehub.client.dsl.ItemContainer<org.gcube.common.storagehub.model.items.FolderItem>
org.gcube.common.storagehub.client.dsl.FolderContainer

public class FolderContainer extends ItemContainer<org.gcube.common.storagehub.model.items.FolderItem>
  • Constructor Details

    • FolderContainer

      protected FolderContainer(ItemManagerClient itemclient, org.gcube.common.storagehub.model.items.FolderItem item)
    • FolderContainer

      protected FolderContainer(ItemManagerClient itemclient, String folderId)
  • Method Details

    • getType

      public ContainerType getType()
      Specified by:
      getType in class ItemContainer<org.gcube.common.storagehub.model.items.FolderItem>
    • list

      public ListResolverTyped list() throws org.gcube.common.storagehub.model.exceptions.StorageHubException
      returns the children of this FolderContainer By default this method return all FolderContainers (asContainers) or Items (asItems) without accounting data, content data and metadata of the item to add these information see ListResolverTyped
      Returns:
      ListResolverTyped
      Throws:
      org.gcube.common.storagehub.model.exceptions.StorageHubException - if user is not authorized to read this folder or the item is invalid
    • uploadFile

      public FileContainer uploadFile(InputStream stream, String filename, String description) throws org.gcube.common.storagehub.model.exceptions.StorageHubException
      creates a AbstractFileItem inside the folder represented by this FolderContainer
      Parameters:
      stream - the file stream
      filename - the name of the item in the workspace
      description - the description of the item in the workspace
      Returns:
      FileContainer of the Item created
      Throws:
      org.gcube.common.storagehub.model.exceptions.StorageHubException - if user is not authorized to write in this folder or the item is invalid
    • uploadFile

      public FileContainer uploadFile(InputStream stream, String filename, String description, long size) throws org.gcube.common.storagehub.model.exceptions.StorageHubException
      creates a AbstractFileItem inside the folder represented by this FolderContainer
      Parameters:
      stream - the file stream
      filename - the name of the item in the workspace
      description - the description of the item in the workspace
      size - the size of the stream in Bytes
      Returns:
      FileContainer of the Item created
      Throws:
      org.gcube.common.storagehub.model.exceptions.StorageHubException - if user is not authorized to write in this folder or the item is invalid
    • uploadFile

      public FileContainer uploadFile(File file, String description) throws org.gcube.common.storagehub.model.exceptions.StorageHubException
      creates a AbstractFileItem inside the folder represented by this FolderContainer
      Parameters:
      file - the file
      description - the description of the item in the workspace
      Returns:
      FileContainer of the Item created
      Throws:
      org.gcube.common.storagehub.model.exceptions.StorageHubException - if user is not authorized to write in this folder or the item is invalid
    • uploadFile

      public FileContainer uploadFile(URI uri, String name, String description) throws org.gcube.common.storagehub.model.exceptions.StorageHubException
      creates a AbstractFileItem inside the folder represented by this FolderContainer
      Parameters:
      uri - URI of the file
      name - the name of the item in the workspace
      description - the description of the item in the workspace
      Returns:
      FileContainer of the Item created
      Throws:
      org.gcube.common.storagehub.model.exceptions.StorageHubException - if user is not authorized to write in this folder or the item is invalid
    • addUrl

      public URLContainer addUrl(URL url, String name, String description) throws org.gcube.common.storagehub.model.exceptions.StorageHubException
      creates an ExternalLink inside the folder represented by this FolderContainer
      Parameters:
      url - the url
      name - the name of the item in the workspace
      description - the description of the item in the workspace
      Returns:
      URLContainer of the Item created
      Throws:
      org.gcube.common.storagehub.model.exceptions.StorageHubException - if user is not authorized to write in this folder or the item is invalid
    • uploadArchive

      public FolderContainer uploadArchive(InputStream stream, String extractionFolderName) throws org.gcube.common.storagehub.model.exceptions.StorageHubException
      creates a set of Items in the workspace extracting the Archive
      Parameters:
      stream - the file stream
      extractionFolderName - the root name of the folder where the archive will be extracted (A new folder with this name will be created)
      Returns:
      FolderContainer of the extraction Folder
      Throws:
      org.gcube.common.storagehub.model.exceptions.StorageHubException - if user is not authorized to write in this folder or the item is invalid
    • uploadArchive

      public FolderContainer uploadArchive(InputStream stream, String extractionFolderName, long size) throws org.gcube.common.storagehub.model.exceptions.StorageHubException
      creates a set of Items in the workspace extracting the Archive
      Parameters:
      stream - the file stream
      extractionFolderName - the root name of the folder where the archive will be extracted (A new folder with this name will be created)
      Returns:
      FolderContainer of the extraction Folder
      Throws:
      org.gcube.common.storagehub.model.exceptions.StorageHubException - if user is not authorized to write in this folder or the item is invalid
    • newFolder

      public FolderContainer newFolder(String name, String description) throws org.gcube.common.storagehub.model.exceptions.StorageHubException
      create a new FolderItem inside the FolderItem represented by this FolderContainer
      Parameters:
      name - the name of the folder
      description - the description of the folder
      Returns:
      the FolderContainer representing the new folder
      Throws:
      org.gcube.common.storagehub.model.exceptions.StorageHubException - if user is not authorized to write in this folder or the item is invalid
    • newExternalFolder

      public FolderContainer newExternalFolder(String name, String description, boolean hidden, String storageName, org.gcube.common.storagehub.model.plugins.PluginParameters storageParameters) throws org.gcube.common.storagehub.model.exceptions.StorageHubException
      create a new FolderItem inside the FolderItem represented by this FolderContainer
      Parameters:
      name - the name of the folder
      description - the description of the folder
      Returns:
      the FolderContainer representing the new folder
      Throws:
      org.gcube.common.storagehub.model.exceptions.StorageHubException - if user is not authorized to write in this folder or the item is invalid
    • newHiddenFolder

      public FolderContainer newHiddenFolder(String name, String description) throws org.gcube.common.storagehub.model.exceptions.StorageHubException
      create a new hidden FolderItem inside the folder represented by this FolderContainer
      Parameters:
      name - the name of the folder
      description - the description of the folder
      Returns:
      the FolderContainer representing the new folder
      Throws:
      org.gcube.common.storagehub.model.exceptions.StorageHubException - if user is not authorized to write in this folder or the item is invalid
    • newGcubeItem

      public GenericItemContainer newGcubeItem(org.gcube.common.storagehub.model.items.GCubeItem item) throws org.gcube.common.storagehub.model.exceptions.StorageHubException
      create a new hidden Folder inside the folder represented by this FolderContainer
      Parameters:
      item - the GCubeItem to create
      Returns:
      the FolderContainer representing the new folder
      Throws:
      org.gcube.common.storagehub.model.exceptions.StorageHubException - if user is not authorized to write in this folder or the item is invalid
    • getAcls

      public List<org.gcube.common.storagehub.model.acls.ACL> getAcls() throws org.gcube.common.storagehub.model.exceptions.StorageHubException
      returns the ACL of the FolderItem represented by this FolderContainer
      Returns:
      a List of ACL
      Throws:
      org.gcube.common.storagehub.model.exceptions.StorageHubException - if retrieval fails
    • changeAcls

      public FolderContainer changeAcls(String user, org.gcube.common.storagehub.model.acls.AccessType accessType) throws org.gcube.common.storagehub.model.exceptions.StorageHubException
      changes ACL of the FolderItem represented by this FolderContainer for a user
      Returns:
      the FolderContainer
      Throws:
      org.gcube.common.storagehub.model.exceptions.StorageHubException - if user is not administrator of this folder or the item is invalid
    • canWrite

      public boolean canWrite() throws Exception
      Throws:
      Exception
    • findByName

      public ListResolver findByName(String namePattern) throws org.gcube.common.storagehub.model.exceptions.StorageHubException
      returns the children of this FolderContainer that matches the name pattern
      Returns:
      ListResolver
      Throws:
      org.gcube.common.storagehub.model.exceptions.StorageHubException - if user is not authorized to read this folder or the item is invalid
    • openByRelativePath

      public OpenResolver openByRelativePath(String relativePath) throws org.gcube.common.storagehub.model.exceptions.StorageHubException
      returns the children of this FolderContainer that matches the name pattern
      Returns:
      ListResolver
      Throws:
      org.gcube.common.storagehub.model.exceptions.StorageHubException - if user is not authorized to read this folder or the item is invalid
    • search

      public ListResolver search(String nameTomatch, boolean excludeTrashed) throws org.gcube.common.storagehub.model.exceptions.StorageHubException
      returns the items that matches the name pattern searching recursively on all subfolders filtering the trashed Items
      Returns:
      ListResolver
      Throws:
      org.gcube.common.storagehub.model.exceptions.StorageHubException - if user is not authorized to read this folder or the item is invalid
    • search

      public ListResolver search(String nameTomatch) throws org.gcube.common.storagehub.model.exceptions.StorageHubException
      returns the items that matches the name pattern searching recursively on all subfolders
      Returns:
      ListResolver
      Throws:
      org.gcube.common.storagehub.model.exceptions.StorageHubException - if user is not authorized to read this folder or the item is invalid
    • share

      public FolderContainer share(Set<String> users, org.gcube.common.storagehub.model.acls.AccessType accessType) throws org.gcube.common.storagehub.model.exceptions.StorageHubException
      shares this Folder with a list of users setting the same AccessType for everyone in the list. if the folder is already shared it add the users to the share.
      Returns:
      the current FolderContainer updated
      Throws:
      org.gcube.common.storagehub.model.exceptions.StorageHubException - if user is not authorized to share this folder or the item is invalid
    • unshare

      public FolderContainer unshare(Set<String> users) throws Exception
      remove share from this Folder for a list of users, for everyone or only for the caller. Is applicable only on SharedFolder. if users is empty or null unshare the entire folder for everyone. if users contains only the caller login the folder is removed only for him.
      Returns:
      the current FolderContainer updated
      Throws:
      Exception - if this folder is not shared or the user is not authorized to unshare this folder
    • unpublish

      public FolderContainer unpublish() throws Exception
      unpublish this Folder.
      Returns:
      the current FolderContainer updated
      Throws:
      Exception - if this is not a Folder or the user is not authorized to unpublish this folder
    • publish

      public FolderContainer publish() throws Exception
      makes this Folder public.
      Returns:
      the current FolderContainer updated
      Throws:
      Exception - if this is not a Folder or the user is not authorized to publish this folder
    • info

      public org.gcube.common.storagehub.model.types.FolderInfoType info() throws Exception, org.gcube.common.storagehub.model.exceptions.InvalidCallParameters, org.gcube.common.storagehub.model.exceptions.UserNotAuthorizedException
      retrieve the folder info (item count and size)
      Returns:
      the FolderInfoType
      Throws:
      Exception - if this is not a Folder or the user is not authorized to get the info
      org.gcube.common.storagehub.model.exceptions.InvalidCallParameters
      org.gcube.common.storagehub.model.exceptions.UserNotAuthorizedException