added method isItemSynched

This commit is contained in:
Francesco Mangiacrapa 2021-05-13 15:24:55 +02:00
parent 462f5787fa
commit e4614f70ef
3 changed files with 44 additions and 15 deletions

View File

@ -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.WorkspaceInteractionException;
import org.gcube.usecases.ws.thredds.faults.WorkspaceNotSynchedException; import org.gcube.usecases.ws.thredds.faults.WorkspaceNotSynchedException;
// TODO: Auto-generated Javadoc
/** /**
* The Interface DoCheckSyncItem. * The Interface DoCheckSyncItem.
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Feb 8, 2018
* Feb 8, 2018
* @param <T> the generic type * @param <T> the generic type
*/ */
public interface DoCheckSyncItem<T> { public interface DoCheckSyncItem<T> {
/** /**
* Check item synched. * Check item synched.
* *
* @param itemId the item id * @param itemId the item id
* @return the t * @return the t
* @throws ItemNotSynched the item not synched * @throws ItemNotSynched the item not synched
* @throws Exception the exception * @throws Exception the exception
*/ */
T checkItemSynched(String itemId) throws ItemNotSynched, Exception; T checkItemSynched(String itemId) throws ItemNotSynched, Exception;
/** /**
* Gets the configuration. * Gets the configuration.
* *
* @param itemId the item id * @param itemId the item id
* @return the configuration * @return the configuration
* @throws WorkspaceInteractionException the workspace interaction exception * @throws WorkspaceInteractionException the workspace interaction exception
* @throws WorkspaceNotSynchedException the workspace not synched exception * @throws WorkspaceNotSynchedException the workspace not synched exception
* @throws Exception * @throws Exception the exception
*/ */
T getConfiguration(String itemId) throws WorkspaceInteractionException, WorkspaceNotSynchedException, 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;
} }

View File

@ -2,7 +2,6 @@ package org.gcube.portal.wssynclibrary.shared.thredds;
import java.io.Serializable; import java.io.Serializable;
// TODO: Auto-generated Javadoc
/** /**
* The Class ThSynchFolderConfiguration. * The Class ThSynchFolderConfiguration.
* *
@ -33,7 +32,7 @@ public class ThSynchFolderConfiguration implements Serializable {
* Instantiates a new th synch folder configuration. * Instantiates a new th synch folder configuration.
*/ */
public ThSynchFolderConfiguration() { public ThSynchFolderConfiguration() {
// TODO Auto-generated constructor stub
} }
/** /**
@ -186,7 +185,4 @@ public class ThSynchFolderConfiguration implements Serializable {
return builder.toString(); return builder.toString();
} }
} }

View File

@ -31,6 +31,7 @@ import org.gcube.usecases.ws.thredds.model.gui.CatalogBean;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
// TODO: Auto-generated Javadoc
/** /**
* The Class WorkspaceThreddsSynchronize. * The Class WorkspaceThreddsSynchronize.
* *
@ -364,7 +365,34 @@ public class WorkspaceThreddsSynchronize
ThSynchFolderConfiguration toFolderConfig = ThreddsConverter.toThSynchFolderConfiguration ThSynchFolderConfiguration toFolderConfig = ThreddsConverter.toThSynchFolderConfiguration
.apply(syncFolderConfig); .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;
} }