@ -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 scop es for logged user
* @throws Exception the exception
* /
@Override
public List < GcubeScope > getListOf ScopesForLoggedUser( ) throws Exception {
public List < GcubeScope > getListOf DataManager ScopesForLoggedUser( ) 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 = availableScopeForRoleAnd Catalogue( roles , gCubeGroup , groupManager , scopeType ) ;
GcubeScope gcubeScope = checkDataManagerCapacityAndThredds Catalogue( 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 = availableScopeForRoleAnd Catalogue( roles , theRootVO , groupManager , GcubeScopeType . ROOT ) ;
GcubeScope gcubeScope = checkDataManagerCapacityAndThredds Catalogue( 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 , c hecks if for the input scope :
* C hecks 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 availableScopeForRoleAnd Catalogue( GatewayRolesThredds role , GCubeGroup scope , GroupManager groupManager , GcubeScopeType scopeType ) throws Exception {
private GcubeScope checkDataManagerCapacityAndThredds Catalogue( 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 ;