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;
|
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.api.ScopeProvider;
|
||||||
import org.gcube.common.scope.impl.ScopeBean;
|
import org.gcube.common.scope.impl.ScopeBean;
|
||||||
|
|
||||||
import com.itextpdf.text.log.SysoCounter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
* @Jan 29, 2014
|
* @Jan 29, 2014
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ItemRetrieve {
|
public class ItemRetrieve {
|
||||||
|
|
||||||
|
|
||||||
// public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps"; //PRODUCTION
|
// public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps"; //PRODUCTION
|
||||||
public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
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 = "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
|
// d81d3a64-603f-4907-ae74-be8353211807
|
||||||
protected static Logger logger = Logger.getLogger(ItemRetrieve.class);
|
protected static Logger logger = Logger.getLogger(ItemRetrieve.class);
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
|
ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
|
||||||
ScopeProvider.instance.set(scope.toString());
|
ScopeProvider.instance.set(scope.toString());
|
||||||
|
|
||||||
System.out.println("init HL");
|
System.out.println("init HL");
|
||||||
try {
|
try {
|
||||||
Workspace ws = getWorkspace();
|
Workspace ws = getWorkspace();
|
||||||
|
|
||||||
|
|
||||||
retrieveFirstLevel(ws, null);
|
// retrieveFirstLevel(ws, null);
|
||||||
|
|
||||||
retrieveFirstLevel(ws, ITEMID);
|
retrieveFirstLevel(ws, ITEMID);
|
||||||
|
|
||||||
System.out.println("get workspace -> OK");
|
System.out.println("get workspace -> OK");
|
||||||
WorkspaceItem item = ws.getItem(ITEMID);
|
WorkspaceItem item = ws.getItem(ITEMID);
|
||||||
System.out.println("get item id: "+item.getId()+", name: "+item.getName() +", parent: "+item.getParent());
|
System.out.println("get item id: "+item.getId()+", name: "+item.getName() +", parent: "+item.getParent());
|
||||||
|
@ -61,7 +59,7 @@ public class ItemRetrieve {
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
// } catch (WorkspaceFolderNotFoundException e) {
|
// } catch (WorkspaceFolderNotFoundException e) {
|
||||||
// // TODO Auto-generated catch block
|
// // TODO Auto-generated catch block
|
||||||
// e.printStackTrace();
|
// e.printStackTrace();
|
||||||
|
@ -75,85 +73,85 @@ public class ItemRetrieve {
|
||||||
// // TODO Auto-generated catch block
|
// // TODO Auto-generated catch block
|
||||||
// e.printStackTrace();
|
// e.printStackTrace();
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Workspace getWorkspace() throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException, UserNotFoundException
|
public static Workspace getWorkspace() throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException, UserNotFoundException
|
||||||
{
|
{
|
||||||
|
|
||||||
logger.trace("Get Workspace scope: "+DEFAULT_SCOPE + " username: "+TEST_USER);
|
logger.trace("Get Workspace scope: "+DEFAULT_SCOPE + " username: "+TEST_USER);
|
||||||
ScopeProvider.instance.set(DEFAULT_SCOPE);
|
ScopeProvider.instance.set(DEFAULT_SCOPE);
|
||||||
logger.trace("Scope provider instancied");
|
logger.trace("Scope provider instancied");
|
||||||
|
|
||||||
// return HomeLibrary.getUserWorkspace(TEST_USER);
|
// return HomeLibrary.getUserWorkspace(TEST_USER);
|
||||||
return HomeLibrary.getHomeManagerFactory().getHomeManager().getHome(TEST_USER).getWorkspace();
|
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 {
|
try {
|
||||||
|
|
||||||
//TEST TIME
|
//TEST TIME
|
||||||
Long startTime = System.currentTimeMillis();
|
Long startTime = System.currentTimeMillis();
|
||||||
Long endTime = System.currentTimeMillis() - startTime;
|
Long endTime = System.currentTimeMillis() - startTime;
|
||||||
String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime));
|
String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime));
|
||||||
|
|
||||||
startTime = System.currentTimeMillis();
|
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.getItem(ITEMID);
|
||||||
WorkspaceItem root = ws.getRoot();
|
WorkspaceItem fd = ws.getItem(foundFolder);
|
||||||
System.out.println("root id: "+root.getId());
|
System.out.println("foundFolder id: "+foundFolder);
|
||||||
System.out.println("start get children");
|
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("tree getChildren() returning "+children.size()+" elements in " + time);
|
||||||
|
|
||||||
System.out.println("children size: "+children.size());
|
System.out.println("children size: "+children.size());
|
||||||
|
|
||||||
int i=0;
|
int i=0;
|
||||||
int foldersCounter = 0;
|
int foldersCounter = 0;
|
||||||
int sharedFoldersCounter = 0;
|
int sharedFoldersCounter = 0;
|
||||||
int folderItemCounter = 0;
|
int folderItemCounter = 0;
|
||||||
int othersCounter = 0;
|
int othersCounter = 0;
|
||||||
for (WorkspaceItem workspaceItem : children) {
|
for (WorkspaceItem workspaceItem : children) {
|
||||||
|
|
||||||
if(foundID!=null && !foundID.isEmpty()){
|
/*if(foundFolder!=null && !foundFolder.isEmpty()){
|
||||||
if(workspaceItem.getId().compareTo(foundID)==0){
|
if(workspaceItem.getId().compareTo(foundFolder)==0){
|
||||||
System.out.println("ITEM FOUND id: "+workspaceItem.getId()+", name: "+workspaceItem.getName());
|
System.out.println("ITEM FOUND id: "+workspaceItem.getId()+", name: "+workspaceItem.getName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
switch (workspaceItem.getType()) {
|
switch (workspaceItem.getType()) {
|
||||||
|
|
||||||
case FOLDER:
|
case FOLDER:
|
||||||
|
|
||||||
WorkspaceFolder folder = (WorkspaceFolder) workspaceItem;
|
WorkspaceFolder folder = (WorkspaceFolder) workspaceItem;
|
||||||
|
|
||||||
System.out.println(++i+") "+folder.getId() +" folder name: "+folder.getName() + " owner "+folder.getOwner());
|
System.out.println(++i+") "+folder.getId() +" folder name: "+folder.getName() + " owner "+folder.getOwner());
|
||||||
foldersCounter++;
|
foldersCounter++;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SHARED_FOLDER:
|
case SHARED_FOLDER:
|
||||||
|
|
||||||
WorkspaceSharedFolder shared = (WorkspaceSharedFolder) workspaceItem;
|
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.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());
|
// System.out.println(++i+") shared folder name: "+shared.getName() + " owner "+shared.getOwner().getPortalLogin());
|
||||||
sharedFoldersCounter++;
|
sharedFoldersCounter++;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FOLDER_ITEM:
|
case FOLDER_ITEM:
|
||||||
|
|
||||||
FolderItem folderItem = (FolderItem) workspaceItem;
|
FolderItem folderItem = (FolderItem) workspaceItem;
|
||||||
|
|
||||||
System.out.println(++i+") folderItem id: "+folderItem.getId() +", name: "+folderItem.getName() + ", own: "+folderItem.getOwner());
|
System.out.println(++i+") folderItem id: "+folderItem.getId() +", name: "+folderItem.getName() + ", own: "+folderItem.getOwner());
|
||||||
folderItemCounter++;
|
folderItemCounter++;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
System.out.println(++i+") DEFAULT - item id: "+workspaceItem.getId() +", name: "+workspaceItem.getName() + ", own: "+workspaceItem.getOwner());
|
System.out.println(++i+") DEFAULT - item id: "+workspaceItem.getId() +", name: "+workspaceItem.getName() + ", own: "+workspaceItem.getOwner());
|
||||||
|
@ -161,7 +159,7 @@ public class ItemRetrieve {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TEST TIME
|
//TEST TIME
|
||||||
endTime = System.currentTimeMillis();
|
endTime = System.currentTimeMillis();
|
||||||
long difference = endTime - startTime;
|
long difference = endTime - startTime;
|
||||||
|
|
Loading…
Reference in New Issue