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
3f330194
Commit
3f330194
authored
Jan 04, 2018
by
Madhan Neethiraj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2321: fix V1 REST API for search to correctly handle empty results (#2)
parent
38159334
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
15 deletions
+4
-15
MetadataDiscoveryResource.java
...apache/atlas/web/resources/MetadataDiscoveryResource.java
+4
-15
No files found.
webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java
View file @
3f330194
...
...
@@ -23,7 +23,6 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
import
com.google.common.base.Preconditions
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.AtlasConfiguration
;
import
org.apache.atlas.classification.InterfaceAudience
;
import
org.apache.atlas.discovery.AtlasDiscoveryService
;
import
org.apache.atlas.model.discovery.AtlasSearchResult
;
import
org.apache.atlas.query.QueryParams
;
...
...
@@ -49,9 +48,6 @@ import javax.ws.rs.QueryParam;
import
javax.ws.rs.WebApplicationException
;
import
javax.ws.rs.core.Response
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
/**
* Jersey Resource for metadata operations.
...
...
@@ -65,13 +61,9 @@ public class MetadataDiscoveryResource {
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
MetadataDiscoveryResource
.
class
);
private
static
final
Logger
PERF_LOG
=
AtlasPerfTracer
.
getPerfLogger
(
"rest.MetadataDiscoveryResource"
);
private
static
final
String
QUERY_TYPE_DSL
=
"dsl"
;
private
static
final
String
QUERY_TYPE_GREMLIN
=
"gremlin"
;
private
static
final
String
QUERY_TYPE_FULLTEXT
=
"full-text"
;
private
static
final
String
LIMIT_OFFSET_DEFAULT
=
"-1"
;
private
final
boolean
gremlinSearchEnabled
;
private
static
Configuration
applicationProperties
=
null
;
private
static
final
String
ENABLE_GREMLIN_SEARCH_PROPERTY
=
"atlas.search.gremlin.enable"
;
private
final
AtlasDiscoveryService
atlasDiscoveryService
;
/**
...
...
@@ -83,8 +75,6 @@ public class MetadataDiscoveryResource {
@Inject
public
MetadataDiscoveryResource
(
AtlasDiscoveryService
atlasDiscoveryService
,
Configuration
configuration
)
{
this
.
atlasDiscoveryService
=
atlasDiscoveryService
;
applicationProperties
=
configuration
;
gremlinSearchEnabled
=
applicationProperties
!=
null
&&
applicationProperties
.
getBoolean
(
ENABLE_GREMLIN_SEARCH_PROPERTY
,
false
);
}
/**
...
...
@@ -156,7 +146,7 @@ public class MetadataDiscoveryResource {
dslQuery
=
ParamChecker
.
notEmpty
(
dslQuery
,
"dslQuery cannot be null"
);
QueryParams
queryParams
=
validateQueryParams
(
limit
,
offset
);
AtlasSearchResult
result
=
atlasDiscoveryService
.
searchUsingDslQuery
(
dslQuery
,
queryParams
.
limit
(),
queryParams
.
offset
());
final
String
jsonResultStr
=
AtlasType
.
toJson
(
result
.
getEntities
());
final
String
jsonResultStr
=
result
.
getEntities
()
==
null
?
null
:
AtlasType
.
toJson
(
result
.
getEntities
());
ObjectNode
response
=
new
DSLJSONResponseBuilder
().
results
(
jsonResultStr
).
query
(
dslQuery
).
build
();
...
...
@@ -229,10 +219,9 @@ public class MetadataDiscoveryResource {
query
=
ParamChecker
.
notEmpty
(
query
,
"query cannot be null or empty"
);
QueryParams
queryParams
=
validateQueryParams
(
limit
,
offset
);
AtlasSearchResult
result
=
atlasDiscoveryService
.
searchUsingFullTextQuery
(
query
,
false
,
queryParams
.
limit
(),
queryParams
.
offset
());
final
String
jsonResultStr
=
AtlasType
.
toJson
(
result
.
getEntities
());
ArrayNode
rowsJsonArr
=
AtlasJson
.
parseToV1ArrayNode
(
jsonResultStr
);
final
String
jsonResultStr
=
result
.
getFullTextResult
()
==
null
?
null
:
AtlasType
.
toJson
(
result
.
getFullTextResult
());
ObjectNode
response
=
new
FullTextJSonResponseBuilder
().
results
(
rowsJsonAr
r
).
query
(
query
).
build
();
ObjectNode
response
=
new
FullTextJSonResponseBuilder
().
results
(
jsonResultSt
r
).
query
(
query
).
build
();
return
Response
.
ok
(
response
).
build
();
}
catch
(
IllegalArgumentException
e
)
{
LOG
.
error
(
"Unable to get entity list for query {}"
,
query
,
e
);
...
...
@@ -332,7 +321,7 @@ public class MetadataDiscoveryResource {
}
public
FullTextJSonResponseBuilder
results
(
String
dslResults
)
throws
IOException
{
return
results
(
AtlasJson
.
parseToV1ArrayNode
(
dslResults
));
return
results
(
StringUtils
.
isEmpty
(
dslResults
)
?
AtlasJson
.
createV1ArrayNode
()
:
AtlasJson
.
parseToV1ArrayNode
(
dslResults
));
}
public
FullTextJSonResponseBuilder
()
{
...
...
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