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
d97a7236
Commit
d97a7236
authored
Jan 27, 2015
by
Dan Markwat
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/hortonworks/metadata.git
parents
c7218046
7828bdf5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
21 deletions
+23
-21
MetadataDiscoveryResource.java
...oop/metadata/web/resources/MetadataDiscoveryResource.java
+17
-16
MetadataDiscoveryResourceIT.java
...p/metadata/web/resources/MetadataDiscoveryResourceIT.java
+6
-5
No files found.
webapp/src/main/java/org/apache/hadoop/metadata/web/resources/MetadataDiscoveryResource.java
View file @
d97a7236
...
...
@@ -26,9 +26,9 @@ import com.tinkerpop.blueprints.Edge;
import
com.tinkerpop.blueprints.Graph
;
import
com.tinkerpop.blueprints.Vertex
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.hadoop.metadata.MetadataException
;
import
org.apache.hadoop.metadata.discovery.DiscoveryService
;
import
org.apache.hadoop.metadata.repository.graph.GraphHelper
;
import
org.apache.hadoop.metadata.repository.graph.GraphService
;
import
org.apache.hadoop.metadata.types.TypeSystem
;
import
org.apache.hadoop.metadata.web.util.Servlets
;
...
...
@@ -154,25 +154,30 @@ public class MetadataDiscoveryResource {
// Parent JSON Object
JSONObject
response
=
new
JSONObject
();
// HashMaps, which contain sub JOSN Objects to be relayed back to the parent.
HashMap
<
String
,
Map
<
String
,
String
>>
vertices
=
new
HashMap
<
String
,
Map
<
String
,
String
>>();
HashMap
<
String
,
Map
<
String
,
String
>>
edges
=
new
HashMap
<
String
,
Map
<
String
,
String
>>();
// Get the Vertex with the specified GUID.
for
(
Vertex
v:
getGraph
().
query
().
has
(
"guid"
,
guid
).
vertices
())
{
Vertex
v
=
GraphHelper
.
findVertexByGUID
(
getGraph
(),
guid
);
if
(
v
!=
null
)
{
searchWalker
(
v
,
depth
,
0
,
edges
,
vertices
,
edgesToFollow
);
LOG
.
debug
(
"Vertex {} found for guid {}"
,
v
,
guid
);
}
else
{
LOG
.
debug
(
"Vertex not found for guid {}"
,
guid
);
}
try
{
response
.
put
(
"requestId"
,
Thread
.
currentThread
().
getName
());
response
.
put
(
"vertices"
,
vertices
);
response
.
put
(
"edges"
,
edges
);
}
catch
(
JSONException
e
)
{
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
"Search: Error building JSON result set."
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
LOG
.
debug
(
"JSON result:"
+
response
.
toString
());
return
Response
.
ok
(
response
).
build
();
}
...
...
@@ -215,20 +220,26 @@ public class MetadataDiscoveryResource {
HashMap
<
String
,
Map
<
String
,
String
>>
vertices
=
new
HashMap
<
String
,
Map
<
String
,
String
>>();
HashMap
<
String
,
Map
<
String
,
String
>>
edges
=
new
HashMap
<
String
,
Map
<
String
,
String
>>();
int
resultCount
=
0
;
for
(
Vertex
v:
getGraph
().
query
().
has
(
prop
,
searchText
).
vertices
())
{
searchWalker
(
v
,
depth
,
0
,
edges
,
vertices
,
null
);
resultCount
++;
}
LOG
.
debug
(
"Search for {} returned {} results."
,
searchText
,
resultCount
);
try
{
response
.
put
(
"requestId"
,
Thread
.
currentThread
().
getName
());
response
.
put
(
"vertices"
,
vertices
);
response
.
put
(
"edges"
,
edges
);
}
catch
(
JSONException
e
)
{
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
"Search: Error building JSON result set."
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
LOG
.
debug
(
"JSON result:"
+
response
.
toString
());
return
Response
.
ok
(
response
).
build
();
}
...
...
@@ -305,15 +316,5 @@ public class MetadataDiscoveryResource {
}
private
static
void
validateInputs
(
String
errorMsg
,
String
...
inputs
)
{
for
(
String
input
:
inputs
)
{
if
(
StringUtils
.
isEmpty
(
input
))
{
throw
new
WebApplicationException
(
Response
.
status
(
Response
.
Status
.
BAD_REQUEST
)
.
entity
(
errorMsg
)
.
type
(
"text/plain"
)
.
build
());
}
}
}
}
webapp/src/test/java/org/apache/hadoop/metadata/web/resources/MetadataDiscoveryResourceIT.java
View file @
d97a7236
...
...
@@ -59,18 +59,19 @@ public class MetadataDiscoveryResourceIT extends BaseResourceIT {
}
@Test
(
dependsOnMethods
=
"test
UriExists"
,
enabled
=
false
)
public
void
testSearchFor
NonExistent
Text
()
throws
Exception
{
@Test
(
dependsOnMethods
=
"test
FullTextUriExists"
)
public
void
testSearchForText
()
throws
Exception
{
WebResource
resource
=
service
.
path
(
"api/metadata/discovery/search/fulltext"
)
.
queryParam
(
"depth"
,
"
0"
).
queryParam
(
"text"
,
"foo"
).
queryParam
(
"property"
,
"N
ame"
);
.
queryParam
(
"depth"
,
"
3"
).
queryParam
(
"text"
,
"bar"
).
queryParam
(
"property"
,
"hive_table.n
ame"
);
ClientResponse
clientResponse
=
resource
.
accept
(
MediaType
.
APPLICATION_JSON
)
.
type
(
MediaType
.
APPLICATION_JSON
)
.
method
(
HttpMethod
.
GET
,
ClientResponse
.
class
);
//TODO - Assure zero vertices and edges.
Assert
.
assertEquals
(
true
,
true
);
//TODO - Assure zero vertices and edges.
Assert
.
assertNotEquals
(
clientResponse
.
getStatus
(),
Response
.
Status
.
NOT_FOUND
.
getStatusCode
());
}
...
...
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