- test.user as Test User

- added test class SizeRetrieving

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@90972 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2014-02-06 13:02:14 +00:00
parent 7c7ce1cb49
commit 39f6487f91
2 changed files with 83 additions and 2 deletions

View File

@ -74,10 +74,10 @@ public class WsUtil {
/*USE ANOTHER ACCOUNT (OTHERWHISE BY TEST_USER) FOR RUNNING /*USE ANOTHER ACCOUNT (OTHERWHISE BY TEST_USER) FOR RUNNING
* COMMENT THIS IN DEVELOP ENVIROMENT (UNCOMMENT IN PRODUCTION)*/ * COMMENT THIS IN DEVELOP ENVIROMENT (UNCOMMENT IN PRODUCTION)*/
// user=TEST_USER; user=TEST_USER;
//UNCOMMENT THIS IN DEVELOP ENVIROMENT //UNCOMMENT THIS IN DEVELOP ENVIROMENT
user = "francesco.mangiacrapa"; // user = "francesco.mangiacrapa";
logger.warn("WORKSPACE PORTLET STARTING IN TEST MODE - NO USER FOUND - PORTLETS STARTING WITH FOLLOWING SETTINGS:"); logger.warn("WORKSPACE PORTLET STARTING IN TEST MODE - NO USER FOUND - PORTLETS STARTING WITH FOLLOWING SETTINGS:");
logger.warn("session id: "+sessionID); logger.warn("session id: "+sessionID);

View File

@ -0,0 +1,81 @@
/**
*
*/
package org.gcube.portlets.user.workspace;
import java.util.List;
import org.gcube.common.homelibrary.home.HomeLibrary;
import org.gcube.common.homelibrary.home.workspace.Workspace;
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.common.homelibrary.home.workspace.WorkspaceItemType;
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.scope.impl.ScopeBean;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* @Jan 29, 2014
*
*/
public class SizeRetrieving {
public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
public static String TEST_USER = "andrea.manzi";
public static void main(String[] args) {
try {
ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
ScopeProvider.instance.set(scope.toString());
Workspace ws = HomeLibrary
.getHomeManagerFactory()
.getHomeManager()
.getHome(TEST_USER)
.getWorkspace();
//
System.out.println("start get root");
WorkspaceItem root = ws.getRoot();
System.out.println("start get children");
List<? extends WorkspaceItem> children = root.getChildren();
System.out.println("children size: "+children.size());
int i=0;
for (WorkspaceItem workspaceItem : children) {
if(workspaceItem.getType().equals(WorkspaceItemType.FOLDER) || workspaceItem.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
WorkspaceFolder folder = (WorkspaceFolder) workspaceItem;
System.out.println(++i+") folder name: "+folder.getName());
}else{
if(workspaceItem.getType().equals(WorkspaceItemType.FOLDER_ITEM)){
FolderItem folderItem = (FolderItem) workspaceItem;
System.out.println(++i+") folderItem id: "+folderItem.getId() +", name: "+folderItem.getName() + ", size: "+folderItem.getLength());
}
}
}
System.out.println("end");
} catch (Exception e) {
e.printStackTrace();
}
}
}