2018-03-02 17:03:57 +01:00
package org.gcube.portlets.widgets.wsthreddssync.server ;
import java.util.ArrayList ;
2018-03-14 16:04:08 +01:00
import java.util.Collections ;
2021-03-04 16:24:54 +01:00
import java.util.HashMap ;
2018-03-02 17:03:57 +01:00
import java.util.List ;
2021-03-04 16:24:54 +01:00
import java.util.Map ;
2021-03-03 18:14:53 +01:00
import java.util.Set ;
2018-03-02 17:03:57 +01:00
import org.gcube.common.portal.PortalContext ;
import org.gcube.portal.wssynclibrary.shared.ItemNotSynched ;
2018-03-13 15:09:36 +01:00
import org.gcube.portal.wssynclibrary.shared.WorkspaceFolderLocked ;
2018-03-02 17:03:57 +01:00
import org.gcube.portal.wssynclibrary.shared.thredds.Sync_Status ;
2018-03-08 17:59:33 +01:00
import org.gcube.portal.wssynclibrary.shared.thredds.ThCatalogueBean ;
2018-03-02 17:03:57 +01:00
import org.gcube.portal.wssynclibrary.shared.thredds.ThSyncFolderDescriptor ;
import org.gcube.portal.wssynclibrary.shared.thredds.ThSyncStatus ;
import org.gcube.portal.wssynclibrary.shared.thredds.ThSynchFolderConfiguration ;
import org.gcube.portlets.widgets.wsthreddssync.client.rpc.ThreddsWorkspaceSyncService ;
2021-03-03 18:14:53 +01:00
import org.gcube.portlets.widgets.wsthreddssync.shared.GatewayRolesThredds ;
2018-03-12 17:43:51 +01:00
import org.gcube.portlets.widgets.wsthreddssync.shared.GcubeScope ;
import org.gcube.portlets.widgets.wsthreddssync.shared.GcubeScopeType ;
2018-03-02 17:03:57 +01:00
import org.gcube.portlets.widgets.wsthreddssync.shared.WsThreddsSynchFolderConfiguration ;
import org.gcube.portlets.widgets.wsthreddssync.shared.WsThreddsSynchFolderDescriptor ;
import org.gcube.vomanagement.usermanagement.GroupManager ;
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault ;
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException ;
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.slf4j.Logger ;
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 .
*
* @author Francesco Mangiacrapa francesco . mangiacrapa @isti.cnr.it
* Feb 14 , 2018
* /
@SuppressWarnings ( " serial " )
public class ThreddsWorkspaceSyncServiceImpl extends RemoteServiceServlet implements ThreddsWorkspaceSyncService {
2018-03-08 17:59:33 +01:00
2018-03-02 17:03:57 +01:00
/** The logger. */
private static Logger logger = LoggerFactory . getLogger ( ThreddsWorkspaceSyncServiceImpl . class ) ;
2018-03-08 17:59:33 +01:00
2018-03-02 17:03:57 +01:00
/** The sync thredds. */
private SyncronizeWithThredds syncThredds = null ;
/ * *
* Gets the sync service .
*
* @return the sync service
* /
public synchronized SyncronizeWithThredds getSyncService ( ) {
2018-03-08 17:59:33 +01:00
2018-03-02 17:03:57 +01:00
if ( syncThredds = = null )
syncThredds = new SyncronizeWithThredds ( ) ;
2018-03-08 17:59:33 +01:00
2018-03-02 17:03:57 +01:00
return syncThredds ;
2018-03-08 17:59:33 +01:00
2018-03-02 17:03:57 +01:00
}
2018-03-08 17:59:33 +01:00
2018-03-02 17:03:57 +01:00
/ * *
* Checks if is within portal .
*
* @return true if you ' re running into the portal , false if in development
* /
public static boolean isWithinPortal ( ) {
try {
UserLocalServiceUtil . getService ( ) ;
return true ;
}
catch ( Exception ex ) {
2021-03-04 16:24:54 +01:00
logger . warn ( " Development Mode ON " ) ;
2018-03-02 17:03:57 +01:00
return false ;
}
}
2018-03-08 17:59:33 +01:00
2018-03-02 17:03:57 +01:00
/ * *
* Do sync folder .
*
* @param folderId the folder id
* @param clientConfig the th config
* @return the th sync status
* @throws Exception the exception
* /
/ * ( non - Javadoc )
* @see org . gcube . portlets . widgets . wsthreddssync . client . rpc . ThreddsWorkspaceSyncService # doSyncFolder ( java . lang . String , org . gcube . portlets . widgets . wsthreddssync . shared . WsThreddsSynchFolderDescriptor )
* /
@Override
public ThSyncStatus doSyncFolder ( final String folderId , WsThreddsSynchFolderConfiguration clientConfig ) throws Exception {
logger . info ( " Performing doSyncFolder method on id: " + folderId + " , config: " + clientConfig ) ;
try {
GCubeUser user = PortalContext . getConfiguration ( ) . getCurrentUser ( this . getThreadLocalRequest ( ) ) ;
String targetScopeUserToken = null ;
ThSynchFolderConfiguration config = null ;
if ( clientConfig ! = null ) {
2018-03-12 17:43:51 +01:00
targetScopeUserToken = PortalContext . getConfiguration ( ) . getCurrentUserToken ( clientConfig . getSelectedScope ( ) . getScopeName ( ) , user . getUsername ( ) ) ;
2018-03-28 14:55:45 +02:00
config = BeanConverter . toThSynchFolderConfiguration ( clientConfig , folderId , targetScopeUserToken ) ;
2018-03-02 17:03:57 +01:00
logger . debug ( " Creating server config " + config ) ;
}
2018-03-08 17:59:33 +01:00
2018-03-02 17:03:57 +01:00
logger . info ( " Calling doSyncFolder on folderId: " + folderId + " , config: " + config ) ;
String wsScope = PortalContext . getConfiguration ( ) . getCurrentScope ( this . getThreadLocalRequest ( ) ) ;
String wsUserToken = PortalContext . getConfiguration ( ) . getCurrentUserToken ( wsScope , user . getUsername ( ) ) ;
2018-03-08 17:59:33 +01:00
2018-03-02 17:03:57 +01:00
ThSyncStatus status = getSyncService ( ) . doSyncFolder ( folderId , config , wsScope , wsUserToken ) ;
logger . debug ( " Returning for folderId " + folderId + " the syncStatus: " + status ) ;
2018-03-08 17:59:33 +01:00
2018-03-02 17:03:57 +01:00
return status ;
} catch ( Exception e ) {
logger . error ( " Do sync Folder error: " , e ) ;
throw new Exception ( " Sorry, an error occurred during synchonization phase, try again later " ) ;
}
}
2018-03-08 17:59:33 +01:00
/ * *
* Gets the available catalogues for scope .
*
* @param scope the scope
* @return the available catalogues for scope
* @throws Exception the exception
* /
@Override
public List < ThCatalogueBean > getAvailableCataloguesForScope ( String scope ) throws Exception {
if ( scope = = null )
throw new Exception ( " Invalid scope null " ) ;
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 ) ;
logger . debug ( " Retuning " + listCtlgs . size ( ) + " Catalogues for scope: " + scope ) ;
if ( logger . isDebugEnabled ( ) ) {
for ( ThCatalogueBean thCatalogueBean : listCtlgs ) {
logger . debug ( thCatalogueBean . toString ( ) ) ;
}
}
return listCtlgs ;
}
2021-03-04 16:24:54 +01:00
/ * *
* 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
* /
@Override
public Map < String , GatewayRolesThredds > getScopesWithThreddsRolesForLoggedUser ( ) throws Exception {
logger . info ( " called getScopesWithThreddsRolesForLoggedUser " ) ;
GCubeUser user = null ;
Map < String , GatewayRolesThredds > mapScopesRoles = null ;
//DEV MODE
if ( ! isWithinPortal ( ) ) {
mapScopesRoles = new HashMap < String , GatewayRolesThredds > ( ) ;
// mapScopesRoles.put( "/gcube/devsec/devVRE", GatewayRolesThredds.THREDDS_PUBLISHER);
// mapScopesRoles.put( "/gcube", GatewayRolesThredds.THREDDS_PUBLISHER);
// mapScopesRoles.put( "/gcube/devNext/NextNext", GatewayRolesThredds.THREDDS_PUBLISHER);
return mapScopesRoles ;
}
try {
user = PortalContext . getConfiguration ( ) . getCurrentUser ( this . getThreadLocalRequest ( ) ) ;
mapScopesRoles = WsUtil . getScopesWithThreddsRolesForUser ( user ) ;
logger . info ( " returning Map(scopes,roles): " + mapScopesRoles ) ;
return mapScopesRoles ;
} catch ( Exception e ) {
String errorMsg = " An error occurred on checking user roles. Refresh the page and try again. " ;
logger . error ( " An error occurred on checking user roles for user: " + user , e ) ;
throw new Exception ( errorMsg ) ;
}
}
2018-03-08 17:59:33 +01:00
2018-03-02 17:03:57 +01:00
/ * *
* Gets the list of VR es for logged user .
*
* @return the list of VR es for logged user
* @throws Exception the exception
* /
@Override
2018-03-12 17:43:51 +01:00
public List < GcubeScope > getListOfScopesForLoggedUser ( ) throws Exception {
2021-03-03 18:14:53 +01:00
logger . info ( " getListOfVREsForLoggedUser...: " ) ;
2018-03-02 17:03:57 +01:00
GCubeUser user = PortalContext . getConfiguration ( ) . getCurrentUser ( this . getThreadLocalRequest ( ) ) ;
long userId = user . getUserId ( ) ;
// Instanciate the manager
GroupManager groupManager = new LiferayGroupManager ( ) ;
2018-03-14 16:04:08 +01:00
List < GcubeScope > listOfScopes = new ArrayList < GcubeScope > ( ) ;
2021-03-04 16:24:54 +01:00
//DEV MODE
2018-03-02 17:03:57 +01:00
if ( ! isWithinPortal ( ) ) {
2018-03-14 16:04:08 +01:00
listOfScopes . add ( new GcubeScope ( " devVRE " , " /gcube/devsec/devVRE " , GcubeScopeType . VRE ) ) ;
listOfScopes . add ( new GcubeScope ( " NextNext " , " /gcube/devNext/NextNext " , GcubeScopeType . VRE ) ) ;
2018-03-14 16:26:18 +01:00
listOfScopes . add ( new GcubeScope ( " devNext " , " /gcube/devNext " , GcubeScopeType . VO ) ) ;
listOfScopes . add ( new GcubeScope ( " devsec " , " /gcube/devsec " , GcubeScopeType . VO ) ) ;
listOfScopes . add ( new GcubeScope ( " gcube " , " /gcube " , GcubeScopeType . ROOT ) ) ;
Collections . sort ( listOfScopes ) ;
2018-03-14 16:04:08 +01:00
return listOfScopes ;
2018-03-02 17:03:57 +01:00
}
try {
2021-03-03 18:14:53 +01:00
String gatewayHostname = GenericUtils . getGatewayClientHostname ( getThreadLocalRequest ( ) ) ;
//list of Scopes filtered for gateway
Set < GCubeGroup > filteredGroupsForGatw = groupManager . listGroupsByUserAndSite ( userId , gatewayHostname ) ;
//List<GCubeGroup> listOfGroups = groupManager.listGroupsByUser(userId);
List < GCubeGroup > listOfGroups = new ArrayList < GCubeGroup > ( filteredGroupsForGatw ) ;
logger . info ( " list of VREs in the gateway " + gatewayHostname + " are " + listOfGroups . size ( ) ) ;
2018-03-02 17:03:57 +01:00
for ( GCubeGroup gCubeGroup : listOfGroups ) {
2018-03-12 17:43:51 +01:00
GcubeScopeType scopeType = null ;
2018-03-02 17:03:57 +01:00
if ( groupManager . isVRE ( gCubeGroup . getGroupId ( ) ) ) {
2018-03-12 17:43:51 +01:00
scopeType = GcubeScopeType . VRE ;
} else if ( groupManager . isVO ( gCubeGroup . getGroupId ( ) ) ) {
scopeType = GcubeScopeType . VO ;
}
2018-03-14 16:04:08 +01:00
// }else if(groupManager.isRootVO(gCubeGroup.getGroupId())){
// scopeType = GcubeScopeType.ROOT;
// }
2018-03-12 17:43:51 +01:00
if ( scopeType ! = null ) {
2021-03-04 16:24:54 +01:00
GatewayRolesThredds roles = WsUtil . getThreddsRoleFor ( user , gCubeGroup ) ;
2021-03-03 18:14:53 +01:00
//Adding only the scope where the user has the THREDDS_ADMIN role
2021-03-04 16:24:54 +01:00
GcubeScope gcubeScope = availableScopeForRoleAndCatalogue ( roles , gCubeGroup , groupManager , scopeType ) ;
2021-03-03 18:14:53 +01:00
if ( gcubeScope ! = null ) {
listOfScopes . add ( gcubeScope ) ;
}
2018-03-02 17:03:57 +01:00
}
2021-03-03 18:14:53 +01:00
}
GCubeGroup theRootVO = groupManager . getRootVO ( ) ;
2021-03-04 16:24:54 +01:00
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 ) ;
2021-03-03 18:14:53 +01:00
if ( gcubeScope ! = null ) {
listOfScopes . add ( gcubeScope ) ;
2018-03-02 17:03:57 +01:00
}
2018-03-14 16:04:08 +01:00
//ADDING THE ROOT SCOPE
2021-03-03 18:14:53 +01:00
/ * String infraName = PortalContext . getConfiguration ( ) . getInfrastructureName ( ) ;
2018-03-14 16:04:08 +01:00
GcubeScope gcubeRoot = new GcubeScope ( infraName , " / " + infraName , GcubeScopeType . ROOT ) ;
2021-03-03 18:14:53 +01:00
listOfScopes . add ( gcubeRoot ) * /
2018-03-14 16:04:08 +01:00
2018-03-02 17:03:57 +01:00
}
catch ( UserRetrievalFault | UserManagementSystemException
| GroupRetrievalFault e ) {
logger . error ( " Error occurred server-side getting VRE folders: " , e ) ;
throw new Exception ( " Sorry, an error occurred server-side getting VRE folders, try again later " ) ;
}
2021-03-03 18:14:53 +01:00
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 " ) ;
}
2018-03-02 17:03:57 +01:00
2018-03-14 16:04:08 +01:00
Collections . sort ( listOfScopes ) ;
2021-03-04 16:24:54 +01:00
logger . info ( " Returning list of allowed scope/s with: " + GatewayRolesThredds . THREDDS_ADMIN + " role/s: " + listOfScopes ) ;
2018-03-14 16:04:08 +01:00
return listOfScopes ;
2018-03-02 17:03:57 +01:00
}
2021-03-03 18:14:53 +01:00
/ * *
* Available scope for role and catalogue , checks if for the input scope :
2021-03-04 16:24:54 +01:00
* - the user has the role { @link GatewayRolesThredds . # THREDDS_ADMIN }
* - the scope has an available thredds catalogue configured
*
* @param role the role
2021-03-03 18:14:53 +01:00
* @param scope the scope
* @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
* /
2021-03-04 16:24:54 +01:00
private GcubeScope availableScopeForRoleAndCatalogue ( GatewayRolesThredds role , GCubeGroup scope , GroupManager groupManager , GcubeScopeType scopeType ) throws Exception {
2021-03-03 18:14:53 +01:00
2021-03-04 16:24:54 +01:00
if ( role ! = null & & role . equals ( GatewayRolesThredds . THREDDS_ADMIN ) ) {
2021-03-03 18:14:53 +01:00
try {
List < ThCatalogueBean > list = getAvailableCataloguesForScope ( scope . getGroupName ( ) ) ;
2021-03-04 16:24:54 +01:00
if ( list ! = null ) {
2021-03-03 18:14:53 +01:00
return new GcubeScope ( scope . getGroupName ( ) , groupManager . getInfrastructureScope ( scope . getGroupId ( ) ) , scopeType ) ;
}
} catch ( Exception e ) {
logger . error ( " Error on checking available catalogue for scope: " + scope . getGroupName ( ) , e ) ;
}
}
return null ;
}
/ * *
* Available scope for role , checks if for the input scope the user has the role of { @link GatewayRolesThredds . # THREDDS_ADMIN }
2021-03-04 16:24:54 +01:00
*
* @param role the role
2021-03-03 18:14:53 +01:00
* @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
* /
2021-03-04 16:24:54 +01:00
private GcubeScope availableScopeForRole ( GatewayRolesThredds role , GCubeGroup scope , GroupManager groupManager , GcubeScopeType scopeType ) throws Exception {
2021-03-03 18:14:53 +01:00
2021-03-04 16:24:54 +01:00
if ( role ! = null & & role . equals ( GatewayRolesThredds . THREDDS_ADMIN ) ) {
2021-03-03 18:14:53 +01:00
return new GcubeScope ( scope . getGroupName ( ) , groupManager . getInfrastructureScope ( scope . getGroupId ( ) ) , scopeType ) ;
}
return null ;
}
2018-03-02 17:03:57 +01:00
2018-03-08 17:59:33 +01:00
2021-03-03 18:14:53 +01:00
/ * *
* Checks if is item synched .
*
* @param folderId the folder id
* @return the ws thredds synch folder descriptor
* @throws WorkspaceFolderLocked the workspace folder locked
* @throws Exception the exception
* /
2018-03-02 17:03:57 +01:00
/ * ( non - Javadoc )
* @see org . gcube . portlets . widgets . wsthreddssync . client . rpc . ThreddsWorkspaceSyncService # isItemSynched ( java . lang . String )
* /
@Override
2018-03-13 15:09:36 +01:00
public WsThreddsSynchFolderDescriptor isItemSynched ( String folderId ) throws WorkspaceFolderLocked , Exception {
2018-03-08 17:59:33 +01:00
2018-03-02 17:03:57 +01:00
logger . debug ( " Performing isItemSynched for foldeId: " + folderId ) ;
2018-03-08 17:59:33 +01:00
2018-03-02 17:03:57 +01:00
try {
2018-03-08 17:59:33 +01:00
2018-03-02 17:03:57 +01:00
GCubeUser user = PortalContext . getConfiguration ( ) . getCurrentUser ( this . getThreadLocalRequest ( ) ) ;
String wsScope = PortalContext . getConfiguration ( ) . getCurrentScope ( this . getThreadLocalRequest ( ) ) ;
Sync_Status theStatus = getSyncService ( ) . getSynchedStatusFromItemProperty ( folderId , wsScope , user . getUsername ( ) ) ;
2018-03-08 17:59:33 +01:00
2018-03-02 17:03:57 +01:00
if ( theStatus ! = null ) {
logger . info ( " Folder id: " + folderId + " is synched " ) ;
String wsUserToken = PortalContext . getConfiguration ( ) . getCurrentUserToken ( wsScope , user . getUsername ( ) ) ;
ThSyncFolderDescriptor serverFolderSync = getSyncService ( ) . checkItemSynched ( folderId , wsScope , wsUserToken ) ;
WsThreddsSynchFolderDescriptor toWsThreddFolder = BeanConverter . toWsThreddsFolderConfig ( serverFolderSync , theStatus ) ;
logger . debug ( " IsItemSynched for id: " + folderId + " returning: " + toWsThreddFolder ) ;
return toWsThreddFolder ;
}
2018-03-08 17:59:33 +01:00
2018-03-02 17:03:57 +01:00
logger . info ( " Folder id: " + folderId + " is not synched, returning null descriptor " ) ;
return null ;
2018-03-08 17:59:33 +01:00
2018-03-02 17:03:57 +01:00
} catch ( ItemNotSynched e ) {
logger . info ( " The folderId: " + folderId + " is not synched, returning null FolderDescriptor " ) ;
return null ;
2018-03-13 15:09:36 +01:00
} catch ( WorkspaceFolderLocked e ) {
logger . warn ( e . getMessage ( ) + " , sending exception to client... " ) ;
throw new WorkspaceFolderLocked ( e . getFolderId ( ) , e . getMessage ( ) ) ;
2018-03-02 17:03:57 +01:00
} catch ( Exception e ) {
logger . info ( " Error on isItemSynched for folderId: " + folderId , e ) ;
throw new Exception ( e ) ;
}
}
2018-03-08 17:59:33 +01:00
2018-03-02 17:03:57 +01:00
/ * *
* Register callback for id .
*
* @param folderId the folder id
* @throws Exception the exception
* /
public void registerCallbackForId ( String folderId ) throws Exception {
GCubeUser user = PortalContext . getConfiguration ( ) . getCurrentUser ( this . getThreadLocalRequest ( ) ) ;
String wsScope = PortalContext . getConfiguration ( ) . getCurrentScope ( this . getThreadLocalRequest ( ) ) ;
String wsUserToken = PortalContext . getConfiguration ( ) . getCurrentUserToken ( wsScope , user . getUsername ( ) ) ;
getSyncService ( ) . registerCallbackForId ( folderId , wsScope , wsUserToken ) ;
}
2018-03-08 17:59:33 +01:00
2021-03-03 18:14:53 +01:00
/ * *
* Monitor sync status .
*
* @param folderId the folder id
* @return the th sync status
* @throws ItemNotSynched the item not synched
* @throws Exception the exception
* /
2018-03-02 17:03:57 +01:00
/ * ( non - Javadoc )
* @see org . gcube . portlets . widgets . wsthreddssync . client . rpc . ThreddsWorkspaceSyncService # monitorSyncStatus ( java . lang . String )
* /
@Override
public ThSyncStatus monitorSyncStatus ( String folderId ) throws ItemNotSynched , Exception {
GCubeUser user = PortalContext . getConfiguration ( ) . getCurrentUser ( this . getThreadLocalRequest ( ) ) ;
String wsScope = PortalContext . getConfiguration ( ) . getCurrentScope ( this . getThreadLocalRequest ( ) ) ;
String wsUserToken = PortalContext . getConfiguration ( ) . getCurrentUserToken ( wsScope , user . getUsername ( ) ) ;
return getSyncService ( ) . monitorSyncStatus ( folderId , wsScope , wsUserToken ) ;
}
2018-03-13 17:39:09 +01:00
/ * *
* Do sync folder .
*
* @param folderId the folder id
* @return the th sync status
* @throws Exception the exception
* /
/ * ( non - Javadoc )
* @see org . gcube . portlets . widgets . wsthreddssync . client . rpc . ThreddsWorkspaceSyncService # doSyncFolder ( java . lang . String , org . gcube . portlets . widgets . wsthreddssync . shared . WsThreddsSynchFolderDescriptor )
* /
@Override
public Boolean doUnSyncFolder ( final String folderId ) throws Exception {
logger . info ( " Performing unsync on folder id: " + folderId ) ;
// String scope = PortalContext.getConfiguration().getCurrentScope(this.getThreadLocalRequest());
// GCubeUser username = PortalContext.getConfiguration().getCurrentUser(this.getThreadLocalRequest());
// String groupName = PortalContext.getConfiguration().getCurrentGroupName(this.getThreadLocalRequest());
// new GcubeVRE(groupName, scope)
try {
GCubeUser user = PortalContext . getConfiguration ( ) . getCurrentUser ( this . getThreadLocalRequest ( ) ) ;
String wsScope = PortalContext . getConfiguration ( ) . getCurrentScope ( this . getThreadLocalRequest ( ) ) ;
String wsUserToken = PortalContext . getConfiguration ( ) . getCurrentUserToken ( wsScope , user . getUsername ( ) ) ;
return getSyncService ( ) . doUnSync ( folderId , false , wsScope , wsUserToken ) ;
} catch ( Exception e ) {
logger . error ( " Do un sync Folder error: " , e ) ;
throw new Exception ( " Sorry, an error occurred on deleting sync configurations, refresh and try again later " ) ;
}
}
2018-03-02 17:03:57 +01:00
}