1925: Uri-Resolver: resolve gCubeStorage smp uri like http uri
Task-Url: https://support.d4science.org/issues/1925 Updated get public link method according to #1959 git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@122319 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7166913ade
commit
981a04d901
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.workspace;
|
||||
|
||||
|
@ -20,40 +20,38 @@ import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
|||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.common.scope.impl.ScopeBean;
|
||||
|
||||
import com.itextpdf.text.log.SysoCounter;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* @Jan 29, 2014
|
||||
*
|
||||
*/
|
||||
public class ItemRetrieve {
|
||||
|
||||
|
||||
|
||||
|
||||
// public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps"; //PRODUCTION
|
||||
public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
||||
public static String TEST_USER = "francesco.mangiacrapa";
|
||||
public static String TEST_USER = "giancarlo.panichi";
|
||||
// public static String ITEMID = "63832213-098d-42d1-8774-89b6349764c0"; //Activity T3.4 working drafts/T2-EC-IMAR-HO-14-015 iMarine Sustainability WP - Business Model tools.pdf
|
||||
public static String ITEMID = "d81d3a64-603f-4907-ae74-be8353211807";
|
||||
public static String ITEMID = "79b2490b-43aa-40b0-98ec-e073cf7d4887";
|
||||
// d81d3a64-603f-4907-ae74-be8353211807
|
||||
protected static Logger logger = Logger.getLogger(ItemRetrieve.class);
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
|
||||
ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
|
||||
ScopeProvider.instance.set(scope.toString());
|
||||
|
||||
|
||||
System.out.println("init HL");
|
||||
try {
|
||||
Workspace ws = getWorkspace();
|
||||
|
||||
|
||||
retrieveFirstLevel(ws, null);
|
||||
|
||||
|
||||
|
||||
// retrieveFirstLevel(ws, null);
|
||||
|
||||
retrieveFirstLevel(ws, ITEMID);
|
||||
|
||||
|
||||
System.out.println("get workspace -> OK");
|
||||
WorkspaceItem item = ws.getItem(ITEMID);
|
||||
System.out.println("get item id: "+item.getId()+", name: "+item.getName() +", parent: "+item.getParent());
|
||||
|
@ -61,7 +59,7 @@ public class ItemRetrieve {
|
|||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
// } catch (WorkspaceFolderNotFoundException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
|
@ -75,85 +73,85 @@ public class ItemRetrieve {
|
|||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
public static Workspace getWorkspace() throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException, UserNotFoundException
|
||||
{
|
||||
|
||||
|
||||
logger.trace("Get Workspace scope: "+DEFAULT_SCOPE + " username: "+TEST_USER);
|
||||
ScopeProvider.instance.set(DEFAULT_SCOPE);
|
||||
logger.trace("Scope provider instancied");
|
||||
|
||||
|
||||
// return HomeLibrary.getUserWorkspace(TEST_USER);
|
||||
return HomeLibrary.getHomeManagerFactory().getHomeManager().getHome(TEST_USER).getWorkspace();
|
||||
}
|
||||
|
||||
|
||||
private static void retrieveFirstLevel(Workspace ws, String foundID){
|
||||
|
||||
|
||||
|
||||
private static void retrieveFirstLevel(Workspace ws, String foundFolder){
|
||||
|
||||
try {
|
||||
|
||||
//TEST TIME
|
||||
Long startTime = System.currentTimeMillis();
|
||||
Long endTime = System.currentTimeMillis() - startTime;
|
||||
String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime));
|
||||
|
||||
|
||||
startTime = System.currentTimeMillis();
|
||||
System.out.println("Start get root at time: "+startTime);
|
||||
System.out.println("Start foundFolder at time: "+startTime);
|
||||
// WorkspaceItem root = ws.getItem(ITEMID);
|
||||
WorkspaceItem root = ws.getRoot();
|
||||
System.out.println("root id: "+root.getId());
|
||||
WorkspaceItem fd = ws.getItem(foundFolder);
|
||||
System.out.println("foundFolder id: "+foundFolder);
|
||||
System.out.println("start get children");
|
||||
List<? extends WorkspaceItem> children = root.getChildren();
|
||||
List<? extends WorkspaceItem> children = fd.getChildren();
|
||||
System.out.println("tree getChildren() returning "+children.size()+" elements in " + time);
|
||||
|
||||
|
||||
System.out.println("children size: "+children.size());
|
||||
|
||||
|
||||
int i=0;
|
||||
int foldersCounter = 0;
|
||||
int sharedFoldersCounter = 0;
|
||||
int folderItemCounter = 0;
|
||||
int othersCounter = 0;
|
||||
for (WorkspaceItem workspaceItem : children) {
|
||||
|
||||
if(foundID!=null && !foundID.isEmpty()){
|
||||
if(workspaceItem.getId().compareTo(foundID)==0){
|
||||
|
||||
/*if(foundFolder!=null && !foundFolder.isEmpty()){
|
||||
if(workspaceItem.getId().compareTo(foundFolder)==0){
|
||||
System.out.println("ITEM FOUND id: "+workspaceItem.getId()+", name: "+workspaceItem.getName());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}*/
|
||||
|
||||
|
||||
switch (workspaceItem.getType()) {
|
||||
|
||||
|
||||
case FOLDER:
|
||||
|
||||
|
||||
WorkspaceFolder folder = (WorkspaceFolder) workspaceItem;
|
||||
|
||||
System.out.println(++i+") "+folder.getId() +" folder name: "+folder.getName() + " owner "+folder.getOwner());
|
||||
foldersCounter++;
|
||||
|
||||
|
||||
break;
|
||||
|
||||
case SHARED_FOLDER:
|
||||
|
||||
|
||||
WorkspaceSharedFolder shared = (WorkspaceSharedFolder) workspaceItem;
|
||||
|
||||
System.out.println(++i+") "+shared.getId() +" shared folder name: "+shared.getName() + " owner "+shared.getOwner()+" isVRE "+shared.isVreFolder() +" ACLOwner: "+shared.getACLOwner()+" AclUser: "+shared.getACLUser());
|
||||
|
||||
|
||||
// System.out.println(++i+") shared folder name: "+shared.getName() + " owner "+shared.getOwner().getPortalLogin());
|
||||
sharedFoldersCounter++;
|
||||
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case FOLDER_ITEM:
|
||||
|
||||
|
||||
FolderItem folderItem = (FolderItem) workspaceItem;
|
||||
|
||||
|
||||
System.out.println(++i+") folderItem id: "+folderItem.getId() +", name: "+folderItem.getName() + ", own: "+folderItem.getOwner());
|
||||
folderItemCounter++;
|
||||
|
||||
|
||||
break;
|
||||
default:
|
||||
System.out.println(++i+") DEFAULT - item id: "+workspaceItem.getId() +", name: "+workspaceItem.getName() + ", own: "+workspaceItem.getOwner());
|
||||
|
@ -161,7 +159,7 @@ public class ItemRetrieve {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//TEST TIME
|
||||
endTime = System.currentTimeMillis();
|
||||
long difference = endTime - startTime;
|
||||
|
|
Loading…
Reference in New Issue