diff --git a/CHANGELOG.md b/CHANGELOG.md index aad5d7b..9694977 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm **Enhancements** - Added method update item [#26640] +- Added method deleteDataset [#26793] - Added method getListExtrasAsHashMap - D4Science model compliant + ## [v1.3.0] - 2023-02-06 **Enhancements** diff --git a/src/main/java/org/gcube/datacatalogue/utillibrary/server/DataCatalogue.java b/src/main/java/org/gcube/datacatalogue/utillibrary/server/DataCatalogue.java index cd9bd9c..426e369 100644 --- a/src/main/java/org/gcube/datacatalogue/utillibrary/server/DataCatalogue.java +++ b/src/main/java/org/gcube/datacatalogue/utillibrary/server/DataCatalogue.java @@ -332,28 +332,27 @@ public interface DataCatalogue { String description, String licenseId, List tags, Map> customFieldsMultiple, List resources, boolean setPublic, boolean setSearchable, boolean socialPost) throws Exception; - /** * Update ckan dataset multiple custom fields. * - * @param username the username - * @param title the title - * @param name the name - * @param organizationName the organization name - * @param author the author - * @param authorMail the author mail - * @param maintainer the maintainer - * @param maintainerMail the maintainer mail - * @param version the version - * @param description the description - * @param licenseId the license id - * @param tags the tags + * @param username the username + * @param title the title + * @param name the name + * @param organizationName the organization name + * @param author the author + * @param authorMail the author mail + * @param maintainer the maintainer + * @param maintainerMail the maintainer mail + * @param version the version + * @param description the description + * @param licenseId the license id + * @param tags the tags * @param customFieldsMultiple the custom fields multiple - * @param resources the resources - * @param setPublic the set public - * @param setSearchable the set searchable - * @param socialPost the social post + * @param resources the resources + * @param setPublic the set public + * @param setSearchable the set searchable + * @param socialPost the social post * @return the string * @throws Exception the exception */ @@ -374,19 +373,19 @@ public interface DataCatalogue { * @throws Exception the exception */ String addResourceToDataset(ResourceBean resourceBean, String organizationName, String username) throws Exception; - - + /** * Adds the resource. * - * @param resourceBean the resource bean - * @param datasetId the dataset id + * @param resourceBean the resource bean + * @param datasetId the dataset id * @param organizationName the organization name - * @param username the username + * @param username the username * @return the ckan resource * @throws Exception the exception */ - CkanResource addResource(ResourceBean resourceBean, String datasetId, String organizationName, String username) throws Exception; + CkanResource addResource(ResourceBean resourceBean, String datasetId, String organizationName, String username) + throws Exception; /** * Remove the resource with id resourceId from dataset in which it is. @@ -463,6 +462,15 @@ public interface DataCatalogue { */ String refreshDataset(String datasetName) throws Exception; + /** + * Delete dataset. + * + * @param datasetName the dataset name + * @return true, if successful + * @throws Exception the exception + */ + boolean deleteDataset(String datasetName) throws Exception; + /** * Patch a product with product id productId by using the couples in * customFieldsToChange. NOTE: only the specified custom fields will be changed. diff --git a/src/main/java/org/gcube/datacatalogue/utillibrary/server/DataCatalogueImpl.java b/src/main/java/org/gcube/datacatalogue/utillibrary/server/DataCatalogueImpl.java index df99bf0..4e33479 100644 --- a/src/main/java/org/gcube/datacatalogue/utillibrary/server/DataCatalogueImpl.java +++ b/src/main/java/org/gcube/datacatalogue/utillibrary/server/DataCatalogueImpl.java @@ -1320,6 +1320,29 @@ public class DataCatalogueImpl implements DataCatalogue { return null; } + /** + * Update ckan dataset multiple custom fields. + * + * @param username the username + * @param title the title + * @param name the name + * @param organizationName the organization name + * @param author the author + * @param authorMail the author mail + * @param maintainer the maintainer + * @param maintainerMail the maintainer mail + * @param version the version + * @param description the description + * @param licenseId the license id + * @param tags the tags + * @param customFieldsMultiple the custom fields multiple + * @param resources the resources + * @param setPublic the set public + * @param setSearchable the set searchable + * @param socialPost the social post + * @return the string + * @throws Exception the exception + */ @Override public String updateCkanDatasetMultipleCustomFields(String username, String title, String name, String organizationName, String author, String authorMail, String maintainer, String maintainerMail, @@ -1411,6 +1434,32 @@ public class DataCatalogueImpl implements DataCatalogue { return null; } + /** + * Delete dataset. + * + * @param datasetName the dataset name + * @return true, if successful + * @throws Exception the exception + */ + @Override + public boolean deleteDataset(String datasetName) throws Exception { + LOG.info("Called deleteDataset"); + + checkNotNull(datasetName); + boolean deleted = false; + try { + + gCatCaller.deleteItem(datasetName, true); + deleted = true; + LOG.info("Deleted the dataset: {} ", datasetName); + return deleted; + + } catch (Exception e) { + LOG.error("Error on deleting the dataset: ", e); + throw e; + } + } + /** * Patch fields for dataset. * @@ -1523,6 +1572,7 @@ public class DataCatalogueImpl implements DataCatalogue { * Adds the resource to dataset. * * @param resourceBean the resource bean + * @param datasetId the dataset id * @param organizationName the organization name * @param username the username * @return the string @@ -1537,6 +1587,15 @@ public class DataCatalogueImpl implements DataCatalogue { return createResource(resourceBean, organizationName, username); } + /** + * Creates the resource. + * + * @param resourceBean the resource bean + * @param organizationName the organization name + * @param username the username + * @return the ckan resource + * @throws Exception the exception + */ private CkanResource createResource(ResourceBean resourceBean, String organizationName, String username) throws Exception {