From fa3da33e5a31a7573e280da4a76cbfde7653a8f2 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 25 Jan 2023 16:25:51 +0100 Subject: [PATCH] in progress #23903 --- CHANGELOG.md | 6 +++++ pom.xml | 2 +- .../CkanContentModeratorCheckConfigs.java | 5 +++- .../client/CkanContentModeratorService.java | 25 +++++++++---------- .../CkanContentModeratorServiceAsync.java | 16 +++++++++++- .../client/ui/DoActionCMSView.java | 3 ++- .../client/ui/HomeView.java | 8 +++--- .../CkanContentModeratorServiceImpl.java | 13 +++++++--- 8 files changed, 54 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5cc512e..37fd7e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ 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.2.0-SNAPSHOT] - 2023-01-19 + +#### Enhancements + +- [#23903] Catalogue Moderation: allow to send a message to the moderators on reject to pending operation + ## [v1.1.1] - 2022-10-27 #### Fixing diff --git a/pom.xml b/pom.xml index e61733b..64444da 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.gcube.portlets.widgets ckan-content-moderator-widget jar - 1.1.1 + 1.2.0-SNAPSHOT gCube Ckan Content Moderator Widget diff --git a/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/CkanContentModeratorCheckConfigs.java b/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/CkanContentModeratorCheckConfigs.java index 90b677d..c4a5b51 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/CkanContentModeratorCheckConfigs.java +++ b/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/CkanContentModeratorCheckConfigs.java @@ -106,7 +106,10 @@ public class CkanContentModeratorCheckConfigs { attemptLC++; GWT.log("checking configuration loaded, attempt " + attemptLC + " of " + MAX_RETRY_ON_LOADING_CONFIG); - boolean configsLoaded = getConfigurationLoaded() == CONFIGURATION_EXPECTED; + int confLoaded = getConfigurationLoaded(); + GWT.log("configuration loaded " + confLoaded + " of " + + CONFIGURATION_EXPECTED); + boolean configsLoaded = confLoaded == CONFIGURATION_EXPECTED; GWT.log("configsLoaded: " + configsLoaded); if (configsLoaded) { GWT.log("ContentModeratorCheckConfig loaded correclty"); diff --git a/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/CkanContentModeratorService.java b/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/CkanContentModeratorService.java index b7b3a8d..870c1c3 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/CkanContentModeratorService.java +++ b/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/CkanContentModeratorService.java @@ -21,17 +21,6 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; @RemoteServiceRelativePath("ckanContentModeratorService") public interface CkanContentModeratorService extends RemoteService { - /** - * Sets the status. Currently, this only used to change the status from Rejected - * to Pending - * - * @param theStatus the the status - * @param itemNames the item names - * @return the operation report - * @throws Exception the exception - */ - public OperationReport setStatus(ItemStatus theStatus, List itemNames) throws Exception; - /** * Reject item. * @@ -67,7 +56,7 @@ public interface CkanContentModeratorService extends RemoteService { * @return the list items for status * @throws Exception the exception */ - List getListItemsForStatus(ItemStatus theStatus, int offset, int limit, boolean allFields, + public List getListItemsForStatus(ItemStatus theStatus, int offset, int limit, boolean allFields, boolean restrictedToLoggedInUser, String sortForField) throws Exception; /** @@ -135,6 +124,16 @@ public interface CkanContentModeratorService extends RemoteService { * @return the item for name * @throws Exception the exception */ - CatalogueDataset getItemForName(String itemName) throws Exception; + public CatalogueDataset getItemForName(String itemName) throws Exception; + + /** + * Sets the status. + * + * @param theStatus the the status + * @param itemNames the item names + * @return the operation report + * @throws Exception the exception + */ + public OperationReport setStatus(ItemStatus theStatus, List itemNames, String message) throws Exception; } diff --git a/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/CkanContentModeratorServiceAsync.java b/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/CkanContentModeratorServiceAsync.java index ded10ed..ea862e9 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/CkanContentModeratorServiceAsync.java +++ b/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/CkanContentModeratorServiceAsync.java @@ -30,6 +30,18 @@ public interface CkanContentModeratorServiceAsync { void rejectItem(List itemNames, boolean permanentlyDelete, String reasonMsg, AsyncCallback callback); + /** + * Gets the list items for status. + * + * @param theStatus the the status + * @param offset the offset + * @param limit the limit + * @param allFields the all fields + * @param restrictedToLoggedInUser the restricted to logged in user + * @param sortForField the sort for field + * @param callback the callback + * @return the list items for status + */ void getListItemsForStatus(ItemStatus theStatus, int offset, int limit, boolean allFields, boolean restrictedToLoggedInUser, String sortForField, AsyncCallback> callback); @@ -70,9 +82,11 @@ public interface CkanContentModeratorServiceAsync { * * @param theStatus the the status * @param itemNames the item names + * @param message the message * @param callback the callback */ - void setStatus(ItemStatus theStatus, List itemNames, AsyncCallback callback); + void setStatus(ItemStatus theStatus, List itemNames, String message, + AsyncCallback callback); /** * Gets the CMS roles for user in the context. diff --git a/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/ui/DoActionCMSView.java b/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/ui/DoActionCMSView.java index 1010c6c..35a0e2e 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/ui/DoActionCMSView.java +++ b/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/ui/DoActionCMSView.java @@ -117,7 +117,8 @@ public class DoActionCMSView extends Composite { switch (toStatus) { case PENDING: checkBoxPermDelete.setVisible(false); - txtMsgReason.setVisible(false); + txtMsgReason.setVisible(true); + txtMsgReason.setPlaceholder("(Optional) Type a message..."); break; case APPROVED: checkBoxPermDelete.setVisible(false); diff --git a/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/ui/HomeView.java b/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/ui/HomeView.java index 53d3909..d8d9a27 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/ui/HomeView.java +++ b/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/ui/HomeView.java @@ -106,7 +106,7 @@ public class HomeView extends Composite { * @param status the status * @param displayFields the display fields * @param sortByField the sort by field - * @param readOnlyMode the read only mode + * @param readOnlyMode the read only mode * @param restrictDataToLoggedInUser the restrict data to logged in user */ public HomeView(HandlerManager eventBus, ItemStatus status, DISPLAY_FIELD[] displayFields, @@ -423,8 +423,8 @@ public class HomeView extends Composite { /** * Load form server the items with status. * - * @param itemStatus the item status - * @param sortForField + * @param itemStatus the item status + * @param sortForField */ public void loadItemsWithStatus(ItemStatus itemStatus, String sortForField) { GWT.log("loadItemsWithStatus started"); @@ -456,7 +456,7 @@ public class HomeView extends Composite { case PENDING: CkanContentModeratorWidgetController.contentModeratorService.setStatus(toStatus, listDatasetNames, - new AsyncCallback() { + doActionCMSView.getTxtReasonMsg(), new AsyncCallback() { @Override public void onSuccess(OperationReport result) { diff --git a/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/server/CkanContentModeratorServiceImpl.java b/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/server/CkanContentModeratorServiceImpl.java index 35fdc7d..ac8569a 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/server/CkanContentModeratorServiceImpl.java +++ b/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/server/CkanContentModeratorServiceImpl.java @@ -54,6 +54,7 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem DataCatalogueImpl catalogueImpl = CatalogueCMSFactory.getFactory().getCatalogueImplPerScope(scope); CatalogueContentModeratorSystem cmsInstance = catalogueImpl.getCatalogueContentModerator(); isModerationEnabled = cmsInstance.isModerationEnabled(reloadConfig); + LOG.info("is ModerationEnabled? " + isModerationEnabled); } catch (Exception e) { LOG.error("Error occured on checking isContentModeratorEnabled, so returning false", e); return false; @@ -296,22 +297,29 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem * * @param theStatus the the status * @param itemNames the item names + * @param message the message to send to Moderators. If null no messange is sent * @return the operation report * @throws Exception the exception */ @Override - public OperationReport setStatus(ItemStatus theStatus, List itemNames) throws Exception { - LOG.info("Called set status " + theStatus + " for Items with name: " + itemNames); + public OperationReport setStatus(ItemStatus theStatus, List itemNames, String message) throws Exception { + LOG.info("Called set status " + theStatus + " for items with name: " + itemNames + ". Is message null?: "+(message==null)); try { String scope = setContexts(); DataCatalogueImpl catalogueImpl = CatalogueCMSFactory.getFactory().getCatalogueImplPerScope(scope); + CatalogueContentModeratorSystem cmsInstance = catalogueImpl.getCatalogueContentModerator(); Map errorMapItems = new HashMap(); List changedStatusListItems = new ArrayList(); for (String itemName : itemNames) { try { catalogueImpl.refreshDataset(itemName); + LOG.info("refresh dataset done"); changedStatusListItems.add(itemName); + if(message!=null && !message.isEmpty()) { + LOG.debug("Sending message: "+message); + cmsInstance.messageItem(itemName, message); + } } catch (Exception e) { LOG.warn("Error when setting status (updating) the itemName: " + itemName, e); errorMapItems.put(itemName, e.getMessage()); @@ -500,5 +508,4 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem LOG.debug("Returning: " + searchedData); return searchedData; } - }