the select and save dialog work

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-explorer@167667 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2018-05-22 14:47:23 +00:00
parent f1b444b2dc
commit 29e0405e97
7 changed files with 119 additions and 126 deletions

View File

@ -21,7 +21,7 @@ public class Util {
// public static final NumberFormat numberFormatterKB = NumberFormat.getFormat("#,##0 KB;(#,##0 KB)"); // public static final NumberFormat numberFormatterKB = NumberFormat.getFormat("#,##0 KB;(#,##0 KB)");
public static final ItemType[] FOLDERS = new ItemType[] {ItemType.FOLDER}; public static final ItemType[] FOLDERS = new ItemType[] {ItemType.FOLDER, ItemType.PRIVATE_FOLDER, ItemType.SHARED_FOLDER, ItemType.VRE_FOLDER};
/** /**
* Checks if is folder. * Checks if is folder.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -179,7 +179,7 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes, Folder
// we make a copy of showable types // we make a copy of showable types
List<ItemType> showableTypesParam = new ArrayList<ItemType>(showableTypes); List<ItemType> showableTypesParam = new ArrayList<ItemType>(showableTypes);
// we get sure that folders are displayed // we make sure that folders are displayed
for (ItemType folder : Util.FOLDERS) { for (ItemType folder : Util.FOLDERS) {
if (!showableTypesParam.contains(folder)) if (!showableTypesParam.contains(folder))
showableTypesParam.add(folder); showableTypesParam.add(folder);
@ -198,6 +198,7 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes, Folder
} }
public void onSuccess(Item item) { public void onSuccess(Item item) {
GWT.log("Succes getting root");
eventBus.fireEvent(new RootLoadedEvent(item)); eventBus.fireEvent(new RootLoadedEvent(item));
updateExplorer(item.getChildren()); updateExplorer(item.getChildren());

View File

@ -145,7 +145,7 @@ public class ItemBuilder {
itemName = shared.isVreFolder()?shared.getDisplayName():workspaceItem.getTitle(); itemName = shared.isVreFolder()?shared.getDisplayName():workspaceItem.getTitle();
isFolder = true; isFolder = true;
} }
// _log.debug("Building Item for: "+itemName); // _log.debug("Building Item for: "+itemName);
org.gcube.portlets.widgets.wsexplorer.shared.Item item = null; org.gcube.portlets.widgets.wsexplorer.shared.Item item = null;
try{ try{
@ -273,15 +273,12 @@ public class ItemBuilder {
* @return the folder item type * @return the folder item type
*/ */
protected static ItemType getFolderItemType(Item item){ protected static ItemType getFolderItemType(Item item){
System.out.println("***\n\n\"+getFolderItemType " + item.getTitle());
if (item instanceof SharedFolder || item instanceof VreFolder) { if (item instanceof SharedFolder || item instanceof VreFolder) {
SharedFolder folder = (SharedFolder) item; SharedFolder folder = (SharedFolder) item;
if (folder.isVreFolder()) if (folder.isVreFolder())
return ItemType.VRE_FOLDER; return ItemType.VRE_FOLDER;
System.out.println("***" + item.getTitle() + " is a SHARED FOLDER");
return ItemType.SHARED_FOLDER; return ItemType.SHARED_FOLDER;
} else if (item instanceof FolderItem) { } else if (item instanceof FolderItem) {
System.out.println("***" + item.getTitle() + " is a PRIVATE FOLDER");
return ItemType.PRIVATE_FOLDER; return ItemType.PRIVATE_FOLDER;
} }
_log.warn("Item Type non found: "); _log.warn("Item Type non found: ");
@ -468,9 +465,16 @@ public class ItemBuilder {
if(wsFolder.getParentId() == null){ //IS ROOT if(wsFolder.getParentId() == null){ //IS ROOT
name = WorkspaceExplorerConstants.HOME_LABEL; name = WorkspaceExplorerConstants.HOME_LABEL;
isRoot = true; isRoot = true;
}else if(wsFolder.isShared()){ //MANAGEMENT SHARED FOLDER NAME }
SharedFolder shared = (SharedFolder) wsFolder; else if(wsFolder.isShared()){ //MANAGEMENT SHARED FOLDER NAME
name = shared.isVreFolder()?shared.getDisplayName():shared.getTitle(); if (wsFolder instanceof SharedFolder) {
SharedFolder shared = (SharedFolder) wsFolder;
name = shared.isVreFolder() ? shared.getDisplayName() : shared.getTitle();
}
else {
FolderItem shared = (FolderItem) wsFolder;
name = shared.getTitle();
}
//MANAGEMENT SPECIAL FOLDER //MANAGEMENT SPECIAL FOLDER
}else if(isSpecialFolder(wsFolder)){ }else if(isSpecialFolder(wsFolder)){
name = WorkspaceExplorerConstants.VRE_FOLDERS_LABEL; name = WorkspaceExplorerConstants.VRE_FOLDERS_LABEL;

View File

@ -5,10 +5,10 @@ import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.portal.PortalContext; import org.gcube.common.portal.PortalContext;
import org.gcube.common.storagehub.model.items.AbstractFileItem;
import org.gcube.common.storagehub.model.items.FolderItem; import org.gcube.common.storagehub.model.items.FolderItem;
import org.gcube.common.storagehub.model.items.Item; import org.gcube.common.storagehub.model.items.Item;
import org.gcube.common.storagehub.model.items.SharedFolder; import org.gcube.common.storagehub.model.items.SharedFolder;
@ -37,14 +37,17 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implements WorkspaceExplorerService { public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implements WorkspaceExplorerService {
public static final Logger logger = LoggerFactory.getLogger(WorkspaceExplorerServiceImpl.class); public static final Logger _log = LoggerFactory.getLogger(WorkspaceExplorerServiceImpl.class);
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public org.gcube.portlets.widgets.wsexplorer.shared.Item getRoot(List<ItemType> showableTypes, boolean purgeEmpyFolders, FilterCriteria filterCriteria) throws WorkspaceNavigatorServiceException { public org.gcube.portlets.widgets.wsexplorer.shared.Item getRoot(
logger.trace("getRoot showableTypes: "+showableTypes+" purgeEmpyFolders: "+purgeEmpyFolders+" filterCriteria: "+ filterCriteria); List<ItemType> showableTypes,
boolean purgeEmpyFolders,
FilterCriteria filterCriteria)
throws WorkspaceNavigatorServiceException {
_log.trace("getRoot showableTypes: "+showableTypes+" purgeEmpyFolders: "+purgeEmpyFolders+" filterCriteria: "+ filterCriteria);
try { try {
PortalContext pContext = PortalContext.getConfiguration(); PortalContext pContext = PortalContext.getConfiguration();
String userName = pContext.getCurrentUser(getThreadLocalRequest()).getUsername(); String userName = pContext.getCurrentUser(getThreadLocalRequest()).getUsername();
@ -52,13 +55,9 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
String authorizationToken = pContext.getCurrentUserToken(scope, userName); String authorizationToken = pContext.getCurrentUserToken(scope, userName);
SecurityTokenProvider.instance.set(authorizationToken); SecurityTokenProvider.instance.set(authorizationToken);
logger.trace("Start getRoot..."); _log.trace("Start getRoot...");
Item root = Whorespace.getRoot(getThreadLocalRequest()); Item root = Whorespace.getRoot(getThreadLocalRequest());
logger.trace("GetRoot - Replyiing root");
long startTime = System.currentTimeMillis();
logger.trace("start time - " + startTime);
org.gcube.portlets.widgets.wsexplorer.shared.Item rootItem = ItemBuilder.getItem(null, root, root.getPath(), showableTypes, filterCriteria, true, false); org.gcube.portlets.widgets.wsexplorer.shared.Item rootItem = ItemBuilder.getItem(null, root, root.getPath(), showableTypes, filterCriteria, true, false);
rootItem.setName(WorkspaceExplorerConstants.HOME_LABEL); rootItem.setName(WorkspaceExplorerConstants.HOME_LABEL);
rootItem.setIsRoot(true); rootItem.setIsRoot(true);
@ -66,18 +65,12 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
if (purgeEmpyFolders) { if (purgeEmpyFolders) {
rootItem = ItemBuilder.purgeEmptyFolders(rootItem); rootItem = ItemBuilder.purgeEmptyFolders(rootItem);
} }
logger.trace("Returning:");
Long endTime = System.currentTimeMillis() - startTime;
logger.debug("end time - " + String.format("%d msc %d sec", endTime - startTime, TimeUnit.MILLISECONDS.toSeconds(endTime)));
Collections.sort(rootItem.getChildren(), new ItemComparator()); Collections.sort(rootItem.getChildren(), new ItemComparator());
logger.info("Returning children size: "+rootItem.getChildren().size()); _log.info("->Returning children size: "+rootItem.getChildren().size());
return rootItem; return rootItem;
} catch (Exception e) { } catch (Exception e) {
logger.error("Error during root retrieving", e); _log.error("Error during root retrieving", e);
e.printStackTrace();
throw new WorkspaceNavigatorServiceException("Sorry, an error occurred when performing get root"); throw new WorkspaceNavigatorServiceException("Sorry, an error occurred when performing get root");
} }
} }
@ -86,8 +79,13 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public org.gcube.portlets.widgets.wsexplorer.shared.Item getFolder(ItemInterface item, List<ItemType> showableTypes, boolean purgeEmpyFolders, FilterCriteria filterCriteria, boolean loadGcubeProperties) throws WorkspaceNavigatorServiceException { public org.gcube.portlets.widgets.wsexplorer.shared.Item getFolder(
logger.trace("getFolder folderId: "+item.getId()+" showableTypes: "+showableTypes+" purgeEmpyFolders: "+purgeEmpyFolders+" filterCriteria: "+filterCriteria); ItemInterface item, List<ItemType> showableTypes,
boolean purgeEmpyFolders,
FilterCriteria filterCriteria,
boolean loadGcubeProperties)
throws WorkspaceNavigatorServiceException {
_log.trace("getFolder folderId: "+item.getId()+" showableTypes: "+showableTypes+" purgeEmpyFolders: "+purgeEmpyFolders+" filterCriteria: "+filterCriteria);
try { try {
@ -97,7 +95,7 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
String authorizationToken = pContext.getCurrentUserToken(scope, userName); String authorizationToken = pContext.getCurrentUserToken(scope, userName);
SecurityTokenProvider.instance.set(authorizationToken); SecurityTokenProvider.instance.set(authorizationToken);
Item folder = Whorespace.getItem(getThreadLocalRequest(), item.getId()); Item folder = Whorespace.getItem(getThreadLocalRequest(), item.getId());
logger.trace("GetFolder - Replying folder"); _log.trace("GetFolder - Replying folder");
//TO AVOID SLOW CALL getPATH() //TO AVOID SLOW CALL getPATH()
String folderPath = item.getPath()!=null && !item.getPath().isEmpty()?item.getPath():folder.getPath(); String folderPath = item.getPath()!=null && !item.getPath().isEmpty()?item.getPath():folder.getPath();
@ -109,12 +107,12 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
} }
Collections.sort(itemFolder.getChildren(), new ItemComparator()); Collections.sort(itemFolder.getChildren(), new ItemComparator());
logger.info("Returning children size: "+itemFolder.getChildren().size()); _log.info("Returning children size: "+itemFolder.getChildren().size());
return itemFolder; return itemFolder;
} catch (Exception e) { } catch (Exception e) {
logger.error("Error during folder retrieving", e); _log.error("Error during folder retrieving", e);
throw new WorkspaceNavigatorServiceException("Sorry, an error occurred when performing get folder"); throw new WorkspaceNavigatorServiceException("Sorry, an error occurred when performing get folder");
} }
} }
@ -131,7 +129,7 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
*/ */
@Override @Override
public org.gcube.portlets.widgets.wsexplorer.shared.Item getItemByCategory(ItemCategory category) throws WorkspaceNavigatorServiceException{ public org.gcube.portlets.widgets.wsexplorer.shared.Item getItemByCategory(ItemCategory category) throws WorkspaceNavigatorServiceException{
logger.trace("GetItemByCategory category: "+category); _log.trace("GetItemByCategory category: "+category);
PortalContext pContext = PortalContext.getConfiguration(); PortalContext pContext = PortalContext.getConfiguration();
String userName = pContext.getCurrentUser(getThreadLocalRequest()).getUsername(); String userName = pContext.getCurrentUser(getThreadLocalRequest()).getUsername();
String scope = pContext.getCurrentScope(getThreadLocalRequest()); String scope = pContext.getCurrentScope(getThreadLocalRequest());
@ -157,7 +155,16 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
case VRE_FOLDER:{ case VRE_FOLDER:{
String vreFolderId = Whorespace.getVREFoldersId(getThreadLocalRequest()); String vreFolderId = Whorespace.getVREFoldersId(getThreadLocalRequest());
Item folder = Whorespace.getItem(getThreadLocalRequest(), vreFolderId); Item folder = Whorespace.getItem(getThreadLocalRequest(), vreFolderId);
item = new org.gcube.portlets.widgets.wsexplorer.shared.Item(null, folder.getId(), WorkspaceExplorerConstants.VRE_FOLDERS_LABEL, ItemType.FOLDER, folder.getPath(), folder.getOwner(), null, true, false); item = new org.gcube.portlets.widgets.wsexplorer.shared.Item(
null,
folder.getId(),
WorkspaceExplorerConstants.VRE_FOLDERS_LABEL,
ItemType.FOLDER,
folder.getPath(),
folder.getOwner(),
null,
true,
false);
//SET SPECIAL FOLDER /Workspace/MySpecialFolders //SET SPECIAL FOLDER /Workspace/MySpecialFolders
item.setSpecialFolder(true); item.setSpecialFolder(true);
break; break;
@ -165,7 +172,7 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
} }
return item; return item;
} catch (Exception e) { } catch (Exception e) {
logger.error("Error during get item by category", e); _log.error("Error during get item by category", e);
throw new WorkspaceNavigatorServiceException("Sorry, an error occurred when performing get item by category"); throw new WorkspaceNavigatorServiceException("Sorry, an error occurred when performing get item by category");
} }
} }
@ -174,8 +181,12 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public org.gcube.portlets.widgets.wsexplorer.shared.Item getMySpecialFolder(List<ItemType> showableTypes, boolean purgeEmpyFolders, FilterCriteria filterCriteria) throws WorkspaceNavigatorServiceException { public org.gcube.portlets.widgets.wsexplorer.shared.Item getMySpecialFolder(
logger.trace("GetMySpecialFolder showableTypes: "+showableTypes+" purgeEmpyFolders: "+purgeEmpyFolders+" filterCriteria: "+filterCriteria); List<ItemType> showableTypes,
boolean purgeEmpyFolders,
FilterCriteria filterCriteria)
throws WorkspaceNavigatorServiceException {
_log.trace("GetMySpecialFolder showableTypes: "+showableTypes+" purgeEmpyFolders: "+purgeEmpyFolders+" filterCriteria: "+filterCriteria);
try { try {
PortalContext pContext = PortalContext.getConfiguration(); PortalContext pContext = PortalContext.getConfiguration();
@ -186,35 +197,23 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
String vreFolderId = Whorespace.getVREFoldersId(getThreadLocalRequest()); String vreFolderId = Whorespace.getVREFoldersId(getThreadLocalRequest());
Item folder = Whorespace.getItem(getThreadLocalRequest(), vreFolderId); Item folder = Whorespace.getItem(getThreadLocalRequest(), vreFolderId);
long startTime = System.currentTimeMillis();
logger.trace("start time - " + startTime);
org.gcube.portlets.widgets.wsexplorer.shared.Item itemFolder = ItemBuilder.getItem(null, folder, folder.getPath(), showableTypes, filterCriteria, true, false); org.gcube.portlets.widgets.wsexplorer.shared.Item itemFolder = ItemBuilder.getItem(null, folder, folder.getPath(), showableTypes, filterCriteria, true, false);
//OVERRIDING VRE FOLDERS NAME - SET SPECIAL FOLDER /Workspace/MySpecialFolders //OVERRIDING VRE FOLDERS NAME - SET SPECIAL FOLDER /Workspace/MySpecialFolders
itemFolder.setName(WorkspaceExplorerConstants.VRE_FOLDERS_LABEL); itemFolder.setName(WorkspaceExplorerConstants.VRE_FOLDERS_LABEL);
itemFolder.setSpecialFolder(true); itemFolder.setSpecialFolder(true);
logger.trace("Builded MySpecialFolder: "+itemFolder); _log.trace("Builded MySpecialFolder: "+itemFolder);
logger.trace("Only showable types:"); _log.trace("Only showable types:");
//printName("", folderItem);
if (purgeEmpyFolders) { if (purgeEmpyFolders) {
itemFolder = ItemBuilder.purgeEmptyFolders(itemFolder); itemFolder = ItemBuilder.purgeEmptyFolders(itemFolder);
} }
logger.trace("Returning:");
Long endTime = System.currentTimeMillis() - startTime;
String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime));
logger.trace("end time - " + time);
//printName("", folderItem);
Collections.sort(itemFolder.getChildren(), new ItemComparator()); Collections.sort(itemFolder.getChildren(), new ItemComparator());
return itemFolder; return itemFolder;
} catch (Exception e) { } catch (Exception e) {
logger.error("Error during special folders retrieving", e); _log.error("Error during special folders retrieving", e);
throw new WorkspaceNavigatorServiceException("Sorry, an error occurred when performing get My Special Folder"); throw new WorkspaceNavigatorServiceException("Sorry, an error occurred when performing get My Special Folder");
} }
} }
@ -225,20 +224,12 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
*/ */
@Override @Override
public boolean checkName(String name) throws WorkspaceNavigatorServiceException { public boolean checkName(String name) throws WorkspaceNavigatorServiceException {
logger.warn("checkName name NOT IMPLEMENTED: "+name); _log.warn("checkName name NOT IMPLEMENTED: "+name);
return true; //TODO: return true; //TODO:
} }
/*protected void printName(String indentation, Item item)
{
if(item!=null){
_log.trace(indentation+item.getName());
for (Item child:item.getChildren()) printName(indentation+"\t", child);
}
}*/
/** /**
* Gets Breadcrumbs (the list of parents) by item identifier. * Gets Breadcrumbs (the list of parents) by item identifier and name ( the name is added as last item of the breadcrumb)
* *
* @param itemIdentifier the 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 * @param includeItemAsParent - if parameter is true and item passed in input is a folder, the folder is included in path returned as last parent
@ -246,18 +237,27 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
* @throws Exception the exception * @throws Exception the exception
*/ */
@Override @Override
public ArrayList<org.gcube.portlets.widgets.wsexplorer.shared.Item> getBreadcrumbsByItemIdentifier(String itemIdentifier, String itemName, boolean includeItemAsParent) throws Exception { public ArrayList<org.gcube.portlets.widgets.wsexplorer.shared.Item> getBreadcrumbsByItemIdentifier(
logger.trace("ListParents By Item Identifier "+ itemIdentifier); String itemIdentifier, String itemName, boolean includeItemAsParent)
throws Exception {
System.out.println("ListParents By Item id "+ itemIdentifier + " name="+itemName);
try { try {
List<? extends Item> parents = Whorespace.getParents(getThreadLocalRequest(), itemIdentifier); List<? extends Item> parents = Whorespace.getParents(getThreadLocalRequest(), itemIdentifier);
System.out.println("parents size: "+parents.size() + " follows them in order");
ArrayList<org.gcube.portlets.widgets.wsexplorer.shared.Item> toReturn = new ArrayList<>(parents.size()); ArrayList<org.gcube.portlets.widgets.wsexplorer.shared.Item> toReturn = new ArrayList<>(parents.size());
for (Item item : parents) {
if (item instanceof SharedFolder)
toReturn.add( ItemBuilder.buildFolderForBreadcrumbs((SharedFolder) item, null));
else
toReturn.add( ItemBuilder.buildFolderForBreadcrumbs((FolderItem) item, null));
System.out.println("->"+item.getTitle());
}
Collections.reverse(toReturn); Collections.reverse(toReturn);
String theClickedFolderName = (itemName == null || itemName.equals("")) ? "current folder" : itemName; String theClickedFolderName = (itemName == null || itemName.equals("")) ? "current folder" : itemName;
toReturn.add(new org.gcube.portlets.widgets.wsexplorer.shared.Item(itemIdentifier, theClickedFolderName, true)); //this is the last non clickable item on the BC toReturn.add(new org.gcube.portlets.widgets.wsexplorer.shared.Item(itemIdentifier, theClickedFolderName, true)); //this is the last non clickable item on the BC
return toReturn; return toReturn;
} catch (Exception e) { } catch (Exception e) {
logger.error("Error in get List Parents By Item Identifier ", e); _log.error("Error in get List Parents By Item Identifier ", e);
throw new Exception("Sorry, an error occurred during path retrieving!"); throw new Exception("Sorry, an error occurred during path retrieving!");
} }
} }
@ -273,18 +273,12 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
*/ */
@Override @Override
public List<org.gcube.portlets.widgets.wsexplorer.shared.Item> getBreadcrumbsByItemIdentifierToParentLimit(String itemIdentifier, String parentLimit, boolean includeItemAsParent) throws Exception { public List<org.gcube.portlets.widgets.wsexplorer.shared.Item> getBreadcrumbsByItemIdentifierToParentLimit(String itemIdentifier, String parentLimit, boolean includeItemAsParent) throws Exception {
logger.trace("getBreadcrumbsByItemIdentifierToParentLimit by Item Identifier " + itemIdentifier +" and limit: "+parentLimit); _log.trace("getBreadcrumbsByItemIdentifierToParentLimit by Item Identifier " + itemIdentifier +" and limit: "+parentLimit);
try { try {
Item wsItem = Whorespace.getItem(getThreadLocalRequest(), itemIdentifier); Item wsItem = Whorespace.getItem(getThreadLocalRequest(), itemIdentifier);
System.out.println("**** workspace retrieved item name: "+wsItem.getName());
List<? extends Item> parents = Whorespace.getParents(getThreadLocalRequest(), itemIdentifier); List<? extends Item> parents = Whorespace.getParents(getThreadLocalRequest(), itemIdentifier);
System.out.println("parents size: "+parents.size() + " follows them in order"); _log.trace("parents size: "+parents.size());
for (Item item : parents) {
System.out.println("parent: "+item.getTitle());
}
System.out.println("parents size: "+parents.size());
logger.trace("parents size: "+parents.size());
org.gcube.portlets.widgets.wsexplorer.shared.Item[] arrayParents; org.gcube.portlets.widgets.wsexplorer.shared.Item[] arrayParents;
if(includeItemAsParent==true && wsItem instanceof FolderItem){ if(includeItemAsParent==true && wsItem instanceof FolderItem){
@ -302,33 +296,33 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
*/ */
if( wsItem instanceof FolderItem){ if( wsItem instanceof FolderItem){
if(ItemBuilder.isSpecialFolder((FolderItem) wsItem)){ if(ItemBuilder.isSpecialFolder((FolderItem) wsItem)){
logger.debug("item id is special folder, returning"); _log.debug("item id is special folder, returning");
return new ArrayList<org.gcube.portlets.widgets.wsexplorer.shared.Item>(Arrays.asList(arrayParents)); return new ArrayList<org.gcube.portlets.widgets.wsexplorer.shared.Item>(Arrays.asList(arrayParents));
} }
if(itemIdentifier.compareTo(parentLimit)==0){ if(itemIdentifier.compareTo(parentLimit)==0){
logger.debug("item and parent limit are identical element, returning"); _log.debug("item and parent limit are identical element, returning");
return new ArrayList<org.gcube.portlets.widgets.wsexplorer.shared.Item>(Arrays.asList(arrayParents)); return new ArrayList<org.gcube.portlets.widgets.wsexplorer.shared.Item>(Arrays.asList(arrayParents));
} }
} }
//CONVERTING PATH //CONVERTING PATH
logger.trace("converting path from second-last.."); _log.trace("converting path from second-last..");
for (int i = parents.size()-2; i >= 0; i--) { for (int i = parents.size()-2; i >= 0; i--) {
FolderItem wsParentFolder = (FolderItem) parents.get(i); FolderItem wsParentFolder = (FolderItem) parents.get(i);
arrayParents[i] = ItemBuilder.buildFolderForBreadcrumbs(wsParentFolder, null); arrayParents[i] = ItemBuilder.buildFolderForBreadcrumbs(wsParentFolder, null);
if(arrayParents[i].isSpecialFolder()){ //SKIP HOME PARENT FOR MY_SPECIAL_FOLDER if(arrayParents[i].isSpecialFolder()){ //SKIP HOME PARENT FOR MY_SPECIAL_FOLDER
logger.info("arrayParents index "+i+" is special folder, break"); _log.info("arrayParents index "+i+" is special folder, break");
break; break;
}else if(parentLimit.compareTo(arrayParents[i].getId())==0){ }else if(parentLimit.compareTo(arrayParents[i].getId())==0){
logger.info("reached parent limit "+parentLimit+", break"); _log.info("reached parent limit "+parentLimit+", break");
break; break;
} }
} }
//SET PARENTS //SET PARENTS
logger.trace("setting parents.."); _log.trace("setting parents..");
for(int i=0; i<arrayParents.length-1; i++){ for(int i=0; i<arrayParents.length-1; i++){
org.gcube.portlets.widgets.wsexplorer.shared.Item parent = arrayParents[i]; org.gcube.portlets.widgets.wsexplorer.shared.Item parent = arrayParents[i];
@ -339,7 +333,7 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
} }
} }
logger.trace("ListParents return size: "+arrayParents.length); _log.trace("ListParents return size: "+arrayParents.length);
if(arrayParents[0]==null){ //EXIT BY BREAK IN CASE OF SPECIAL FOLDER OR REACHED PARENT LIMIT if(arrayParents[0]==null){ //EXIT BY BREAK IN CASE OF SPECIAL FOLDER OR REACHED PARENT LIMIT
List<org.gcube.portlets.widgets.wsexplorer.shared.Item> breadcrumbs = new ArrayList<org.gcube.portlets.widgets.wsexplorer.shared.Item>(); List<org.gcube.portlets.widgets.wsexplorer.shared.Item> breadcrumbs = new ArrayList<org.gcube.portlets.widgets.wsexplorer.shared.Item>();
for (int i=1; i<arrayParents.length; i++) { for (int i=1; i<arrayParents.length; i++) {
@ -354,7 +348,7 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("Error in get List Parents By Item Identifier ", e); _log.error("Error in get List Parents By Item Identifier ", e);
throw new Exception("Sorry, an error occurred during path retrieving!"); throw new Exception("Sorry, an error occurred during path retrieving!");
} }
} }
@ -411,27 +405,20 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
*/ */
@Override @Override
public String getMimeType(String itemId) throws Exception { public String getMimeType(String itemId) throws Exception {
return ""; _log.debug("get MimeType By ItemId "+ itemId);
//TODO: implement later try {
// Item wsItem = Whorespace.getItem(getThreadLocalRequest(), itemId);
// logger.info("get MimeType By ItemId "+ itemId); _log.trace("workspace retrieve item name: "+wsItem.getName());
// try { if((wsItem instanceof FolderItem)) //if is a folder no mime
// Item wsItem = Whorespace.getItem(getThreadLocalRequest(), itemId); return null;
// logger.trace("workspace retrieve item name: "+wsItem.getName());
// AbstractFileItem file = (AbstractFileItem) wsItem;
// return file.getContent().getMimeType();
// if(! (wsItem instanceof FolderItem)) {
// return null; } catch (Exception e) {
// } _log.error("get MimeType By ItemId ", e);
// throw new Exception(e.getMessage());
// FolderItem folderItem = (FolderItem) wsItem; }
// //TODO:folderItem.getMimeType();
// return "unknown";
//
// } catch (Exception e) {
// logger.error("get MimeType By ItemId ", e);
// throw new Exception(e.getMessage());
// }
} }
@ -484,7 +471,7 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
} }
return false; return false;
}catch(Exception e){ }catch(Exception e){
logger.error("Error in server isASharedFolder", e); _log.error("Error in server isASharedFolder", e);
return false; return false;
} }
} }
@ -504,11 +491,11 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
public String getReadableSizeByItemId(String itemId) throws Exception { public String getReadableSizeByItemId(String itemId) throws Exception {
try{ try{
logger.info("getFormattedSize ByItemId "+ itemId); _log.info("getFormattedSize ByItemId "+ itemId);
long size = getSizeByItemId(itemId); long size = getSizeByItemId(itemId);
return StringUtil.readableFileSize(size); return StringUtil.readableFileSize(size);
} catch (Exception e) { } catch (Exception e) {
logger.error("getFormattedSize By ItemId ", e); _log.error("getFormattedSize By ItemId ", e);
throw new Exception(e.getMessage()); throw new Exception(e.getMessage());
} }
} }
@ -525,7 +512,7 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
@Override @Override
public org.gcube.portlets.widgets.wsexplorer.shared.Item createFolder(String nameFolder, String description, String parentId) throws Exception { public org.gcube.portlets.widgets.wsexplorer.shared.Item createFolder(String nameFolder, String description, String parentId) throws Exception {
logger.debug("creating folder: "+nameFolder +", parent id: "+parentId); _log.debug("creating folder: "+nameFolder +", parent id: "+parentId);
//TODO //TODO
return null; return null;
// try { // try {
@ -595,7 +582,7 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
*/ */
@Override @Override
public Map<String, String> getGcubePropertiesForWorspaceId(String id) throws Exception { public Map<String, String> getGcubePropertiesForWorspaceId(String id) throws Exception {
logger.trace("getGcubePropertiesForWorspaceId "+id); _log.trace("getGcubePropertiesForWorspaceId "+id);
//TODO //TODO
return null; return null;
// try { // try {
@ -625,7 +612,7 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
FilterCriteria filterCriteria, boolean loadGcubeProperties, FilterCriteria filterCriteria, boolean loadGcubeProperties,
final int startIndex, final int limit, final int serverStartIndex) throws WorkspaceNavigatorServiceException { final int startIndex, final int limit, final int serverStartIndex) throws WorkspaceNavigatorServiceException {
logger.trace("getFolder folderId: "+item.getId()+" showableTypes: "+showableTypes+" purgeEmpyFolders: "+purgeEmpyFolders+" filterCriteria: "+filterCriteria); _log.trace("getFolder folderId: "+item.getId()+" showableTypes: "+showableTypes+" purgeEmpyFolders: "+purgeEmpyFolders+" filterCriteria: "+filterCriteria);
try { try {
@ -633,7 +620,7 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
int searchStartIndex = startIndex < serverStartIndex? serverStartIndex : startIndex; int searchStartIndex = startIndex < serverStartIndex? serverStartIndex : startIndex;
//logger.trace("GetFolder - Replyiing folder"); //logger.trace("GetFolder - Replyiing folder");
logger.debug("MyLg getFolder searchIndex: "+searchStartIndex+", limit: "+limit); _log.debug("MyLg getFolder searchIndex: "+searchStartIndex+", limit: "+limit);
//long startTime = System.currentTimeMillis(); //long startTime = System.currentTimeMillis();
//logger.trace("start time - " + startTime); //logger.trace("start time - " + startTime);
@ -643,18 +630,18 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
SearchedFolder sf = new SearchedFolder(itemFolderToReturn, startIndex, limit, searchStartIndex, false); SearchedFolder sf = new SearchedFolder(itemFolderToReturn, startIndex, limit, searchStartIndex, false);
int currentListCount = sf.getFolder().getChildren().size(); int currentListCount = sf.getFolder().getChildren().size();
logger.debug("MyLg Total item returning is: "+currentListCount); _log.debug("MyLg Total item returning is: "+currentListCount);
FolderItem hlFolder = (FolderItem) folder; FolderItem hlFolder = (FolderItem) folder;
int folderChildrenCount = Whorespace.getItemChildrenCount(getThreadLocalRequest(), hlFolder.getId()); int folderChildrenCount = Whorespace.getItemChildrenCount(getThreadLocalRequest(), hlFolder.getId());
logger.debug("MyLg Folder children count is: "+folderChildrenCount); _log.debug("MyLg Folder children count is: "+folderChildrenCount);
if(currentListCount == limit || folderChildrenCount==0){ if(currentListCount == limit || folderChildrenCount==0){
logger.debug("Page completed returning "+currentListCount+ " items"); _log.debug("Page completed returning "+currentListCount+ " items");
int offset = searchStartIndex+limit; int offset = searchStartIndex+limit;
Collections.sort(sf.getFolder().getChildren(), new ItemComparator()); Collections.sort(sf.getFolder().getChildren(), new ItemComparator());
sf.setServerSearchFinished(offset>folderChildrenCount || folderChildrenCount == 0); sf.setServerSearchFinished(offset>folderChildrenCount || folderChildrenCount == 0);
logger.debug("is Search finished: "+sf.isServerSearchFinished()); _log.debug("is Search finished: "+sf.isServerSearchFinished());
return sf; return sf;
} }
@ -664,25 +651,25 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
int offsetStartIndex = searchStartIndex; int offsetStartIndex = searchStartIndex;
boolean pageOffsetOut = false; boolean pageOffsetOut = false;
while(currentListCount < limit && !sf.isServerSearchFinished() && !pageOffsetOut){ //&& SEARCH NOT ULTIMATED while(currentListCount < limit && !sf.isServerSearchFinished() && !pageOffsetOut){ //&& SEARCH NOT ULTIMATED
logger.debug("MyLg new WHILE Items count: "+currentListCount+" is less than limit.."); _log.debug("MyLg new WHILE Items count: "+currentListCount+" is less than limit..");
int newstartIndex = offsetStartIndex+limit+1; int newstartIndex = offsetStartIndex+limit+1;
logger.debug("MyLg NewStartIndex is startIndex+limit: "+newstartIndex); _log.debug("MyLg NewStartIndex is startIndex+limit: "+newstartIndex);
//THERE ARE OTHER CHILDREN OVER NEW START INDEX //THERE ARE OTHER CHILDREN OVER NEW START INDEX
if(newstartIndex < folderChildrenCount){ if(newstartIndex < folderChildrenCount){
//newLimit = limit - childrenToReturn.size(); //newLimit = limit - childrenToReturn.size();
logger.debug("MyLg getting items with index start: "+newstartIndex + ", limit: "+limit); _log.debug("MyLg getting items with index start: "+newstartIndex + ", limit: "+limit);
org.gcube.portlets.widgets.wsexplorer.shared.Item newItemFolder = ItemBuilder.getItem(null, folder, folderPath, showableTypes, filterCriteria, true, loadGcubeProperties, newstartIndex, limit); org.gcube.portlets.widgets.wsexplorer.shared.Item newItemFolder = ItemBuilder.getItem(null, folder, folderPath, showableTypes, filterCriteria, true, loadGcubeProperties, newstartIndex, limit);
int diff = limit - currentListCount; //How items are remaining int diff = limit - currentListCount; //How items are remaining
//int offset = 0; //int offset = 0;
logger.debug("MyLg new search start: "+newstartIndex + ", diff: "+diff+ ", retrieved: "+newItemFolder.getChildren().size()); _log.debug("MyLg new search start: "+newstartIndex + ", diff: "+diff+ ", retrieved: "+newItemFolder.getChildren().size());
if(diff >= newItemFolder.getChildren().size()){ if(diff >= newItemFolder.getChildren().size()){
logger.debug("MyLg Adding sublist from 0 to 'diff' "+diff+" to children"); _log.debug("MyLg Adding sublist from 0 to 'diff' "+diff+" to children");
childrenToReturn.addAll(newItemFolder.getChildren().subList(0, newItemFolder.getChildren().size())); childrenToReturn.addAll(newItemFolder.getChildren().subList(0, newItemFolder.getChildren().size()));
//offset = diff; //offset = diff;
}else{ }else{
logger.debug("MyLg PageOffsetOut, the sublist size: "+newItemFolder.getChildren().size()+ " is greather than (limit-currentListCount)"+diff+" leaving WHILE..."); _log.debug("MyLg PageOffsetOut, the sublist size: "+newItemFolder.getChildren().size()+ " is greather than (limit-currentListCount)"+diff+" leaving WHILE...");
//childrenToReturn.addAll(newItemFolder.getChildren().subList(0, newItemFolder.getChildren().size())); //childrenToReturn.addAll(newItemFolder.getChildren().subList(0, newItemFolder.getChildren().size()));
//offset = newItemFolder.getChildren().size(); //offset = newItemFolder.getChildren().size();
pageOffsetOut = true; pageOffsetOut = true;
@ -690,10 +677,10 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
offsetStartIndex = newstartIndex; offsetStartIndex = newstartIndex;
currentListCount = childrenToReturn.size(); currentListCount = childrenToReturn.size();
//int realServerEndIndex = newstartIndex+offset; //int realServerEndIndex = newstartIndex+offset;
logger.debug("MyLg New items count is: "+currentListCount + " serverEndIndex: "+offsetStartIndex); _log.debug("MyLg New items count is: "+currentListCount + " serverEndIndex: "+offsetStartIndex);
sf.setServerEndIndex(offsetStartIndex); sf.setServerEndIndex(offsetStartIndex);
}else{ }else{
logger.debug("MyLg New start index (oldStartIndex+limit) is grather than folder children count, search is finished"); _log.debug("MyLg New start index (oldStartIndex+limit) is grather than folder children count, search is finished");
sf.setServerSearchFinished(true); sf.setServerSearchFinished(true);
} }
} }
@ -716,11 +703,11 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
// } // }
Collections.sort(itemFolderToReturn.getChildren(), new ItemComparator()); Collections.sort(itemFolderToReturn.getChildren(), new ItemComparator());
logger.debug("Returning: "+sf); _log.debug("Returning: "+sf);
return sf; return sf;
} catch (Exception e) { } catch (Exception e) {
logger.error("Error during folder retrieving", e); _log.error("Error during folder retrieving", e);
throw new WorkspaceNavigatorServiceException("Sorry, an error occurred when performing get folder"); throw new WorkspaceNavigatorServiceException("Sorry, an error occurred when performing get folder");
} }
} }

View File

@ -11,7 +11,7 @@ package org.gcube.portlets.widgets.wsexplorer.shared;
* Jun 18, 2015 * Jun 18, 2015
*/ */
public enum ItemType { public enum ItemType {
PRIVATE_FOLDER, //MANDATORY PRIVATE_FOLDER,
SHARED_FOLDER, SHARED_FOLDER,
VRE_FOLDER, VRE_FOLDER,
FOLDER, //MANDATORY FOLDER, //MANDATORY

View File

@ -25,6 +25,7 @@ m%n
log4j.logger.org.apache.jasper.compiler.TldLocationsCache.level=ERROR, CA log4j.logger.org.apache.jasper.compiler.TldLocationsCache.level=ERROR, CA
#AVOID LOGGING EHCACHE Hearbeat problem #AVOID LOGGING EHCACHE Hearbeat problem
log4j.logger.net.sf.ehcache.distribution.PayloadUtil=OFF, CA log4j.logger.net.sf.ehcache.distribution.PayloadUtil=OFF, CA
log4j.loggercom.liferay.portal.kernel.log.Jdk14LogImpl=OFF, CA
log4j.logger.org.gcube.portal.notifications=INFO, CA log4j.logger.org.gcube.portal.notifications=INFO, CA
log4j.logger.org.gcube.common.scope.impl=INFO, CA log4j.logger.org.gcube.common.scope.impl=INFO, CA