Merge pull request 'Changed the roles to "Data-Editor", "Data-Manager" according to #20889' (#2) from feature_20847 into master
This commit is contained in:
commit
f0d4347266
|
@ -1,9 +1,11 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
||||
|
|
|
@ -183,8 +183,8 @@ public class WsThreddsWidget implements HasWsSyncNotificationListner {
|
|||
if(result!=null) {
|
||||
|
||||
GWT.log("Returned Map(Scope,Role): "+result);
|
||||
final boolean isThreddsPubliser = result.containsValue(GatewayRolesThredds.THREDDS_PUBLISHER);
|
||||
final boolean isThreddsAdmin = result.containsValue(GatewayRolesThredds.THREDDS_ADMIN);
|
||||
final boolean isThreddsPubliser = result.containsValue(GatewayRolesThredds.DATA_EDITOR);
|
||||
final boolean isThreddsAdmin = result.containsValue(GatewayRolesThredds.DATA_MANAGER);
|
||||
|
||||
//no rights assigned
|
||||
if(!isThreddsAdmin && !isThreddsPubliser) {
|
||||
|
|
|
@ -61,7 +61,7 @@ public interface ThreddsWorkspaceSyncService extends RemoteService {
|
|||
* @return the list of vr es for logged user
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
List<GcubeScope> getListOfScopesForLoggedUser() throws Exception;
|
||||
List<GcubeScope> getListOfDataManagerScopesForLoggedUser() throws Exception;
|
||||
|
||||
/**
|
||||
* Gets the available catalogues for scope.
|
||||
|
|
|
@ -92,7 +92,7 @@ public interface ThreddsWorkspaceSyncServiceAsync
|
|||
* @param callback the callback
|
||||
* @return the list of scopes for logged user
|
||||
*/
|
||||
void getListOfScopesForLoggedUser(AsyncCallback<List<GcubeScope>> callback);
|
||||
void getListOfDataManagerScopesForLoggedUser(AsyncCallback<List<GcubeScope>> callback);
|
||||
|
||||
/**
|
||||
* Gets the available catalogues for scope.
|
||||
|
|
|
@ -187,7 +187,7 @@ public abstract class CreateThreddsConfigurationView extends Composite {
|
|||
});
|
||||
|
||||
|
||||
WsThreddsWidget.wsThreddsSyncService.getListOfScopesForLoggedUser(new AsyncCallback<List<GcubeScope>>() {
|
||||
WsThreddsWidget.wsThreddsSyncService.getListOfDataManagerScopesForLoggedUser(new AsyncCallback<List<GcubeScope>>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<GcubeScope> result) {
|
||||
|
|
|
@ -179,7 +179,7 @@ public abstract class ShowThreddsFolderInfoView extends Composite {
|
|||
});
|
||||
|
||||
if(isCreateConfiguration) {
|
||||
WsThreddsWidget.wsThreddsSyncService.getListOfScopesForLoggedUser(new AsyncCallback<List<GcubeScope>>() {
|
||||
WsThreddsWidget.wsThreddsSyncService.getListOfDataManagerScopesForLoggedUser(new AsyncCallback<List<GcubeScope>>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<GcubeScope> result) {
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
|
|||
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
||||
import org.gcube.vomanagement.usermanagement.model.GCubeGroup;
|
||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||
import org.gcube.vomanagement.usermanagement.model.GatewayRolesNames;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -155,9 +156,8 @@ public class ThreddsWorkspaceSyncServiceImpl extends RemoteServiceServlet implem
|
|||
/**
|
||||
* Gets the list of Scopes (Root-VO, VOs and VREs) for user and the Thredds roles that user has in them.
|
||||
*
|
||||
* @param user the user
|
||||
* @return the VREs and Thredds roles for a given user
|
||||
* @throws Exception
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Override
|
||||
public Map<String, GatewayRolesThredds> getScopesWithThreddsRolesForLoggedUser() throws Exception{
|
||||
|
@ -190,14 +190,15 @@ public class ThreddsWorkspaceSyncServiceImpl extends RemoteServiceServlet implem
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the list of VR es for logged user.
|
||||
* Gets the list scope with the role Data-Manager for logged user.
|
||||
*
|
||||
* @return the list of VR es for logged user
|
||||
* @return the list of manager scopes for logged user
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Override
|
||||
public List<GcubeScope> getListOfScopesForLoggedUser() throws Exception{
|
||||
public List<GcubeScope> getListOfDataManagerScopesForLoggedUser() throws Exception{
|
||||
logger.info("getListOfVREsForLoggedUser...: ");
|
||||
GCubeUser user = PortalContext.getConfiguration().getCurrentUser(this.getThreadLocalRequest());
|
||||
long userId = user.getUserId();
|
||||
|
@ -240,7 +241,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 = availableScopeForRoleAndCatalogue(roles, gCubeGroup, groupManager, scopeType);
|
||||
GcubeScope gcubeScope = checkDataManagerCapacityAndThreddsCatalogue(roles, gCubeGroup, groupManager, scopeType);
|
||||
if(gcubeScope!=null) {
|
||||
listOfScopes.add(gcubeScope);
|
||||
}
|
||||
|
@ -250,7 +251,7 @@ public class ThreddsWorkspaceSyncServiceImpl extends RemoteServiceServlet implem
|
|||
GCubeGroup theRootVO = groupManager.getRootVO();
|
||||
GatewayRolesThredds roles = WsUtil.getThreddsRoleFor(user, theRootVO);
|
||||
///ADDING THE ROOT SCOPE if the user has the THREDDS_ADMIN role in the ROOT-VO
|
||||
GcubeScope gcubeScope = availableScopeForRoleAndCatalogue(roles, theRootVO, groupManager, GcubeScopeType.ROOT);
|
||||
GcubeScope gcubeScope = checkDataManagerCapacityAndThreddsCatalogue(roles, theRootVO, groupManager, GcubeScopeType.ROOT);
|
||||
if(gcubeScope!=null) {
|
||||
listOfScopes.add(gcubeScope);
|
||||
}
|
||||
|
@ -269,19 +270,19 @@ public class ThreddsWorkspaceSyncServiceImpl extends RemoteServiceServlet implem
|
|||
}
|
||||
|
||||
if(listOfScopes.isEmpty()) {
|
||||
throw new Exception("No scope detected with the needed role: "+GatewayRolesThredds.THREDDS_ADMIN.getRoleName()+". Contact the VRE manager or the portal administrator");
|
||||
throw new Exception("No scope detected with the needed role: "+GatewayRolesThredds.DATA_MANAGER.getRoleName()+". Contact the VRE manager or the portal administrator");
|
||||
}
|
||||
|
||||
Collections.sort(listOfScopes);
|
||||
logger.info("Returning list of allowed scope/s with: "+GatewayRolesThredds.THREDDS_ADMIN + " role/s: "+listOfScopes);
|
||||
logger.info("Returning list of allowed scope/s with: "+GatewayRolesThredds.DATA_MANAGER + " role/s: "+listOfScopes);
|
||||
return listOfScopes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Available scope for role and catalogue, checks if for the input scope:
|
||||
* Checks if for the input scope:
|
||||
* - the user has the role {@link GatewayRolesThredds.#THREDDS_ADMIN}
|
||||
* - the scope has an available thredds catalogue configured
|
||||
* - the scope has an available THREDDS catalogue configured
|
||||
*
|
||||
* @param role the role
|
||||
* @param scope the scope
|
||||
|
@ -290,9 +291,9 @@ public class ThreddsWorkspaceSyncServiceImpl extends RemoteServiceServlet implem
|
|||
* @return the gcube scope {@link GcubeScope} if the two conditions (see description) are satisfied, null otherwise
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
private GcubeScope availableScopeForRoleAndCatalogue(GatewayRolesThredds role, GCubeGroup scope, GroupManager groupManager, GcubeScopeType scopeType) throws Exception {
|
||||
private GcubeScope checkDataManagerCapacityAndThreddsCatalogue(GatewayRolesThredds role, GCubeGroup scope, GroupManager groupManager, GcubeScopeType scopeType) throws Exception {
|
||||
|
||||
if(role!=null && role.equals(GatewayRolesThredds.THREDDS_ADMIN)) {
|
||||
if(role!=null && role.getRoleName().equalsIgnoreCase(GatewayRolesNames.DATA_MANAGER.getRoleName())){
|
||||
try {
|
||||
List<ThCatalogueBean> list = getAvailableCataloguesForScope(scope.getGroupName());
|
||||
if(list!=null) {
|
||||
|
@ -318,7 +319,7 @@ public class ThreddsWorkspaceSyncServiceImpl extends RemoteServiceServlet implem
|
|||
*/
|
||||
private GcubeScope availableScopeForRole(GatewayRolesThredds role, GCubeGroup scope, GroupManager groupManager, GcubeScopeType scopeType) throws Exception {
|
||||
|
||||
if(role!=null && role.equals(GatewayRolesThredds.THREDDS_ADMIN)) {
|
||||
if(role!=null && role.equals(GatewayRolesThredds.DATA_MANAGER)) {
|
||||
return new GcubeScope(scope.getGroupName(), groupManager.getInfrastructureScope(scope.getGroupId()), scopeType);
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -160,21 +160,21 @@ public class WsUtil {
|
|||
List<GCubeRole> roles = roleManager.listRolesByUserAndGroup(user.getUserId(), scope.getGroupId());
|
||||
List<GatewayRolesThredds> threddsRoles = new ArrayList<GatewayRolesThredds>();
|
||||
for (GCubeRole gCubeRole : roles) {
|
||||
if(gCubeRole.getRoleName().equalsIgnoreCase(GatewayRolesThredds.THREDDS_ADMIN.getRoleName())){
|
||||
threddsRoles.add(GatewayRolesThredds.THREDDS_ADMIN);
|
||||
if(gCubeRole.getRoleName().equalsIgnoreCase(GatewayRolesThredds.DATA_MANAGER.getRoleName())){
|
||||
threddsRoles.add(GatewayRolesThredds.DATA_MANAGER);
|
||||
}
|
||||
if(gCubeRole.getRoleName().equalsIgnoreCase(GatewayRolesThredds.THREDDS_PUBLISHER.getRoleName())){
|
||||
threddsRoles.add(GatewayRolesThredds.THREDDS_PUBLISHER);
|
||||
if(gCubeRole.getRoleName().equalsIgnoreCase(GatewayRolesThredds.DATA_EDITOR.getRoleName())){
|
||||
threddsRoles.add(GatewayRolesThredds.DATA_EDITOR);
|
||||
}
|
||||
}
|
||||
|
||||
logger.info("For user: "+user+" in the scope: "+scope.getGroupName()+" read the role/s: " + threddsRoles);
|
||||
|
||||
GatewayRolesThredds toReturn = null;
|
||||
if (threddsRoles.contains(GatewayRolesThredds.THREDDS_ADMIN))
|
||||
toReturn = GatewayRolesThredds.THREDDS_ADMIN;
|
||||
else if (threddsRoles.contains(GatewayRolesThredds.THREDDS_PUBLISHER))
|
||||
toReturn = GatewayRolesThredds.THREDDS_PUBLISHER;
|
||||
if (threddsRoles.contains(GatewayRolesThredds.DATA_MANAGER))
|
||||
toReturn = GatewayRolesThredds.DATA_MANAGER;
|
||||
else if (threddsRoles.contains(GatewayRolesThredds.DATA_EDITOR))
|
||||
toReturn = GatewayRolesThredds.DATA_EDITOR;
|
||||
|
||||
logger.info("returning role: " + toReturn);
|
||||
return toReturn;
|
||||
|
|
|
@ -2,8 +2,8 @@ package org.gcube.portlets.widgets.wsthreddssync.shared;
|
|||
|
||||
public enum GatewayRolesThredds {
|
||||
|
||||
THREDDS_ADMIN("Thredds-Admin"),
|
||||
THREDDS_PUBLISHER("Thredds-Publisher");
|
||||
DATA_MANAGER("Data-Manager"),
|
||||
DATA_EDITOR("Data-Editor");
|
||||
|
||||
private String name;
|
||||
|
||||
|
|
Loading…
Reference in New Issue