aditya-gupta36 commented on code in PR #333:
URL: https://github.com/apache/atlas/pull/333#discussion_r2051983984
##########
webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java:
##########
@@ -885,7 +885,56 @@ private void validateSearchParameters(SearchParameters
parameters) throws AtlasB
if (StringUtils.isNotEmpty(parameters.getQuery()) &&
parameters.getQuery().length() > maxFullTextQueryLength) {
throw new
AtlasBaseException(AtlasErrorCode.INVALID_QUERY_LENGTH,
Constants.MAX_FULLTEXT_QUERY_STR_LENGTH);
}
+
+ validateEntityFilter(parameters);
+ }
+ }
+
+ private void validateEntityFilter(SearchParameters parameters) throws
AtlasBaseException {
+ FilterCriteria entityFilter = parameters.getEntityFilters();
+
+ if (entityFilter == null) {
+ return;
}
+
+ if (entityFilter.getCriterion() != null &&
+ !entityFilter.getCriterion().isEmpty()) {
+ if (entityFilter.getCondition() == null ||
StringUtils.isEmpty(entityFilter.getCondition().toString())) {
+ throw new AtlasBaseException("Condition (AND/OR) must be
specified when using multiple filters.");
+ }
+
+ for (FilterCriteria filterCriteria : entityFilter.getCriterion()) {
+ if (filterCriteria.getOperator() == null) {
+ throw new
AtlasBaseException(AtlasErrorCode.INVALID_OPERATOR,
filterCriteria.getAttributeName());
+ }
+
+ if (StringUtils.isBlank(filterCriteria.getAttributeName())) {
+ throw new
AtlasBaseException(AtlasErrorCode.BLANK_NAME_ATTRIBUTE);
+ }
+
+ if (requiresValue(filterCriteria.getOperator()) &&
StringUtils.isBlank(filterCriteria.getAttributeValue())) {
+ throw new
AtlasBaseException(AtlasErrorCode.BLANK_VALUE_ATTRIBUTE);
+ }
+ }
+ }
+ else {
+ if (entityFilter.getOperator() == null) {
+ throw new AtlasBaseException(AtlasErrorCode.INVALID_OPERATOR,
entityFilter.getAttributeName());
Review Comment:
Hi @rkundam,
Yes, checks for invalid or unsupported operators have been implemented. You
can refer to the enum block in the following file:
https://github.com/apache/atlas/blame/4b702b07650d0376b535275fa8b739c3c01237ac/intg/src/main/java/org/apache/atlas/model/discovery/SearchParameters.java#L431
If an operator is not found in the map, the method returns null, which
should be treated as an indication of an invalid or unsupported operator. Since
this logic is implemented within an enum, throwing an AtlasBaseException
directly is not feasible. Therefore, a null return value effectively signals an
unsupported case.
We had initially considered handling this condition directly within the
enum, but since we needed to propagate an appropriate message, we chose this
approach instead.
Let me know if this aligns with your expectations or if any further
clarification is needed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]