merged with trunk

feature_20847
Francesco Mangiacrapa 3 years ago
parent 44027d88f8
commit 2239c3f357

@ -56,11 +56,7 @@ public class WsThreddsWidget implements HasWsSyncNotificationListner {
private final List<SyncCompletedNotificationListner> syncEventsListeners = new ArrayList<SyncCompletedNotificationListner>();
public static final String MISSING_THREDDS_ADMIN_RIGHTS = "It seems you are not authorized to create a configuration towards THREDDS Catalogue. Request it to the VRE manager or the portal administrator.";
public static final String MISSING_THREDDS_PUBLISHER_RIGHTS = "It seems you are not authorized to run a syncronization task towards THREDDS Catalogue. Request it to the VRE manager or the portal administrator.";
public static final String MISSING_THREDDS_RIGHTS = "It seems you are not authorized to interact with the facility 'Sync with THREDDS'. Request authorization to the VRE manager or the portal administrator.";
private Map<String, GatewayRolesThredds> mapScopeThreddsRoles = null;
/**
* This is the entry point method.
@ -152,7 +148,7 @@ public class WsThreddsWidget implements HasWsSyncNotificationListner {
}
final Modal box = new Modal(true);
box.setTitle("Checking configurations...");
box.setTitle("Checking authorizations and configurations...");
final HorizontalPanel hpLoader = new HorizontalPanel();
LoaderIcon loader = new LoaderIcon("Checking authorizations and folder configurations...");
hpLoader.add(loader);
@ -161,6 +157,8 @@ public class WsThreddsWidget implements HasWsSyncNotificationListner {
//LAOADING ROLES
WsThreddsWidget.wsThreddsSyncService.getScopesWithThreddsRolesForLoggedUser(new AsyncCallback<Map<String,GatewayRolesThredds>>() {
@Override
public void onFailure(Throwable caught) {
hpLoader.clear();
@ -173,76 +171,57 @@ public class WsThreddsWidget implements HasWsSyncNotificationListner {
@Override
public void onSuccess(Map<String, GatewayRolesThredds> result) {
try {
hpLoader.clear();
hpLoader.setVisible(false);
}catch (Exception e) {
//Silent
}
GWT.log("Returned Map(Scope,Role): "+result);
mapScopeThreddsRoles = result;
if(result!=null) {
GWT.log("Returned Map(Scope,Role): "+result);
final boolean isThreddsPubliser = result.containsValue(GatewayRolesThredds.DATA_EDITOR);
final boolean isThreddsAdmin = result.containsValue(GatewayRolesThredds.DATA_MANAGER);
//no rights assigned
if(!isThreddsAdmin && !isThreddsPubliser) {
showMissingRights(box);
return;
}
//at least one THREDDS rights is assigned
GWT.log("Performing isItemSynched: "+folder.getFolderId());
WsThreddsWidget.wsThreddsSyncService.isItemSynched(folder.getFolderId(), new AsyncCallback<WsThreddsSynchFolderDescriptor>() {
@Override
public void onSuccess(WsThreddsSynchFolderDescriptor result) {
box.hide();
//GWT.log("WsThreddsSynchFolderDescriptor result: "+result);
viewManager.showThreddsFolderInfo(folder, result, isThreddsAdmin, isThreddsPubliser);
//at least one THREDDS rights is assigned
GWT.log("Performing isItemSynched: "+folder.getFolderId());
WsThreddsWidget.wsThreddsSyncService.isItemSynched(folder.getFolderId(), new AsyncCallback<WsThreddsSynchFolderDescriptor>() {
@Override
public void onSuccess(WsThreddsSynchFolderDescriptor result) {
try {
hpLoader.clear();
hpLoader.setVisible(false);
}catch (Exception e) {
//Silent
}
box.hide();
//GWT.log("WsThreddsSynchFolderDescriptor result: "+result);
viewManager.showThreddsFolderInfo(folder, result, mapScopeThreddsRoles);
@Override
public void onFailure(Throwable caught) {
box.hide();
}
if(caught instanceof WorkspaceFolderLocked){
viewManager.showMonitorSyncToFolder(folder,syncEventsListeners);
return;
}
@Override
public void onFailure(Throwable caught) {
box.hide();
viewManager.cancelMonitor(folder);
Window.alert(caught.getMessage());
if(caught instanceof WorkspaceFolderLocked){
viewManager.showMonitorSyncToFolder(folder,syncEventsListeners);
return;
}
});
}else {
//no rights detected
showMissingRights(box);
return;
}
viewManager.cancelMonitor(folder);
Window.alert(caught.getMessage());
}
});
}
});
box.show();
}
private void showMissingRights(Modal box) {
Alert alert = new Alert();
alert.setType(AlertType.WARNING);
alert.setText(MISSING_THREDDS_RIGHTS);
alert.setClose(false);
box.add(alert);
}
// private void showMissingRights(Modal box) {
// Alert alert = new Alert();
// alert.setType(AlertType.WARNING);
// alert.setText(MISSING_THREDDS_RIGHTS);
// alert.setClose(false);
// box.add(alert);
// }
private void performFolderUnSync(final WsFolder folder) {
GWT.log("Performing doSyncFolder on: "+folder);

Loading…
Cancel
Save