diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java b/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java index 160cca1..e6dce8a 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java @@ -5,6 +5,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; +import org.gcube.portlets.user.workspace.client.ConstantsExplorer.WsPortletInitOperation; import org.gcube.portlets.user.workspace.client.event.AccountingHistoryEvent; import org.gcube.portlets.user.workspace.client.event.AccountingHistoryEventHandler; import org.gcube.portlets.user.workspace.client.event.AccountingReadersEvent; @@ -424,7 +425,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt // int last = currentUrl.lastIndexOf("/"); // String shareLinkUrl = currentUrl.substring(0,last+1) + "?" +ConstantsExplorer.GET_ITEMID_PARAMETER+"="+getLinkEvent.getSourceFile().getIdentifier(); String shareLinkUrl = currentUrl+ "?" +ConstantsExplorer.GET_ITEMID_PARAMETER+"="+getLinkEvent.getSourceFile().getIdentifier(); - + shareLinkUrl+="&"+ConstantsExplorer.GET_OPEARATION_PARAMETER+"="+WsPortletInitOperation.sharelink; DialogShareLink dialog = new DialogShareLink("Copy to clipboard Share Link: Ctrl+C", shareLinkUrl); dialog.show(); diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/ConstantsExplorer.java b/src/main/java/org/gcube/portlets/user/workspace/client/ConstantsExplorer.java index a2f30ea..bcda392 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/ConstantsExplorer.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/ConstantsExplorer.java @@ -185,9 +185,11 @@ public class ConstantsExplorer { public static final NumberFormat numberFormatterKB = NumberFormat.getFormat("#,##0 KB;(#,##0 KB)"); - //USED IN HTTP GET AS PARAMETER + //USED IN HTTP GET AS PARAMETER.. THIS PARAMS ARE REPLICATED IN THE CONSTANTS OF TREE WIDGET + public static final String GET_SEARCH_PARAMETER ="search"; public static final String GET_ITEMID_PARAMETER ="itemid"; - + public static final String GET_OPEARATION_PARAMETER ="operation"; + public static enum WsPortletInitOperation {sharelink, gotofolder}; //DEFAULT OPERATION IS GOTOFOLDER public enum ViewSwitchType {Tree, SmartFolder, Messages}; diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java index 78cb919..31076e7 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java @@ -151,4 +151,11 @@ public interface GWTWorkspaceService extends RemoteService{ */ public FileGridModel getItemForFileGrid(String itemId) throws Exception; + /** + * @param folderId + * @return + * @throws Exception + */ + List getFolderChildrenForFileGridById(String folderId) throws Exception; + } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java index 451b1fb..6935f26 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java @@ -149,5 +149,8 @@ public interface GWTWorkspaceServiceAsync { void getItemForFileGrid(String itemId, AsyncCallback callback); + void getFolderChildrenForFileGridById(String folderId, + AsyncCallback> callback); + } diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java index fae921d..81db4e9 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java @@ -240,9 +240,9 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT } catch (Exception e) { workspaceLogger.error("Error in server During item retrieving", e); // workspaceLogger.trace("Error in server During item retrieving " + e); - + String error = ConstantsExplorer.SERVER_ERROR + " retrieving item. Item doesn't exists or you haven't permission to access this item"; //GWT can't serialize all exceptions - throw new Exception("Error during item loading, please contact the support."); + throw new Exception(error); } } @@ -283,8 +283,75 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT workspaceLogger.error("Error in server During items retrieving", e); // workspaceLogger.trace("Error in server During items retrieving " + e); // e.printStackTrace(); + String error = ConstantsExplorer.SERVER_ERROR + " retrieving item. Item doesn't exists or you haven't permission to access this item"; //GWT can't serialize all exceptions - throw new Exception("Error during item loading, please contact the support."); + throw new Exception(error); + } + } + + @Override + public List getFolderChildrenForFileGridById(String folderId) throws Exception { + + Workspace workspace; + + try { + GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class); + + workspace = getWorkspace(); + + logger.trace("get children for Grid by id: "+folderId); + List listFileGridModels = new ArrayList(); + + + if(folderId==null || folderId.isEmpty()){ + logger.trace("id is null or empty, return"); + return listFileGridModels; + } + + workspaceLogger.trace("get children for Grid by id: "+folderId); + + GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder(); + + //BUILD PARENT + WorkspaceItem wsItem = workspace.getItem(folderId); + + WorkspaceFolder parent; + + if(wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER) || wsItem.getType().equals(WorkspaceItemType.FOLDER)){ + workspaceLogger.trace("item id: "+folderId +" is of type: "+wsItem.getType()); + parent = (WorkspaceFolder) workspace.getItem(folderId); + + }else{ + workspaceLogger.trace("item id: "+folderId +" is not a folder but of type: "+wsItem.getType()+", get parent"); + parent = wsItem.getParent(); + } + + if(parent==null) + return listFileGridModels; + + FileGridModel wsParent = builder.buildGXTFileGridModelItem(parent, null); + Long startTime = System.currentTimeMillis(); + + //GET CHILDREN + List listItems = (List) parent.getChildren(); + + Long endTime = System.currentTimeMillis() - startTime; + String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime)); + logger.trace("grid getChildren() returning "+listItems.size()+" elements in " + time); + + + listFileGridModels = builder.buildGXTListFileGridModelItem(listItems, wsParent); + + return listFileGridModels; + + } catch (Exception e) { + workspaceLogger.error("Error in server During items retrieving", e); +// workspaceLogger.trace("Error in server During items retrieving " + e); + + String error = ConstantsExplorer.SERVER_ERROR + " retrieving item. Item doesn't exists or you haven't permission to access this item"; +// e.printStackTrace(); + //GWT can't serialize all exceptions + throw new Exception(error); } }