added method getMetadata

updated changelog

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/storagehub-client-wrapper@174513 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2018-12-03 11:21:17 +00:00
parent 610504689b
commit 2572456fb3
4 changed files with 53 additions and 6 deletions

View File

@ -1,4 +1,9 @@
<ReleaseNotes> <ReleaseNotes>
<Changeset component="org.gcube.common.storagehubwrapper.0-4-0"
date="${buildDate}">
<Change>Updated to new SHub interface</Change>
<Change>Added method getMetadata</Change>
</Changeset>
<Changeset component="org.gcube.common.storagehubwrapper.0-3-0" <Changeset component="org.gcube.common.storagehubwrapper.0-3-0"
date="${buildDate}"> date="${buildDate}">
<Change>[Task #12059] added delete item</Change> <Change>[Task #12059] added delete item</Change>

View File

@ -3,6 +3,7 @@ package org.gcube.common.storagehubwrapper.server;
import java.io.InputStream; import java.io.InputStream;
import java.net.URL; import java.net.URL;
import java.util.List; import java.util.List;
import java.util.Map;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
@ -180,8 +181,6 @@ public class StorageHubClientService {
* Gets the item. * Gets the item.
* *
* @param itemId the item id * @param itemId the item id
* @param withAccounting the with accounting
* @param withMetadata the with metadata
* @return the item * @return the item
* @throws Exception the exception * @throws Exception the exception
*/ */
@ -207,6 +206,25 @@ public class StorageHubClientService {
} }
/**
* Gets the metadata.
*
* @param itemId the item id
* @return the metadata
* @throws Exception the exception
*/
public Map<String, Object> getMetadata(String itemId) throws Exception{
setContextProviders(scope, authorizationToken);
ItemContainer<Item> itemCont = shcClient.open(itemId).asItem();
Metadata metadata = shcClient.open(itemId).asItem().get().getMetadata();
if(metadata!=null)
return metadata.getMap();
return null;
}
/** /**
* Gets the folder container. * Gets the folder container.
* *

View File

@ -894,6 +894,23 @@ public final class WorkspaceStorageHubClientService implements Workspace{
} }
/* (non-Javadoc)
* @see org.gcube.common.storagehubwrapper.server.tohl.Workspace#getMetadata(java.lang.String)
*/
@Override
public Map<String, Object> getMetadata(String itemId) throws Exception {
try{
return storageHubClientService.getMetadata(itemId);
}catch(Exception e){
logger.error("Error on getting Metadata for: "+itemId, e);
throw new Exception("Error on getting Metadata for: "+itemId);
}
}

View File

@ -63,7 +63,6 @@ public interface Workspace{
* Gets the children. * Gets the children.
* *
* @param id the id * @param id the id
* @param withMetadata the with metadata
* @return the children * @return the children
* @throws Exception the exception * @throws Exception the exception
*/ */
@ -192,8 +191,6 @@ public interface Workspace{
public List<WorkspaceItem> find(String name, String folderId) throws InternalErrorException, ItemNotFoundException, WrongItemTypeException; public List<WorkspaceItem> find(String name, String folderId) throws InternalErrorException, ItemNotFoundException, WrongItemTypeException;
/** /**
* Gets the root shared folder. * Gets the root shared folder.
* *
@ -312,16 +309,26 @@ public interface Workspace{
public ItemStreamDescriptor getThumbnailData(String itemId) throws Exception; public ItemStreamDescriptor getThumbnailData(String itemId) throws Exception;
/** /**
* Mark as public. * Mark as public.
* *
* @param itemId the item id
* @param isPublic the is public * @param isPublic the is public
* @return the boolean * @return the boolean
*/ */
public Boolean markAsPublic(String itemId, boolean isPublic); public Boolean markAsPublic(String itemId, boolean isPublic);
/**
* Gets the metadata.
*
* @param itemId the item id
* @return the metadata
* @throws Exception the exception
*/
public Map<String, Object> getMetadata(String itemId) throws Exception;