added test class

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@115362 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2015-06-12 15:18:08 +00:00
parent c56ff2882d
commit cfc335cacc
2 changed files with 61 additions and 2 deletions

View File

@ -3759,7 +3759,6 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
} }
try { try {
Workspace workspace = getWorkspace(); Workspace workspace = getWorkspace();
WorkspaceItem item = workspace.getItem(itemId); WorkspaceItem item = workspace.getItem(itemId);
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder(); GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
@ -3829,10 +3828,12 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
if(item instanceof GCubeItem){ if(item instanceof GCubeItem){
workspaceLogger.info("Adding "+properties.size()+" properties to GCubeItem: "+itemId); workspaceLogger.info("Adding "+properties.size()+" properties to GCubeItem: "+itemId);
GCubeItem gItem = (GCubeItem) item; GCubeItem gItem = (GCubeItem) item;
for (String key : properties.keySet()) {//ADD PROPERTIES for (String key : properties.keySet()) {
//ADD PROPERTIES
workspaceLogger.trace("Adding property: ["+key+","+properties.get(key)+"]"); workspaceLogger.trace("Adding property: ["+key+","+properties.get(key)+"]");
gItem.getProperties().addProperty(key, properties.get(key)); gItem.getProperties().addProperty(key, properties.get(key));
} }
gItem.getProperties().update();
}else }else
throw new NoGcubeItemTypeException("The item is not a Gcube Item"); throw new NoGcubeItemTypeException("The item is not a Gcube Item");

View File

@ -0,0 +1,58 @@
/**
*
*/
package org.gcube.portlets.user.workspace;
import org.apache.log4j.Logger;
import org.gcube.common.homelibrary.home.HomeLibrary;
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
import org.gcube.common.homelibrary.home.workspace.Properties;
import org.gcube.common.homelibrary.home.workspace.Workspace;
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundException;
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
import org.gcube.common.homelibrary.home.workspace.folder.items.GCubeItem;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.scope.impl.ScopeBean;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jun 12, 2015
*/
public class GcubeProperties {
public static Logger logger = Logger.getLogger(GcubeProperties.class);
public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
public static String TEST_USER = "francesco.mangiacrapa";
public static void main(String[] args) {
try{
ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
ScopeProvider.instance.set(scope.toString());
Workspace ws = getWorkspace();
GCubeItem item = (GCubeItem) ws.getItem("7d5fd78a-6543-4d20-b6e7-9ae490fa1ad8");
// Properties props = item.getProperties();
// item.getProperties().addProperty("key06", "value0006");
// item.getProperties().addProperty("key05", "value0005");
// item.getProperties().update();
//
System.out.println(item.getProperties().getProperties());
}catch (Exception e) {
e.printStackTrace();
}
}
public static Workspace getWorkspace() throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException{
logger.trace("Get Workspace scope: "+DEFAULT_SCOPE + " username: "+TEST_USER);
ScopeProvider.instance.set(DEFAULT_SCOPE);
logger.trace("Scope provider instancied");
Workspace workspace = HomeLibrary.getUserWorkspace(TEST_USER);
return workspace;
}
}