Updated monitorSyncStatus adding ProcessNotFoundException

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portal/ws-synchronized-module-library@165001 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2018-03-13 14:10:41 +00:00
parent a3286ed02b
commit 003642f673
1 changed files with 23 additions and 12 deletions

View File

@ -209,16 +209,27 @@ public class WorkspaceThreddsSynchronize implements WorkspaceThreddsSynchronized
try {
//ThSyncFolderDescriptor descr = checkItemSynched(itemId);
ThSyncStatus synStatus = mapCallBack.get(itemId);
if(synStatus==null) {
logger.info("The sync is not on-going...,returning process status null");
// String err = "The item id: "+itemId +" is not cached as synched";
// throw new ItemNotSynched(err);
return new ThSyncStatus(null, null);
try{
registerCallbackForId(itemId);
ProcessDescriptor descriptor = engine.getProcessDescriptorByFolderId(itemId);
ProcessStatus status = engine.getProcessStatusByFolderId(itemId);
updateMapCallback(itemId, status, descriptor);
ThSyncStatus thSyncStatus = mapCallBack.get(itemId);
if(thSyncStatus==null)
throw new Exception("No sync status found for item id: "+itemId);
return thSyncStatus;
}catch(ProcessNotFoundException e){
throw new Exception("Monitor is not available here. The sync process is in progress on another machine");
}
}
if(synStatus.getProcessStatus()!=null) {
@ -233,11 +244,8 @@ public class WorkspaceThreddsSynchronize implements WorkspaceThreddsSynchronized
logger.trace("MonitorSyncStatus for item: "+itemId+" returning: "+synStatus);
return synStatus;
// } catch (ItemNotSynched e) {
// String err = "The item id: "+itemId +" is not synched repository side";
// throw new ItemNotSynched(err);
} catch (Exception e) {
throw new Exception("Sorry, an error occurred during syncronization for itemId: "+itemId);
throw new Exception("Sorry, an error occurred during getting sync status for itemId: "+itemId, e);
}
}
@ -356,7 +364,7 @@ public class WorkspaceThreddsSynchronize implements WorkspaceThreddsSynchronized
* @throws Exception the exception
*/
@Override
public void registerCallbackForId(String itemId) throws Exception{
public void registerCallbackForId(String itemId) throws ProcessNotFoundException, Exception{
try {
@ -377,8 +385,11 @@ public class WorkspaceThreddsSynchronize implements WorkspaceThreddsSynchronized
logger.debug("Registering callback on itemId: "+itemId);
engine.registerCallBack(itemId, callback);
}catch (ProcessNotFoundException e) {
logger.error("Register callback for id: "+itemId+" threw ProcessNotFoundException: ", e);
throw e;
}catch (Exception e) {
logger.error("Register callback exception: ",e);
throw new Exception("No Process found for item id: "+itemId+ ", refresh an try again");
throw new Exception("An error occurred on registering callback for: "+itemId, e);
}
}