Make basic search more robust
authorMathieu Baudier <mbaudier@argeo.org>
Sat, 2 Sep 2023 11:10:19 +0000 (13:10 +0200)
committerMathieu Baudier <mbaudier@argeo.org>
Sat, 2 Sep 2023 11:10:19 +0000 (13:10 +0200)
org.argeo.cms.jcr/src/org/argeo/cms/jcr/acr/BasicSearchToQom.java

index 99b8392161e34758740b467fc9068a81812b25fa..e1cf8baed5516019f3829902212e2b227e2f3406 100644 (file)
@@ -85,11 +85,13 @@ class BasicSearchToQom {
                                javax.jcr.query.qom.Constraint currQomConstraint = toQomConstraint(constraints.get(0));
                                for (int i = 1; i < constraints.size(); i++) {
                                        Constraint c = constraints.get(i);
-                                       if (where.isUnion()) {
-                                               currQomConstraint = factory.or(currQomConstraint, toQomConstraint(c));
-                                       } else {
-                                               currQomConstraint = factory.and(currQomConstraint, toQomConstraint(c));
-                                       }
+                                       javax.jcr.query.qom.Constraint subQomConstraint = toQomConstraint(c);
+                                       if (subQomConstraint != null) // isContentClass leads to null QOM constraint
+                                               if (where.isUnion()) {
+                                                       currQomConstraint = factory.or(currQomConstraint, subQomConstraint);
+                                               } else {
+                                                       currQomConstraint = factory.and(currQomConstraint, subQomConstraint);
+                                               }
                                }
                                qomConstraint = currQomConstraint;
                        }