task_21363 #1

Closed
francesco.mangiacrapa wants to merge 53 commits from task_21363 into master
6 changed files with 18 additions and 21 deletions
Showing only changes of commit f161ec65e1 - Show all commits

View File

@ -10,3 +10,4 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- [#21363] Implemented the ckan-content-moderator-widget
- [#20650] Provided moderator skills to Catalogue Moderator(s)
- [#23108] Provided Moderation facility accessible to Catalogue Editor/Admin (only) in read only mode
- [#23197] Revised the query passed to gCat with the moderation states

View File

@ -16,7 +16,7 @@ public class CkanContentModeratorCheckConfigs {
private int configurationLoaded = 0;
private static final int CONFIGURATION_EXPECTED = 3;
private int MAX_RETRY_ON_LOADING_CONFIG = 20;
private int MAX_RETRY_ON_LOADING_CONFIG = 50;
private int attemptLC = 0;
private Boolean contentModerationEnabled = null;
private Boolean moderatorRoleAssigned = null;

View File

@ -1,6 +1,5 @@
package org.gcube.portlets.widgets.ckancontentmoderator.client.ui;
import java.util.ArrayList;
import java.util.List;
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;

View File

@ -99,28 +99,24 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
DataCatalogueImpl catalogueImpl = CatalogueCMSFactory.getFactory().getCatalogueImplPerScope(scope);
GCubeUser user = GcubeContextUtil.getCurrentUser(getThreadLocalRequest());
String valueOfQueryEmails = CkanContentModeratorUtil.userQueryForEmails(user, QUERY_OPERATOR.OR);
String valueOfQueryEmails = CkanContentModeratorUtil.userSOLRQueryForEmails(user, QUERY_OPERATOR.OR);
/// BUILDING MODERATION_STATUS QUERY
String system_cm_prefix = GCatCaller.MODERATOR_ITEM_STATUS_FIELD_NAME;
StringBuilder queryValuesBuilder = new StringBuilder();
// QUERYING AUTHOR_MAIL MUST BE IN LIST OF EMAIL
queryValuesBuilder
StringBuilder emailsValuesBuilder = new StringBuilder();
// QUERYING AUTHOR_MAIL. IT MUST BE IN LIST OF EMAILs
emailsValuesBuilder
.append(ContentModeratorWidgetConstants.CKAN_FIELD_NAME_AUTHOR_MAIL + ":" + valueOfQueryEmails);
queryValuesBuilder.append(" AND ");
// QUERYING THE ITEM MUST HAVE THE MODERATIONS STATUS
queryValuesBuilder.append("extras_" + system_cm_prefix + ":*");
Map<String, String> query = new HashMap<String, String>(1);
query.put("q", queryValuesBuilder.toString());
Map<String, String> params = new HashMap<String, String>(1);
params.put("q", emailsValuesBuilder.toString());
// QUERYING THE ITEM HAVING ANY MODERATIONS STATUS
params.put(GCatCaller.MODERATOR_ITEM_STATUS_PARAMETER, GCatCaller.MODERATOR_ITEM_ANY_STATUS_VALUE);
List<String> listItems = catalogueImpl.performQueryForItems(query);
LOG.debug("query returned items: " + listItems);
List<String> listItems = catalogueImpl.performQueryForItems(params);
LOG.debug("existsMyItemInModeration query returned items: " + listItems);
boolean haveItemInModeration = false;
if (listItems != null && listItems.size()>0) {
if (listItems != null && listItems.size() > 0) {
haveItemInModeration = true;
}
@ -191,7 +187,7 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
if (restrictedToLoggedInUser) {
filters = new HashMap<String, String>(1);
GCubeUser user = GcubeContextUtil.getCurrentUser(getThreadLocalRequest());
String valueOfQueryEmails = CkanContentModeratorUtil.userQueryForEmails(user, QUERY_OPERATOR.OR);
String valueOfQueryEmails = CkanContentModeratorUtil.userSOLRQueryForEmails(user, QUERY_OPERATOR.OR);
filters.put(ContentModeratorWidgetConstants.CKAN_FIELD_NAME_AUTHOR_MAIL, valueOfQueryEmails);
}
@ -392,7 +388,7 @@ public class CkanContentModeratorServiceImpl extends RemoteServiceServlet implem
if (restrictedToLoggedInUser) {
filters = new HashMap<String, String>(1);
GCubeUser user = GcubeContextUtil.getCurrentUser(getThreadLocalRequest());
String valueOfQueryEmails = CkanContentModeratorUtil.userQueryForEmails(user, QUERY_OPERATOR.OR);
String valueOfQueryEmails = CkanContentModeratorUtil.userSOLRQueryForEmails(user, QUERY_OPERATOR.OR);
filters.put(ContentModeratorWidgetConstants.CKAN_FIELD_NAME_AUTHOR_MAIL, valueOfQueryEmails);
}

View File

@ -31,7 +31,7 @@ public class CkanContentModeratorUtil {
* Mails
* @throws Exception the exception
*/
public static String userQueryForEmails(GCubeUser user, QUERY_OPERATOR operator) throws Exception {
public static String userSOLRQueryForEmails(GCubeUser user, QUERY_OPERATOR operator) throws Exception {
LOG.debug("userQueryForEmails called for user {}", user);
List<Email> listServerEmails = user.getEmailAddresses();

View File

@ -101,7 +101,8 @@ public class GcubeContextUtil {
// DEV MODE
if (!isWithinPortal()) {
CMSUserRole userRole = CMSUserRole.CATALOGUE_MODERATOR;
//CMSUserRole userRole = CMSUserRole.CATALOGUE_MODERATOR;
CMSUserRole userRole = null;
LOG.warn("\n\n\nDevelopment MODE is enabled, returning CMS user role: "+userRole);
return Arrays.asList(userRole);
}