This is an automated email from the ASF dual-hosted git repository. ilgrosso pushed a commit to branch 3_0_X in repository https://gitbox.apache.org/repos/asf/syncope.git
commit e045a1216982fbfd0b22c06691cf61fa2db2cdd6 Author: Francesco Chicchiriccò <[email protected]> AuthorDate: Fri Sep 5 10:58:57 2025 +0200 Managing error for null or empty FIQL queries --- .../console/notifications/NotificationWrapper.java | 28 +++++++++++----------- .../console/panels/search/AbstractSearchPanel.java | 11 +++++---- .../client/console/rest/FIQLQueryRestClient.java | 8 +++---- .../java/data/FIQLQueryDataBinderImpl.java | 5 +++- 4 files changed, 29 insertions(+), 23 deletions(-) diff --git a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/notifications/NotificationWrapper.java b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/notifications/NotificationWrapper.java index d2dcc47574..cd3f50d8c4 100644 --- a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/notifications/NotificationWrapper.java +++ b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/notifications/NotificationWrapper.java @@ -48,35 +48,35 @@ public class NotificationWrapper extends EntityWrapper<NotificationTO> { } public List<Pair<String, List<SearchClause>>> getAboutClauses() { - if (this.aboutClauses == null) { - this.aboutClauses = SearchUtils.getSearchClauses(getInnerObject().getAbouts()).entrySet().stream(). + if (aboutClauses == null) { + aboutClauses = SearchUtils.getSearchClauses(getInnerObject().getAbouts()).entrySet().stream(). map(entry -> Pair.of(entry.getKey(), entry.getValue())).collect(Collectors.toList()); } - return this.aboutClauses; + return aboutClauses; } public void setAboutClauses(final List<Pair<String, List<SearchClause>>> dynClauses) { - this.aboutClauses = dynClauses; + aboutClauses = dynClauses; } public List<SearchClause> getRecipientClauses() { - if (this.recipientClauses == null) { - this.recipientClauses = SearchUtils.getSearchClauses(getInnerObject().getRecipientsFIQL()); + if (recipientClauses == null) { + recipientClauses = SearchUtils.getSearchClauses(getInnerObject().getRecipientsFIQL()); } - return this.recipientClauses; + return recipientClauses; } public void setRecipientClauses(final List<SearchClause> dynClauses) { - this.recipientClauses = dynClauses; + recipientClauses = dynClauses; } public Map<String, String> getAboutFIQLs() { - if (CollectionUtils.isEmpty(this.aboutClauses) || this.aboutClauses.get(0).getValue().isEmpty()) { + if (CollectionUtils.isEmpty(aboutClauses) || aboutClauses.get(0).getValue().isEmpty()) { return getInnerObject().getAbouts(); } else { Map<String, String> res = new HashMap<>(); - for (Pair<String, List<SearchClause>> pair : this.aboutClauses) { + for (Pair<String, List<SearchClause>> pair : aboutClauses) { AbstractFiqlSearchConditionBuilder<?, ?, ?> builder; switch (pair.getLeft()) { case "USER": @@ -97,21 +97,21 @@ public class NotificationWrapper extends EntityWrapper<NotificationTO> { } private String getRecipientsFIQL() { - if (CollectionUtils.isEmpty(this.recipientClauses)) { + if (CollectionUtils.isEmpty(recipientClauses)) { return null; } else { - return SearchUtils.buildFIQL(this.recipientClauses, SyncopeClient.getUserSearchConditionBuilder()); + return SearchUtils.buildFIQL(recipientClauses, SyncopeClient.getUserSearchConditionBuilder()); } } public NotificationTO fillAboutConditions() { getInnerObject().getAbouts().clear(); - getInnerObject().getAbouts().putAll(this.getAboutFIQLs()); + getInnerObject().getAbouts().putAll(getAboutFIQLs()); return getInnerObject(); } public NotificationTO fillRecipientConditions() { - getInnerObject().setRecipientsFIQL(this.getRecipientsFIQL()); + getInnerObject().setRecipientsFIQL(getRecipientsFIQL()); return getInnerObject(); } } diff --git a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/panels/search/AbstractSearchPanel.java b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/panels/search/AbstractSearchPanel.java index 20c8afcebe..b401fe486c 100644 --- a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/panels/search/AbstractSearchPanel.java +++ b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/panels/search/AbstractSearchPanel.java @@ -22,6 +22,7 @@ import java.io.Serializable; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; @@ -206,10 +207,12 @@ public abstract class AbstractSearchPanel extends Panel { @Override public void onClick(final AjaxRequestTarget target, final Serializable ignore) { - saveFIQLQuery.setFiql( - SearchUtils.buildFIQL(AbstractSearchPanel.this.getModel().getObject(), - getSearchConditionBuilder()). - replaceAll(SearchUtils.getTypeConditionPattern(type).pattern(), "")); + Optional.ofNullable(SearchUtils.buildFIQL( + AbstractSearchPanel.this.getModel().getObject(), getSearchConditionBuilder())). + ifPresentOrElse( + fiql -> saveFIQLQuery.setFiql( + fiql.replaceAll(SearchUtils.getTypeConditionPattern(type).pattern(), "")), + () -> saveFIQLQuery.setFiql(null)); saveFIQLQuery.toggle(target, true); } }, ActionLink.ActionType.EXPORT, StringUtils.EMPTY).hideLabel(); diff --git a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/rest/FIQLQueryRestClient.java b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/rest/FIQLQueryRestClient.java index 876cd7143d..d635c5ae92 100644 --- a/client/idrepo/console/src/main/java/org/apache/syncope/client/console/rest/FIQLQueryRestClient.java +++ b/client/idrepo/console/src/main/java/org/apache/syncope/client/console/rest/FIQLQueryRestClient.java @@ -34,12 +34,12 @@ public class FIQLQueryRestClient extends BaseRestClient { return getService(FIQLQueryService.class).read(key); } - public void update(final FIQLQueryTO roleTO) { - getService(FIQLQueryService.class).update(roleTO); + public void update(final FIQLQueryTO fiqlQueryTO) { + getService(FIQLQueryService.class).update(fiqlQueryTO); } - public void create(final FIQLQueryTO roleTO) { - getService(FIQLQueryService.class).create(roleTO); + public void create(final FIQLQueryTO fiqlQueryTO) { + getService(FIQLQueryService.class).create(fiqlQueryTO); } public List<FIQLQueryTO> list(final String target) { diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/FIQLQueryDataBinderImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/FIQLQueryDataBinderImpl.java index a6ae6d457b..38aace20a2 100644 --- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/FIQLQueryDataBinderImpl.java +++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/FIQLQueryDataBinderImpl.java @@ -18,6 +18,7 @@ */ package org.apache.syncope.core.provisioning.java.data; +import org.apache.commons.lang3.StringUtils; import org.apache.syncope.common.lib.SyncopeClientException; import org.apache.syncope.common.lib.to.FIQLQueryTO; import org.apache.syncope.common.lib.types.ClientExceptionType; @@ -66,7 +67,9 @@ public class FIQLQueryDataBinderImpl implements FIQLQueryDataBinder { fiqlQuery.setName(fiqlQueryTO.getName()); fiqlQuery.setTarget(fiqlQueryTO.getTarget()); - SearchCond cond = SearchCondConverter.convert(searchCondVisitor, fiqlQueryTO.getFiql()); + SearchCond cond = StringUtils.isBlank(fiqlQueryTO.getFiql()) + ? new SearchCond() + : SearchCondConverter.convert(searchCondVisitor, fiqlQueryTO.getFiql()); if (!cond.isValid()) { SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidSearchParameters); sce.getElements().add(fiqlQueryTO.getFiql());
