|
|
|
@ -141,7 +141,7 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
|
|
|
|
|
throw new Exception("Item id is null");
|
|
|
|
|
|
|
|
|
|
workspace = getWorkspace();
|
|
|
|
|
workspaceItem = workspace.getItem(item.getId());
|
|
|
|
|
workspaceItem = workspace.getItemForExplorer(item.getId(), false, false, false);
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("Error during item retrieving", e);
|
|
|
|
@ -232,122 +232,6 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets Breadcrumbs (the list of parents) by item identifier.
|
|
|
|
|
*
|
|
|
|
|
* @param itemIdentifier the item identifier
|
|
|
|
|
* @param includeItemAsParent - if parameter is true and item passed in input is a folder, the folder is included in path returned as last parent
|
|
|
|
|
* @return the list parents by item identifier
|
|
|
|
|
* @throws Exception the exception
|
|
|
|
|
*/
|
|
|
|
|
//@Override
|
|
|
|
|
/*public List<Item> getBreadcrumbsByItemIdentifier(String itemIdentifier, boolean includeItemAsParent) throws Exception {
|
|
|
|
|
logger.trace("ListParents By Item Identifier "+ itemIdentifier);
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
WorkspaceItem wsItem = workspace.getItem(itemIdentifier);
|
|
|
|
|
logger.trace("workspace retrieve item name: "+wsItem.getName());
|
|
|
|
|
List<? extends WorkspaceItem> parents = workspace.getParentsById(itemIdentifier);
|
|
|
|
|
logger.trace("parents size: "+parents.size());
|
|
|
|
|
Item[] arrayParents;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (parents.size()) {
|
|
|
|
|
case 0: // itemIdentifier is ROOT
|
|
|
|
|
logger.trace("itemIdentifier isRoot...");
|
|
|
|
|
if (includeItemAsParent) { //ADDING ROOT
|
|
|
|
|
org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder wsFolder =
|
|
|
|
|
(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder) wsItem;
|
|
|
|
|
Item root = ItemBuilder.buildFolderForBreadcrumbs(wsFolder, null);
|
|
|
|
|
List<Item> listParents = new ArrayList<Item>(1);
|
|
|
|
|
listParents.add(root);
|
|
|
|
|
//workspaceLogger.trace("returning: "+listParents.toString());
|
|
|
|
|
return listParents;
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
logger.trace("returning empty list");
|
|
|
|
|
return new ArrayList<Item>(); // empty list
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 1: //itemIdentifier is first level from root
|
|
|
|
|
logger.trace("itemIdentifier is first level...");
|
|
|
|
|
List<Item> listParents = new ArrayList<Item>();
|
|
|
|
|
org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder wsRootFolder = (org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder) parents.get(0); //isRoot
|
|
|
|
|
Item root = ItemBuilder.buildFolderForBreadcrumbs(wsRootFolder, null);
|
|
|
|
|
Item parent = null;
|
|
|
|
|
if(includeItemAsParent){
|
|
|
|
|
org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder wsFolder1 =
|
|
|
|
|
(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder) workspace.getItem(itemIdentifier); //root
|
|
|
|
|
parent = ItemBuilder.buildFolderForBreadcrumbs(wsFolder1, null);
|
|
|
|
|
}
|
|
|
|
|
listParents.add(root);
|
|
|
|
|
if(parent!=null)
|
|
|
|
|
listParents.add(parent);
|
|
|
|
|
// workspaceLogger.trace("returning: "+listParents.toString());
|
|
|
|
|
return listParents;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WorkspaceItem lastItem = parents.get(parents.size()-1);
|
|
|
|
|
|
|
|
|
|
//CONVERTING LAST ELEMENT IF NECESSARY
|
|
|
|
|
logger.trace("converting last element..");
|
|
|
|
|
if(includeItemAsParent && lastItem.isFolder()){ //FIX BUG #298
|
|
|
|
|
arrayParents = new Item[parents.size()];
|
|
|
|
|
logger.debug("including last item into path: "+lastItem.getName());
|
|
|
|
|
arrayParents[parents.size()-1] = ItemBuilder.buildFolderForBreadcrumbs((WorkspaceFolder) lastItem, null);
|
|
|
|
|
}else
|
|
|
|
|
arrayParents = new Item[parents.size()-1];
|
|
|
|
|
|
|
|
|
|
// HANDLE MY_SPECIAL_FOLDER TO AVOID COMPLETE PATH WORKSPACE/MY_SPECIAL_FOLDER BUT RETURNING ONLY /MY_SPECIAL_FOLDER
|
|
|
|
|
|
|
|
|
|
if(wsItem.isFolder()){
|
|
|
|
|
if(ItemBuilder.isSpecialFolder((WorkspaceFolder) wsItem, lastItem.isRoot())){
|
|
|
|
|
return new ArrayList<Item>(Arrays.asList(arrayParents));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//CONVERTING PATH
|
|
|
|
|
logger.trace("converting path from second-last..");
|
|
|
|
|
for (int i = parents.size()-2; i >= 0; i--) {
|
|
|
|
|
WorkspaceFolder wsParentFolder = (WorkspaceFolder) parents.get(i);
|
|
|
|
|
arrayParents[i] = ItemBuilder.buildFolderForBreadcrumbs(wsParentFolder, null);
|
|
|
|
|
if(arrayParents[i].isSpecialFolder()){ //SKIP HOME PARENT FOR MY_SPECIAL_FOLDER
|
|
|
|
|
logger.info("arrayParents index "+i+" is special folder, exit");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//SET PARENTS
|
|
|
|
|
logger.trace("setting parents..");
|
|
|
|
|
for(int i=0; i<arrayParents.length-1; i++){
|
|
|
|
|
|
|
|
|
|
Item parent = arrayParents[i];
|
|
|
|
|
Item fileModel = arrayParents[i+1];
|
|
|
|
|
fileModel.setParent(parent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
logger.trace("ListParents return size: "+arrayParents.length);
|
|
|
|
|
if(arrayParents[0]==null){ //EXIT BY BREAK IN CASE OF SPECIAL FOLDER
|
|
|
|
|
List<Item> breadcrumbs = new ArrayList<Item>(arrayParents.length-1);
|
|
|
|
|
for (int i=1; i<arrayParents.length; i++) {
|
|
|
|
|
breadcrumbs.add(arrayParents[i]);
|
|
|
|
|
}
|
|
|
|
|
return breadcrumbs;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return new ArrayList<Item>(Arrays.asList(arrayParents));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("Error in get List Parents By Item Identifier ", e);
|
|
|
|
|
throw new Exception("Sorry, an error occurred during path retrieving!");
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the parents by item identifier to limit.
|
|
|
|
|
* when limit is reached parents are null
|
|
|
|
@ -363,8 +247,9 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
WorkspaceItem wsItem = workspace.getItem(itemIdentifier);
|
|
|
|
|
logger.trace("workspace retrieve item name: "+wsItem.getName());
|
|
|
|
|
WorkspaceItem wsItem = workspace.getItemForExplorer(itemIdentifier,false,false,false);
|
|
|
|
|
logger.info("\n\nworkspace retrieve item name: "+wsItem.getName());
|
|
|
|
|
logger.info("\n\n");
|
|
|
|
|
List<? extends WorkspaceItem> parents = null;
|
|
|
|
|
try{
|
|
|
|
|
parents = workspace.getParentsById(itemIdentifier);
|
|
|
|
@ -378,7 +263,8 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
|
|
|
|
|
|
|
|
|
|
if(logger.isDebugEnabled()) {
|
|
|
|
|
for (WorkspaceItem workspaceItem : parents) {
|
|
|
|
|
logger.debug("the parent is: "+workspaceItem.getName());
|
|
|
|
|
logger.info("the parent is: "+workspaceItem.getName());
|
|
|
|
|
logger.info("\n\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -386,6 +272,8 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
|
|
|
|
|
List<Item> arrayParents = new ArrayList<Item>();
|
|
|
|
|
parentLimit = parentLimit!=null?parentLimit:"";
|
|
|
|
|
|
|
|
|
|
logger.info("parent size returned by SHUB is: "+parents.size());
|
|
|
|
|
|
|
|
|
|
switch (parents.size()) {
|
|
|
|
|
case 0: // itemIdentifier is ROOT
|
|
|
|
|
logger.trace("itemIdentifier isRoot...");
|
|
|
|
@ -519,7 +407,7 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
|
|
|
|
|
throw new Exception("Sorry, the itemId is null. The public link for empty item is unavailable");
|
|
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
WorkspaceItem wsItem = workspace.getItem(itemId);
|
|
|
|
|
WorkspaceItem wsItem = workspace.getItemForExplorer(itemId,false,false,false);
|
|
|
|
|
|
|
|
|
|
if(wsItem==null)
|
|
|
|
|
throw new Exception("Sorry, the workspace item is null. The public link for empty item is unavailable");
|
|
|
|
|