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:
parent
003642f673
commit
4500fe31d5
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.gcube.portal.wssynclibrary;
|
package org.gcube.portal.wssynclibrary;
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ import org.gcube.portal.wssynclibrary.shared.ItemNotSynched;
|
||||||
* @param <T> the generic type
|
* @param <T> the generic type
|
||||||
*/
|
*/
|
||||||
public interface DoCheckSyncItem<T> {
|
public interface DoCheckSyncItem<T> {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check item synched.
|
* Check item synched.
|
||||||
|
|
|
@ -22,8 +22,22 @@ public interface DoSyncItem<O> {
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
O doSync(String itemId) throws ItemNotSynched, 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.
|
* Gets the sync status.
|
||||||
*
|
*
|
||||||
|
@ -33,35 +47,36 @@ public interface DoSyncItem<O> {
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
O monitorSyncStatus(String itemId) throws ItemNotSynched, Exception;
|
O monitorSyncStatus(String itemId) throws ItemNotSynched, Exception;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the sync.
|
* Removes the sync.
|
||||||
*
|
*
|
||||||
* @param itemId the item id
|
* @param itemId the item id
|
||||||
* @return true, if successful
|
* @return true, if successful
|
||||||
|
* @throws ItemNotSynched the item not synched
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
Boolean removeSync(String itemId) throws ItemNotSynched, Exception;
|
Boolean removeSync(String itemId) throws ItemNotSynched, Exception;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop sync.
|
* Stop sync.
|
||||||
*
|
*
|
||||||
* @param itemId the item id
|
* @param itemId the item id
|
||||||
* @return true, if successful
|
* @return true, if successful
|
||||||
|
* @throws ItemNotSynched the item not synched
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
Boolean stopSync(String itemId) throws ItemNotSynched, Exception;
|
Boolean stopSync(String itemId) throws ItemNotSynched, Exception;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register callback for id.
|
* Register callback for id.
|
||||||
*
|
*
|
||||||
* @param itemId the item id
|
* @param itemId the item id
|
||||||
* @throws ItemNotSynched the item not synched
|
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
void registerCallbackForId(String itemId) throws Exception;
|
void registerCallbackForId(String itemId) throws Exception;
|
||||||
|
|
|
@ -83,9 +83,6 @@ public class WorkspaceThreddsSynchronize implements WorkspaceThreddsSynchronized
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
//setSynchronizedFolder(config, folder.getId());
|
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.gcube.portal.wssynclibrary.WorkspaceSynchronizedRepository#isItemSynchronized(java.lang.String)
|
* @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..");
|
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");
|
throw new WorkspaceFolderLocked(itemId, "The folder id: "+itemId +" is currently locked. Another sync process is in progress");
|
||||||
//engine.forceUnlock(itemId);
|
//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) {
|
} catch (WorkspaceInteractionException | InternalException e) {
|
||||||
logger.error("Error: ",e);
|
logger.error("Error: ",e);
|
||||||
if(e instanceof WorkspaceInteractionException)
|
if(e instanceof WorkspaceInteractionException)
|
||||||
|
@ -171,7 +162,6 @@ public class WorkspaceThreddsSynchronize implements WorkspaceThreddsSynchronized
|
||||||
try {
|
try {
|
||||||
// INVOKE SYNCHRONIZATION ON FOLDER
|
// INVOKE SYNCHRONIZATION ON FOLDER
|
||||||
ProcessDescriptor descriptor = engine.doSync(itemId);
|
ProcessDescriptor descriptor = engine.doSync(itemId);
|
||||||
|
|
||||||
ThSyncStatus synStatus = mapCallBack.get(itemId);
|
ThSyncStatus synStatus = mapCallBack.get(itemId);
|
||||||
|
|
||||||
if(synStatus==null) {
|
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);
|
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
|
@Override
|
||||||
public ThSyncStatus monitorSyncStatus(String itemId) throws ItemNotSynched, Exception {
|
public ThSyncStatus monitorSyncStatus(String itemId) throws ItemNotSynched, Exception {
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
ThSyncStatus synStatus = mapCallBack.get(itemId);
|
ThSyncStatus synStatus = mapCallBack.get(itemId);
|
||||||
|
|
||||||
if(synStatus==null) {
|
if(synStatus==null) {
|
||||||
|
|
||||||
try{
|
try{
|
||||||
|
|
||||||
registerCallbackForId(itemId);
|
registerCallbackForId(itemId);
|
||||||
|
@ -318,7 +303,7 @@ public class WorkspaceThreddsSynchronize implements WorkspaceThreddsSynchronized
|
||||||
public Sync_Status getSynchedStatusFromItemProperty(String folderId, String username) throws ItemNotSynched, Exception{
|
public Sync_Status getSynchedStatusFromItemProperty(String folderId, String username) throws ItemNotSynched, Exception{
|
||||||
|
|
||||||
if(folderId==null)
|
if(folderId==null)
|
||||||
throw new Exception("Invalid pareter itemId is null");
|
throw new Exception("Invalid parameter itemId is null");
|
||||||
|
|
||||||
String scope = ScopeProvider.instance.get();
|
String scope = ScopeProvider.instance.get();
|
||||||
if(scope == null || scope.isEmpty())
|
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");
|
logger.debug("Returning sorted Catalogue list with: "+listCtlgs.size() +" item/s");
|
||||||
return listCtlgs;
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue