This commit is contained in:
Francesco Mangiacrapa 2023-01-25 16:25:51 +01:00
parent f598f29ca7
commit fa3da33e5a
8 changed files with 54 additions and 24 deletions

View File

@ -4,6 +4,12 @@
All notable changes to this project will be documented in this file. 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). 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 ## [v1.1.1] - 2022-10-27
#### Fixing #### Fixing

View File

@ -14,7 +14,7 @@
<groupId>org.gcube.portlets.widgets</groupId> <groupId>org.gcube.portlets.widgets</groupId>
<artifactId>ckan-content-moderator-widget</artifactId> <artifactId>ckan-content-moderator-widget</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>1.1.1</version> <version>1.2.0-SNAPSHOT</version>
<name>gCube Ckan Content Moderator Widget</name> <name>gCube Ckan Content Moderator Widget</name>
<description> <description>

View File

@ -106,7 +106,10 @@ public class CkanContentModeratorCheckConfigs {
attemptLC++; attemptLC++;
GWT.log("checking configuration loaded, attempt " + attemptLC + " of " GWT.log("checking configuration loaded, attempt " + attemptLC + " of "
+ MAX_RETRY_ON_LOADING_CONFIG); + 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); GWT.log("configsLoaded: " + configsLoaded);
if (configsLoaded) { if (configsLoaded) {
GWT.log("ContentModeratorCheckConfig loaded correclty"); GWT.log("ContentModeratorCheckConfig loaded correclty");

View File

@ -21,17 +21,6 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@RemoteServiceRelativePath("ckanContentModeratorService") @RemoteServiceRelativePath("ckanContentModeratorService")
public interface CkanContentModeratorService extends RemoteService { 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<String> itemNames) throws Exception;
/** /**
* Reject item. * Reject item.
* *
@ -67,7 +56,7 @@ public interface CkanContentModeratorService extends RemoteService {
* @return the list items for status * @return the list items for status
* @throws Exception the exception * @throws Exception the exception
*/ */
List<CatalogueDataset> getListItemsForStatus(ItemStatus theStatus, int offset, int limit, boolean allFields, public List<CatalogueDataset> getListItemsForStatus(ItemStatus theStatus, int offset, int limit, boolean allFields,
boolean restrictedToLoggedInUser, String sortForField) throws Exception; boolean restrictedToLoggedInUser, String sortForField) throws Exception;
/** /**
@ -135,6 +124,16 @@ public interface CkanContentModeratorService extends RemoteService {
* @return the item for name * @return the item for name
* @throws Exception the exception * @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<String> itemNames, String message) throws Exception;
} }

View File

@ -30,6 +30,18 @@ public interface CkanContentModeratorServiceAsync {
void rejectItem(List<String> itemNames, boolean permanentlyDelete, String reasonMsg, void rejectItem(List<String> itemNames, boolean permanentlyDelete, String reasonMsg,
AsyncCallback<OperationReport> callback); AsyncCallback<OperationReport> 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, void getListItemsForStatus(ItemStatus theStatus, int offset, int limit, boolean allFields,
boolean restrictedToLoggedInUser, String sortForField, AsyncCallback<List<CatalogueDataset>> callback); boolean restrictedToLoggedInUser, String sortForField, AsyncCallback<List<CatalogueDataset>> callback);
@ -70,9 +82,11 @@ public interface CkanContentModeratorServiceAsync {
* *
* @param theStatus the the status * @param theStatus the the status
* @param itemNames the item names * @param itemNames the item names
* @param message the message
* @param callback the callback * @param callback the callback
*/ */
void setStatus(ItemStatus theStatus, List<String> itemNames, AsyncCallback<OperationReport> callback); void setStatus(ItemStatus theStatus, List<String> itemNames, String message,
AsyncCallback<OperationReport> callback);
/** /**
* Gets the CMS roles for user in the context. * Gets the CMS roles for user in the context.

View File

@ -117,7 +117,8 @@ public class DoActionCMSView extends Composite {
switch (toStatus) { switch (toStatus) {
case PENDING: case PENDING:
checkBoxPermDelete.setVisible(false); checkBoxPermDelete.setVisible(false);
txtMsgReason.setVisible(false); txtMsgReason.setVisible(true);
txtMsgReason.setPlaceholder("(Optional) Type a message...");
break; break;
case APPROVED: case APPROVED:
checkBoxPermDelete.setVisible(false); checkBoxPermDelete.setVisible(false);

View File

@ -106,7 +106,7 @@ public class HomeView extends Composite {
* @param status the status * @param status the status
* @param displayFields the display fields * @param displayFields the display fields
* @param sortByField the sort by field * @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 * @param restrictDataToLoggedInUser the restrict data to logged in user
*/ */
public HomeView(HandlerManager eventBus, ItemStatus status, DISPLAY_FIELD[] displayFields, 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. * Load form server the items with status.
* *
* @param itemStatus the item status * @param itemStatus the item status
* @param sortForField * @param sortForField
*/ */
public void loadItemsWithStatus(ItemStatus itemStatus, String sortForField) { public void loadItemsWithStatus(ItemStatus itemStatus, String sortForField) {
GWT.log("loadItemsWithStatus started"); GWT.log("loadItemsWithStatus started");
@ -456,7 +456,7 @@ public class HomeView extends Composite {
case PENDING: case PENDING:
CkanContentModeratorWidgetController.contentModeratorService.setStatus(toStatus, listDatasetNames, CkanContentModeratorWidgetController.contentModeratorService.setStatus(toStatus, listDatasetNames,
new AsyncCallback<OperationReport>() { doActionCMSView.getTxtReasonMsg(), new AsyncCallback<OperationReport>() {
@Override @Override
public void onSuccess(OperationReport result) { public void onSuccess(OperationReport result) {

View File

@ -54,6 +54,7 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
DataCatalogueImpl catalogueImpl = CatalogueCMSFactory.getFactory().getCatalogueImplPerScope(scope); DataCatalogueImpl catalogueImpl = CatalogueCMSFactory.getFactory().getCatalogueImplPerScope(scope);
CatalogueContentModeratorSystem cmsInstance = catalogueImpl.getCatalogueContentModerator(); CatalogueContentModeratorSystem cmsInstance = catalogueImpl.getCatalogueContentModerator();
isModerationEnabled = cmsInstance.isModerationEnabled(reloadConfig); isModerationEnabled = cmsInstance.isModerationEnabled(reloadConfig);
LOG.info("is ModerationEnabled? " + isModerationEnabled);
} catch (Exception e) { } catch (Exception e) {
LOG.error("Error occured on checking isContentModeratorEnabled, so returning false", e); LOG.error("Error occured on checking isContentModeratorEnabled, so returning false", e);
return false; return false;
@ -296,22 +297,29 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
* *
* @param theStatus the the status * @param theStatus the the status
* @param itemNames the item names * @param itemNames the item names
* @param message the message to send to Moderators. If null no messange is sent
* @return the operation report * @return the operation report
* @throws Exception the exception * @throws Exception the exception
*/ */
@Override @Override
public OperationReport setStatus(ItemStatus theStatus, List<String> itemNames) throws Exception { public OperationReport setStatus(ItemStatus theStatus, List<String> itemNames, String message) throws Exception {
LOG.info("Called set status " + theStatus + " for Items with name: " + itemNames); LOG.info("Called set status " + theStatus + " for items with name: " + itemNames + ". Is message null?: "+(message==null));
try { try {
String scope = setContexts(); String scope = setContexts();
DataCatalogueImpl catalogueImpl = CatalogueCMSFactory.getFactory().getCatalogueImplPerScope(scope); DataCatalogueImpl catalogueImpl = CatalogueCMSFactory.getFactory().getCatalogueImplPerScope(scope);
CatalogueContentModeratorSystem cmsInstance = catalogueImpl.getCatalogueContentModerator();
Map<String, String> errorMapItems = new HashMap<String, String>(); Map<String, String> errorMapItems = new HashMap<String, String>();
List<String> changedStatusListItems = new ArrayList<String>(); List<String> changedStatusListItems = new ArrayList<String>();
for (String itemName : itemNames) { for (String itemName : itemNames) {
try { try {
catalogueImpl.refreshDataset(itemName); catalogueImpl.refreshDataset(itemName);
LOG.info("refresh dataset done");
changedStatusListItems.add(itemName); changedStatusListItems.add(itemName);
if(message!=null && !message.isEmpty()) {
LOG.debug("Sending message: "+message);
cmsInstance.messageItem(itemName, message);
}
} catch (Exception e) { } catch (Exception e) {
LOG.warn("Error when setting status (updating) the itemName: " + itemName, e); LOG.warn("Error when setting status (updating) the itemName: " + itemName, e);
errorMapItems.put(itemName, e.getMessage()); errorMapItems.put(itemName, e.getMessage());
@ -500,5 +508,4 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
LOG.debug("Returning: " + searchedData); LOG.debug("Returning: " + searchedData);
return searchedData; return searchedData;
} }
} }