Added doUnSync method

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portal/ws-synchronized-module-library@165013 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2018-03-13 15:50:59 +00:00
parent 003642f673
commit 4500fe31d5
3 changed files with 47 additions and 28 deletions

View File

@ -1,5 +1,5 @@
/*
*
*
*/
package org.gcube.portal.wssynclibrary;
@ -14,7 +14,7 @@ import org.gcube.portal.wssynclibrary.shared.ItemNotSynched;
* @param <T> the generic type
*/
public interface DoCheckSyncItem<T> {
/**
* Check item synched.

View File

@ -22,8 +22,22 @@ public interface DoSyncItem<O> {
* @throws Exception the exception
*/
O doSync(String itemId) throws ItemNotSynched, Exception;
/**
* Do un sync.
*
* @param itemId the item id
* @param deleteRemoteContent the delete remote content
* @return the boolean
* @throws ItemNotSynched the item not synched
* @throws Exception the exception
*/
Boolean doUnSync(String itemId, boolean deleteRemoteContent)
throws ItemNotSynched, Exception;
/**
* Gets the sync status.
*
@ -33,35 +47,36 @@ public interface DoSyncItem<O> {
* @throws Exception the exception
*/
O monitorSyncStatus(String itemId) throws ItemNotSynched, Exception;
/**
* Removes the sync.
*
* @param itemId the item id
* @return true, if successful
* @throws ItemNotSynched the item not synched
* @throws Exception the exception
*/
Boolean removeSync(String itemId) throws ItemNotSynched, Exception;
/**
* Stop sync.
*
* @param itemId the item id
* @return true, if successful
* @throws ItemNotSynched the item not synched
* @throws Exception the exception
*/
Boolean stopSync(String itemId) throws ItemNotSynched, Exception;
/**
* Register callback for id.
*
* @param itemId the item id
* @throws ItemNotSynched the item not synched
* @throws Exception the exception
*/
void registerCallbackForId(String itemId) throws Exception;

View File

@ -83,9 +83,6 @@ public class WorkspaceThreddsSynchronize implements WorkspaceThreddsSynchronized
return instance;
}
//setSynchronizedFolder(config, folder.getId());
/* (non-Javadoc)
* @see org.gcube.portal.wssynclibrary.WorkspaceSynchronizedRepository#isItemSynchronized(java.lang.String)
*/
@ -111,12 +108,6 @@ public class WorkspaceThreddsSynchronize implements WorkspaceThreddsSynchronized
logger.warn("Workspace locked, going to force unlock..");
throw new WorkspaceFolderLocked(itemId, "The folder id: "+itemId +" is currently locked. Another sync process is in progress");
//engine.forceUnlock(itemId);
//System.out.println("Workspace locked, going to force unlock.."); // MAINLY FOR TEST PURPOSES, OR WHEN SOMETHIGN GOES WRONG.. USE CAUTIOUSLY
//engine.forceUnlock(folder.getId());
//TODO???
//return null;
//???
} catch (WorkspaceInteractionException | InternalException e) {
logger.error("Error: ",e);
if(e instanceof WorkspaceInteractionException)
@ -171,7 +162,6 @@ public class WorkspaceThreddsSynchronize implements WorkspaceThreddsSynchronized
try {
// INVOKE SYNCHRONIZATION ON FOLDER
ProcessDescriptor descriptor = engine.doSync(itemId);
ThSyncStatus synStatus = mapCallBack.get(itemId);
if(synStatus==null) {
@ -196,8 +186,6 @@ public class WorkspaceThreddsSynchronize implements WorkspaceThreddsSynchronized
throw new Exception("Sorry, an error occurred server side during syncronization for the itemId: "+itemId);
}
}
@ -207,13 +195,10 @@ public class WorkspaceThreddsSynchronize implements WorkspaceThreddsSynchronized
@Override
public ThSyncStatus monitorSyncStatus(String itemId) throws ItemNotSynched, Exception {
try {
ThSyncStatus synStatus = mapCallBack.get(itemId);
if(synStatus==null) {
try{
registerCallbackForId(itemId);
@ -318,7 +303,7 @@ public class WorkspaceThreddsSynchronize implements WorkspaceThreddsSynchronized
public Sync_Status getSynchedStatusFromItemProperty(String folderId, String username) throws ItemNotSynched, Exception{
if(folderId==null)
throw new Exception("Invalid pareter itemId is null");
throw new Exception("Invalid parameter itemId is null");
String scope = ScopeProvider.instance.get();
if(scope == null || scope.isEmpty())
@ -444,4 +429,23 @@ public class WorkspaceThreddsSynchronize implements WorkspaceThreddsSynchronized
logger.debug("Returning sorted Catalogue list with: "+listCtlgs.size() +" item/s");
return listCtlgs;
}
/* (non-Javadoc)
* @see org.gcube.portal.wssynclibrary.DoSyncItem#doUnSync(java.lang.String)
*/
@Override
public Boolean doUnSync(String itemId, boolean deleteRemoteContent) throws Exception {
if(itemId==null)
throw new Exception("Invalid parameter: itemId is null");
try{
engine.unsetSynchronizedFolder(itemId, deleteRemoteContent);
return true;
}catch(Exception e){
logger.error("Unset Syncronized folder exception: ",e);
throw new Exception("An error occurred on deleting configuration to the item id: "+itemId, e);
}
}
}