diff --git a/src/main/java/org/gcube/portal/wssynclibrary/DoCheckSyncItem.java b/src/main/java/org/gcube/portal/wssynclibrary/DoCheckSyncItem.java index 8b56022..b202d42 100644 --- a/src/main/java/org/gcube/portal/wssynclibrary/DoCheckSyncItem.java +++ b/src/main/java/org/gcube/portal/wssynclibrary/DoCheckSyncItem.java @@ -7,37 +7,42 @@ import org.gcube.portal.wssynclibrary.shared.ItemNotSynched; import org.gcube.usecases.ws.thredds.faults.WorkspaceInteractionException; import org.gcube.usecases.ws.thredds.faults.WorkspaceNotSynchedException; -// TODO: Auto-generated Javadoc /** * The Interface DoCheckSyncItem. * - * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it - * Feb 8, 2018 + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Feb 8, 2018 * @param the generic type */ public interface DoCheckSyncItem { - /** * Check item synched. * * @param itemId the item id * @return the t * @throws ItemNotSynched the item not synched - * @throws Exception the exception + * @throws Exception the exception */ T checkItemSynched(String itemId) throws ItemNotSynched, Exception; - - + /** * Gets the configuration. * * @param itemId the item id * @return the configuration * @throws WorkspaceInteractionException the workspace interaction exception - * @throws WorkspaceNotSynchedException the workspace not synched exception - * @throws Exception + * @throws WorkspaceNotSynchedException the workspace not synched exception + * @throws Exception the exception */ T getConfiguration(String itemId) throws WorkspaceInteractionException, WorkspaceNotSynchedException, Exception; + /** + * Checks if is item synched. + * + * @param itemId the item id + * @return true, if is item synched + * @throws Exception the exception + */ + boolean isItemSynched(String itemId) throws Exception; + } diff --git a/src/main/java/org/gcube/portal/wssynclibrary/shared/thredds/ThSynchFolderConfiguration.java b/src/main/java/org/gcube/portal/wssynclibrary/shared/thredds/ThSynchFolderConfiguration.java index ccf4d5f..71b18a6 100644 --- a/src/main/java/org/gcube/portal/wssynclibrary/shared/thredds/ThSynchFolderConfiguration.java +++ b/src/main/java/org/gcube/portal/wssynclibrary/shared/thredds/ThSynchFolderConfiguration.java @@ -2,7 +2,6 @@ package org.gcube.portal.wssynclibrary.shared.thredds; import java.io.Serializable; -// TODO: Auto-generated Javadoc /** * The Class ThSynchFolderConfiguration. * @@ -33,7 +32,7 @@ public class ThSynchFolderConfiguration implements Serializable { * Instantiates a new th synch folder configuration. */ public ThSynchFolderConfiguration() { - // TODO Auto-generated constructor stub + } /** @@ -186,7 +185,4 @@ public class ThSynchFolderConfiguration implements Serializable { return builder.toString(); } - - - } 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 0950e61..9f6c488 100644 --- a/src/main/java/org/gcube/portal/wssynclibrary/thredds/WorkspaceThreddsSynchronize.java +++ b/src/main/java/org/gcube/portal/wssynclibrary/thredds/WorkspaceThreddsSynchronize.java @@ -31,6 +31,7 @@ import org.gcube.usecases.ws.thredds.model.gui.CatalogBean; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +// TODO: Auto-generated Javadoc /** * The Class WorkspaceThreddsSynchronize. * @@ -364,7 +365,34 @@ public class WorkspaceThreddsSynchronize ThSynchFolderConfiguration toFolderConfig = ThreddsConverter.toThSynchFolderConfiguration .apply(syncFolderConfig); - return new ThSyncFolderDescriptor(itemId, null, toFolderConfig, false, null,null); + return new ThSyncFolderDescriptor(itemId, null, toFolderConfig, false, null, null); + + } + + /** + * Checks if is item synched. + * + * @param itemId the item id + * @return true, if is item synched + * @throws Exception the exception + */ + @Override + public boolean isItemSynched(String itemId) throws Exception { + + ThSyncFolderDescriptor config = null; + try { + config = getConfiguration(itemId); + } catch (WorkspaceNotSynchedException e) { + logger.debug("WorkspaceNotSynchedException catched, the item id: " + itemId + " is not synched"); + } catch (Exception e) { + logger.debug("Error on getting configuration for the item id: " + itemId + + ", returning null (means not synched)"); + } + + if (config != null) + return true; + + return false; }