Compare commits
3 Commits
master
...
feature_20
Author | SHA1 | Date |
---|---|---|
Francesco Mangiacrapa | 2239c3f357 | |
Francesco Mangiacrapa | 44027d88f8 | |
Francesco Mangiacrapa | a241ad0a56 |
|
@ -0,0 +1,62 @@
|
|||
package org.gcube.portlets.widgets.wsthreddssync.client;
|
||||
|
||||
|
||||
/**
|
||||
* The Class WsThreddsSyncConstants.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Mar 11, 2021
|
||||
*/
|
||||
public class WsThreddsSyncConstants {
|
||||
|
||||
|
||||
/**
|
||||
* The Class RightsMissing.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Mar 11, 2021
|
||||
*/
|
||||
public static class RightsMissing {
|
||||
|
||||
/** The Constant REQUEST_IT_TO_THE_VRE_MANAGER_OR_THE_PORTAL_ADMINISTRATOR. */
|
||||
public static final String REQUEST_IT_TO_THE_VRE_MANAGER_OR_THE_PORTAL_ADMINISTRATOR = "Request it to the VRE manager or the portal administrator.";
|
||||
|
||||
/**
|
||||
* No run sync rights.
|
||||
*
|
||||
* @param scope the scope
|
||||
* @return the string
|
||||
*/
|
||||
public static String noRunSyncRights(String scope) {
|
||||
|
||||
StringBuilder builder = new StringBuilder("It seems you are not authorized to run a syncronization task towards THREDDS Catalogue");
|
||||
|
||||
if(scope!=null)
|
||||
builder.append(" in the scope \""+scope+"\"");
|
||||
|
||||
builder.append(". ");
|
||||
builder.append(REQUEST_IT_TO_THE_VRE_MANAGER_OR_THE_PORTAL_ADMINISTRATOR);
|
||||
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* No create config rights.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
public static String noCreateConfigRights() {
|
||||
|
||||
StringBuilder builder = new StringBuilder("It seems you are not authorized to create a configuration towards THREDDS Catalogue.");
|
||||
builder.append(REQUEST_IT_TO_THE_VRE_MANAGER_OR_THE_PORTAL_ADMINISTRATOR);
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -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,24 +171,8 @@ public class WsThreddsWidget implements HasWsSyncNotificationListner {
|
|||
|
||||
@Override
|
||||
public void onSuccess(Map<String, GatewayRolesThredds> result) {
|
||||
try {
|
||||
hpLoader.clear();
|
||||
hpLoader.setVisible(false);
|
||||
}catch (Exception e) {
|
||||
//Silent
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
mapScopeThreddsRoles = result;
|
||||
|
||||
//at least one THREDDS rights is assigned
|
||||
GWT.log("Performing isItemSynched: "+folder.getFolderId());
|
||||
|
@ -198,9 +180,17 @@ public class WsThreddsWidget implements HasWsSyncNotificationListner {
|
|||
|
||||
@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, isThreddsAdmin, isThreddsPubliser);
|
||||
viewManager.showThreddsFolderInfo(folder, result, mapScopeThreddsRoles);
|
||||
|
||||
}
|
||||
|
||||
|
@ -217,32 +207,21 @@ public class WsThreddsWidget implements HasWsSyncNotificationListner {
|
|||
Window.alert(caught.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}else {
|
||||
//no rights detected
|
||||
showMissingRights(box);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
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);
|
||||
|
|
|
@ -8,6 +8,7 @@ import org.gcube.portal.wssynclibrary.shared.thredds.Status;
|
|||
import org.gcube.portal.wssynclibrary.shared.thredds.ThCatalogueBean;
|
||||
import org.gcube.portal.wssynclibrary.shared.thredds.ThSyncStatus;
|
||||
import org.gcube.portlets.widgets.wsthreddssync.client.SyncCompletedNotification.SyncCompletedNotificationListner;
|
||||
import org.gcube.portlets.widgets.wsthreddssync.client.WsThreddsSyncConstants;
|
||||
import org.gcube.portlets.widgets.wsthreddssync.client.WsThreddsWidget;
|
||||
import org.gcube.portlets.widgets.wsthreddssync.client.event.PerformDoSyncEvent;
|
||||
import org.gcube.portlets.widgets.wsthreddssync.client.event.ShowMonitorSyncStatusEvent;
|
||||
|
@ -15,6 +16,8 @@ import org.gcube.portlets.widgets.wsthreddssync.client.view.binder.AbstractViewD
|
|||
import org.gcube.portlets.widgets.wsthreddssync.client.view.binder.CreateThreddsConfigurationView;
|
||||
import org.gcube.portlets.widgets.wsthreddssync.client.view.binder.MonitorFolderSyncStatusView;
|
||||
import org.gcube.portlets.widgets.wsthreddssync.client.view.binder.ShowThreddsFolderInfoView;
|
||||
import org.gcube.portlets.widgets.wsthreddssync.shared.GatewayRolesThredds;
|
||||
import org.gcube.portlets.widgets.wsthreddssync.shared.GcubeScope;
|
||||
import org.gcube.portlets.widgets.wsthreddssync.shared.WsFolder;
|
||||
import org.gcube.portlets.widgets.wsthreddssync.shared.WsThreddsSynchFolderConfiguration;
|
||||
import org.gcube.portlets.widgets.wsthreddssync.shared.WsThreddsSynchFolderDescriptor;
|
||||
|
@ -330,18 +333,15 @@ public class WsThreddsWidgetViewManager {
|
|||
*
|
||||
* @param folder the folder
|
||||
* @param folderDescriptor the folder descriptor
|
||||
* @param isThreddsAdmin the is thredds admin
|
||||
* @param isThreddsPubliser the is thredds publiser
|
||||
* @param mapScopeThreddsRoles the map scope with thredds roles
|
||||
*/
|
||||
public void showThreddsFolderInfo(final WsFolder folder, final WsThreddsSynchFolderDescriptor folderDescriptor, final boolean isThreddsAdmin, final boolean isThreddsPubliser){
|
||||
public void showThreddsFolderInfo(final WsFolder folder, final WsThreddsSynchFolderDescriptor folderDescriptor, Map<String, GatewayRolesThredds> mapScopeThreddsRoles){
|
||||
GWT.log("ShowThreddsFolderInfo folder: "+folder);
|
||||
//GWT.log("WsThreddsSynchFolderDescriptor is: "+folderDescriptor);
|
||||
|
||||
final Modal box = new Modal(true);
|
||||
box.hide(false);
|
||||
//box.setWidth(WIDHT_DIALOG+"px");
|
||||
box.setTitle("Thredds Sync Information for: "+FormatUtil.getFolderTitle(folder.getFoderName(), 20));
|
||||
//box.getElement().getStyle().setZIndex(10000);
|
||||
|
||||
final AbstractViewDialogBox panelView = new AbstractViewDialogBox() {
|
||||
|
||||
|
@ -353,14 +353,20 @@ public class WsThreddsWidgetViewManager {
|
|||
@Override
|
||||
public void confirmHanlder(CONFIRM_VALUE confirm, Command command) {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
final boolean isCreateConfiguration = folderDescriptor==null?true:false;
|
||||
|
||||
|
||||
//is the user a THREDDS_ADMIN (so DATA_MANAGER) in at least one scope?
|
||||
boolean isThreddsAdmin = false;
|
||||
|
||||
if(mapScopeThreddsRoles!=null) {
|
||||
isThreddsAdmin = mapScopeThreddsRoles.containsValue(GatewayRolesThredds.DATA_MANAGER);
|
||||
}
|
||||
|
||||
|
||||
final ShowThreddsFolderInfoView folderInfo = new ShowThreddsFolderInfoView(folder.getFolderId(), isCreateConfiguration) {
|
||||
|
||||
@Override
|
||||
|
@ -414,27 +420,55 @@ public class WsThreddsWidgetViewManager {
|
|||
if(isCreateConfiguration) {
|
||||
folderInfo.getMainPanel().setVisible(false);
|
||||
|
||||
//If the user is a THREDDS_ADMIN in at least one scope, he/she can create a configuration.
|
||||
if(isThreddsAdmin) {
|
||||
folderInfo.setError(true, THIS_FOLDER_IS_NOT_CONFIGURED_DO_YOU_WANT_CREATE_A_CONFIGURATION);
|
||||
folderInfo.getPager().getLeft().setText(CREATE_CONFIGURATION);
|
||||
}else {
|
||||
//Create Configuration button
|
||||
folderInfo.getPager().getLeft().setVisible(false);
|
||||
folderInfo.setError(true, WsThreddsWidget.MISSING_THREDDS_ADMIN_RIGHTS);
|
||||
folderInfo.setError(true, WsThreddsSyncConstants.RightsMissing.noCreateConfigRights());
|
||||
}
|
||||
|
||||
}else {
|
||||
//USER CAN PERFORM DO SYNC
|
||||
//IT IS DO SYNC OR READ/VIEW THE CURRENT CONFIGURATION
|
||||
//MOREOVER, HE/SHE COULD UPDATE THE CONFIGURATION BUT IT IS NOT SUPPORTED SERVER-SIDE
|
||||
|
||||
//hiding create/update configuration
|
||||
folderInfo.getPager().getLeft().setVisible(false);
|
||||
|
||||
if(isThreddsPubliser || isThreddsAdmin) {
|
||||
|
||||
//hiding unsync button if the user is a publisher
|
||||
if(isThreddsPubliser)
|
||||
//hiding delete syncr
|
||||
folderInfo.showUnsyncButton(false);
|
||||
//doSync button
|
||||
folderInfo.getPager().getRight().setVisible(false);
|
||||
|
||||
//Checking the user role in the target scope
|
||||
GcubeScope targetScope = folderDescriptor.getSelectedScope();
|
||||
|
||||
boolean isThreddsPublisherInTheTargetScope = false;
|
||||
boolean isThreddsAdminInTheTargetScope = false;
|
||||
|
||||
//the user has at least one role in one scope
|
||||
if(mapScopeThreddsRoles!=null) {
|
||||
|
||||
GatewayRolesThredds rolesInTheTargetScope = mapScopeThreddsRoles.get(targetScope.getScopeName());
|
||||
GWT.log("In the target scope: "+targetScope.getScopeName()+" the role of user is: "+rolesInTheTargetScope);
|
||||
//reading the role for the target scope
|
||||
if(rolesInTheTargetScope!=null) {
|
||||
isThreddsAdminInTheTargetScope = rolesInTheTargetScope.equals(GatewayRolesThredds.DATA_MANAGER);
|
||||
isThreddsPublisherInTheTargetScope = rolesInTheTargetScope.equals(GatewayRolesThredds.DATA_EDITOR);
|
||||
}
|
||||
}
|
||||
|
||||
//the user is ADMIN or EDITOR in the target scope
|
||||
if(isThreddsPublisherInTheTargetScope || isThreddsAdminInTheTargetScope) {
|
||||
|
||||
//he/she can run doSync
|
||||
folderInfo.getPager().getRight().setVisible(true);
|
||||
|
||||
//showing unsync button if the user is an ADMIN
|
||||
if(isThreddsAdminInTheTargetScope) {
|
||||
folderInfo.showUnsyncButton(true);
|
||||
}
|
||||
|
||||
if(folderDescriptor.getServerFolderDescriptor().isLocked()) {
|
||||
VerticalPanel v = new VerticalPanel();
|
||||
|
@ -458,7 +492,7 @@ public class WsThreddsWidgetViewManager {
|
|||
}else {
|
||||
//DoSync button
|
||||
folderInfo.getPager().getRight().setVisible(false);
|
||||
folderInfo.setError(true, WsThreddsWidget.MISSING_THREDDS_PUBLISHER_RIGHTS);
|
||||
folderInfo.setError(true, WsThreddsSyncConstants.RightsMissing.noRunSyncRights(targetScope.getScopeTitle()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,8 +32,6 @@ import com.google.gwt.user.client.ui.HTMLPanel;
|
|||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class ShowThreddsFolderInfoView.
|
||||
*
|
||||
|
@ -101,18 +99,16 @@ public abstract class ShowThreddsFolderInfoView extends Composite {
|
|||
@UiField
|
||||
Pager pager;
|
||||
|
||||
|
||||
|
||||
/** The folder id. */
|
||||
private String folderId;
|
||||
|
||||
/** The map VR es. */
|
||||
private Map<String, GcubeScope> mapScopes = new HashMap<String, GcubeScope>();
|
||||
|
||||
|
||||
private boolean isCreateConfiguration;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The Enum SUBMIT_ACTION.
|
||||
*
|
||||
|
@ -150,6 +146,7 @@ public abstract class ShowThreddsFolderInfoView extends Composite {
|
|||
*
|
||||
* @param folderId the folder id
|
||||
* @param isCreateConfiguration the is create configuration
|
||||
* @param mapScopeThreddsRoles the map scope thredds roles
|
||||
*/
|
||||
public ShowThreddsFolderInfoView(String folderId, boolean isCreateConfiguration) {
|
||||
this.folderId = folderId;
|
||||
|
|
|
@ -56,7 +56,7 @@ public class SyncronizeWithThredds {
|
|||
* @param userToken the user token
|
||||
*/
|
||||
private void setContextParameters(String scope, String userToken) {
|
||||
logger.debug("Setting context parameters, scope: "+scope +", user token: "+userToken);
|
||||
logger.debug("Setting context parameters with scope: "+scope +", user token: "+userToken.substring(0,10)+"-MASKED-TOKEN");
|
||||
ScopeProvider.instance.set(scope);
|
||||
SecurityTokenProvider.instance.set(userToken);
|
||||
}
|
||||
|
@ -170,7 +170,6 @@ public class SyncronizeWithThredds {
|
|||
* @throws Exception the exception
|
||||
*/
|
||||
public ThSyncFolderDescriptor checkItemSynched(String folderId, String scope, String userToken) throws ItemNotSynched, WorkspaceFolderLocked, Exception{
|
||||
|
||||
setContextParameters(scope, userToken);
|
||||
return workspaceThreddsSynchronize.checkItemSynched(folderId);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,9 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.portal.wssynclibrary.shared.ItemNotSynched;
|
||||
import org.gcube.portal.wssynclibrary.shared.WorkspaceFolderLocked;
|
||||
import org.gcube.portal.wssynclibrary.shared.thredds.Sync_Status;
|
||||
|
@ -35,7 +37,7 @@ import org.slf4j.LoggerFactory;
|
|||
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||
import com.liferay.portal.service.UserLocalServiceUtil;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
|
||||
/**
|
||||
* The server side implementation of the RPC service.
|
||||
*
|
||||
|
@ -123,31 +125,54 @@ public class ThreddsWorkspaceSyncServiceImpl extends RemoteServiceServlet implem
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the available catalogues for scope.
|
||||
* Gets the available THREDDS catalogues for target scope.
|
||||
*
|
||||
* @param scope the scope
|
||||
* @param targetFullScope the target scope
|
||||
* @return the available catalogues for scope
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Override
|
||||
public List<ThCatalogueBean> getAvailableCataloguesForScope(String scope) throws Exception {
|
||||
public List<ThCatalogueBean> getAvailableCataloguesForScope(String targetFullScope) throws Exception {
|
||||
|
||||
if(scope==null)
|
||||
if(targetFullScope==null)
|
||||
throw new Exception("Invalid scope null");
|
||||
|
||||
String originalScope = null;
|
||||
String originalToken = null;
|
||||
List<ThCatalogueBean> listCtlgs = null;
|
||||
try {
|
||||
GCubeUser user = PortalContext.getConfiguration().getCurrentUser(this.getThreadLocalRequest());
|
||||
String wsScope = PortalContext.getConfiguration().getCurrentScope(this.getThreadLocalRequest());
|
||||
String wsUserToken = PortalContext.getConfiguration().getCurrentUserToken(wsScope, user.getUsername());
|
||||
String targetScopeUserToken = PortalContext.getConfiguration().getCurrentUserToken(scope, user.getUsername());
|
||||
List<ThCatalogueBean> listCtlgs = getSyncService().getAvailableCataloguesByToken(scope, wsUserToken, targetScopeUserToken);
|
||||
//Thread Local contexts
|
||||
originalScope = wsScope;
|
||||
originalToken = wsUserToken;
|
||||
|
||||
logger.debug("Retuning "+listCtlgs.size()+" Catalogues for scope: "+scope);
|
||||
String targetScopeUserToken = PortalContext.getConfiguration().getCurrentUserToken(targetFullScope, user.getUsername());
|
||||
listCtlgs = getSyncService().getAvailableCataloguesByToken(targetFullScope, wsUserToken, targetScopeUserToken);
|
||||
|
||||
logger.debug("Retuning "+listCtlgs.size()+" Catalogues for scope: "+targetFullScope);
|
||||
if(logger.isDebugEnabled()){
|
||||
for (ThCatalogueBean thCatalogueBean : listCtlgs) {
|
||||
logger.debug(thCatalogueBean.toString());
|
||||
}
|
||||
}
|
||||
}catch (Exception e) {
|
||||
logger.error("Error on checking available Catalogue in the scope: "+targetFullScope, e);
|
||||
}finally {
|
||||
|
||||
if(originalScope!=null && originalScope.compareTo(targetFullScope)!=0) {
|
||||
logger.info("Resetting the scope: "+originalScope + " which was original WS context");
|
||||
ScopeProvider.instance.set(originalScope);
|
||||
if(originalToken!=null) {
|
||||
logger.info("Resetting the user token: "+originalToken.substring(0,10)+"-MASKED-TOKEN which was original WS context");
|
||||
SecurityTokenProvider.instance.set(originalToken);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return listCtlgs;
|
||||
}
|
||||
|
@ -169,7 +194,7 @@ public class ThreddsWorkspaceSyncServiceImpl extends RemoteServiceServlet implem
|
|||
//DEV MODE
|
||||
if (!isWithinPortal()){
|
||||
mapScopesRoles = new HashMap<String, GatewayRolesThredds>();
|
||||
// mapScopesRoles.put( "/gcube/devsec/devVRE", GatewayRolesThredds.THREDDS_PUBLISHER);
|
||||
mapScopesRoles.put("/gcube/devNext/NextNext", GatewayRolesThredds.DATA_MANAGER);
|
||||
// mapScopesRoles.put( "/gcube", GatewayRolesThredds.THREDDS_PUBLISHER);
|
||||
// mapScopesRoles.put( "/gcube/devNext/NextNext", GatewayRolesThredds.THREDDS_PUBLISHER);
|
||||
return mapScopesRoles;
|
||||
|
@ -228,10 +253,13 @@ public class ThreddsWorkspaceSyncServiceImpl extends RemoteServiceServlet implem
|
|||
List<GCubeGroup> listOfGroups = new ArrayList<GCubeGroup>(filteredGroupsForGatw);
|
||||
logger.info("list of VREs in the gateway "+gatewayHostname+" are "+listOfGroups.size());
|
||||
for (GCubeGroup gCubeGroup : listOfGroups) {
|
||||
long groupId = gCubeGroup.getGroupId();
|
||||
String fullScope = groupManager.getInfrastructureScope(groupId);
|
||||
logger.debug("For groupId: "+groupId+" got full scope: "+fullScope);
|
||||
GcubeScopeType scopeType=null;
|
||||
if(groupManager.isVRE(gCubeGroup.getGroupId())){
|
||||
if(groupManager.isVRE(groupId)){
|
||||
scopeType = GcubeScopeType.VRE;
|
||||
}else if(groupManager.isVO(gCubeGroup.getGroupId())){
|
||||
}else if(groupManager.isVO(groupId)){
|
||||
scopeType = GcubeScopeType.VO;
|
||||
}
|
||||
// }else if(groupManager.isRootVO(gCubeGroup.getGroupId())){
|
||||
|
@ -241,7 +269,7 @@ public class ThreddsWorkspaceSyncServiceImpl extends RemoteServiceServlet implem
|
|||
if(scopeType!=null){
|
||||
GatewayRolesThredds roles = WsUtil.getThreddsRoleFor(user, gCubeGroup);
|
||||
//Adding only the scope where the user has the THREDDS_ADMIN role
|
||||
GcubeScope gcubeScope = checkDataManagerCapacityAndThreddsCatalogue(roles, gCubeGroup, groupManager, scopeType);
|
||||
GcubeScope gcubeScope = checkDataManagerCapacityAndThreddsCatalogue(roles, gCubeGroup.getGroupName(), fullScope, groupManager, scopeType);
|
||||
if(gcubeScope!=null) {
|
||||
listOfScopes.add(gcubeScope);
|
||||
}
|
||||
|
@ -250,8 +278,9 @@ public class ThreddsWorkspaceSyncServiceImpl extends RemoteServiceServlet implem
|
|||
|
||||
GCubeGroup theRootVO = groupManager.getRootVO();
|
||||
GatewayRolesThredds roles = WsUtil.getThreddsRoleFor(user, theRootVO);
|
||||
String rootVOFullScope = groupManager.getInfrastructureScope(theRootVO.getGroupId());
|
||||
///ADDING THE ROOT SCOPE if the user has the THREDDS_ADMIN role in the ROOT-VO
|
||||
GcubeScope gcubeScope = checkDataManagerCapacityAndThreddsCatalogue(roles, theRootVO, groupManager, GcubeScopeType.ROOT);
|
||||
GcubeScope gcubeScope = checkDataManagerCapacityAndThreddsCatalogue(roles, theRootVO.getGroupName(), rootVOFullScope, groupManager, GcubeScopeType.ROOT);
|
||||
if(gcubeScope!=null) {
|
||||
listOfScopes.add(gcubeScope);
|
||||
}
|
||||
|
@ -285,47 +314,29 @@ public class ThreddsWorkspaceSyncServiceImpl extends RemoteServiceServlet implem
|
|||
* - the scope has an available THREDDS catalogue configured
|
||||
*
|
||||
* @param role the role
|
||||
* @param scope the scope
|
||||
* @param scopeName the scope name e.g. devVRE
|
||||
* @param fullScope the full scope e.g. /gcube/devsec/devVRE
|
||||
* @param groupManager the group manager
|
||||
* @param scopeType the scope type
|
||||
* @return the gcube scope {@link GcubeScope} if the two conditions (see description) are satisfied, null otherwise
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
private GcubeScope checkDataManagerCapacityAndThreddsCatalogue(GatewayRolesThredds role, GCubeGroup scope, GroupManager groupManager, GcubeScopeType scopeType) throws Exception {
|
||||
|
||||
private GcubeScope checkDataManagerCapacityAndThreddsCatalogue(GatewayRolesThredds role, String scopeName, String fullScope, GroupManager groupManager, GcubeScopeType scopeType) throws Exception {
|
||||
logger.debug("checking Data-Manager capacity and THREEDS catalogues for role: "+role, "scope name: "+scopeName+", scope: "+fullScope + " scope type: "+scopeType);
|
||||
if(role!=null && role.getRoleName().equalsIgnoreCase(GatewayRolesNames.DATA_MANAGER.getRoleName())){
|
||||
try {
|
||||
List<ThCatalogueBean> list = getAvailableCataloguesForScope(scope.getGroupName());
|
||||
List<ThCatalogueBean> list = getAvailableCataloguesForScope(fullScope);
|
||||
if(list!=null) {
|
||||
return new GcubeScope(scope.getGroupName(), groupManager.getInfrastructureScope(scope.getGroupId()), scopeType);
|
||||
return new GcubeScope(scopeName, fullScope, scopeType);
|
||||
}
|
||||
}catch (Exception e) {
|
||||
logger.error("Error on checking available catalogue for scope: "+scope.getGroupName(), e);
|
||||
logger.error("Error on checking available catalogue for scope: "+fullScope, e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Available scope for role , checks if for the input scope the user has the role of {@link GatewayRolesThredds.#THREDDS_ADMIN}
|
||||
*
|
||||
* @param role the role
|
||||
* @param scope the scope
|
||||
* @param groupManager the group manager
|
||||
* @param scopeType the scope type
|
||||
* @return the gcube scope {@link GcubeScope} if the user has the role of {@link GatewayRolesThredds.#THREDDS_ADMIN}, null otherwise
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
private GcubeScope availableScopeForRole(GatewayRolesThredds role, GCubeGroup scope, GroupManager groupManager, GcubeScopeType scopeType) throws Exception {
|
||||
|
||||
if(role!=null && role.equals(GatewayRolesThredds.DATA_MANAGER)) {
|
||||
return new GcubeScope(scope.getGroupName(), groupManager.getInfrastructureScope(scope.getGroupId()), scopeType);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if is item synched.
|
||||
*
|
||||
|
|
|
@ -154,7 +154,12 @@ public class WsUtil {
|
|||
* @return the thredds role for
|
||||
*/
|
||||
public static GatewayRolesThredds getThreddsRoleFor(GCubeUser user, GCubeGroup scope){
|
||||
logger.info("called getThreddsRoleFor user: "+user+", in the scope: "+scope.getGroupName());
|
||||
if(user==null || scope==null) {
|
||||
logger.warn("called getThreddsRoleFor with invalid parameter user: "+user+", in the scope: "+scope, ", returning null");
|
||||
return null;
|
||||
}
|
||||
|
||||
logger.info("called getThreddsRoleFor user: "+user.getUsername()+", in the scope: "+scope.getGroupName());
|
||||
try {
|
||||
RoleManager roleManager = new LiferayRoleManager();
|
||||
List<GCubeRole> roles = roleManager.listRolesByUserAndGroup(user.getUserId(), scope.getGroupId());
|
||||
|
@ -168,7 +173,7 @@ public class WsUtil {
|
|||
}
|
||||
}
|
||||
|
||||
logger.info("For user: "+user+" in the scope: "+scope.getGroupName()+" read the role/s: " + threddsRoles);
|
||||
logger.info("For user: "+user.getUsername()+" in the scope: "+scope.getGroupName()+" read the role/s: " + threddsRoles);
|
||||
|
||||
GatewayRolesThredds toReturn = null;
|
||||
if (threddsRoles.contains(GatewayRolesThredds.DATA_MANAGER))
|
||||
|
@ -176,7 +181,7 @@ public class WsUtil {
|
|||
else if (threddsRoles.contains(GatewayRolesThredds.DATA_EDITOR))
|
||||
toReturn = GatewayRolesThredds.DATA_EDITOR;
|
||||
|
||||
logger.info("returning role: " + toReturn);
|
||||
logger.info("returning highest role: " + toReturn);
|
||||
return toReturn;
|
||||
}catch (UserRetrievalFault | GroupRetrievalFault e) {
|
||||
logger.error("An error occurred during getVreRoleForUser: "+user, e);
|
||||
|
|
Loading…
Reference in New Issue