Added WorkspaceFolderLocked Exception

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portal/ws-synchronized-module-library@164985 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2018-03-13 11:04:23 +00:00
parent c1816bf269
commit a3286ed02b
2 changed files with 50 additions and 3 deletions

View File

@ -0,0 +1,45 @@
package org.gcube.portal.wssynclibrary.shared;
/**
* The Class WorkspaceFolderLocked.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Mar 13, 2018
*/
public class WorkspaceFolderLocked extends Exception {
/**
*
*/
private static final long serialVersionUID = -778037901117579435L;
private String folderId;
/**
* Instantiates a new item not synched.
*/
public WorkspaceFolderLocked() {
super();
}
/**
* Instantiates a new item not synched.
*
* @param arg0 the arg 0
*/
public WorkspaceFolderLocked(String folderId, String arg0) {
super(arg0);
this.folderId = folderId;
}
/**
* @return the folderId
*/
public String getFolderId() {
return folderId;
}
}

View File

@ -13,6 +13,7 @@ import org.gcube.common.homelibrary.home.workspace.Workspace;
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder; import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
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.Status; import org.gcube.portal.wssynclibrary.shared.thredds.Status;
import org.gcube.portal.wssynclibrary.shared.thredds.Sync_Status; 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;
@ -89,7 +90,7 @@ public class WorkspaceThreddsSynchronize implements WorkspaceThreddsSynchronized
* @see org.gcube.portal.wssynclibrary.WorkspaceSynchronizedRepository#isItemSynchronized(java.lang.String) * @see org.gcube.portal.wssynclibrary.WorkspaceSynchronizedRepository#isItemSynchronized(java.lang.String)
*/ */
@Override @Override
public ThSyncFolderDescriptor checkItemSynched(String itemId) throws ItemNotSynched, Exception { public ThSyncFolderDescriptor checkItemSynched(String itemId) throws ItemNotSynched, WorkspaceFolderLocked, Exception {
logger.debug("Perfoming checkItemSynched for id: "+itemId); logger.debug("Perfoming checkItemSynched for id: "+itemId);
try { try {
// WHEN OPENING A FOLDER, INVOKE CHECK TO UPDATE SYNCH STATUS // WHEN OPENING A FOLDER, INVOKE CHECK TO UPDATE SYNCH STATUS
@ -108,12 +109,13 @@ public class WorkspaceThreddsSynchronize implements WorkspaceThreddsSynchronized
//engine.setSynchronizedFolder(config, folder.getId()); //engine.setSynchronizedFolder(config, folder.getId());
}catch(WorkspaceLockedException e) { }catch(WorkspaceLockedException e) {
logger.warn("Workspace locked, going to force unlock.."); logger.warn("Workspace locked, going to force unlock..");
engine.forceUnlock(itemId); 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 //System.out.println("Workspace locked, going to force unlock.."); // MAINLY FOR TEST PURPOSES, OR WHEN SOMETHIGN GOES WRONG.. USE CAUTIOUSLY
//engine.forceUnlock(folder.getId()); //engine.forceUnlock(folder.getId());
//TODO??? //TODO???
return null; //return null;
//??? //???
} catch (WorkspaceInteractionException | InternalException e) { } catch (WorkspaceInteractionException | InternalException e) {
logger.error("Error: ",e); logger.error("Error: ",e);