diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c3f65a..e0f4fbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [v1.3.0-SNAPSHOT] - 2023-02-06 + +**Enhancements** + +- [#23903] Catalogue Moderation: allow to send a message to the moderators +- [#23692] Changed interface 'approveItem' adding the parameter socialPost + ## [v1.2.0] - 2022-08-01 **Enhancements** diff --git a/pom.xml b/pom.xml index 7ef0fe7..6b3ac2f 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ org.gcube.datacatalogue catalogue-util-library - 1.2.0 + 1.3.0-SNAPSHOT Ckan utility library Utility library to retrieve users information, organizations information and so on from the ckan d4science datacatalogue diff --git a/src/main/java/org/gcube/datacatalogue/utillibrary/gcat/GCatCaller.java b/src/main/java/org/gcube/datacatalogue/utillibrary/gcat/GCatCaller.java index 6179bde..3fcd5eb 100644 --- a/src/main/java/org/gcube/datacatalogue/utillibrary/gcat/GCatCaller.java +++ b/src/main/java/org/gcube/datacatalogue/utillibrary/gcat/GCatCaller.java @@ -162,21 +162,41 @@ public class GCatCaller { } + /** + * Message item. Send a message to Moderators + * + * @param datasetName the dataset name + * @param moderatorMessage the moderator message + * @throws WebApplicationException the web application exception + * @throws MalformedURLException the malformed URL exception + */ + public void messageItem(String datasetName, String moderatorMessage) + throws WebApplicationException, MalformedURLException { + LOG.trace("messageItem called"); + LOG.info("Calling mesage item with name: " + datasetName + ", and msg: " + moderatorMessage); + + new Item().message(datasetName, moderatorMessage); + return; + } + /** * Approve item. * * @param datasetName the dataset name * @param moderatorMessage the moderator message + * @param sendSocialPost the send social post. If 'true` sends the social post * @return the string * @throws WebApplicationException the web application exception * @throws MalformedURLException the malformed URL exception */ - public String approveItem(String datasetName, String moderatorMessage) + public String approveItem(String datasetName, String moderatorMessage, Boolean sendSocialPost) throws WebApplicationException, MalformedURLException { LOG.trace("approveItem called"); - LOG.info("Calling approve item with name: " + datasetName + ", and msg: " + moderatorMessage); + LOG.info("Calling approve item with name: " + datasetName + ", sendSocialPost: " + sendSocialPost + + ", msg: " + moderatorMessage); + + return new Item().approve(datasetName, moderatorMessage, sendSocialPost); - return new Item().approve(datasetName, moderatorMessage); } @@ -239,8 +259,8 @@ public class GCatCaller { LOG.info("called getListItemsForCMStatus called with [status: " + status + "], [limit: " + limit + "], [offset: " + offset + "], [filters: " + filters + "]"); - Map queryParams = GCatCallerUtil.genericQueryBuilderFor(status, limit, offset, false, allFields, filters, - sortForField); + Map queryParams = GCatCallerUtil.genericQueryBuilderFor(status, limit, offset, false, allFields, + filters, sortForField); return getListItemsForQuery(queryParams); } @@ -249,7 +269,7 @@ public class GCatCaller { * Count list items for CM status. * * @param status the status - * @param filters + * @param filters the filters * @return the number of items * @throws WebServiceException the web service exception * @throws MalformedURLException the malformed URL exception @@ -312,7 +332,7 @@ public class GCatCaller { * * @param reload the reload * @return the configuration - * @throws MalformedURLException + * @throws MalformedURLException the malformed URL exception */ public GCatCatalogueConfiguration getConfiguration(boolean reload) throws MalformedURLException { LOG.trace("getConfiguration called"); @@ -337,6 +357,13 @@ public class GCatCaller { return catalogueConfiguration; } + /** + * Offset to page number. + * + * @param limit the limit + * @param offset the offset + * @return the int + */ private static int offsetToPageNumber(int limit, int offset) { int pageNumber = offset; diff --git a/src/main/java/org/gcube/datacatalogue/utillibrary/server/cms/CatalogueContentModeratorSystem.java b/src/main/java/org/gcube/datacatalogue/utillibrary/server/cms/CatalogueContentModeratorSystem.java index 0af1cd8..044a407 100644 --- a/src/main/java/org/gcube/datacatalogue/utillibrary/server/cms/CatalogueContentModeratorSystem.java +++ b/src/main/java/org/gcube/datacatalogue/utillibrary/server/cms/CatalogueContentModeratorSystem.java @@ -82,11 +82,20 @@ public interface CatalogueContentModeratorSystem { * * @param itemName the item name * @param moderatorMessage the moderator message + * @param sendSocialPost the send social post. If 'true` sends the social post * @throws WebApplicationException the web application exception * @throws MalformedURLException the malformed URL exception */ - void approveItem(String itemName, String moderatorMessage) throws WebApplicationException, MalformedURLException; - + void approveItem(String itemName, String moderatorMessage, Boolean sendSocialPost) throws WebApplicationException, MalformedURLException; + /** + * Message item. + * + * @param datasetName the dataset name + * @param moderatorMessage the moderator message + * @throws WebServiceException the web service exception + * @throws MalformedURLException the malformed URL exception + */ + void messageItem(String datasetName, String moderatorMessage) throws WebServiceException, MalformedURLException; } diff --git a/src/main/java/org/gcube/datacatalogue/utillibrary/server/cms/DataCatalogueCMSImpl.java b/src/main/java/org/gcube/datacatalogue/utillibrary/server/cms/DataCatalogueCMSImpl.java index 40aba2a..10eef77 100644 --- a/src/main/java/org/gcube/datacatalogue/utillibrary/server/cms/DataCatalogueCMSImpl.java +++ b/src/main/java/org/gcube/datacatalogue/utillibrary/server/cms/DataCatalogueCMSImpl.java @@ -50,10 +50,11 @@ public class DataCatalogueCMSImpl implements CatalogueContentModeratorSystem { } /** - * Checks if is Moderation is enabled in the working scope + * Checks if is Moderation is enabled in the working scope. * + * @param reloadConfig the reload config * @return true, if is content moderator enabled - * @throws MalformedURLException + * @throws MalformedURLException the malformed URL exception */ @Override public boolean isModerationEnabled(boolean reloadConfig) throws MalformedURLException { @@ -65,13 +66,30 @@ public class DataCatalogueCMSImpl implements CatalogueContentModeratorSystem { * * @param datasetName the dataset name * @param moderatorMessage the moderator message + * @param sendSocialPost the send social post. If 'true` sends the social post * @throws WebApplicationException the web application exception * @throws MalformedURLException the malformed URL exception */ @Override - public void approveItem(String datasetName, String moderatorMessage) + public void approveItem(String datasetName, String moderatorMessage, Boolean sendSocialPost) throws WebApplicationException, MalformedURLException { - gCatCaller.approveItem(datasetName, moderatorMessage); + gCatCaller.approveItem(datasetName, moderatorMessage, sendSocialPost); + + } + + + /** + * Message item. + * + * @param datasetName the dataset name + * @param moderatorMessage the moderator message + * @throws WebServiceException the web service exception + * @throws MalformedURLException the malformed URL exception + */ + @Override + public void messageItem(String datasetName, String moderatorMessage) + throws WebServiceException, MalformedURLException { + gCatCaller.messageItem(datasetName, moderatorMessage); }