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 6540877..92cbdab 100644 --- a/src/main/java/org/gcube/portal/wssynclibrary/thredds/WorkspaceThreddsSynchronize.java +++ b/src/main/java/org/gcube/portal/wssynclibrary/thredds/WorkspaceThreddsSynchronize.java @@ -10,7 +10,7 @@ import java.util.Set; import org.gcube.common.homelibrary.home.HomeLibrary; import org.gcube.common.homelibrary.home.workspace.Properties; import org.gcube.common.homelibrary.home.workspace.Workspace; -import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder; +import org.gcube.common.homelibrary.home.workspace.WorkspaceItem; import org.gcube.common.scope.api.ScopeProvider; import org.gcube.portal.wssynclibrary.shared.ItemNotSynched; import org.gcube.portal.wssynclibrary.shared.WorkspaceFolderLocked; @@ -300,43 +300,40 @@ public class WorkspaceThreddsSynchronize implements WorkspaceThreddsSynchronized * @throws ItemNotSynched the item not synched * @throws Exception the exception */ - public Sync_Status getSynchedStatusFromItemProperty(String folderId, String username) throws ItemNotSynched, Exception{ + public Sync_Status getSynchedStatusFromItemProperty(String itemId, String username) throws ItemNotSynched, Exception{ - if(folderId==null) + if(itemId==null) throw new Exception("Invalid parameter itemId is null"); String scope = ScopeProvider.instance.get(); if(scope == null || scope.isEmpty()) throw new Exception("You must set a valid scope into ScopeProvider instance"); - WorkspaceFolder folder = null; + WorkspaceItem wsItem = null; try { logger.debug("Scope provider instancied at: "+scope); Workspace workspace = HomeLibrary.getUserWorkspace(username); - folder = (WorkspaceFolder) workspace.getItem(folderId); + wsItem = workspace.getItem(itemId); }catch (Exception e) { - logger.error("Error HL side: "+folderId, e); - throw new Exception("Sorry an error occurred getting HL item for id: "+folderId); + logger.error("Error HL side: "+itemId, e); + throw new Exception("Sorry, an error occurred getting synched status for item id: "+itemId, e); } - if(folder==null) - throw new Exception("Sorry an error occurred getting HL item for id: "+folderId); - - Properties properties = folder.getProperties(); + Properties properties = wsItem.getProperties(); if(properties==null || properties.getProperties()==null || properties.getProperties().size()==0) { throw new ItemNotSynched("No properties to read"); } String wsSyncStatus = properties.getProperties().get(WS_SYNCH_SYNCH_STATUS); - logger.info("Folder id: "+folder.getId()+" has current: "+WS_SYNCH_SYNCH_STATUS +" value at: "+wsSyncStatus); + logger.info("Item id: "+itemId+" has current: "+WS_SYNCH_SYNCH_STATUS +" value at: "+wsSyncStatus); try { return Sync_Status.valueOf(wsSyncStatus); }catch (Exception e) { - logger.warn(wsSyncStatus + "is not value of "+Sync_Status.values()); + logger.warn(wsSyncStatus + " is not value of "+Sync_Status.values()+", returning null"); return null; } }