go to folder completed

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@77067 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2013-06-14 13:04:43 +00:00
parent 52e6dfd548
commit 3e8643d502
5 changed files with 86 additions and 6 deletions

View File

@ -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();

View File

@ -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};

View File

@ -151,4 +151,11 @@ public interface GWTWorkspaceService extends RemoteService{
*/
public FileGridModel getItemForFileGrid(String itemId) throws Exception;
/**
* @param folderId
* @return
* @throws Exception
*/
List<FileGridModel> getFolderChildrenForFileGridById(String folderId) throws Exception;
}

View File

@ -149,5 +149,8 @@ public interface GWTWorkspaceServiceAsync {
void getItemForFileGrid(String itemId, AsyncCallback<FileGridModel> callback);
void getFolderChildrenForFileGridById(String folderId,
AsyncCallback<List<FileGridModel>> callback);
}

View File

@ -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<FileGridModel> 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<FileGridModel> listFileGridModels = new ArrayList<FileGridModel>();
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<WorkspaceItem> listItems = (List<WorkspaceItem>) 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);
}
}