added timer to delay the refresh due to back-end late sync

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@177213 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2019-02-22 09:57:16 +00:00
parent 8a6d54ae1d
commit 08096d34a8
7 changed files with 146 additions and 69 deletions

View File

@ -214,6 +214,8 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
private WsThreddsWidget wsThreddsWidget = new WsThreddsWidget();
private WsTaskExecutorWidget taskExecutor = new WsTaskExecutorWidget();
private int waitTiming = 3000;
/**
* Instantiates a new app controller explorer.
*/
@ -547,10 +549,22 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
@Override
public void onSuccess(Boolean result) {
explorerPanel.getAsycTreePanel().unmask();
if(result) //REFRESH PARENT FOLDER
eventBus.fireEvent(new RefreshFolderEvent(source.getParentFileModel(), true, false, false));
GWT.log("Unshare was: "+result);
GWT.log("Waiting "+waitTiming);
if(result){ //REFRESH PARENT FOLDER
Timer t = new Timer() {
@Override
public void run() {
GWT.log("Runing refresh after wait: "+waitTiming);
eventBus.fireEvent(new RefreshFolderEvent(source.getParentFileModel(), true, true, false));
explorerPanel.getAsycTreePanel().unmask();
}
};
t.schedule(waitTiming);
}else
explorerPanel.getAsycTreePanel().unmask();
}
});
}
@ -748,7 +762,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
Info.display("Info", "An operation of sharing was submitted");
explorerPanel.mask("Setting permissions", ConstantsExplorer.LOADINGSTYLE);
rpcWorkspaceService.shareFolder(fileModel, finalDialog.getSharedListUsers(), isNewFolder, finalDialog.getSelectedACL(), new AsyncCallback<Boolean>() {
rpcWorkspaceService.shareFolder(fileModel, finalDialog.getSharedListUsers(), isNewFolder, finalDialog.getSelectedACL(), new AsyncCallback<FileModel>() {
@Override
public void onFailure(Throwable caught) {
@ -765,25 +779,34 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
}
@Override
public void onSuccess(Boolean result) {
if(result){
FileModel parentToRefresh=null;
public void onSuccess(FileModel result) {
if(isNewFolder)
parentToRefresh = parentModel;
else
parentToRefresh = parentFileModel;
if(result!=null){
final FileModel parentToRefresh = result.getParentFileModel();
GWT.log("share completed throwing refresh folder: "+parentToRefresh.getName()+", its id is: "+parentToRefresh.getIdentifier());
GWT.log("share completed throwing refresh folder : "+parentToRefresh.getName() +" get id: "+parentToRefresh.getIdentifier());
GWT.log("Waiting "+waitTiming);
// eventBus.fireEvent(new RefreshFolderEvent(parentToRefresh, true, false, false));
//REFRESH PARENT FOLDER
Timer t = new Timer() {
@Override
public void run() {
GWT.log("Runing refresh after wait: "+waitTiming);
//TODO UPDATED ID
RefreshFolderEvent refEvent = new RefreshFolderEvent(parentToRefresh, true, true, false);
refEvent.setForceReloadBreadCrumb(true);
eventBus.fireEvent(refEvent);
explorerPanel.unmask();
}
};
//TODO UPDATED ID
RefreshFolderEvent refEvent = new RefreshFolderEvent(parentToRefresh, true, true, false);
refEvent.setForceReloadBreadCrumb(true);
eventBus.fireEvent(refEvent);
t.schedule(waitTiming);
}else{
new MessageBoxAlert("Error", "Sharing error, please refresh and try again", null);
explorerPanel.unmask();
}
explorerPanel.unmask();
}
});
}
@ -898,7 +921,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
if(refreshItemEvent.getFolderTarget()!=null && refreshItemEvent.getFolderTarget().getIdentifier()!=null){
if(!refreshItemEvent.isIfExists()){ //Called Tree side
if(!refreshItemEvent.isCalledTreeSide()){ //Called Tree side
explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(refreshItemEvent.getFolderTarget().getIdentifier(), refreshItemEvent.isExpandFolder());
notifySubscriber(refreshItemEvent);
}

View File

@ -6,91 +6,152 @@ import org.gcube.portlets.user.workspace.client.model.FileModel;
import com.google.gwt.event.shared.GwtEvent;
/**
* The Class RefreshFolderEvent.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Feb 1, 2019
*/
public class RefreshFolderEvent extends GwtEvent<RefreshItemEventHandler> implements GuiEventInterface {
public static Type<RefreshItemEventHandler> TYPE = new Type<RefreshItemEventHandler>();
private FileModel folderTarget= null;
private boolean expandFolder = true; //DEFAULT EXPAND FOLDER
private boolean forceRefresh;
private boolean ifExists = false;
private boolean isCalledTreeSide = false;
private boolean forceReloadBreadCrumb = false;
/**
*
* @param folderTarget
* @param expandFolder - used to expand the folder into tree after refresh
* @param forceRefresh - used to force refresh into grid
* @param ifExists - refresh only if items exists (into tree)
* Instantiates a new refresh folder event.
*
* @param folderTarget the folder target
* @param expandFolder the expand folder
* @param forceRefresh the force refresh
* @param calledTreeSide the called tree side
*/
public RefreshFolderEvent(FileModel folderTarget, boolean expandFolder, boolean forceRefresh, boolean ifExists) {
public RefreshFolderEvent(FileModel folderTarget, boolean expandFolder, boolean forceRefresh, boolean calledTreeSide) {
this.folderTarget = folderTarget;
this.expandFolder = expandFolder;
this.forceRefresh = forceRefresh;
this.ifExists = ifExists;
this.isCalledTreeSide = calledTreeSide;
}
/* (non-Javadoc)
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
*/
@Override
public Type<RefreshItemEventHandler> getAssociatedType() {
return TYPE;
}
/* (non-Javadoc)
* @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler)
*/
@Override
protected void dispatch(RefreshItemEventHandler handler) {
handler.onRefreshItem(this);
}
/**
* Gets the folder target.
*
* @return the folder target
*/
public FileModel getFolderTarget() {
return folderTarget;
}
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.interfaces.GuiEventInterface#getKey()
*/
@Override
public EventsTypeEnum getKey() {
return EventsTypeEnum.REFRESH_FOLDER;
}
/**
* Checks if is expand folder.
*
* @return true, if is expand folder
*/
public boolean isExpandFolder() {
return expandFolder;
}
/**
* Sets the expand folder.
*
* @param expandFolder the new expand folder
*/
public void setExpandFolder(boolean expandFolder) {
this.expandFolder = expandFolder;
}
/**
* Checks if is force refresh.
*
* @return true, if is force refresh
*/
public boolean isForceRefresh() {
return forceRefresh;
}
/**
* Sets the force refresh.
*
* @param forceRefresh the new force refresh
*/
public void setForceRefresh(boolean forceRefresh) {
this.forceRefresh = forceRefresh;
}
public boolean isIfExists() {
return ifExists;
/**
* Checks if is called tree side.
*
* @return true, if is called tree side
*/
public boolean isCalledTreeSide() {
return isCalledTreeSide;
}
/**
* Checks if is force reload bread crumb.
*
* @return true, if is force reload bread crumb
*/
public boolean isForceReloadBreadCrumb() {
return forceReloadBreadCrumb;
}
/**
* Sets the force reload bread crumb.
*
* @param forceReloadBreadCrumb the new force reload bread crumb
*/
public void setForceReloadBreadCrumb(boolean forceReloadBreadCrumb) {
this.forceReloadBreadCrumb = forceReloadBreadCrumb;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("RefreshFolderEvent [folderTarget=");
builder.append(folderTarget);
@ -98,12 +159,11 @@ public class RefreshFolderEvent extends GwtEvent<RefreshItemEventHandler> implem
builder.append(expandFolder);
builder.append(", forceRefresh=");
builder.append(forceRefresh);
builder.append(", ifExists=");
builder.append(ifExists);
builder.append(", forceReloadBreadCrumb=");
builder.append(forceReloadBreadCrumb);
builder.append("]");
return builder.toString();
}
}

View File

@ -314,7 +314,7 @@ public interface GWTWorkspaceService extends RemoteService{
* @return true, if successful
* @throws Exception the exception
*/
boolean shareFolder(FileModel folder, List<InfoContactModel> listContacts,
FileModel shareFolder(FileModel folder, List<InfoContactModel> listContacts,
boolean isNewFolder, WorkspaceACL acl) throws Exception;
/**

View File

@ -285,18 +285,9 @@ public interface GWTWorkspaceServiceAsync {
void getTimeSeriesById(String identifier,
AsyncCallback<GWTWorkspaceItem> callback);
/**
* Share folder.
*
* @param folder the folder
* @param listContacts the list contacts
* @param isNewFolder the is new folder
* @param acl the acl
* @param callback the callback
*/
void shareFolder(FileModel folder, List<InfoContactModel> listContacts,
boolean isNewFolder, WorkspaceACL acl,
AsyncCallback<Boolean> callback);
void shareFolder(
FileModel folder, List<InfoContactModel> listContacts,
boolean isNewFolder, WorkspaceACL acl, AsyncCallback<FileModel> callback);
/**
* Gets the list user shared by folder shared id.

View File

@ -454,8 +454,6 @@ public class DialogShareFolder extends Dialog {
multiDrag.addTargetContact(infoContactModel);
}
// multiDrag.addAlreadySharedContacts(suggestPanel.getSelectedUser());
multiDrag.addAlreadySharedContacts(listAlreadyShared);
multiDrag.getButtonById(Dialog.OK).addSelectionListener(new SelectionListener<ButtonEvent>() {

View File

@ -825,6 +825,7 @@ public class AsyncTreePanel extends LayoutContainer {
* @param expandFolder the expand folder
*/
private void reloadTreeLevelAndExpandFolder(final FolderModel folder, final boolean expandFolder){
GWT.log("Calling Reload Tree Level and Exand folder: "+expandFolder +" for folder : "+folder.getName());
AppControllerExplorer.rpcWorkspaceService.getFolderChildren(folder, new AsyncCallback<List<FileModel>>(){
@ -843,6 +844,7 @@ public class AsyncTreePanel extends LayoutContainer {
@Override
public void onSuccess(List<FileModel> result) {
GWT.log("Refresh TREE with results: "+result);
treePanel.mask(ConstantsExplorer.VALIDATINGOPERATION,ConstantsExplorer.LOADINGSTYLE);
store.removeAll(folder);
// addChildrenToFolder(folder.getIdentifier(), result);

View File

@ -1119,10 +1119,6 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
try {
Workspace workspace = getWorkspace();
// workspaceLogger.trace("######### SEND TO: ");
// workspaceLogger.trace("subject " + subject);
// workspaceLogger.trace("body " + body);
//DEBUG
for(String contactId : listContactsId)
workspaceLogger.trace("contactId " + contactId);
@ -1193,18 +1189,8 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#shareFolder(org.gcube.portlets.user.workspace.client.model.FileModel, java.util.List, boolean, org.gcube.portlets.user.workspace.shared.WorkspaceACL)
*/
/**
* Share folder.
*
* @param folder the folder
* @param listContacts the list contacts
* @param isNewFolder the is new folder
* @param acl the acl
* @return true, if successful
* @throws Exception the exception
*/
@Override
public boolean shareFolder(FileModel folder, List<InfoContactModel> listContacts, boolean isNewFolder, WorkspaceACL acl) throws Exception {
public FileModel shareFolder(FileModel folder, List<InfoContactModel> listContacts, boolean isNewFolder, WorkspaceACL acl) throws Exception {
if(isSessionExpired())
throw new SessionExpiredException();
@ -1227,7 +1213,6 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
List<InfoContactModel> listSharedContact = null;
boolean sourceFolderIsShared = folder.isShared();
if(sourceFolderIsShared){ //if source folder is already share... retrieve old list of sharing to notify
listSharedContact = getListUserSharedByFolderSharedId(folder.getIdentifier());
}
@ -1271,7 +1256,15 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
if(acl!=null)
setACLs(sharedFolder.getId(), listLogin, acl.getId().toString());
FileModel theSharedFolder = null;
if(created){
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
WorkspaceFolder parent = sharedFolder.getParent();
FileModel theParent = builder.buildGXTFileModelItem(parent, null);
theSharedFolder = builder.buildGXTFileModelItem(sharedFolder, theParent);
NotificationsProducer np = getNotificationProducer();
if(!sourceFolderIsShared) //if source folder is not already shared
np.notifyFolderSharing(listContacts, sharedFolder);
@ -1281,7 +1274,8 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
}
}
return created;
return theSharedFolder;
}catch (WorkspaceFolderLocked e1){
throw new Exception(e1.getMessage());
@ -3599,7 +3593,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
if(folder == null)
throw new Exception("Folder is null");
workspaceLogger.trace("getting workspace");
workspaceLogger.trace("Getting Workspace from SHUB");
shWorkspace = getWorkspaceFromStorageHub();
//org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = workspace.getItem(folder.getIdentifier()); //removed for optimization
@ -3609,6 +3603,10 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
List<? extends org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem> children =
shWorkspace.getFilteredChildren(folder.getIdentifier(),org.gcube.common.storagehub.model.items.FolderItem.class);
for (org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem workspaceItem : children) {
workspaceLogger.trace("The ITEM: "+workspaceItem.getName() + ", is shared: "+workspaceItem.isShared() + ", is folder: "+workspaceItem.isFolder() +" the id: "+workspaceItem.getId());
}
StorageHubToWorkpaceConverter converter = getStorageHubToWorkpaceConverter();
List<FileModel> listFileModels = new ArrayList<FileModel>(children.size());
@ -3655,6 +3653,11 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
for (FileModel fileModel : listFileModels) {
System.out.println(i++ +")"+fileModel);
}*/
// if(!WsUtil.isWithinPortal()){
// workspaceLogger.trace("Sleeping 4 sec...");
// Thread.sleep(4000);
// }
return listFileModels;
} catch (Exception e) {