3892: Workspace Enhancement: use a cache to the list of users during Workspace init

Task-Url: https://support.d4science.org/issues/3892

Updated pom version at 6.11.2

Moved UserStore to get all contacts from DialogShare to ApplicationController in order to load list of users in init phase 

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@128471 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2016-05-05 09:49:36 +00:00
parent 6baae05b1c
commit 4fa170fa62
8 changed files with 411 additions and 376 deletions

22
pom.xml
View File

@ -10,7 +10,7 @@
<groupId>org.gcube.portlets.user</groupId> <groupId>org.gcube.portlets.user</groupId>
<artifactId>workspace-tree-widget</artifactId> <artifactId>workspace-tree-widget</artifactId>
<version>6.11.1-SNAPSHOT</version> <version>6.11.2-SNAPSHOT</version>
<name>gCube Workspace Tree Widget</name> <name>gCube Workspace Tree Widget</name>
<description> <description>
gCube Workspace Tree Widget is a widget to navigate and interact with gCube Workspace gCube Workspace Tree Widget is a widget to navigate and interact with gCube Workspace
@ -37,7 +37,7 @@
<dependency> <dependency>
<groupId>org.gcube.distribution</groupId> <groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId> <artifactId>maven-portal-bom</artifactId>
<version>LATEST</version> <version>2.6.0-SNAPSHOT</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>
@ -47,11 +47,11 @@
<dependencies> <dependencies>
<!-- UNCOMMENT THIS TO RUN IN DEVO MODE --> <!-- UNCOMMENT THIS TO RUN IN DEVO MODE -->
<!-- <dependency> --> <!-- <dependency> -->
<!-- <groupId>xerces</groupId> --> <!-- <groupId>xerces</groupId> -->
<!-- <artifactId>xerces</artifactId> --> <!-- <artifactId>xerces</artifactId> -->
<!-- <version>2.4.0</version> --> <!-- <version>2.4.0</version> -->
<!-- </dependency> --> <!-- </dependency> -->
<!-- This dependency is needed to use GWT UI BInder without old Xerces <!-- This dependency is needed to use GWT UI BInder without old Xerces
version of gCore complaining --> version of gCore complaining -->
@ -196,13 +196,6 @@
<artifactId>xstream</artifactId> <artifactId>xstream</artifactId>
<version>1.4.5</version> <version>1.4.5</version>
</dependency> </dependency>
<!-- FILE UPLOAD-progress-bar -->
<!-- <dependency> -->
<!-- <groupId>org.gcube.portlets.widgets</groupId> -->
<!-- <artifactId>fileupload-progress-bar</artifactId> -->
<!-- <version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version> -->
<!-- </dependency> -->
<dependency> <dependency>
<groupId>org.gcube.portlets.widgets</groupId> <groupId>org.gcube.portlets.widgets</groupId>
@ -242,7 +235,6 @@
<dependency> <dependency>
<groupId>org.gcube.portal</groupId> <groupId>org.gcube.portal</groupId>
<artifactId>social-networking-library</artifactId> <artifactId>social-networking-library</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -106,6 +106,7 @@ import org.gcube.portlets.user.workspace.client.util.RequestBuilderWorkspaceVali
import org.gcube.portlets.user.workspace.client.util.WindowOpenParameter; import org.gcube.portlets.user.workspace.client.util.WindowOpenParameter;
import org.gcube.portlets.user.workspace.client.view.ExplorerPanel; import org.gcube.portlets.user.workspace.client.view.ExplorerPanel;
import org.gcube.portlets.user.workspace.client.view.sharing.DialogShareFolder; import org.gcube.portlets.user.workspace.client.view.sharing.DialogShareFolder;
import org.gcube.portlets.user.workspace.client.view.sharing.UserStore;
import org.gcube.portlets.user.workspace.client.view.sharing.permissions.DialogPermission; import org.gcube.portlets.user.workspace.client.view.sharing.permissions.DialogPermission;
import org.gcube.portlets.user.workspace.client.view.tree.AsyncTreePanel; import org.gcube.portlets.user.workspace.client.view.tree.AsyncTreePanel;
import org.gcube.portlets.user.workspace.client.view.windows.BulkCreatorWindow; import org.gcube.portlets.user.workspace.client.view.windows.BulkCreatorWindow;
@ -175,6 +176,8 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
// private FileUploader fileUploader; // private FileUploader fileUploader;
public static String myLogin; public static String myLogin;
public static String myLoginFirstName; public static String myLoginFirstName;
//PRE-LOAD LIST OF USER FORM LIFERAY
private UserStore userStore = new UserStore();
private static AppControllerExplorer singleton; private static AppControllerExplorer singleton;
@ -440,7 +443,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
if(isNewFolder) if(isNewFolder)
dialogSharedFolder = new DialogShareFolder(parentDirectoryName,eventBus); dialogSharedFolder = new DialogShareFolder(parentDirectoryName,eventBus);
else else
dialogSharedFolder = new DialogShareFolder(parentDirectoryName, sourceFileModel, eventBus); dialogSharedFolder = new DialogShareFolder(parentDirectoryName, sourceFileModel, eventBus, userStore);
final DialogShareFolder finalDialog = dialogSharedFolder; final DialogShareFolder finalDialog = dialogSharedFolder;
@ -1904,6 +1907,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
* @return ExplorerPanel * @return ExplorerPanel
* @deprecated * @deprecated
*/ */
@Deprecated
public ExplorerPanel getTreePanel(){ public ExplorerPanel getTreePanel(){
this.explorerPanel = getPanel(); this.explorerPanel = getPanel();

View File

@ -47,8 +47,8 @@ public class DialogShareFolder extends Dialog {
private TextField<String> txtName; private TextField<String> txtName;
private TextArea textAreaDescription = new TextArea(); private TextArea textAreaDescription = new TextArea();
private FileModel parentFolder = null; private FileModel parentFolder = null;
private UserStore userStore = new UserStore(); private UserStore userStore;
private MultiValuePanel suggestPanel = new MultiValuePanel(userStore); private MultiValuePanel suggestPanel;
private Button buttonMultiDrag = new Button("Choose Contacts"); private Button buttonMultiDrag = new Button("Choose Contacts");
private TextField<String> txtOwner; private TextField<String> txtOwner;
private PanelTogglePermission permission; private PanelTogglePermission permission;
@ -63,7 +63,9 @@ public class DialogShareFolder extends Dialog {
* @param folder the folder * @param folder the folder
* @param eventBus the event bus * @param eventBus the event bus
*/ */
public DialogShareFolder(String folderParentName, final FileModel folder, HandlerManager eventBus) { public DialogShareFolder(String folderParentName, final FileModel folder, HandlerManager eventBus, UserStore userStore) {
this.userStore = userStore;
this.suggestPanel = new MultiValuePanel(userStore);
initLayout(folderParentName); initLayout(folderParentName);
this.parentFolder = folder; this.parentFolder = folder;
this.setIcon(Resources.getIconShareFolder()); this.setIcon(Resources.getIconShareFolder());

View File

@ -12,8 +12,9 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
/** /**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * The Class UserStore.
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
*/ */
public class UserStore implements ContactFetcher{ public class UserStore implements ContactFetcher{
@ -21,9 +22,16 @@ public class UserStore implements ContactFetcher{
// public boolean syncronizeCleanSharedUser = false; // public boolean syncronizeCleanSharedUser = false;
/**
* Instantiates a new user store.
*/
public UserStore() { public UserStore() {
loadAllUsersFromServer(null);
} }
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.view.sharing.ContactFetcher#getListContact(com.google.gwt.user.client.rpc.AsyncCallback, boolean)
*/
@Override @Override
public void getListContact(AsyncCallback<List<InfoContactModel>> callback, boolean reloadList){ public void getListContact(AsyncCallback<List<InfoContactModel>> callback, boolean reloadList){
@ -33,11 +41,19 @@ public class UserStore implements ContactFetcher{
callback.onSuccess(listAllContact); callback.onSuccess(listAllContact);
} }
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.view.sharing.ContactFetcher#getListSharedUserByFolderId(java.lang.String, com.google.gwt.user.client.rpc.AsyncCallback)
*/
@Override @Override
public void getListSharedUserByFolderId(String sharedFolderId, AsyncCallback<List<InfoContactModel>> callback){ public void getListSharedUserByFolderId(String sharedFolderId, AsyncCallback<List<InfoContactModel>> callback){
loadSharedUserBySharedFolderId(sharedFolderId, callback); loadSharedUserBySharedFolderId(sharedFolderId, callback);
} }
/**
* Load all users from server.
*
* @param callback the callback
*/
private void loadAllUsersFromServer(final AsyncCallback<List<InfoContactModel>> callback){ private void loadAllUsersFromServer(final AsyncCallback<List<InfoContactModel>> callback){
listAllContact = new ArrayList<InfoContactModel>(); listAllContact = new ArrayList<InfoContactModel>();
@ -48,17 +64,25 @@ public class UserStore implements ContactFetcher{
public void onSuccess(List<InfoContactModel> result) { public void onSuccess(List<InfoContactModel> result) {
GWT.log("loaded "+result.size() + " contacts from server"); GWT.log("loaded "+result.size() + " contacts from server");
listAllContact = result; listAllContact = result;
callback.onSuccess(listAllContact); if(callback!=null)
callback.onSuccess(listAllContact);
} }
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR +" retrieving user " + ConstantsExplorer.TRY_AGAIN, null); new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR +" retrieving user " + ConstantsExplorer.TRY_AGAIN, null);
callback.onFailure(caught); if(callback!=null)
callback.onFailure(caught);
} }
}); });
} }
/**
* Load shared user by shared folder id.
*
* @param sharedFolderId the shared folder id
* @param callback the callback
*/
private void loadSharedUserBySharedFolderId(final String sharedFolderId, final AsyncCallback<List<InfoContactModel>> callback){ private void loadSharedUserBySharedFolderId(final String sharedFolderId, final AsyncCallback<List<InfoContactModel>> callback){
// comboSharedUsers.mask("Loading users"); // comboSharedUsers.mask("Loading users");
@ -68,17 +92,22 @@ public class UserStore implements ContactFetcher{
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR +" retrieving user. " + ConstantsExplorer.TRY_AGAIN, null); new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR +" retrieving user. " + ConstantsExplorer.TRY_AGAIN, null);
callback.onFailure(caught); if(callback!=null)
callback.onFailure(caught);
} }
@Override @Override
public void onSuccess(List<InfoContactModel> result) { public void onSuccess(List<InfoContactModel> result) {
GWT.log("loaded "+result.size() + " contacts from server for "+sharedFolderId); GWT.log("loaded "+result.size() + " contacts from server for "+sharedFolderId);
callback.onSuccess(result); if(callback!=null)
callback.onSuccess(result);
} }
}); });
} }
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.view.sharing.ContactFetcher#getExclusiveContactsFromAllContact(java.util.List)
*/
@Override @Override
public List<InfoContactModel> getExclusiveContactsFromAllContact(List<InfoContactModel> listSharedUser){ public List<InfoContactModel> getExclusiveContactsFromAllContact(List<InfoContactModel> listSharedUser){
@ -92,6 +121,9 @@ public class UserStore implements ContactFetcher{
return listExclusiveContact; return listExclusiveContact;
} }
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.view.sharing.ContactFetcher#getOwner(java.lang.String, com.google.gwt.user.client.rpc.AsyncCallback)
*/
@Override @Override
public void getOwner(final String sharedFolderId,final AsyncCallback<InfoContactModel> callback) { public void getOwner(final String sharedFolderId,final AsyncCallback<InfoContactModel> callback) {
@ -105,8 +137,8 @@ public class UserStore implements ContactFetcher{
@Override @Override
public void onSuccess(InfoContactModel result) { public void onSuccess(InfoContactModel result) {
callback.onSuccess(result); if(callback!=null)
callback.onSuccess(result);
} }
}); });
} }

View File

@ -1463,7 +1463,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
try { try {
workspaceLogger.trace("Get all contacts from server..."); workspaceLogger.debug("Get all contacts from server...");
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder(); GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
org.gcube.common.homelibrary.home.workspace.usermanager.UserManager hlUserManager = HomeLibrary.getHomeManagerFactory().getUserManager(); org.gcube.common.homelibrary.home.workspace.usermanager.UserManager hlUserManager = HomeLibrary.getHomeManagerFactory().getUserManager();
@ -1504,6 +1504,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
workspaceLogger.trace("Home Library User Manager getting list Gcube Group"); workspaceLogger.trace("Home Library User Manager getting list Gcube Group");
listContactsModel.addAll(builder.buildGXTListContactsModelFromGcubeGroup(hlUserManager.getGroups())); listContactsModel.addAll(builder.buildGXTListContactsModelFromGcubeGroup(hlUserManager.getGroups()));
workspaceLogger.debug("Returning list of contacts!");
return listContactsModel; return listContactsModel;
} catch (Exception e) { } catch (Exception e) {

View File

@ -394,7 +394,7 @@ public class NotificationsProducer {
if(userUnShared.getLogin().compareTo(userId)!=0){ if(userUnShared.getLogin().compareTo(userId)!=0){
logger.debug("Sending notification to user "+userUnShared.getLogin() +" unshared from folder "+shareFolder.getName()); logger.debug("Sending notification to user "+userUnShared.getLogin() +" unshared from folder "+shareFolder.getName());
boolean notify = notificationsMng.notifyFolderRemovedUser(userUnShared.getLogin(), (WorkspaceSharedFolder) shareFolder); boolean notify = notificationsMng.notifyFolderRemovedUser(userUnShared.getLogin(), shareFolder);
if(!notify) if(!notify)
logger.error("An error occured when notifies user: "+userUnShared.getLogin()); logger.error("An error occured when notifies user: "+userUnShared.getLogin());
@ -437,10 +437,7 @@ public class NotificationsProducer {
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER //NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
if(infoContactModel.getLogin().compareTo(userId)!=0){ if(infoContactModel.getLogin().compareTo(userId)!=0){
logger.trace("Sending notification to user "+infoContactModel.getLogin() +" added item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName()); logger.info("Sending notification to user "+infoContactModel.getLogin() +" added item [id: "+workspaceItem.getId() +"] name: "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
//DEBUG
System.out.println("Sending notification to user "+infoContactModel.getLogin() +" added item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
//DEBUG //DEBUG
// System.out.println("Send notify folder un share user "+infoContactModel.getLogin()); // System.out.println("Send notify folder un share user "+infoContactModel.getLogin());

View File

@ -31,9 +31,9 @@ public class ItemRetrieve {
// public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps"; //PRODUCTION // public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps"; //PRODUCTION
public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
public static String TEST_USER = "gianpaolo.coro"; public static String TEST_USER = "francesco.mangiacrapa";
// public static String ITEMID = "63832213-098d-42d1-8774-89b6349764c0"; //Activity T3.4 working drafts/T2-EC-IMAR-HO-14-015 iMarine Sustainability WP - Business Model tools.pdf // public static String ITEMID = "63832213-098d-42d1-8774-89b6349764c0"; //Activity T3.4 working drafts/T2-EC-IMAR-HO-14-015 iMarine Sustainability WP - Business Model tools.pdf
public static String ITEMID = "a5aca54d-67cf-4838-9025-9ef5bb204ae9"; public static String ITEMID = "ce4866ee-8079-4acf-bcd6-1c9dd786eb73";
// d81d3a64-603f-4907-ae74-be8353211807 // d81d3a64-603f-4907-ae74-be8353211807
protected static Logger logger = Logger.getLogger(ItemRetrieve.class); protected static Logger logger = Logger.getLogger(ItemRetrieve.class);
@ -48,14 +48,14 @@ public class ItemRetrieve {
Workspace ws = getWorkspace(); Workspace ws = getWorkspace();
System.out.println(ws.getRoot().getId()); System.out.println(ws.getRoot().getId());
// retrieveFirstLevel(ws, null); retrieveFirstLevel(ws, null);
//
retrieveFirstLevel(ws, ITEMID); // retrieveFirstLevel(ws, ITEMID);
//
System.out.println("get workspace -> OK"); // System.out.println("get workspace -> OK");
// WorkspaceItem item = ws.getItem(ITEMID); WorkspaceItem item = ws.getItem(ITEMID);
// System.out.println("get item id: "+item.getId()+", name: "+item.getName() +", parent: "+item.getParent()); System.out.println("get item id: "+item.getId()+", name: "+item.getName() +", parent: "+item.getParent().getId() +", parent name: "+item.getParent().getName()+", path :"+item.getPath());
// System.out.println(item); System.out.println(item);
}catch(Exception e){ }catch(Exception e){
e.printStackTrace(); e.printStackTrace();
} }
@ -119,50 +119,57 @@ public class ItemRetrieve {
int folderItemCounter = 0; int folderItemCounter = 0;
int othersCounter = 0; int othersCounter = 0;
for (WorkspaceItem workspaceItem : children) { for (WorkspaceItem workspaceItem : children) {
try{
/*if(foundFolder!=null && !foundFolder.isEmpty()){ /*if(foundFolder!=null && !foundFolder.isEmpty()){
if(workspaceItem.getId().compareTo(foundFolder)==0){ if(workspaceItem.getId().compareTo(foundFolder)==0){
System.out.println("ITEM FOUND id: "+workspaceItem.getId()+", name: "+workspaceItem.getName()); System.out.println("ITEM FOUND id: "+workspaceItem.getId()+", name: "+workspaceItem.getName());
return; return;
}
}*/
switch (workspaceItem.getType()) {
case FOLDER:
WorkspaceFolder folder = (WorkspaceFolder) workspaceItem;
// System.out.println(++i+") "+folder.getId() +" folder name: "+folder.getName() + " owner "+folder.getOwner() +" path: "+folder.getPath());
System.out.println(++i+") "+folder.getId() +" folder name: "+folder.getName() + " owner "+folder.getOwner());
foldersCounter++;
break;
case SHARED_FOLDER:
WorkspaceSharedFolder shared = (WorkspaceSharedFolder) workspaceItem;
// System.out.println(++i+") "+shared.getId() +" shared folder name: "+shared.getName() + " owner "+shared.getOwner()+" isVRE "+shared.isVreFolder() +" ACLOwner: "+shared.getACLOwner()+" AclUser: "+shared.getACLUser() +" path: "+shared.getPath());
System.out.println(++i+") "+shared.getId() +" shared folder name: "+shared.getName());
// System.out.println(++i+") shared folder name: "+shared.getName() + " owner "+shared.getOwner().getPortalLogin());
sharedFoldersCounter++;
break;
case FOLDER_ITEM:
FolderItem folderItem = (FolderItem) workspaceItem;
// System.out.println(++i+") folderItem id: "+folderItem.getId() +", name: "+folderItem.getName() + ", own: "+folderItem.getOwner() +" path: "+folderItem.getPath());
System.out.println(++i+") folderItem id: "+folderItem.getId() +", name: "+folderItem.getName() + ", own: "+folderItem.getOwner());
folderItemCounter++;
break;
default:
// System.out.println(++i+") DEFAULT - item id: "+workspaceItem.getId() +", name: "+workspaceItem.getName() + ", own: "+workspaceItem.getOwner());
// othersCounter++;
break;
} }
}*/ }catch (Exception e) {
// TODO: handle exception
switch (workspaceItem.getType()) {
case FOLDER:
WorkspaceFolder folder = (WorkspaceFolder) workspaceItem;
System.out.println(++i+") "+folder.getId() +" folder name: "+folder.getName() + " owner "+folder.getOwner() +" path: "+folder.getPath());
foldersCounter++;
break;
case SHARED_FOLDER:
WorkspaceSharedFolder shared = (WorkspaceSharedFolder) workspaceItem;
System.out.println(++i+") "+shared.getId() +" shared folder name: "+shared.getName() + " owner "+shared.getOwner()+" isVRE "+shared.isVreFolder() +" ACLOwner: "+shared.getACLOwner()+" AclUser: "+shared.getACLUser() +" path: "+shared.getPath());
// System.out.println(++i+") shared folder name: "+shared.getName() + " owner "+shared.getOwner().getPortalLogin());
sharedFoldersCounter++;
break;
case FOLDER_ITEM:
FolderItem folderItem = (FolderItem) workspaceItem;
System.out.println(++i+") folderItem id: "+folderItem.getId() +", name: "+folderItem.getName() + ", own: "+folderItem.getOwner() +" path: "+folderItem.getPath());
folderItemCounter++;
break;
default:
// System.out.println(++i+") DEFAULT - item id: "+workspaceItem.getId() +", name: "+workspaceItem.getName() + ", own: "+workspaceItem.getOwner());
// othersCounter++;
break;
} }
} }
//TEST TIME //TEST TIME