updated unsync

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portal/ws-synchronized-module-library@165049 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2018-03-14 13:24:17 +00:00
parent 4500fe31d5
commit e7f9ea14a4
1 changed files with 10 additions and 13 deletions

View File

@ -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;
}
}