Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
atlas
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dataplatform
atlas
Commits
6e561852
Commit
6e561852
authored
Sep 13, 2017
by
apoorvnaik
Committed by
Madhan Neethiraj
Sep 14, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2028: invalid attributes in basic-search request should fail with status code 400
Signed-off-by:
Madhan Neethiraj
<
madhan@apache.org
>
parent
d1c585a2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
+25
-0
SearchContext.java
...c/main/java/org/apache/atlas/discovery/SearchContext.java
+25
-0
No files found.
repository/src/main/java/org/apache/atlas/discovery/SearchContext.java
View file @
6e561852
...
...
@@ -25,6 +25,7 @@ import org.apache.atlas.model.discovery.SearchParameters.FilterCriteria;
import
org.apache.atlas.repository.graphdb.AtlasGraph
;
import
org.apache.atlas.type.AtlasClassificationType
;
import
org.apache.atlas.type.AtlasEntityType
;
import
org.apache.atlas.type.AtlasStructType
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -67,6 +68,12 @@ public class SearchContext {
throw
new
AtlasBaseException
(
AtlasErrorCode
.
UNKNOWN_CLASSIFICATION
,
searchParameters
.
getClassification
());
}
// Invalid attributes will raise an exception with 400 error code
validateAttributes
(
entityType
,
searchParameters
.
getEntityFilters
());
// Invalid attributes will raise an exception with 400 error code
validateAttributes
(
classificationType
,
searchParameters
.
getTagFilters
());
if
(
needFullTextProcessor
())
{
addProcessor
(
new
FullTextSearchProcessor
(
this
));
}
...
...
@@ -131,6 +138,24 @@ public class SearchContext {
return
entityType
!=
null
;
}
private
void
validateAttributes
(
final
AtlasStructType
structType
,
final
FilterCriteria
filterCriteria
)
throws
AtlasBaseException
{
if
(
filterCriteria
!=
null
)
{
FilterCriteria
.
Condition
condition
=
filterCriteria
.
getCondition
();
if
(
condition
!=
null
&&
CollectionUtils
.
isNotEmpty
(
filterCriteria
.
getCriterion
()))
{
for
(
FilterCriteria
criteria
:
filterCriteria
.
getCriterion
())
{
validateAttributes
(
structType
,
criteria
);
}
}
else
{
String
attributeName
=
filterCriteria
.
getAttributeName
();
if
(
StringUtils
.
isNotEmpty
(
attributeName
)
&&
structType
.
getAttributeType
(
attributeName
)
==
null
)
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
UNKNOWN_ATTRIBUTE
,
attributeName
,
structType
.
getTypeName
());
}
}
}
}
private
boolean
hasAttributeFilter
(
FilterCriteria
filterCriteria
)
{
return
filterCriteria
!=
null
&&
(
CollectionUtils
.
isNotEmpty
(
filterCriteria
.
getCriterion
())
||
StringUtils
.
isNotEmpty
(
filterCriteria
.
getAttributeName
()));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment