diff --git a/CHANGELOG.md b/CHANGELOG.md index 975282f..3410cc5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 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 3567e4a..6ef9f58 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 @@ -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; diff --git a/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/ui/ContentModeratorPaginatedView.java b/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/ui/ContentModeratorPaginatedView.java index bc3f2da..8d68e2a 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/ui/ContentModeratorPaginatedView.java +++ b/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/client/ui/ContentModeratorPaginatedView.java @@ -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; 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 51d173e..781d3a8 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 @@ -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 query = new HashMap(1); - query.put("q", queryValuesBuilder.toString()); + Map params = new HashMap(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 listItems = catalogueImpl.performQueryForItems(query); - LOG.debug("query returned items: " + listItems); + List 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(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(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); } diff --git a/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/server/CkanContentModeratorUtil.java b/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/server/CkanContentModeratorUtil.java index 3b739cd..161e17f 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/server/CkanContentModeratorUtil.java +++ b/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/server/CkanContentModeratorUtil.java @@ -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 listServerEmails = user.getEmailAddresses(); diff --git a/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/server/GcubeContextUtil.java b/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/server/GcubeContextUtil.java index 65c3f4b..3bedfb3 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/server/GcubeContextUtil.java +++ b/src/main/java/org/gcube/portlets/widgets/ckancontentmoderator/server/GcubeContextUtil.java @@ -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); }