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
f690755f
Commit
f690755f
authored
Jul 07, 2020
by
Pinal Shah
Committed by
nixonrodrigues
Jul 09, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-3880 : BasicSearch: Multiple type/tag: Log invalid and allow searching valid type/tag names
Signed-off-by:
nixonrodrigues
<
nixon@apache.org
>
parent
06cd0cb3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
12 deletions
+21
-12
SearchContext.java
...c/main/java/org/apache/atlas/discovery/SearchContext.java
+11
-9
EntitySearchProcessorTest.java
...org/apache/atlas/discovery/EntitySearchProcessorTest.java
+1
-1
DiscoveryREST.java
...rc/main/java/org/apache/atlas/web/rest/DiscoveryREST.java
+9
-2
No files found.
repository/src/main/java/org/apache/atlas/discovery/SearchContext.java
View file @
f690755f
...
...
@@ -370,11 +370,13 @@ public class SearchContext {
});
// Validate if the classification exists
if
(
CollectionUtils
.
isEmpty
(
classificationNames
)
||
classificationNames
.
size
()
!=
names
.
size
())
{
if
(
CollectionUtils
.
isNotEmpty
(
classificationNames
))
{
if
(
CollectionUtils
.
isEmpty
(
classificationNames
))
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
UNKNOWN_CLASSIFICATION
,
classification
);
}
else
if
(
classificationNames
.
size
()
!=
names
.
size
())
{
names
.
removeAll
(
classificationNames
);
}
throw
new
AtlasBaseException
(
AtlasErrorCode
.
UNKNOWN_CLASSIFICATION
,
String
.
join
(
TYPENAME_DELIMITER
,
names
));
LOG
.
info
(
"Could not search for {} , invalid classifications"
,
String
.
join
(
TYPENAME_DELIMITER
,
names
));
}
}
...
...
@@ -398,8 +400,10 @@ public class SearchContext {
getEntityType
(
n
)).
filter
(
Objects:
:
nonNull
).
collect
(
Collectors
.
toSet
());
// Validate if the type name is incorrect
if
(
CollectionUtils
.
isEmpty
(
entityTypes
)
||
entityTypes
.
size
()
!=
typeNames
.
size
())
{
if
(
CollectionUtils
.
isNotEmpty
(
entityTypes
))
{
if
(
CollectionUtils
.
isEmpty
(
entityTypes
))
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
UNKNOWN_TYPENAME
,
typeName
);
}
else
if
(
entityTypes
.
size
()
!=
typeNames
.
size
())
{
Set
<
String
>
validEntityTypes
=
new
HashSet
<>();
for
(
AtlasEntityType
entityType
:
entityTypes
)
{
String
name
=
entityType
.
getTypeName
();
...
...
@@ -411,11 +415,9 @@ public class SearchContext {
}
typeNames
.
removeAll
(
validEntityTypes
);
}
throw
new
AtlasBaseException
(
AtlasErrorCode
.
UNKNOWN_TYPENAME
,
String
.
join
(
TYPENAME_DELIMITER
,
typeNames
));
LOG
.
info
(
"Could not search for {} , invalid typeNames"
,
String
.
join
(
TYPENAME_DELIMITER
,
typeNames
));
}
}
return
entityTypes
;
...
...
repository/src/test/java/org/apache/atlas/discovery/EntitySearchProcessorTest.java
View file @
f690755f
...
...
@@ -250,7 +250,7 @@ public class EntitySearchProcessorTest extends BasicTestSetup {
@Test
(
expectedExceptions
=
AtlasBaseException
.
class
,
expectedExceptionsMessageRegExp
=
"Not_Exists: Unknown/invalid typename"
)
public
void
entityTypesNotAllowed
()
throws
AtlasBaseException
{
SearchParameters
params
=
new
SearchParameters
();
params
.
setTypeName
(
DATABASE_TYPE
+
",
Not_Exists"
);
params
.
setTypeName
(
"
Not_Exists"
);
params
.
setLimit
(
20
);
SearchContext
context
=
new
SearchContext
(
params
,
typeRegistry
,
graph
,
Collections
.<
String
>
emptySet
());
...
...
webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java
View file @
f690755f
...
...
@@ -326,9 +326,16 @@ public class DiscoveryREST {
throw
new
AtlasBaseException
(
AtlasErrorCode
.
BAD_REQUEST
,
"Limit/offset should be non-negative"
);
}
if
(
StringUtils
.
isEmpty
(
parameters
.
getTypeName
())
&&
!
isEmpty
(
parameters
.
getEntityFilters
()))
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
BAD_REQUEST
,
"EntityFilters specified without Type name"
);
}
if
(
StringUtils
.
isEmpty
(
parameters
.
getClassification
())
&&
!
isEmpty
(
parameters
.
getTagFilters
()))
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
BAD_REQUEST
,
"TagFilters specified without tag name"
);
}
if
(
StringUtils
.
isEmpty
(
parameters
.
getTypeName
())
&&
StringUtils
.
isEmpty
(
parameters
.
getClassification
())
&&
StringUtils
.
isEmpty
(
parameters
.
getQuery
())
&&
StringUtils
.
isEmpty
(
parameters
.
getTermName
())
&&
isEmpty
(
parameters
.
getEntityFilters
())
&&
isEmpty
(
parameters
.
getTagFilters
()))
{
StringUtils
.
isEmpty
(
parameters
.
getQuery
())
&&
StringUtils
.
isEmpty
(
parameters
.
getTermName
()))
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
INVALID_SEARCH_PARAMS
);
}
...
...
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