added lock server-side to ckeck if ws-sync is on-going
added message one-shot if a folder is under sync git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@165516 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
8ec93e3684
commit
90d1be3a05
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.gcube.portal.clientcontext.client.GCubeClientContext;
|
import org.gcube.portal.clientcontext.client.GCubeClientContext;
|
||||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer.WS_UPLOAD_TYPE;
|
import org.gcube.portlets.user.workspace.client.ConstantsExplorer.WS_UPLOAD_TYPE;
|
||||||
|
@ -18,6 +19,8 @@ import org.gcube.portlets.user.workspace.client.event.AddFolderEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.AddFolderEventHandler;
|
import org.gcube.portlets.user.workspace.client.event.AddFolderEventHandler;
|
||||||
import org.gcube.portlets.user.workspace.client.event.AddSmartFolderEvent;
|
import org.gcube.portlets.user.workspace.client.event.AddSmartFolderEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.AddSmartFolderEventHandler;
|
import org.gcube.portlets.user.workspace.client.event.AddSmartFolderEventHandler;
|
||||||
|
import org.gcube.portlets.user.workspace.client.event.CheckItemLockedBySyncEvent;
|
||||||
|
import org.gcube.portlets.user.workspace.client.event.CheckItemLockedBySyncEventHandler;
|
||||||
import org.gcube.portlets.user.workspace.client.event.CompletedFileUploadEvent;
|
import org.gcube.portlets.user.workspace.client.event.CompletedFileUploadEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.CompletedFileUploadEventHandler;
|
import org.gcube.portlets.user.workspace.client.event.CompletedFileUploadEventHandler;
|
||||||
import org.gcube.portlets.user.workspace.client.event.CopytemEvent;
|
import org.gcube.portlets.user.workspace.client.event.CopytemEvent;
|
||||||
|
@ -195,6 +198,8 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
private UserStore userStore = new UserStore();
|
private UserStore userStore = new UserStore();
|
||||||
private static AppControllerExplorer singleton;
|
private static AppControllerExplorer singleton;
|
||||||
|
|
||||||
|
private Map<String, String> msgFolderSynched = new HashMap<String,String>();
|
||||||
|
|
||||||
private WsThreddsWidget wsThreddsWidget = new WsThreddsWidget();
|
private WsThreddsWidget wsThreddsWidget = new WsThreddsWidget();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -242,6 +247,44 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
*/
|
*/
|
||||||
private void bind() {
|
private void bind() {
|
||||||
|
|
||||||
|
eventBus.addHandler(CheckItemLockedBySyncEvent.TYPE, new CheckItemLockedBySyncEventHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCheckItemLockedBySync(final CheckItemLockedBySyncEvent checkItemLockedBySyncEvent) {
|
||||||
|
|
||||||
|
GWT.log("Fired CheckItemLocked...");
|
||||||
|
|
||||||
|
if(checkItemLockedBySyncEvent.getItem()!=null){
|
||||||
|
|
||||||
|
rpcWorkspaceService.isItemUnderSync(checkItemLockedBySyncEvent.getItem().getIdentifier(), new AsyncCallback<Boolean>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Boolean result) {
|
||||||
|
|
||||||
|
GWT.log("CheckItemLocked for folder: "+checkItemLockedBySyncEvent.getItem().getName() +" returned locked: "+result);
|
||||||
|
|
||||||
|
String msgDisplayed = msgFolderSynched.get(checkItemLockedBySyncEvent.getItem().getIdentifier());
|
||||||
|
|
||||||
|
if(msgDisplayed==null && result){
|
||||||
|
String msg= "The folder: "+checkItemLockedBySyncEvent.getItem().getName()+", "+ConstantsExplorer.MSG_FOLDER_LOCKED_BY_SYNC;
|
||||||
|
MessageBox.info("Warning: folder under synchornization", msg, null);
|
||||||
|
msgFolderSynched.put(checkItemLockedBySyncEvent.getItem().getIdentifier(), msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
eventBus.addHandler(PublishOnDataCatalogueEvent.TYPE, new PublishOnDataCatalogueEventHandler() {
|
eventBus.addHandler(PublishOnDataCatalogueEvent.TYPE, new PublishOnDataCatalogueEventHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -257,6 +257,7 @@ public static enum WS_UPLOAD_TYPE {File, Archive};
|
||||||
public static final int HEIGHT_DIALOG_SHARE_FOLDER = 445;
|
public static final int HEIGHT_DIALOG_SHARE_FOLDER = 445;
|
||||||
|
|
||||||
|
|
||||||
|
public static final String MSG_FOLDER_LOCKED_BY_SYNC= "is under synchronization process.\nPlease be aware that some operations are not currently available and that the content might change during this process.";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log.
|
* Log.
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
package org.gcube.portlets.user.workspace.client.event;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||||
|
|
||||||
|
import com.google.gwt.event.shared.GwtEvent;
|
||||||
|
|
||||||
|
|
||||||
|
public class CheckItemLockedBySyncEvent extends GwtEvent<CheckItemLockedBySyncEventHandler>{
|
||||||
|
public static Type<CheckItemLockedBySyncEventHandler> TYPE = new Type<CheckItemLockedBySyncEventHandler>();
|
||||||
|
|
||||||
|
private FileModel item;
|
||||||
|
|
||||||
|
public CheckItemLockedBySyncEvent(FileModel item) {
|
||||||
|
this.item = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Type<CheckItemLockedBySyncEventHandler> getAssociatedType() {
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void dispatch(CheckItemLockedBySyncEventHandler handler) {
|
||||||
|
handler.onCheckItemLockedBySync(this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the itemId
|
||||||
|
*/
|
||||||
|
public FileModel getItem() {
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package org.gcube.portlets.user.workspace.client.event;
|
||||||
|
|
||||||
|
import com.google.gwt.event.shared.EventHandler;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Interface CheckItemLockedBySyncEventHandler.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
|
* Mar 28, 2018
|
||||||
|
*/
|
||||||
|
public interface CheckItemLockedBySyncEventHandler extends EventHandler {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On check item locked by sync.
|
||||||
|
*
|
||||||
|
* @param checkItemLockedBySyncEvent the check item locked by sync event
|
||||||
|
*/
|
||||||
|
void onCheckItemLockedBySync(CheckItemLockedBySyncEvent checkItemLockedBySyncEvent);
|
||||||
|
}
|
|
@ -4,7 +4,6 @@ import org.gcube.portlets.user.workspace.client.interfaces.GXTFolderItemTypeEnum
|
||||||
|
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.resources.client.ImageResource;
|
import com.google.gwt.resources.client.ImageResource;
|
||||||
import com.google.gwt.resources.client.ClientBundle.Source;
|
|
||||||
import com.google.gwt.user.client.ui.AbstractImagePrototype;
|
import com.google.gwt.user.client.ui.AbstractImagePrototype;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -789,5 +789,14 @@ public interface GWTWorkspaceService extends RemoteService{
|
||||||
*/
|
*/
|
||||||
List<GcubeVRE> getListOfVREsForLoggedUser()
|
List<GcubeVRE> getListOfVREsForLoggedUser()
|
||||||
throws Exception;
|
throws Exception;
|
||||||
|
/**
|
||||||
|
* @param itemId
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
Boolean isItemUnderSync(String itemId)
|
||||||
|
throws Exception;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -214,6 +214,15 @@ public interface GWTWorkspaceServiceAsync {
|
||||||
*/
|
*/
|
||||||
void getUrlById(String identifier, boolean isInternalUrl, boolean fullDetails, AsyncCallback<GWTWorkspaceItem> callback);
|
void getUrlById(String identifier, boolean isInternalUrl, boolean fullDetails, AsyncCallback<GWTWorkspaceItem> callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the external url.
|
||||||
|
*
|
||||||
|
* @param parentId the parent id
|
||||||
|
* @param name the name
|
||||||
|
* @param description the description
|
||||||
|
* @param url the url
|
||||||
|
* @param callback the callback
|
||||||
|
*/
|
||||||
void createExternalUrl(
|
void createExternalUrl(
|
||||||
String parentId, String name, String description, String url,
|
String parentId, String name, String description, String url,
|
||||||
AsyncCallback<FileModel> callback);
|
AsyncCallback<FileModel> callback);
|
||||||
|
@ -777,4 +786,14 @@ public interface GWTWorkspaceServiceAsync {
|
||||||
* @return the list of vr es for logged user
|
* @return the list of vr es for logged user
|
||||||
*/
|
*/
|
||||||
void getListOfVREsForLoggedUser(AsyncCallback<List<GcubeVRE>> callback);
|
void getListOfVREsForLoggedUser(AsyncCallback<List<GcubeVRE>> callback);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if is item under sync.
|
||||||
|
*
|
||||||
|
* @param itemId the item id
|
||||||
|
* @param callback the callback
|
||||||
|
*/
|
||||||
|
void isItemUnderSync(String itemId, AsyncCallback<Boolean> callback);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.util.List;
|
||||||
import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
|
import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
|
||||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
||||||
import org.gcube.portlets.user.workspace.client.constant.WorkspaceOperation;
|
import org.gcube.portlets.user.workspace.client.constant.WorkspaceOperation;
|
||||||
|
import org.gcube.portlets.user.workspace.client.event.CheckItemLockedBySyncEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.ExpandFolderEvent;
|
import org.gcube.portlets.user.workspace.client.event.ExpandFolderEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.MoveItemEvent;
|
import org.gcube.portlets.user.workspace.client.event.MoveItemEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.SelectedItemEvent;
|
import org.gcube.portlets.user.workspace.client.event.SelectedItemEvent;
|
||||||
|
@ -886,6 +887,8 @@ public class AsyncTreePanel extends LayoutContainer {
|
||||||
store.removeAll(folder);
|
store.removeAll(folder);
|
||||||
addChildrenToFolder(folder, result);
|
addChildrenToFolder(folder, result);
|
||||||
GWT.log("End RPC - getFolderChildren");
|
GWT.log("End RPC - getFolderChildren");
|
||||||
|
|
||||||
|
AppControllerExplorer.getEventBus().fireEvent(new CheckItemLockedBySyncEvent(folder));
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -46,6 +46,7 @@ import org.gcube.common.homelibrary.home.workspace.trash.WorkspaceTrashItem;
|
||||||
import org.gcube.common.portal.PortalContext;
|
import org.gcube.common.portal.PortalContext;
|
||||||
import org.gcube.portal.wssynclibrary.shared.ItemNotSynched;
|
import org.gcube.portal.wssynclibrary.shared.ItemNotSynched;
|
||||||
import org.gcube.portal.wssynclibrary.shared.WorkspaceFolderLocked;
|
import org.gcube.portal.wssynclibrary.shared.WorkspaceFolderLocked;
|
||||||
|
import org.gcube.portal.wssynclibrary.shared.thredds.Sync_Status;
|
||||||
import org.gcube.portal.wssynclibrary.thredds.WorkspaceThreddsSynchronize;
|
import org.gcube.portal.wssynclibrary.thredds.WorkspaceThreddsSynchronize;
|
||||||
import org.gcube.portlets.user.urlshortener.UrlShortener;
|
import org.gcube.portlets.user.urlshortener.UrlShortener;
|
||||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
||||||
|
@ -661,6 +662,9 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
if(itemId == null)
|
if(itemId == null)
|
||||||
throw new Exception(IDENTIFIER_IS_NULL);
|
throw new Exception(IDENTIFIER_IS_NULL);
|
||||||
|
|
||||||
|
checkItemLocked(itemId);
|
||||||
|
checkItemLocked(destinationId);
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
@ -692,6 +696,9 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
|
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
|
|
||||||
|
}catch (WorkspaceFolderLocked e1){
|
||||||
|
throw new Exception(e1.getMessage());
|
||||||
|
|
||||||
}catch (InsufficientPrivilegesException e) {
|
}catch (InsufficientPrivilegesException e) {
|
||||||
workspaceLogger.error("Error in server Item move", e);
|
workspaceLogger.error("Error in server Item move", e);
|
||||||
String error = "An error occurred on moving item. "+e.getMessage();
|
String error = "An error occurred on moving item. "+e.getMessage();
|
||||||
|
@ -4357,4 +4364,31 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if is item under sync.
|
||||||
|
*
|
||||||
|
* @return true, if is item under sync
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean isItemUnderSync(String itemId) throws Exception{
|
||||||
|
|
||||||
|
try {
|
||||||
|
GCubeUser user = PortalContext.getConfiguration().getCurrentUser(this.getThreadLocalRequest());
|
||||||
|
try{
|
||||||
|
Sync_Status status = WorkspaceThreddsSynchronize.getInstance().getSynchedStatusFromItemProperty(itemId, user.getUsername());
|
||||||
|
}catch(Exception e){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//HERE THE ITEM IS SYNCHED SO CHECK IF IT IS LOCKED
|
||||||
|
checkItemLocked(itemId);
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}catch (WorkspaceFolderLocked e1){
|
||||||
|
return true;
|
||||||
|
}catch (Exception e) {
|
||||||
|
throw new Exception("Error on checking item "+itemId+" is under sync");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue