diff --git a/src/main/java/org/gcube/portal/wssynclibrary/DoCheckSyncItem.java b/src/main/java/org/gcube/portal/wssynclibrary/DoCheckSyncItem.java index 8585f16..6b4ee83 100644 --- a/src/main/java/org/gcube/portal/wssynclibrary/DoCheckSyncItem.java +++ b/src/main/java/org/gcube/portal/wssynclibrary/DoCheckSyncItem.java @@ -1,5 +1,5 @@ /* - * + * */ package org.gcube.portal.wssynclibrary; @@ -14,7 +14,7 @@ import org.gcube.portal.wssynclibrary.shared.ItemNotSynched; * @param the generic type */ public interface DoCheckSyncItem { - + /** * Check item synched. diff --git a/src/main/java/org/gcube/portal/wssynclibrary/DoSyncItem.java b/src/main/java/org/gcube/portal/wssynclibrary/DoSyncItem.java index 968c326..5e8caf7 100644 --- a/src/main/java/org/gcube/portal/wssynclibrary/DoSyncItem.java +++ b/src/main/java/org/gcube/portal/wssynclibrary/DoSyncItem.java @@ -22,8 +22,22 @@ public interface DoSyncItem { * @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 { * @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; diff --git a/src/main/java/org/gcube/portal/wssynclibrary/thredds/WorkspaceThreddsSynchronize.java b/src/main/java/org/gcube/portal/wssynclibrary/thredds/WorkspaceThreddsSynchronize.java index 24cfb5c..6540877 100644 --- a/src/main/java/org/gcube/portal/wssynclibrary/thredds/WorkspaceThreddsSynchronize.java +++ b/src/main/java/org/gcube/portal/wssynclibrary/thredds/WorkspaceThreddsSynchronize.java @@ -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); + } + } }