Class StorageHubClientService
- java.lang.Object
-
- org.gcube.common.storagehubwrapper.server.StorageHubClientService
-
public class StorageHubClientService extends Object
The Class StorageHubClientService.- Author:
- Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) Nov 22, 2018
-
-
Field Summary
Fields Modifier and Type Field Description static StringACCOUNTING_HL_NODE_NAMEThe Constant ACCOUNTING_HL_NODE_NAME.
-
Constructor Summary
Constructors Constructor Description StorageHubClientService(String scope, String authorizationToken)Instantiates a new storage hub service util.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.gcube.common.storagehub.model.items.ExternalLinkaddURL(String folderId, URL URL, String name, String description)Adds the URL.booleancanWrite(String folderContainerId)Can write.org.gcube.common.storagehub.model.items.AbstractFileItemcopyFileItem(String fileItemId, org.gcube.common.storagehub.client.dsl.FolderContainer destFolderContainer, String newFileName)Copy item.org.gcube.common.storagehub.model.items.ItemcreateFolder(String parentId, String folderName, String folderDescription)Creates the folder.voiddeleteItemById(String itemId)Delete item by id.org.gcube.common.storagehub.client.StreamDescriptordownloadFile(String itemId, String versionName, String... nodeIdsToExclude)Download file.org.gcube.common.storagehub.client.StreamDescriptordownloadFolder(String folderId, String nodeIdsToExclude)Download folder.voidemptyTrash()Empty trash.List<? extends org.gcube.common.storagehub.model.items.Item>findByName(String name, String folderId)Find by name.org.gcube.common.storagehub.model.items.nodes.AccountinggetAccounting(String itemId)Gets the accounting.List<? extends org.gcube.common.storagehub.model.items.Item>getChildren(String id, boolean withAccounting, boolean withMapProperties)Gets the children.List<? extends org.gcube.common.storagehub.model.items.Item>getChildren(String id, boolean withAccounting, boolean withMapProperties, boolean includeHidden)Gets the children.longgetDiskUsage()Gets the disk usage.List<? extends org.gcube.common.storagehub.model.items.Item>getFilteredChildren(String id, Class<? extends org.gcube.common.storagehub.model.items.Item> aType, boolean withAccounting, boolean withMapProperties)Gets the filtered children.org.gcube.common.storagehub.client.dsl.FolderContainergetFolderContainer(String itemId)Gets the folder container.org.gcube.common.storagehub.model.MetadatagetGcubeItemProperties(String gcubeItemId)Gets the gcube item properties.StringgetIdSharedFolder(String itemId)Gets the id shared folder.org.gcube.common.storagehub.model.items.nodes.ImageContentgetImageContent(String itemId)Gets the image content.org.gcube.common.storagehub.model.items.ItemgetItem(String itemId)Gets the item.org.gcube.common.storagehub.model.items.ItemgetItem(String itemId, boolean withAccounting, boolean withMetadata)Gets the item.org.gcube.common.storagehub.model.items.ItemgetItemByPath(String folderId, String relativePath)Gets the item by path.intgetItemChildrenCount(String itemId)Gets the item children count.List<org.gcube.common.storagehub.model.service.Version>getListVersions(String fileItemId)Gets the list versions.Map<String,Object>getMetadata(String itemId)Gets the metadata.List<? extends org.gcube.common.storagehub.model.items.Item>getParents(String itemId)Gets the parents.URLgetPublicLinkForFile(String fileItemId)Gets the file public link.URLgetPublicLinkForFileVersion(String fileItemId, String version)Gets the public link for file version.org.gcube.common.storagehub.model.items.FolderItemgetRoot()Gets the root.org.gcube.common.storagehub.model.items.FolderItemgetRootSharedFolder(String itemId)Gets the root shared folder.org.gcube.common.storagehub.model.items.FolderItemgetRootSharedFolder(org.gcube.common.storagehub.client.dsl.ItemContainer<org.gcube.common.storagehub.model.items.Item> itemContainer)Gets the root shared folder.static StringgetScopeFromVREGroupName(String context, String infrastructurName, String vreName)List<Member>getSharedFolderMembers(String folderId)Gets the shared folder members.longgetTotalItems()Gets the total items.org.gcube.common.storagehub.model.items.ItemgetTrash()Gets the root.StringgetUserACLForFolderId(String infrastructureName, String userName, String folderId)Gets the user acl for folder id.StringgetVREFoldersId()Gets the VRE folders id.booleanisItemShared(String itemId)Checks if is item shared.org.gcube.common.storagehub.model.items.ItemmoveItem(String itemId, org.gcube.common.storagehub.client.dsl.FolderContainer destFolderContainer)Move item.org.gcube.common.storagehub.model.items.ItemopenTrash()Open trash.org.gcube.common.storagehub.model.items.ItemrenameItem(String itemId, String newName)Rename item.org.gcube.common.storagehub.model.items.ItemrestoreThrashItem(String itemId, String destinationFolderId)Restore thrash item.List<? extends org.gcube.common.storagehub.model.items.Item>searchForText(String text, String folderId)Search for text.voidsetFolderAsHidden(String folderId, boolean hide)Sets the Folder As Hidden or visible .booleansetFolderAsPublic(String folderId, boolean setPublic)Sets the folder as public.voidsetMetadata(String itemId, Map<String,Object> mapProperties)Sets the metadata.org.gcube.common.storagehub.model.items.ItemsetMetadata(String itemId, org.gcube.common.storagehub.model.Metadata metadata)Sets the metadata and returns the Item with metadata updated.WorkspaceSharedFoldershareFolder(String folderId, Set<String> users, ACLType type)Share folder.StringtoString()To string.WorkspaceSharedFolderunshareFolder(String folderId, Set<String> users)Unshare folder.StringupdateDescriptionForItem(String itemId, String newDescription)Update description for item.org.gcube.common.storagehub.model.items.ItemuploadArchive(String folderId, InputStream is, String extractionFolderName, Long fileSize)Upload archive.org.gcube.common.storagehub.model.items.ItemuploadFile(String folderId, InputStream is, String fileName, String fileDescription, Long fileSize)Upload file.
-
-
-
Field Detail
-
ACCOUNTING_HL_NODE_NAME
public static final String ACCOUNTING_HL_NODE_NAME
The Constant ACCOUNTING_HL_NODE_NAME.- See Also:
- Constant Field Values
-
-
Method Detail
-
getRoot
public org.gcube.common.storagehub.model.items.FolderItem getRoot() throws ExceptionGets the root.- Returns:
- the root
- Throws:
Exception- the exception
-
getTrash
public org.gcube.common.storagehub.model.items.Item getTrash()
Gets the root.- Returns:
- the root
-
getChildren
public List<? extends org.gcube.common.storagehub.model.items.Item> getChildren(String id, boolean withAccounting, boolean withMapProperties) throws Exception
Gets the children.- Parameters:
id- the idwithAccounting- the with accountingwithMapProperties- the with map properties- Returns:
- the children
- Throws:
Exception- the exception
-
getChildren
public List<? extends org.gcube.common.storagehub.model.items.Item> getChildren(String id, boolean withAccounting, boolean withMapProperties, boolean includeHidden) throws Exception
Gets the children.- Parameters:
id- the idwithAccounting- the with accountingwithMapProperties- the with map propertiesincludeHidden- the include hidden- Returns:
- the children
- Throws:
Exception- the exception
-
getFilteredChildren
public List<? extends org.gcube.common.storagehub.model.items.Item> getFilteredChildren(String id, Class<? extends org.gcube.common.storagehub.model.items.Item> aType, boolean withAccounting, boolean withMapProperties) throws Exception
Gets the filtered children.- Parameters:
id- the idaType- the a typewithAccounting- the with accountingwithMapProperties- the with map properties- Returns:
- the filtered children
- Throws:
Exception- the exception
-
getItem
public org.gcube.common.storagehub.model.items.Item getItem(String itemId, boolean withAccounting, boolean withMetadata) throws Exception
Gets the item.- Parameters:
itemId- the item idwithAccounting- the with accountingwithMetadata- the with metadata- Returns:
- the item
- Throws:
Exception- the exception
-
getItemByPath
public org.gcube.common.storagehub.model.items.Item getItemByPath(String folderId, String relativePath) throws Exception
Gets the item by path.- Parameters:
folderId- the folder idrelativePath- the relative path- Returns:
- the item by path
- Throws:
Exception- the exception
-
getItem
public org.gcube.common.storagehub.model.items.Item getItem(String itemId) throws Exception
Gets the item.- Parameters:
itemId- the item id- Returns:
- the item
- Throws:
Exception- the exception
-
setMetadata
public org.gcube.common.storagehub.model.items.Item setMetadata(String itemId, org.gcube.common.storagehub.model.Metadata metadata) throws Exception
Sets the metadata and returns the Item with metadata updated.- Parameters:
itemId- the item idmetadata- the metadata- Returns:
- the item
- Throws:
Exception- the exception
-
getMetadata
public Map<String,Object> getMetadata(String itemId) throws Exception
Gets the metadata.- Parameters:
itemId- the item id- Returns:
- the metadata
- Throws:
Exception- the exception
-
getFolderContainer
public org.gcube.common.storagehub.client.dsl.FolderContainer getFolderContainer(String itemId) throws Exception
Gets the folder container.- Parameters:
itemId- the item id- Returns:
- the folder container
- Throws:
Exception- the exception
-
getParents
public List<? extends org.gcube.common.storagehub.model.items.Item> getParents(String itemId) throws Exception
Gets the parents.- Parameters:
itemId- the item id- Returns:
- the parents
- Throws:
Exception- the exception
-
getIdSharedFolder
public String getIdSharedFolder(String itemId) throws Exception
Gets the id shared folder.- Parameters:
itemId- the item id- Returns:
- the id shared folder
- Throws:
Exception- the exception
-
getRootSharedFolder
public org.gcube.common.storagehub.model.items.FolderItem getRootSharedFolder(String itemId) throws Exception
Gets the root shared folder.- Parameters:
itemId- the item id- Returns:
- the root shared folder
- Throws:
Exception- the exception
-
isItemShared
public boolean isItemShared(String itemId) throws Exception
Checks if is item shared.- Parameters:
itemId- the item id- Returns:
- true, if is item shared
- Throws:
Exception- the exception
-
canWrite
public boolean canWrite(String folderContainerId) throws Exception
Can write.- Parameters:
folderContainerId- the folder container id- Returns:
- true, if true. Otherwise false.
- Throws:
Exception- the exception
-
getRootSharedFolder
public org.gcube.common.storagehub.model.items.FolderItem getRootSharedFolder(org.gcube.common.storagehub.client.dsl.ItemContainer<org.gcube.common.storagehub.model.items.Item> itemContainer) throws ExceptionGets the root shared folder.- Parameters:
itemContainer- the item container- Returns:
- the root shared folder
- Throws:
Exception- the exception
-
createFolder
public org.gcube.common.storagehub.model.items.Item createFolder(String parentId, String folderName, String folderDescription) throws Exception
Creates the folder.- Parameters:
parentId- the parent idfolderName- the folder namefolderDescription- the folder description- Returns:
- the item
- Throws:
Exception- the exception
-
getVREFoldersId
public String getVREFoldersId()
Gets the VRE folders id.- Returns:
- the VRE folders id
-
getUserACLForFolderId
public String getUserACLForFolderId(String infrastructureName, String userName, String folderId) throws Exception
Gets the user acl for folder id.- Parameters:
infrastructureName- the infrastructure nameuserName- the user namefolderId- the folder id- Returns:
- the user acl for folder id
- Throws:
Exception- the exception
-
getItemChildrenCount
public int getItemChildrenCount(String itemId) throws Exception
Gets the item children count.- Parameters:
itemId- the item id- Returns:
- the item children count
- Throws:
Exception- the exception
-
uploadFile
public org.gcube.common.storagehub.model.items.Item uploadFile(String folderId, InputStream is, String fileName, String fileDescription, Long fileSize) throws Exception
Upload file.- Parameters:
folderId- the folder idis- the isfileName- the file namefileDescription- the file descriptionfileSize- the file size- Returns:
- the item
- Throws:
Exception- the exception
-
downloadFile
public org.gcube.common.storagehub.client.StreamDescriptor downloadFile(String itemId, String versionName, String... nodeIdsToExclude) throws Exception
Download file.- Parameters:
itemId- the item idversionName- the version name. If is null or empty returns the latest version of filenodeIdsToExclude- the node ids to exclude- Returns:
- the stream descriptor
- Throws:
Exception- the exception
-
downloadFolder
public org.gcube.common.storagehub.client.StreamDescriptor downloadFolder(String folderId, String nodeIdsToExclude) throws Exception
Download folder.- Parameters:
folderId- the folder idnodeIdsToExclude- the node ids to exclude- Returns:
- the stream descriptor
- Throws:
Exception- the exception
-
uploadArchive
public org.gcube.common.storagehub.model.items.Item uploadArchive(String folderId, InputStream is, String extractionFolderName, Long fileSize) throws Exception
Upload archive.- Parameters:
folderId- the folder idis- the isextractionFolderName- the extraction folder namefileSize- the file size- Returns:
- the item
- Throws:
Exception- the exception
-
getSharedFolderMembers
public List<Member> getSharedFolderMembers(String folderId) throws Exception
Gets the shared folder members.- Parameters:
folderId- the folder id- Returns:
- the shared folder members
- Throws:
Exception- the exception
-
getScopeFromVREGroupName
public static String getScopeFromVREGroupName(String context, String infrastructurName, String vreName)
-
findByName
public List<? extends org.gcube.common.storagehub.model.items.Item> findByName(String name, String folderId) throws Exception
Find by name.- Parameters:
name- the namefolderId- the folder id- Returns:
- the list extends item>
- Throws:
Exception- the exception
-
searchForText
public List<? extends org.gcube.common.storagehub.model.items.Item> searchForText(String text, String folderId) throws Exception
Search for text.- Parameters:
text- the textfolderId- the folder id- Returns:
- the list extends item>
- Throws:
Exception- the exception
-
deleteItemById
public void deleteItemById(String itemId) throws Exception
Delete item by id.- Parameters:
itemId- the item id- Throws:
Exception- the exception
-
openTrash
public org.gcube.common.storagehub.model.items.Item openTrash() throws ExceptionOpen trash.- Returns:
- the item
- Throws:
Exception- the exception
-
restoreThrashItem
public org.gcube.common.storagehub.model.items.Item restoreThrashItem(String itemId, String destinationFolderId) throws Exception
Restore thrash item.- Parameters:
itemId- the item iddestinationFolderId- the destination folder id- Returns:
- the item
- Throws:
Exception- the exception
-
moveItem
public org.gcube.common.storagehub.model.items.Item moveItem(String itemId, org.gcube.common.storagehub.client.dsl.FolderContainer destFolderContainer) throws Exception
Move item.- Parameters:
itemId- the item iddestFolderContainer- the dest folder container- Returns:
- the abstract file item
- Throws:
Exception- the exception
-
copyFileItem
public org.gcube.common.storagehub.model.items.AbstractFileItem copyFileItem(String fileItemId, org.gcube.common.storagehub.client.dsl.FolderContainer destFolderContainer, String newFileName) throws Exception
Copy item.- Parameters:
fileItemId- the copy item iddestFolderContainer- the dest folder containernewFileName- the new file name- Returns:
- the abstract file item
- Throws:
Exception- the exception
-
renameItem
public org.gcube.common.storagehub.model.items.Item renameItem(String itemId, String newName) throws Exception
Rename item.- Parameters:
itemId- the item idnewName- the new name- Returns:
- the item
- Throws:
Exception- the exception
-
getPublicLinkForFile
public URL getPublicLinkForFile(String fileItemId) throws Exception
Gets the file public link.- Parameters:
fileItemId- the file item id- Returns:
- the file public link
- Throws:
Exception- the exception
-
getPublicLinkForFileVersion
public URL getPublicLinkForFileVersion(String fileItemId, String version) throws Exception
Gets the public link for file version.- Parameters:
fileItemId- the file item idversion- the version- Returns:
- the public link for file version
- Throws:
Exception- the exception
-
getListVersions
public List<org.gcube.common.storagehub.model.service.Version> getListVersions(String fileItemId) throws Exception
Gets the list versions.- Parameters:
fileItemId- the file item id- Returns:
- the list versions
- Throws:
Exception- the exception
-
getImageContent
public org.gcube.common.storagehub.model.items.nodes.ImageContent getImageContent(String itemId) throws Exception
Gets the image content.- Parameters:
itemId- the item id- Returns:
- the image content
- Throws:
Exception- the exception
-
getTotalItems
public long getTotalItems() throws ExceptionGets the total items.- Returns:
- the total items
- Throws:
Exception- the exception
-
getDiskUsage
public long getDiskUsage() throws ExceptionGets the disk usage.- Returns:
- the disk usage
- Throws:
Exception- the exception
-
getAccounting
public org.gcube.common.storagehub.model.items.nodes.Accounting getAccounting(String itemId) throws Exception
Gets the accounting.- Parameters:
itemId- the item id- Returns:
- the accounting
- Throws:
Exception- the exception
-
getGcubeItemProperties
public org.gcube.common.storagehub.model.Metadata getGcubeItemProperties(String gcubeItemId) throws Exception
Gets the gcube item properties.- Parameters:
gcubeItemId- the gcube item id- Returns:
- the gcube item properties
- Throws:
Exception- the exception
-
setMetadata
public void setMetadata(String itemId, Map<String,Object> mapProperties) throws Exception
Sets the metadata.- Parameters:
itemId- the item idmapProperties- the map properties- Throws:
Exception- the exception
-
setFolderAsHidden
public void setFolderAsHidden(String folderId, boolean hide) throws Exception
Sets the Folder As Hidden or visible .- Parameters:
folderId- the folder idhide- true to set hide, false to set visible- Throws:
Exception- the exception
-
shareFolder
public WorkspaceSharedFolder shareFolder(String folderId, Set<String> users, ACLType type) throws Exception
Share folder.- Parameters:
folderId- the folder id to shareusers- the users to sharetype- the permission- Returns:
- the workspace shared folder
- Throws:
Exception- the exception
-
unshareFolder
public WorkspaceSharedFolder unshareFolder(String folderId, Set<String> users) throws Exception
Unshare folder.- Parameters:
folderId- the folder id to shareusers- the users to share- Returns:
- the workspace shared folder
- Throws:
Exception- the exception
-
addURL
public org.gcube.common.storagehub.model.items.ExternalLink addURL(String folderId, URL URL, String name, String description) throws org.gcube.common.storagehub.model.exceptions.StorageHubException
Adds the URL.- Parameters:
folderId- the folder idURL- the urlname- the namedescription- the description- Returns:
- the external link
- Throws:
org.gcube.common.storagehub.model.exceptions.StorageHubException- the storage hub exception
-
setFolderAsPublic
public boolean setFolderAsPublic(String folderId, boolean setPublic) throws Exception
Sets the folder as public.- Parameters:
folderId- the folder idsetPublic- the set public- Returns:
- boolean value of isPublicItem()
- Throws:
Exception- the exception
-
updateDescriptionForItem
public String updateDescriptionForItem(String itemId, String newDescription) throws Exception
Update description for item.- Parameters:
itemId- the item idnewDescription- the new description- Returns:
- the description updated
- Throws:
Exception- the exception
-
-