From fa3da33e5a31a7573e280da4a76cbfde7653a8f2 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 25 Jan 2023 16:25:51 +0100 Subject: [PATCH 1/5] 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; } - } From 4faef436f17aacc5c5b2551c1694488c45e8c04e Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 25 Jan 2023 16:50:52 +0100 Subject: [PATCH 2/5] updated configurations --- .classpath | 21 +++++++++---------- .../com.gwtplugins.gdt.eclipse.core.prefs | 2 +- .../com.gwtplugins.gwt.eclipse.core.prefs | 1 + .settings/org.eclipse.wst.common.component | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.classpath b/.classpath index d3cfefb..a218ae3 100644 --- a/.classpath +++ b/.classpath @@ -11,16 +11,6 @@ - - - - - - - - - - @@ -34,6 +24,15 @@ - + + + + + + + + + + diff --git a/.settings/com.gwtplugins.gdt.eclipse.core.prefs b/.settings/com.gwtplugins.gdt.eclipse.core.prefs index a21cd08..c4efd22 100644 --- a/.settings/com.gwtplugins.gdt.eclipse.core.prefs +++ b/.settings/com.gwtplugins.gdt.eclipse.core.prefs @@ -1,4 +1,4 @@ eclipse.preferences.version=1 -lastWarOutDir=/home/francescomangiacrapa/git/ckan-content-moderator-widget/target/ckan-content-moderator-widget-0.1.0-SNAPSHOT +lastWarOutDir=/home/francescomangiacrapa/git/ckan-content-moderator-widget/target/ckan-content-moderator-widget-1.2.0-SNAPSHOT warSrcDir=src/main/webapp warSrcDirIsOutput=false diff --git a/.settings/com.gwtplugins.gwt.eclipse.core.prefs b/.settings/com.gwtplugins.gwt.eclipse.core.prefs index f23a752..c516ac9 100644 --- a/.settings/com.gwtplugins.gwt.eclipse.core.prefs +++ b/.settings/com.gwtplugins.gwt.eclipse.core.prefs @@ -1,2 +1,3 @@ eclipse.preferences.version=1 entryPointModules= +gwtSyncCodeServer=true diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 3422968..b0937c4 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -3,7 +3,7 @@ - + @@ -41,7 +41,7 @@ - + From 19bedd46980292cacb5190a14506ad7e2f2ff5e0 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 27 Jan 2023 10:19:01 +0100 Subject: [PATCH 3/5] Enabling the owner of the rejected item, to change the Status and send a message --- .../CkanContentModeratorWidgetController.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/CkanContentModeratorWidgetController.java b/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/CkanContentModeratorWidgetController.java index 5c0fbef..494216f 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/CkanContentModeratorWidgetController.java +++ b/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/CkanContentModeratorWidgetController.java @@ -276,6 +276,21 @@ public class CkanContentModeratorWidgetController { GWT.log("sortForField is: " + sortForField); howeView.loadItemsWithStatus(statusSelectedEvent.getItemStatus(), sortForField); mainTabPanel.selectTab(0); + + //#23903 Enabling the owner of the rejected item, to change the Status and send a message + switch (statusSelectedEvent.getItemStatus()) { + case REJECTED: + howeView.hideUpdateStatusAction(false); + howeView.hideSelectableRow(false); + break; + + default: + howeView.hideUpdateStatusAction(readOnlyMode); + howeView.hideSelectableRow(readOnlyMode); + break; + } + //#23903 end + } if (statusSelectedEvent.getDisplayMessage() != null) { From c0e0c2814cff11d56184645608de837e58b2a3ff Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 27 Jan 2023 15:14:29 +0100 Subject: [PATCH 4/5] only changed eclipse settings --- .classpath | 1 + .project | 11 ----- .../com.gwtplugins.gdt.eclipse.core.prefs | 3 +- .../com.gwtplugins.gwt.eclipse.core.prefs | 1 + .settings/org.eclipse.wst.common.component | 46 +++++++++++-------- ...se.wst.common.project.facet.core.prefs.xml | 7 --- ....eclipse.wst.common.project.facet.core.xml | 4 +- .../CkanContentModeratorServiceTest.java | 1 - 8 files changed, 31 insertions(+), 43 deletions(-) delete mode 100644 .settings/org.eclipse.wst.common.project.facet.core.prefs.xml diff --git a/.classpath b/.classpath index a218ae3..5bcac96 100644 --- a/.classpath +++ b/.classpath @@ -32,6 +32,7 @@ + diff --git a/.project b/.project index 88c3a4c..5ea670e 100644 --- a/.project +++ b/.project @@ -15,16 +15,6 @@ - - com.gwtplugins.gdt.eclipse.core.webAppProjectValidator - - - - - com.gwtplugins.gwt.eclipse.core.gwtProjectValidator - - - org.eclipse.wst.validation.validationbuilder @@ -42,7 +32,6 @@ org.eclipse.jdt.core.javanature org.eclipse.m2e.core.maven2Nature org.eclipse.wst.common.project.facet.core.nature - com.gwtplugins.gwt.eclipse.core.gwtNature org.eclipse.wst.jsdt.core.jsNature diff --git a/.settings/com.gwtplugins.gdt.eclipse.core.prefs b/.settings/com.gwtplugins.gdt.eclipse.core.prefs index c4efd22..eb53cab 100644 --- a/.settings/com.gwtplugins.gdt.eclipse.core.prefs +++ b/.settings/com.gwtplugins.gdt.eclipse.core.prefs @@ -1,4 +1,5 @@ eclipse.preferences.version=1 +jarsExcludedFromWebInfLib= lastWarOutDir=/home/francescomangiacrapa/git/ckan-content-moderator-widget/target/ckan-content-moderator-widget-1.2.0-SNAPSHOT -warSrcDir=src/main/webapp +warSrcDir= warSrcDirIsOutput=false diff --git a/.settings/com.gwtplugins.gwt.eclipse.core.prefs b/.settings/com.gwtplugins.gwt.eclipse.core.prefs index c516ac9..d80f7da 100644 --- a/.settings/com.gwtplugins.gwt.eclipse.core.prefs +++ b/.settings/com.gwtplugins.gwt.eclipse.core.prefs @@ -1,3 +1,4 @@ eclipse.preferences.version=1 entryPointModules= +filesCopiedToWebInfLib= gwtSyncCodeServer=true diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index b0937c4..5c13042 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,53 +1,59 @@ - + + + - + - - - - - - - - - + + + - + + + + + + + uses + + - + + + - - - - - - + + + + - + + + diff --git a/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml b/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml deleted file mode 100644 index cc81385..0000000 --- a/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml index 8867594..1c32d17 100644 --- a/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -1,9 +1,7 @@ - - - + diff --git a/src/test/java/org/gcube/portlets/widgets/ckancontentmoderator/server/CkanContentModeratorServiceTest.java b/src/test/java/org/gcube/portlets/widgets/ckancontentmoderator/server/CkanContentModeratorServiceTest.java index 4b9ec69..df0eb3f 100644 --- a/src/test/java/org/gcube/portlets/widgets/ckancontentmoderator/server/CkanContentModeratorServiceTest.java +++ b/src/test/java/org/gcube/portlets/widgets/ckancontentmoderator/server/CkanContentModeratorServiceTest.java @@ -13,7 +13,6 @@ import org.gcube.datacatalogue.utillibrary.server.cms.CatalogueContentModeratorS import org.gcube.datacatalogue.utillibrary.shared.ItemStatus; import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanDataset; import org.gcube.portlets.widgets.ckancontentmoderator.client.ContentModeratorWidgetConstants; -import org.junit.Test; import org.slf4j.LoggerFactory; public class CkanContentModeratorServiceTest { From c124ed4177b2a8aff16167f9d743c4a74d481783 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 6 Feb 2023 15:14:02 +0100 Subject: [PATCH 5/5] Added socialPost=true to the 'approveItem' request --- CHANGELOG.md | 1 + .../server/CkanContentModeratorServiceImpl.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37fd7e3..1b511e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm #### Enhancements - [#23903] Catalogue Moderation: allow to send a message to the moderators on reject to pending operation +- [#24519] Added social_post=true to approve request ## [v1.1.1] - 2022-10-27 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 ac8569a..f33cbc2 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 @@ -356,7 +356,7 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem List approvedListItems = new ArrayList(); for (String itemName : itemNames) { try { - cmsInstance.approveItem(itemName, moderatorMessage); + cmsInstance.approveItem(itemName, moderatorMessage, true); approvedListItems.add(itemName); } catch (Exception e) { LOG.warn("Error when approving itemName: " + itemName, e);