Checking the old property isPublic added as "<boolean>true</boolean>" by HL

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/storagehub-client-wrapper@174309 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2018-11-21 16:45:29 +00:00
parent 53b60d3e11
commit db3c9eda54
5 changed files with 69 additions and 19 deletions

View File

@ -17,6 +17,7 @@ import org.gcube.common.storagehub.client.dsl.StorageHubClient;
import org.gcube.common.storagehub.client.plugins.AbstractPlugin; import org.gcube.common.storagehub.client.plugins.AbstractPlugin;
import org.gcube.common.storagehub.client.proxies.ItemManagerClient; import org.gcube.common.storagehub.client.proxies.ItemManagerClient;
import org.gcube.common.storagehub.client.proxies.WorkspaceManagerClient; 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.ACL;
import org.gcube.common.storagehub.model.items.AbstractFileItem; import org.gcube.common.storagehub.model.items.AbstractFileItem;
import org.gcube.common.storagehub.model.items.FolderItem; import org.gcube.common.storagehub.model.items.FolderItem;
@ -126,8 +127,6 @@ public class StorageHubClientService {
} }
/** /**
* Gets the item. * Gets the item.
* *
@ -142,6 +141,22 @@ public class StorageHubClientService {
} }
/**
* Sets the metadata and returns the Item with metadata updated
*
* @param itemId the item id
* @param metadata the metadata
* @return the item
* @throws Exception the exception
*/
public Item setMetadata(String itemId, Metadata metadata) throws Exception{
setContextProviders(scope, authorizationToken);
ItemContainer<Item> itemCont = shcClient.open(itemId).asItem();
itemCont.setMetadata(metadata);
return itemCont.get();
}
/** /**
* Gets the folder container. * Gets the folder container.
* *

View File

@ -227,6 +227,17 @@ public final class WorkspaceStorageHubClientService implements Workspace{
} }
/* (non-Javadoc)
* @see org.gcube.common.storagehubwrapper.server.tohl.Workspace#markAsPublic(java.lang.String, boolean)
*/
@Override
public Boolean markAsPublic(String itemId, boolean isPublic) {
//TODO
return false;
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#getOwner() * @see org.gcube.portal.storagehubwrapper.shared.Workspace#getOwner()
@ -1203,5 +1214,4 @@ public final class WorkspaceStorageHubClientService implements Workspace{
} }

View File

@ -184,13 +184,22 @@ public class HLMapper {
} }
} }
((WorkspaceFolder) theItem).setPublicFolder(folderItem.isPublicItem()); boolean isPublicItem = folderItem.isPublicItem();
//((WorkspaceFolder) theItem).setPublicFolder(folderItem.isPublicItem());
//logger.debug("Wrapped as Folder"); //logger.debug("Wrapped as Folder");
// if(logger.isTraceEnabled()){ //TODO THIS MUST BE REMOVED. Checking the old property isPublic added as "<boolean>true</boolean>" by HL
// WorkspaceFolder theFolder = (WorkspaceFolder) theItem; if(!isPublicItem){
// logger.debug("Wrapped as Folder"); try{
// } String isPublic = (String) item.getPropertyMap().getValues().get("isPublic");
logger.debug("The item name: "+item.getName()+ " has isPublic property like: "+isPublic);
isPublicItem = isPublic!=null?isPublic.toLowerCase().contains("true"):false;
}catch(Exception e){
//silent
}
}
((WorkspaceFolder) theItem).setPublicFolder(isPublicItem);
} }

View File

@ -312,6 +312,15 @@ public interface Workspace{
/**
* Mark as public.
*
* @param isPublic the is public
* @return the boolean
*/
public Boolean markAsPublic(String itemId, boolean isPublic);

View File

@ -27,27 +27,27 @@ import org.junit.Test;
*/ */
public class WorkspaceInstance { public class WorkspaceInstance {
public static String USERNAME = "francesco.mangiacrapa";
public static String SCOPE = "/gcube"; public static String SCOPE = "/gcube";
//public static String SCOPE = "/d4science.research-infrastructures.eu"; //public static String SCOPE = "/d4science.research-infrastructures.eu";
//public static String TOKEN = "0e2c7963-8d3e-4ea6-a56d-ffda530dd0fa-98187548";
//public static String TOKEN = "bdc2e70f-36c3-4db4-8b03-829a973b3095-98187548"; //PREVRE
public static String TOKEN = "57b42a99-6239-44c4-9a68-591c18363222-843339462"; //BiodiversityLab public static String USERNAME = "massimiliano.assante";
//public static String USERNAME = "francesco.mangiacrapa";
public static String TOKEN; //YOU MUST SET THIS AS VM PARAMETER
public static String FIND_FILE_NAME = "francesco"; public static String FIND_FILE_NAME = "francesco";
public static String rootId = null; public static String rootId = null;
private StorageHubWrapper storageHubWrapper = null;
StorageHubWrapper storageHubWrapper = null;
//Workspace workspace = null;
@Before @Before
public void init(){ public void init(){
TOKEN = System.getProperty("token");
System.out.println("Read TOKEN: "+TOKEN);
//METHOD 1 //METHOD 1
storageHubWrapper = new StorageHubWrapper(SCOPE, TOKEN); storageHubWrapper = new StorageHubWrapper(SCOPE, TOKEN);
//workspace = storageHubWrapper.getWorkspace(); //workspace = storageHubWrapper.getWorkspace();
@ -88,6 +88,13 @@ public class WorkspaceInstance {
// System.out.println(++i+")"+workspaceItem); // System.out.println(++i+")"+workspaceItem);
// System.out.println(workspaceItem.getType() +" "+workspaceItem.getClass()); // System.out.println(workspaceItem.getType() +" "+workspaceItem.getClass());
System.out.println(++i+")"); System.out.println(++i+")");
if(workspaceItem.isFolder()){
WorkspaceFolder folder = (WorkspaceFolder) workspaceItem;
System.out.println("is public? "+folder.isPublicFolder());
}
printMap(workspaceItem); printMap(workspaceItem);
} }