Merge pull request 'feature_23903' (#3) from feature_23903 into master

Reviewed-on: #3
This commit is contained in:
Francesco Mangiacrapa 2023-02-07 08:40:16 +01:00
commit 3ce9381cbf
17 changed files with 115 additions and 81 deletions

View File

@ -11,16 +11,6 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="test" value="true"/>
@ -34,6 +24,16 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="/home/francescomangiacrapa/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@ -15,16 +15,6 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.gwtplugins.gdt.eclipse.core.webAppProjectValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.gwtplugins.gwt.eclipse.core.gwtProjectValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
@ -42,7 +32,6 @@
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>com.gwtplugins.gwt.eclipse.core.gwtNature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>

View File

@ -1,4 +1,5 @@
eclipse.preferences.version=1
lastWarOutDir=/home/francescomangiacrapa/git/ckan-content-moderator-widget/target/ckan-content-moderator-widget-0.1.0-SNAPSHOT
warSrcDir=src/main/webapp
jarsExcludedFromWebInfLib=
lastWarOutDir=/home/francescomangiacrapa/git/ckan-content-moderator-widget/target/ckan-content-moderator-widget-1.2.0-SNAPSHOT
warSrcDir=
warSrcDirIsOutput=false

View File

@ -1,2 +1,4 @@
eclipse.preferences.version=1
entryPointModules=
filesCopiedToWebInfLib=
gwtSyncCodeServer=true

View File

@ -3,17 +3,11 @@
<wb-module deploy-name="ckan-content-moderator-widget-0.1.0-SNAPSHOT">
<wb-module deploy-name="ckan-content-moderator-widget-1.2.0-SNAPSHOT">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
@ -23,27 +17,37 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="catalogue-util-library-1.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/catalogue-util-library/catalogue-util-library">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="context-root" value="ckan-content-moderator-widget"/>
<property name="java-output-path" value="/ckan-content-moderator-widget/target/classes"/>
<property name="java-output-path" value="/ckan-content-moderator-widget/target/ckan-content-moderator-widget-0.1.0-SNAPSHOT/WEB-INF/classes"/>
</wb-module>
@ -51,4 +55,6 @@
</project-modules>

View File

@ -1,7 +0,0 @@
<root>
<facet id="jst.jaxrs">
<node name="libprov">
<attribute name="provider-id" value="jaxrs-no-op-library-provider"/>
</node>
</facet>
</root>

View File

@ -1,9 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<fixed facet="wst.jsdt.web"/>
<installed facet="jst.web" version="2.3"/>
<installed facet="com.gwtplugins.gwt.facet" version="1.0"/>
<installed facet="wst.jsdt.web" version="1.0"/>
<installed facet="java" version="1.8"/>
<installed facet="jst.jaxrs" version="2.0"/>
<installed facet="jst.utility" version="1.0"/>
</faceted-project>

View File

@ -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.2.0-SNAPSHOT] - 2023-01-19
#### 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
#### Fixing

View File

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

View File

@ -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");

View File

@ -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<String> 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<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;
/**
@ -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<String> itemNames, String message) throws Exception;
}

View File

@ -30,6 +30,18 @@ public interface CkanContentModeratorServiceAsync {
void rejectItem(List<String> itemNames, boolean permanentlyDelete, String reasonMsg,
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,
boolean restrictedToLoggedInUser, String sortForField, AsyncCallback<List<CatalogueDataset>> 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<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.

View File

@ -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) {

View File

@ -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);

View File

@ -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,7 +423,7 @@ public class HomeView extends Composite {
/**
* Load form server the items with status.
*
* @param itemStatus the item status
* @param itemStatus the item status
* @param sortForField
*/
public void loadItemsWithStatus(ItemStatus itemStatus, String sortForField) {
@ -456,7 +456,7 @@ public class HomeView extends Composite {
case PENDING:
CkanContentModeratorWidgetController.contentModeratorService.setStatus(toStatus, listDatasetNames,
new AsyncCallback<OperationReport>() {
doActionCMSView.getTxtReasonMsg(), new AsyncCallback<OperationReport>() {
@Override
public void onSuccess(OperationReport result) {

View File

@ -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<String> itemNames) throws Exception {
LOG.info("Called set status " + theStatus + " for Items with name: " + itemNames);
public OperationReport setStatus(ItemStatus theStatus, List<String> 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<String, String> errorMapItems = new HashMap<String, String>();
List<String> changedStatusListItems = new ArrayList<String>();
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());
@ -348,7 +356,7 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
List<String> approvedListItems = new ArrayList<String>();
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);
@ -500,5 +508,4 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
LOG.debug("Returning: " + searchedData);
return searchedData;
}
}

View File

@ -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 {