first complete commit for task #21379
This commit is contained in:
parent
f2dc0cce19
commit
8f191559c3
|
@ -6,7 +6,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
||||||
|
|
||||||
## [v1.4.0-SNAPSHOT] - 2021-05-10
|
## [v1.4.0-SNAPSHOT] - 2021-05-10
|
||||||
|
|
||||||
[#20847] Support the roles of THREDDS Admin and THREDDS Publisher
|
[#21379] Moved to new ws-synchronized-module-library (based on w-thredds 1.x) and performed UMA tokens "context switches"
|
||||||
|
|
||||||
|
|
||||||
## [v1.3.0] - 2021-03-17
|
## [v1.3.0] - 2021-03-17
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -92,7 +92,7 @@
|
||||||
<groupId>org.gcube.portal</groupId>
|
<groupId>org.gcube.portal</groupId>
|
||||||
<artifactId>oidc-library-portal</artifactId>
|
<artifactId>oidc-library-portal</artifactId>
|
||||||
<version>[1.0.0, 2.0.0-SNAPSHOT)</version>
|
<version>[1.0.0, 2.0.0-SNAPSHOT)</version>
|
||||||
<scope>provided</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- <dependency> -->
|
<!-- <dependency> -->
|
||||||
|
|
|
@ -14,8 +14,6 @@ import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.oidc.rest.JWTToken;
|
import org.gcube.oidc.rest.JWTToken;
|
||||||
import org.gcube.portal.oidc.lr62.OIDCUmaUtil;
|
import org.gcube.portal.oidc.lr62.OIDCUmaUtil;
|
||||||
import org.gcube.portal.wssynclibrary.shared.ItemNotSynched;
|
import org.gcube.portal.wssynclibrary.shared.ItemNotSynched;
|
||||||
import org.gcube.portal.wssynclibrary.shared.WorkspaceFolderLocked;
|
|
||||||
import org.gcube.portal.wssynclibrary.shared.thredds.Sync_Status;
|
|
||||||
import org.gcube.portal.wssynclibrary.shared.thredds.ThCatalogueBean;
|
import org.gcube.portal.wssynclibrary.shared.thredds.ThCatalogueBean;
|
||||||
import org.gcube.portal.wssynclibrary.shared.thredds.ThSyncFolderDescriptor;
|
import org.gcube.portal.wssynclibrary.shared.thredds.ThSyncFolderDescriptor;
|
||||||
import org.gcube.portal.wssynclibrary.shared.thredds.ThSyncStatus;
|
import org.gcube.portal.wssynclibrary.shared.thredds.ThSyncStatus;
|
||||||
|
@ -30,12 +28,10 @@ import org.slf4j.LoggerFactory;
|
||||||
/**
|
/**
|
||||||
* The Class SyncronizeWithThredds.
|
* The Class SyncronizeWithThredds.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Feb 7, 2018
|
||||||
* Feb 7, 2018
|
|
||||||
*/
|
*/
|
||||||
public class SyncronizeWithThredds {
|
public class SyncronizeWithThredds {
|
||||||
|
|
||||||
|
|
||||||
/** The logger. */
|
/** The logger. */
|
||||||
private Logger logger = LoggerFactory.getLogger(SyncronizeWithThredds.class);
|
private Logger logger = LoggerFactory.getLogger(SyncronizeWithThredds.class);
|
||||||
|
|
||||||
|
@ -43,7 +39,8 @@ public class SyncronizeWithThredds {
|
||||||
private WorkspaceThreddsSynchronize workspaceThreddsSynchronize;
|
private WorkspaceThreddsSynchronize workspaceThreddsSynchronize;
|
||||||
|
|
||||||
/** The Constant sdf. */
|
/** The Constant sdf. */
|
||||||
//private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss");
|
// private static final SimpleDateFormat sdf = new
|
||||||
|
// SimpleDateFormat("yyyy.MM.dd.HH.mm.ss");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new publish on thredds.
|
* Instantiates a new publish on thredds.
|
||||||
|
@ -116,14 +113,13 @@ public class SyncronizeWithThredds {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if is item synched.
|
* Checks if is item synched.
|
||||||
*
|
*
|
||||||
* @param folderId the folder id
|
* @param folderId the folder id
|
||||||
* @return the th sync folder descriptor
|
* @return the th sync folder descriptor
|
||||||
* @throws ItemNotSynched the item not synched
|
* @throws ItemNotSynched the item not synched
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
public ThSyncFolderDescriptor isItemSynched(String folderId) throws ItemNotSynched, Exception {
|
public ThSyncFolderDescriptor isItemSynched(String folderId) throws ItemNotSynched, Exception {
|
||||||
ThSyncFolderDescriptor config = null;
|
ThSyncFolderDescriptor config = null;
|
||||||
|
@ -133,7 +129,8 @@ public class SyncronizeWithThredds {
|
||||||
logger.debug("WorkspaceNotSynchedException catched, the item id: " + folderId + " is not synched");
|
logger.debug("WorkspaceNotSynchedException catched, the item id: " + folderId + " is not synched");
|
||||||
throw new ItemNotSynched("the item id: " + folderId + " is not synched");
|
throw new ItemNotSynched("the item id: " + folderId + " is not synched");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.debug("Error on getting configuration for the item id: " + folderId + ", returning null (means not synched)");
|
logger.debug("Error on getting configuration for the item id: " + folderId
|
||||||
|
+ ", returning null (means not synched)");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,6 +172,7 @@ public class SyncronizeWithThredds {
|
||||||
listCatalogues = workspaceThreddsSynchronize.getAvailableCatalogues();
|
listCatalogues = workspaceThreddsSynchronize.getAvailableCatalogues();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error on getting available Catalogues in the scope: " + targetScope, e);
|
logger.error("Error on getting available Catalogues in the scope: " + targetScope, e);
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
|
|
||||||
// resetting UMA token in the WS scope
|
// resetting UMA token in the WS scope
|
||||||
|
@ -192,152 +190,188 @@ public class SyncronizeWithThredds {
|
||||||
}
|
}
|
||||||
return listCatalogues;
|
return listCatalogues;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//NOT UPDATED
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do sync folder.
|
* Do sync folder.
|
||||||
*
|
*
|
||||||
* @param folderId the folder id
|
* @param folderId the folder id
|
||||||
* @param thConfig the th config
|
* @param thConfig the th config
|
||||||
* @param scope the scope
|
* @param httpRequest the http request
|
||||||
* @param userToken the user token
|
* @param user the user
|
||||||
* @return the th sync status
|
* @return the th sync status
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
public synchronized ThSyncStatus doSyncFolder(final String folderId, ThSynchFolderConfiguration thConfig, String scope, String userToken) throws Exception{
|
public synchronized ThSyncStatus doSyncFolder(final String folderId, ThSynchFolderConfiguration thConfig,
|
||||||
logger.debug("Perfoming doSynFolder on folderId: "+folderId);
|
HttpServletRequest httpRequest, GCubeUser user) throws Exception {
|
||||||
|
logger.debug("called doSynFolder for folderId: " + folderId);
|
||||||
|
|
||||||
boolean firstSync = false;
|
boolean firstSync = false;
|
||||||
|
String originalScope = null;
|
||||||
|
String originalToken = null;
|
||||||
|
String previousUmaToken = null;
|
||||||
|
|
||||||
|
if (thConfig == null) {
|
||||||
|
throw new Exception("A valid folder configuration must be provided to perform the synchronization");
|
||||||
|
}
|
||||||
|
|
||||||
|
String targetScope = thConfig.getTargetContext();
|
||||||
|
if (targetScope == null || targetScope.isEmpty()) {
|
||||||
|
throw new Exception("Error, the target scope is not valid!");
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.info("going to doSynFolder for folderId: " + folderId + ", target scope is: " + targetScope);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setContextParameters(scope, userToken);
|
// context switch for Uma token
|
||||||
|
previousUmaToken = changeContextForUMA(httpRequest, user, targetScope);
|
||||||
|
|
||||||
|
// context switch for gcube-token and scope
|
||||||
|
PortalContext pConfig = PortalContext.getConfiguration();
|
||||||
|
String wsScope = pConfig.getCurrentScope(httpRequest);
|
||||||
|
String wsUserToken = pConfig.getCurrentUserToken(wsScope, user.getUsername());
|
||||||
|
// Thread Local contexts
|
||||||
|
originalScope = wsScope;
|
||||||
|
originalToken = wsUserToken;
|
||||||
|
// getting token into target scope
|
||||||
|
String targetScopeUserToken = PortalContext.getConfiguration().getCurrentUserToken(targetScope,
|
||||||
|
user.getUsername());
|
||||||
|
setContextParameters(targetScope, targetScopeUserToken);
|
||||||
|
|
||||||
ThSyncFolderDescriptor folder = workspaceThreddsSynchronize.checkItemSynched(folderId);
|
ThSyncFolderDescriptor folder = workspaceThreddsSynchronize.checkItemSynched(folderId);
|
||||||
}catch (ItemNotSynched e) {
|
|
||||||
|
} catch (ItemNotSynched e) {
|
||||||
firstSync = true;
|
firstSync = true;
|
||||||
// TODO: handle exception
|
} catch (Exception e) {
|
||||||
}catch (Exception e) {
|
logger.error("Error on check item sync: ", e);
|
||||||
logger.error("Error on check item sync: ",e);
|
|
||||||
throw new Exception("Sorry an error occurred during folder publishing, refresh and try again");
|
throw new Exception("Sorry an error occurred during folder publishing, refresh and try again");
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try {
|
||||||
|
|
||||||
if(firstSync) {
|
if (firstSync) {
|
||||||
if(thConfig==null) {
|
logger.info("First sync setting the synchronized folder configuration: " + thConfig);
|
||||||
throw new Exception("A valid folder configuration must be provided to perform the synchronization");
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.info("First sync setting synchronized folder configuration: "+thConfig);
|
|
||||||
workspaceThreddsSynchronize.setSynchronizedFolder(thConfig, folderId);
|
workspaceThreddsSynchronize.setSynchronizedFolder(thConfig, folderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("Calling do sync on folder id: "+folderId);
|
logger.info("Calling do sync on folder id: " + folderId);
|
||||||
return workspaceThreddsSynchronize.doSync(folderId);
|
return workspaceThreddsSynchronize.doSync(folderId);
|
||||||
//SessionUtil.setTransferPublishingOnThredds(httpSession, status);
|
|
||||||
}catch (Exception e) {
|
|
||||||
logger.error("Error on do sync: ",e);
|
|
||||||
throw new Exception(e.getMessage() +", refresh and try again");
|
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Error on do sync: ", e);
|
||||||
|
throw new Exception(e.getMessage() + ", refresh and try again");
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
|
||||||
|
// resetting UMA token in the WS scope
|
||||||
|
setContextForUMA(previousUmaToken);
|
||||||
|
|
||||||
|
if (originalScope != null && originalScope.compareTo(targetScope) != 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * Gets the synched status from item property.
|
|
||||||
// *
|
|
||||||
// * @param folderId the folder id
|
|
||||||
// * @param scope the scope
|
|
||||||
// * @param username the username
|
|
||||||
// * @return the synched status from item property
|
|
||||||
// * @throws Exception the exception
|
|
||||||
// */
|
|
||||||
// public Sync_Status getSynchedStatusFromItemProperty(String folderId, String scope, String username) throws Exception{
|
|
||||||
//
|
|
||||||
// try {
|
|
||||||
// try {
|
|
||||||
// ScopeProvider.instance.set(scope);
|
|
||||||
// return workspaceThreddsSynchronize.getSynchedStatusFromItemProperty(folderId, username);
|
|
||||||
// }catch (ItemNotSynched e) {
|
|
||||||
// logger.info("The folder id: "+folderId +" is not synched returning null as "+Sync_Status.class.getSimpleName());
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }catch (Exception e) {
|
|
||||||
// logger.error("Error on getSynchedStatusFromItemProperty for id: "+folderId, e);
|
|
||||||
// throw new Exception("Sorry, an error occurred during read sync status from HL properties, try again later");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check item synched.
|
* Do un sync.
|
||||||
*
|
*
|
||||||
* @param folderId the folder id
|
* @param folderId the folder id
|
||||||
* @param scope the scope
|
* @param deleteRemoteContent the delete remote content
|
||||||
* @param userToken the user token
|
* @param thConfig the th config
|
||||||
* @return the th sync folder descriptor
|
* @param httpRequest the http request
|
||||||
* @throws ItemNotSynched the item not synched
|
* @param user the user
|
||||||
* @throws WorkspaceFolderLocked the workspace folder locked
|
* @return the boolean
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
public ThSyncFolderDescriptor checkItemSynched(String folderId, String scope, String userToken) throws ItemNotSynched, WorkspaceFolderLocked, Exception{
|
public Boolean doUnSync(String folderId, boolean deleteRemoteContent, ThSynchFolderConfiguration thConfig,
|
||||||
setContextParameters(scope, userToken);
|
HttpServletRequest httpRequest, GCubeUser user) throws Exception {
|
||||||
return workspaceThreddsSynchronize.checkItemSynched(folderId);
|
logger.debug("called doUnSync for folderId: " + folderId);
|
||||||
|
|
||||||
|
String originalScope = null;
|
||||||
|
String originalToken = null;
|
||||||
|
String previousUmaToken = null;
|
||||||
|
|
||||||
|
if (thConfig == null) {
|
||||||
|
throw new Exception("A valid folder configuration must be provided to perform the synchronization");
|
||||||
|
}
|
||||||
|
|
||||||
|
String targetScope = thConfig.getTargetContext();
|
||||||
|
if (targetScope == null || targetScope.isEmpty()) {
|
||||||
|
throw new Exception("Error, the target scope is not valid!");
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.info("going to doSynFolder for folderId: " + folderId + ", target scope is: " + targetScope);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// context switch for Uma token
|
||||||
|
previousUmaToken = changeContextForUMA(httpRequest, user, targetScope);
|
||||||
|
|
||||||
|
// context switch for gcube-token and scope
|
||||||
|
PortalContext pConfig = PortalContext.getConfiguration();
|
||||||
|
String wsScope = pConfig.getCurrentScope(httpRequest);
|
||||||
|
String wsUserToken = pConfig.getCurrentUserToken(wsScope, user.getUsername());
|
||||||
|
// Thread Local contexts
|
||||||
|
originalScope = wsScope;
|
||||||
|
originalToken = wsUserToken;
|
||||||
|
// getting token into target scope
|
||||||
|
String targetScopeUserToken = PortalContext.getConfiguration().getCurrentUserToken(targetScope,
|
||||||
|
user.getUsername());
|
||||||
|
setContextParameters(targetScope, targetScopeUserToken);
|
||||||
|
|
||||||
|
return workspaceThreddsSynchronize.doUnSync(folderId, deleteRemoteContent);
|
||||||
|
|
||||||
|
} catch (ItemNotSynched e) {
|
||||||
|
throw new Exception("The item with id: " + folderId + " is not synched");
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Error on check item sync: ", e);
|
||||||
|
throw new Exception("Sorry an error occurred during folder publishing, refresh and try again");
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
|
||||||
|
// resetting UMA token in the WS scope
|
||||||
|
setContextForUMA(previousUmaToken);
|
||||||
|
|
||||||
|
if (originalScope != null && originalScope.compareTo(targetScope) != 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOT UPDATED
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the sync status.
|
* Gets the sync status.
|
||||||
*
|
*
|
||||||
* @param itemId the item id
|
* @param itemId the item id
|
||||||
* @param scope the scope
|
* @param scope the scope
|
||||||
* @param userToken the user token
|
* @param userToken the user token
|
||||||
* @return the sync status
|
* @return the sync status
|
||||||
* @throws ItemNotSynched the item not synched
|
* @throws ItemNotSynched the item not synched
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
public ThSyncStatus monitorSyncStatus(String itemId, String scope, String userToken) throws ItemNotSynched, Exception{
|
public ThSyncStatus monitorSyncStatus(String itemId, String scope, String userToken)
|
||||||
|
throws ItemNotSynched, Exception {
|
||||||
|
|
||||||
setContextParameters(scope, userToken);
|
setContextParameters(scope, userToken);
|
||||||
return workspaceThreddsSynchronize.monitorSyncStatus(itemId);
|
return workspaceThreddsSynchronize.monitorSyncStatus(itemId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Do un sync.
|
|
||||||
*
|
|
||||||
* @param folderId the folder id
|
|
||||||
* @param deleteRemoteContent the delete remote content
|
|
||||||
* @param scope the scope
|
|
||||||
* @param userToken the user token
|
|
||||||
* @return the boolean
|
|
||||||
* @throws Exception the exception
|
|
||||||
*/
|
|
||||||
public Boolean doUnSync(String folderId, boolean deleteRemoteContent, String scope, String userToken) throws Exception {
|
|
||||||
|
|
||||||
setContextParameters(scope, userToken);
|
|
||||||
return workspaceThreddsSynchronize.doUnSync(folderId, deleteRemoteContent);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register callback for id.
|
* Register callback for id.
|
||||||
*
|
*
|
||||||
* @param folderId the folder id
|
* @param folderId the folder id
|
||||||
* @param scope the scope
|
* @param scope the scope
|
||||||
* @param userToken the user token
|
* @param userToken the user token
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
|
@ -346,5 +380,4 @@ public class SyncronizeWithThredds {
|
||||||
workspaceThreddsSynchronize.registerCallbackForId(folderId);
|
workspaceThreddsSynchronize.registerCallbackForId(folderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,8 +130,7 @@ public class ThreddsWorkspaceSyncServiceImpl extends RemoteServiceServlet implem
|
||||||
//UPDATED
|
//UPDATED
|
||||||
@Override
|
@Override
|
||||||
public WsThreddsSynchFolderDescriptor isItemSynched(String folderId) throws WorkspaceFolderLocked, Exception{
|
public WsThreddsSynchFolderDescriptor isItemSynched(String folderId) throws WorkspaceFolderLocked, Exception{
|
||||||
|
logger.debug("called isItemSynched for folderId: "+folderId);
|
||||||
logger.debug("Performing isItemSynched for foldeId: "+folderId);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
@ -146,7 +145,7 @@ public class ThreddsWorkspaceSyncServiceImpl extends RemoteServiceServlet implem
|
||||||
//the status is not set here (into isItemSynched implementation).
|
//the status is not set here (into isItemSynched implementation).
|
||||||
Sync_Status theStatus = null;
|
Sync_Status theStatus = null;
|
||||||
WsThreddsSynchFolderDescriptor toWsThreddFolder = BeanConverter.toWsThreddsFolderConfig(theConfig, theStatus);
|
WsThreddsSynchFolderDescriptor toWsThreddFolder = BeanConverter.toWsThreddsFolderConfig(theConfig, theStatus);
|
||||||
logger.debug("IsItemSynched for id: "+folderId +" returning: "+toWsThreddFolder);
|
logger.debug("isItemSynched for id: "+folderId +" returning: "+toWsThreddFolder);
|
||||||
return toWsThreddFolder;
|
return toWsThreddFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +153,7 @@ public class ThreddsWorkspaceSyncServiceImpl extends RemoteServiceServlet implem
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
} catch (ItemNotSynched e) {
|
} catch (ItemNotSynched e) {
|
||||||
logger.info("The folderId: "+folderId +" is not synched, returning null FolderDescriptor");
|
logger.info("The folderId: "+folderId +" is not synched, returning null for "+WsThreddsSynchFolderDescriptor.class.getSimpleName());
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
} catch (WorkspaceFolderLocked e) {
|
} catch (WorkspaceFolderLocked e) {
|
||||||
|
@ -168,23 +167,27 @@ public class ThreddsWorkspaceSyncServiceImpl extends RemoteServiceServlet implem
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do sync folder.
|
* Do sync folder.
|
||||||
*
|
*
|
||||||
* @param folderId the folder id
|
* @param folderId the folder id
|
||||||
* @param clientConfig the th config
|
* @param clientConfig the client config
|
||||||
* @return the th sync status
|
* @return the th sync status
|
||||||
* @throws Exception the exception
|
* @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)
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.gcube.portlets.widgets.wsthreddssync.client.rpc.
|
||||||
|
* ThreddsWorkspaceSyncService#doSyncFolder(java.lang.String,
|
||||||
|
* org.gcube.portlets.widgets.wsthreddssync.shared.
|
||||||
|
* WsThreddsSynchFolderDescriptor)
|
||||||
*/
|
*/
|
||||||
|
//UPDATED
|
||||||
@Override
|
@Override
|
||||||
public ThSyncStatus doSyncFolder(final String folderId, WsThreddsSynchFolderConfiguration clientConfig) throws Exception{
|
public ThSyncStatus doSyncFolder(final String folderId, WsThreddsSynchFolderConfiguration clientConfig)
|
||||||
logger.info("Performing doSyncFolder method on id: "+folderId +", config: "+clientConfig);
|
throws Exception {
|
||||||
|
logger.info("Performing doSyncFolder method on id: " + folderId + ", config: " + clientConfig);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
GCubeUser user = PortalContext.getConfiguration().getCurrentUser(this.getThreadLocalRequest());
|
GCubeUser user = PortalContext.getConfiguration().getCurrentUser(this.getThreadLocalRequest());
|
||||||
|
@ -195,20 +198,51 @@ public class ThreddsWorkspaceSyncServiceImpl extends RemoteServiceServlet implem
|
||||||
logger.debug("Creating server config " + config);
|
logger.debug("Creating server config " + config);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("Calling doSyncFolder on folderId: "+folderId +", config: "+config);
|
// logger.info("Calling doSyncFolder on folderId: "+folderId +", config: "+config);
|
||||||
String wsScope = PortalContext.getConfiguration().getCurrentScope(this.getThreadLocalRequest());
|
// String wsScope = PortalContext.getConfiguration().getCurrentScope(this.getThreadLocalRequest());
|
||||||
String wsUserToken = PortalContext.getConfiguration().getCurrentUserToken(wsScope, user.getUsername());
|
// String wsUserToken = PortalContext.getConfiguration().getCurrentUserToken(wsScope, user.getUsername());
|
||||||
|
|
||||||
ThSyncStatus status = getSyncService().doSyncFolder(folderId, config, wsScope, wsUserToken);
|
ThSyncStatus status = getSyncService().doSyncFolder(folderId, config, this.getThreadLocalRequest(), user);
|
||||||
logger.debug("Returning for folderId "+folderId+" the syncStatus: "+status);
|
logger.debug("Returning for folderId " + folderId + " the syncStatus: " + status);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Do sync Folder error: ",e);
|
logger.error("Do sync Folder error: ", e);
|
||||||
throw new Exception("Sorry, an error occurred during synchonization phase, try again later");
|
throw new Exception("Sorry, an error occurred during synchonization phase, try again later");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
*/
|
||||||
|
// Updated
|
||||||
|
@Override
|
||||||
|
public Boolean doUnSyncFolder(final String folderId) throws Exception {
|
||||||
|
logger.info("Performing unsync on folder id: " + folderId);
|
||||||
|
|
||||||
|
try {
|
||||||
|
GCubeUser user = PortalContext.getConfiguration().getCurrentUser(this.getThreadLocalRequest());
|
||||||
|
ThSyncFolderDescriptor foldeDesr = getSyncService().isItemSynched(folderId);
|
||||||
|
return getSyncService().doUnSync(folderId, true, foldeDesr.getConfiguration(),
|
||||||
|
this.getThreadLocalRequest(), user);
|
||||||
|
} 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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -257,11 +291,11 @@ public class ThreddsWorkspaceSyncServiceImpl extends RemoteServiceServlet implem
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<GcubeScope> getListOfDataManagerScopesForLoggedUser() throws Exception{
|
public List<GcubeScope> getListOfDataManagerScopesForLoggedUser() throws Exception{
|
||||||
logger.info("getListOfVREsForLoggedUser...: ");
|
logger.info("called getListOfVREsForLoggedUser...: ");
|
||||||
GCubeUser user = PortalContext.getConfiguration().getCurrentUser(this.getThreadLocalRequest());
|
GCubeUser user = PortalContext.getConfiguration().getCurrentUser(this.getThreadLocalRequest());
|
||||||
long userId = user.getUserId();
|
long userId = user.getUserId();
|
||||||
|
|
||||||
// Instanciate the manager
|
// Instantiate the manager
|
||||||
GroupManager groupManager = new LiferayGroupManager();
|
GroupManager groupManager = new LiferayGroupManager();
|
||||||
List<GcubeScope> listOfScopes = new ArrayList<GcubeScope>();
|
List<GcubeScope> listOfScopes = new ArrayList<GcubeScope>();
|
||||||
|
|
||||||
|
@ -318,12 +352,6 @@ public class ThreddsWorkspaceSyncServiceImpl extends RemoteServiceServlet implem
|
||||||
listOfScopes.add(gcubeScope);
|
listOfScopes.add(gcubeScope);
|
||||||
}
|
}
|
||||||
|
|
||||||
//ADDING THE ROOT SCOPE
|
|
||||||
/*String infraName = PortalContext.getConfiguration().getInfrastructureName();
|
|
||||||
GcubeScope gcubeRoot = new GcubeScope(infraName, "/"+infraName, GcubeScopeType.ROOT);
|
|
||||||
listOfScopes.add(gcubeRoot)*/
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (UserRetrievalFault | UserManagementSystemException
|
catch (UserRetrievalFault | UserManagementSystemException
|
||||||
| GroupRetrievalFault e) {
|
| GroupRetrievalFault e) {
|
||||||
|
@ -370,18 +398,18 @@ public class ThreddsWorkspaceSyncServiceImpl extends RemoteServiceServlet implem
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Register callback for id.
|
// * Register callback for id.
|
||||||
*
|
// *
|
||||||
* @param folderId the folder id
|
// * @param folderId the folder id
|
||||||
* @throws Exception the exception
|
// * @throws Exception the exception
|
||||||
*/
|
// */
|
||||||
public void registerCallbackForId(String folderId) throws Exception{
|
// private void registerCallbackForId(String folderId) throws Exception{
|
||||||
GCubeUser user = PortalContext.getConfiguration().getCurrentUser(this.getThreadLocalRequest());
|
// GCubeUser user = PortalContext.getConfiguration().getCurrentUser(this.getThreadLocalRequest());
|
||||||
String wsScope = PortalContext.getConfiguration().getCurrentScope(this.getThreadLocalRequest());
|
// String wsScope = PortalContext.getConfiguration().getCurrentScope(this.getThreadLocalRequest());
|
||||||
String wsUserToken = PortalContext.getConfiguration().getCurrentUserToken(wsScope, user.getUsername());
|
// String wsUserToken = PortalContext.getConfiguration().getCurrentUserToken(wsScope, user.getUsername());
|
||||||
getSyncService().registerCallbackForId(folderId, wsScope, wsUserToken);
|
// getSyncService().registerCallbackForId(folderId, wsScope, wsUserToken);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -403,34 +431,4 @@ public class ThreddsWorkspaceSyncServiceImpl extends RemoteServiceServlet implem
|
||||||
return getSyncService().monitorSyncStatus(folderId, wsScope, wsUserToken);
|
return getSyncService().monitorSyncStatus(folderId, wsScope, wsUserToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue