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.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 <T> the generic type
*/
public interface DoCheckSyncItem<T> {
/**
* 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;
}

View File

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

View File

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