updated classes

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@115457 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2015-06-22 13:42:49 +00:00
parent decb4363ba
commit 7c07422e87
2 changed files with 10 additions and 62 deletions

View File

@ -23,6 +23,7 @@ public class GXTCategoryItemInterface implements Serializable {
public static final String SMF_FOLDERS = "Folders"; public static final String SMF_FOLDERS = "Folders";
public static final String SMF_SHARED_FOLDERS = "Shared Folders"; public static final String SMF_SHARED_FOLDERS = "Shared Folders";
public static final String SMF_GCUBE_ITEMS= "Gcube Items"; public static final String SMF_GCUBE_ITEMS= "Gcube Items";
// public static final String SMF_VRE_FOLDERS = "VRE Folders";
public GXTCategoryItemInterface(){} public GXTCategoryItemInterface(){}
@ -30,4 +31,6 @@ public class GXTCategoryItemInterface implements Serializable {
public static final String MS_MESSAGES = "Messages"; public static final String MS_MESSAGES = "Messages";
public static final String MS_SENT = "Sent"; public static final String MS_SENT = "Sent";
public static final String MS_RECEIVED = "Received"; public static final String MS_RECEIVED = "Received";
} }

View File

@ -44,6 +44,7 @@ import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portal.custom.communitymanager.OrganizationsUtil; import org.gcube.portal.custom.communitymanager.OrganizationsUtil;
import org.gcube.portlets.user.workspace.client.ConstantsExplorer; import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
import org.gcube.portlets.user.workspace.client.interfaces.GXTCategoryItemInterface; import org.gcube.portlets.user.workspace.client.interfaces.GXTCategoryItemInterface;
import org.gcube.portlets.user.workspace.client.interfaces.GXTFolderItemTypeEnum;
import org.gcube.portlets.user.workspace.client.model.BulkCreatorModel; import org.gcube.portlets.user.workspace.client.model.BulkCreatorModel;
import org.gcube.portlets.user.workspace.client.model.FileDetailsModel; import org.gcube.portlets.user.workspace.client.model.FileDetailsModel;
import org.gcube.portlets.user.workspace.client.model.FileGridModel; import org.gcube.portlets.user.workspace.client.model.FileGridModel;
@ -339,13 +340,9 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
workspaceLogger.trace("get folder children for: "+folder.getIdentifier()); workspaceLogger.trace("get folder children for: "+folder.getIdentifier());
workspace = getWorkspace(); workspace = getWorkspace();
List<FileModel> listFileModels = new ArrayList<FileModel>(); List<FileModel> listFileModels = new ArrayList<FileModel>();
WorkspaceItem wsItem = workspace.getItem(folder.getIdentifier()); WorkspaceItem wsItem = workspace.getItem(folder.getIdentifier());
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder(); GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
listFileModels = builder.buildGXTListFileModelItem(wsItem, folder); listFileModels = builder.buildGXTListFileModelItem(wsItem, folder);
//ADDING SPECIAL FOLDER? //ADDING SPECIAL FOLDER?
@ -396,7 +393,6 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
} }
workspaceLogger.info("Read special folder name: '"+sfReader.getSpecialFolderName()+"', from property file.."); workspaceLogger.info("Read special folder name: '"+sfReader.getSpecialFolderName()+"', from property file..");
return sfReader.getSpecialFolderName(); return sfReader.getSpecialFolderName();
} }
@ -416,26 +412,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
throw new Exception("Folder is null"); throw new Exception("Folder is null");
workspaceLogger.trace("get children for Grid for folder: "+folder.getIdentifier()); workspaceLogger.trace("get children for Grid for folder: "+folder.getIdentifier());
Workspace workspace = getWorkspace(); Workspace workspace = getWorkspace();
List<FileGridModel> listFileGridModels = new ArrayList<FileGridModel>(); List<FileGridModel> listFileGridModels = new ArrayList<FileGridModel>();
WorkspaceFolder wsFolder = (WorkspaceFolder) workspace.getItem(folder.getIdentifier());
WorkspaceFolder wsFolder = (WorkspaceFolder) workspace.getItem(folder.getIdentifier()); GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
List<WorkspaceItem> listItems = (List<WorkspaceItem>) wsFolder.getChildren();
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
// Long startTime = System.currentTimeMillis();
List<WorkspaceItem> listItems = (List<WorkspaceItem>) wsFolder.getChildren();
// Long endTime = System.currentTimeMillis() - startTime;
// String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime));
// workspaceLogger.debug("##HL FILLING: grid getChildren() returning "+listItems.size()+" elements in " + time);
listFileGridModels = builder.buildGXTListFileGridModelItem(listItems, folder); listFileGridModels = builder.buildGXTListFileGridModelItem(listItems, folder);
//ADDING SPECIAL FOLDER? //ADDING SPECIAL FOLDER?
if(wsFolder.isRoot()){ if(wsFolder.isRoot()){
//ADD SPECIAL FOLDER //ADD SPECIAL FOLDER
@ -443,6 +426,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
workspaceLogger.info("Folder is root, loading special folders.."); workspaceLogger.info("Folder is root, loading special folders..");
WorkspaceFolder specialFolder = workspace.getMySpecialFolders(); WorkspaceFolder specialFolder = workspace.getMySpecialFolders();
FileGridModel specialFolderModel = builder.buildGXTFileGridModelItem(specialFolder, folder); FileGridModel specialFolderModel = builder.buildGXTFileGridModelItem(specialFolder, folder);
// specialFolderModel.setShortcutCategory(GXTCategoryItemInterface.SMF_VRE_FOLDERS);
specialFolderModel.setSpecialFolder(true); specialFolderModel.setSpecialFolder(true);
String newName = getNameForSpecialFolder(); String newName = getNameForSpecialFolder();
@ -462,8 +446,6 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
} catch (Exception e) { } catch (Exception e) {
workspaceLogger.error("Error in server During items retrieving", e); 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_EITHER_ITEM_DOESN_T_EXIST; String error = ConstantsExplorer.SERVER_ERROR + RETRIEVING_ITEM_EITHER_ITEM_DOESN_T_EXIST;
//GWT can't serialize all exceptions //GWT can't serialize all exceptions
throw new Exception(error); throw new Exception(error);
@ -497,12 +479,10 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
} }
workspaceLogger.trace("get children for Grid by id: "+folderId); workspaceLogger.trace("get children for Grid by id: "+folderId);
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder(); GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
//BUILD PARENT //BUILD PARENT
WorkspaceItem wsItem = workspace.getItem(folderId); WorkspaceItem wsItem = workspace.getItem(folderId);
WorkspaceFolder parent; WorkspaceFolder parent;
if(wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER) || wsItem.getType().equals(WorkspaceItemType.FOLDER)){ if(wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER) || wsItem.getType().equals(WorkspaceItemType.FOLDER)){
@ -517,7 +497,6 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
if(parent==null) if(parent==null)
return listFileGridModels; return listFileGridModels;
FileGridModel wsParent = builder.buildGXTFileGridModelItem(parent, null); FileGridModel wsParent = builder.buildGXTFileGridModelItem(parent, null);
//PARENT BUILDED IS SHARED? //PARENT BUILDED IS SHARED?
@ -530,23 +509,15 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
//GET CHILDREN //GET CHILDREN
List<WorkspaceItem> listItems = (List<WorkspaceItem>) parent.getChildren(); List<WorkspaceItem> listItems = (List<WorkspaceItem>) parent.getChildren();
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));
workspaceLogger.debug("grid getChildren() returning "+listItems.size()+" elements in " + time); workspaceLogger.debug("grid getChildren() returning "+listItems.size()+" elements in " + time);
listFileGridModels = builder.buildGXTListFileGridModelItem(listItems, wsParent); listFileGridModels = builder.buildGXTListFileGridModelItem(listItems, wsParent);
return listFileGridModels; return listFileGridModels;
} catch (Exception e) { } catch (Exception e) {
workspaceLogger.error("Error in server During items retrieving", 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_EITHER_ITEM_DOESN_T_EXIST; String error = ConstantsExplorer.SERVER_ERROR + RETRIEVING_ITEM_EITHER_ITEM_DOESN_T_EXIST;
// e.printStackTrace();
//GWT can't serialize all exceptions
throw new Exception(error); throw new Exception(error);
} }
} }
@ -564,29 +535,19 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
throw new Exception(IDENTIFIER_IS_NULL); throw new Exception(IDENTIFIER_IS_NULL);
Workspace workspace = getWorkspace(); Workspace workspace = getWorkspace();
workspaceLogger.trace("get child for Grid by id: "+itemId); workspaceLogger.trace("get child for Grid by id: "+itemId);
WorkspaceItem wsItem = workspace.getItem(itemId); WorkspaceItem wsItem = workspace.getItem(itemId);
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder(); GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
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));
workspaceLogger.debug("get child for Grid by id returning element in " + time); workspaceLogger.debug("get child for Grid by id returning element in " + time);
//BUILD PARENT //BUILD PARENT
WorkspaceFolder folder = wsItem.getParent(); //get parent WorkspaceFolder folder = wsItem.getParent(); //get parent
FileGridModel wsFolder = builder.buildGXTFileGridModelItem(folder, null); FileGridModel wsFolder = builder.buildGXTFileGridModelItem(folder, null);
//BUILD ITEM //BUILD ITEM
return builder.buildGXTFileGridModelItem(wsItem, wsFolder); return builder.buildGXTFileGridModelItem(wsItem, wsFolder);
} catch (Exception e) { } catch (Exception e) {
workspaceLogger.error("Error in server during item retrieving, getItemForFileGrid", e); workspaceLogger.error("Error in server during item retrieving, getItemForFileGrid", e);
String error = ConstantsExplorer.SERVER_ERROR + RETRIEVING_ITEM_EITHER_ITEM_DOESN_T_EXIST; String error = ConstantsExplorer.SERVER_ERROR + RETRIEVING_ITEM_EITHER_ITEM_DOESN_T_EXIST;
@ -611,7 +572,6 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
throw new Exception(IDENTIFIER_IS_NULL); throw new Exception(IDENTIFIER_IS_NULL);
workspaceLogger.trace("moveItem item: "+itemId+" destination: "+destinationId); workspaceLogger.trace("moveItem item: "+itemId+" destination: "+destinationId);
WorkspaceItem sourceItem = workspace.getItem(itemId); //GET SOURCE ITEM BEFORE OF MOVE WorkspaceItem sourceItem = workspace.getItem(itemId); //GET SOURCE ITEM BEFORE OF MOVE
if(sourceItem==null) if(sourceItem==null)
@ -624,10 +584,8 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
sourceSharedId = sourceItem.getIdSharedFolder(); //GET SHARED ID BEFORE OF MOVE sourceSharedId = sourceItem.getIdSharedFolder(); //GET SHARED ID BEFORE OF MOVE
workspaceLogger.trace("moveItem item: "+itemId+" sourceItem name "+sourceItem.getName() + " shared: "+sourceItemIsShared+ " destination: "+destinationId); workspaceLogger.trace("moveItem item: "+itemId+" sourceItem name "+sourceItem.getName() + " shared: "+sourceItemIsShared+ " destination: "+destinationId);
WorkspaceItem destinationItem = workspace.moveItem(itemId, destinationId); //move item WorkspaceItem destinationItem = workspace.moveItem(itemId, destinationId); //move item
WorkspaceItem folderDestinationItem = workspace.getItem(destinationId); //retrieve folder destination WorkspaceItem folderDestinationItem = workspace.getItem(destinationId); //retrieve folder destination
workspaceLogger.trace("sourceItem.isShared() "+sourceItemIsShared); workspaceLogger.trace("sourceItem.isShared() "+sourceItemIsShared);
workspaceLogger.trace("folderDestinationItem item: "+destinationId+" folderDestinationItem name "+folderDestinationItem.getName() + " folderDestinationItem shared: "+folderDestinationItem.isShared()); workspaceLogger.trace("folderDestinationItem item: "+destinationId+" folderDestinationItem name "+folderDestinationItem.getName() + " folderDestinationItem shared: "+folderDestinationItem.isShared());
@ -695,11 +653,8 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
sourceSharedId = sourceItem.getIdSharedFolder(); //GET SHARED ID BEFORE OF MOVE sourceSharedId = sourceItem.getIdSharedFolder(); //GET SHARED ID BEFORE OF MOVE
workspaceLogger.trace("moveItem item: "+itemId+" sourceItem name "+sourceItem.getName() + " shared: "+sourceItemIsShared+ " destination: "+destinationId); workspaceLogger.trace("moveItem item: "+itemId+" sourceItem name "+sourceItem.getName() + " shared: "+sourceItemIsShared+ " destination: "+destinationId);
WorkspaceItem destinationItem = workspace.moveItem(itemId, destinationId); //move item WorkspaceItem destinationItem = workspace.moveItem(itemId, destinationId); //move item
WorkspaceItem folderDestinationItem = workspace.getItem(destinationId); //retrieve folder destination WorkspaceItem folderDestinationItem = workspace.getItem(destinationId); //retrieve folder destination
workspaceLogger.trace("sourceItem.isShared() "+sourceItemIsShared ); workspaceLogger.trace("sourceItem.isShared() "+sourceItemIsShared );
workspaceLogger.trace("folderDestinationItem item: "+destinationId+" folderDestinationItem name "+folderDestinationItem.getName() + " folderDestinationItem shared: "+folderDestinationItem.isShared()); workspaceLogger.trace("folderDestinationItem item: "+destinationId+" folderDestinationItem name "+folderDestinationItem.getName() + " folderDestinationItem shared: "+folderDestinationItem.isShared());
@ -767,11 +722,8 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
//DEBUG //DEBUG
printContacts(listContacts); printContacts(listContacts);
Workspace workspace = getWorkspace(); Workspace workspace = getWorkspace();
WorkspaceItem destinationSharedFolder = workspace.getItem(folderDestinationItem.getIdSharedFolder()); WorkspaceItem destinationSharedFolder = workspace.getItem(folderDestinationItem.getIdSharedFolder());
NotificationsProducer np = getNotificationProducer(); NotificationsProducer np = getNotificationProducer();
if(destinationSharedFolder instanceof WorkspaceSharedFolder){ if(destinationSharedFolder instanceof WorkspaceSharedFolder){
@ -830,13 +782,8 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
//DEBUG //DEBUG
printContacts(listContacts); printContacts(listContacts);
Workspace workspace = getWorkspace(); Workspace workspace = getWorkspace();
WorkspaceItem sourceSharedFolder = workspace.getItem(sourceSharedId); WorkspaceItem sourceSharedFolder = workspace.getItem(sourceSharedId);
//System.out.println(" name sourceSharedFolder: "+ sourceSharedFolder.getName());
NotificationsProducer np = getNotificationProducer(); NotificationsProducer np = getNotificationProducer();
if(sourceSharedFolder instanceof WorkspaceSharedFolder){ if(sourceSharedFolder instanceof WorkspaceSharedFolder){
@ -2441,9 +2388,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
if(includeItemAsParent==true && wsItem.getType().equals(WorkspaceItemType.FOLDER)){ if(includeItemAsParent==true && wsItem.getType().equals(WorkspaceItemType.FOLDER)){
listParents.add(builder.buildGXTFolderModelItemHandleSpecialFolder((WorkspaceFolder) wsItem, null, nameSpecialFolder)); listParents.add(builder.buildGXTFolderModelItemHandleSpecialFolder((WorkspaceFolder) wsItem, null, nameSpecialFolder));
} }
while(wsItem!=null && wsItem.getParent()!=null){ while(wsItem!=null && wsItem.getParent()!=null){
WorkspaceFolder wsFolder = wsItem.getParent(); WorkspaceFolder wsFolder = wsItem.getParent();