added method getRootSharedFolder
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/storagehub-client-wrapper@169592 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
2d61766e16
commit
19d2937aee
4
.project
4
.project
|
@ -16,12 +16,12 @@
|
|||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
disabled=06target
|
||||
eclipse.preferences.version=1
|
|
@ -135,23 +135,40 @@ public class StorageHubClientService {
|
|||
|
||||
//TODO MAP OF SHARED ROOT ID
|
||||
|
||||
|
||||
/**
|
||||
* Gets the parents.
|
||||
* Gets the id shared folder.
|
||||
*
|
||||
* @param itemId the item id
|
||||
* @return the parents
|
||||
* @return the id shared folder
|
||||
* @throws Exception
|
||||
*/
|
||||
public String getIdSharedFolder(String itemId) {
|
||||
public String getIdSharedFolder(String itemId) throws Exception {
|
||||
setContextProviders(scope, authorizationToken);
|
||||
FolderContainer rootSharedFolder = shcClient.open(itemId).asItem().getRootSharedFolder();
|
||||
try{
|
||||
Validate.notNull(rootSharedFolder, "The root shared folder with id "+itemId+" does not exist");
|
||||
return rootSharedFolder.get().getId();
|
||||
}catch(Exception e){
|
||||
return getRootSharedFolder(itemId).getId();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
/**
|
||||
* Gets the root shared folder.
|
||||
*
|
||||
* @param itemId the item id
|
||||
* @return the root shared folder
|
||||
* @throws Exception
|
||||
*/
|
||||
public FolderItem getRootSharedFolder(String itemId) throws Exception {
|
||||
setContextProviders(scope, authorizationToken);
|
||||
|
||||
ItemContainer<Item> item = shcClient.open(itemId).asItem();
|
||||
FolderContainer rootSharedFolder = null;
|
||||
if(item.get().isShared()){
|
||||
rootSharedFolder = item.getRootSharedFolder();
|
||||
}else
|
||||
throw new Exception("The item with id: "+itemId +" is not shared");
|
||||
|
||||
Validate.notNull(rootSharedFolder, "The root shared folder with id "+itemId+" does not exist");
|
||||
return rootSharedFolder.get();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -189,7 +206,8 @@ public class StorageHubClientService {
|
|||
return null;
|
||||
}
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Get VRE Folders Id ",e);
|
||||
//e.printStackTrace();
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue