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
8535e88c
Commit
8535e88c
authored
Jan 10, 2018
by
Madhan Neethiraj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2351: fixed V1 REST APIs to retain the format for date type attributes as in earlier versions
parent
9f0866c8
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
119 additions
and
103 deletions
+119
-103
AtlasBaseClient.java
...ommon/src/main/java/org/apache/atlas/AtlasBaseClient.java
+3
-5
AtlasJson.java
intg/src/main/java/org/apache/atlas/utils/AtlasJson.java
+33
-21
AdminResource.java
...in/java/org/apache/atlas/web/resources/AdminResource.java
+10
-8
EntityResource.java
...n/java/org/apache/atlas/web/resources/EntityResource.java
+53
-46
TypesResource.java
...in/java/org/apache/atlas/web/resources/TypesResource.java
+20
-23
No files found.
client/common/src/main/java/org/apache/atlas/AtlasBaseClient.java
View file @
8535e88c
...
...
@@ -348,9 +348,7 @@ public abstract class AtlasBaseClient {
clientResponse
=
requestBuilder
.
method
(
api
.
getMethod
(),
ClientResponse
.
class
,
requestObject
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"API {} returned status {}"
,
resource
.
getURI
(),
clientResponse
.
getStatus
());
}
LOG
.
info
(
"HTTP Status : {}"
,
clientResponse
.
getStatus
());
if
(
clientResponse
.
getStatus
()
==
api
.
getExpectedStatus
().
getStatusCode
())
{
if
(
responseType
==
null
)
{
...
...
@@ -361,7 +359,7 @@ public abstract class AtlasBaseClient {
String
stringEntity
=
clientResponse
.
getEntity
(
String
.
class
);
try
{
JsonNode
jsonObject
=
AtlasJson
.
parseToV1JsonNode
(
stringEntity
);
LOG
.
debug
(
"Response =
{}"
,
jsonObject
);
LOG
.
info
(
"Response :
{}"
,
jsonObject
);
LOG
.
info
(
"------------------------------------------------------"
);
return
(
T
)
jsonObject
;
}
catch
(
IOException
e
)
{
...
...
@@ -369,7 +367,7 @@ public abstract class AtlasBaseClient {
}
}
else
{
T
entity
=
clientResponse
.
getEntity
(
responseType
);
LOG
.
debug
(
"Response =
{}"
,
entity
);
LOG
.
info
(
"Response :
{}"
,
entity
);
LOG
.
info
(
"------------------------------------------------------"
);
return
entity
;
}
...
...
intg/src/main/java/org/apache/atlas/utils/AtlasJson.java
View file @
8535e88c
...
...
@@ -97,14 +97,18 @@ public class AtlasJson {
}
public
static
<
T
>
T
fromJson
(
String
jsonStr
,
Class
<
T
>
type
)
{
T
ret
;
try
{
ret
=
mapper
.
readValue
(
jsonStr
,
type
);
}
catch
(
IOException
e
){
LOG
.
error
(
"AtlasType.fromJson()"
,
e
);
T
ret
=
null
;
ret
=
null
;
if
(
jsonStr
!=
null
)
{
try
{
ret
=
mapper
.
readValue
(
jsonStr
,
type
);
}
catch
(
IOException
e
)
{
LOG
.
error
(
"AtlasType.fromJson()"
,
e
);
ret
=
null
;
}
}
return
ret
;
}
...
...
@@ -121,30 +125,38 @@ public class AtlasJson {
}
public
static
<
T
>
T
fromV1Json
(
String
jsonStr
,
Class
<
T
>
type
)
{
T
ret
;
try
{
ret
=
mapperV1
.
readValue
(
jsonStr
,
type
);
T
ret
=
null
;
if
(
ret
instanceof
Struct
)
{
((
Struct
)
ret
).
normalize
();
}
}
catch
(
IOException
e
){
LOG
.
error
(
"AtlasType.fromV1Json()"
,
e
);
if
(
jsonStr
!=
null
)
{
try
{
ret
=
mapperV1
.
readValue
(
jsonStr
,
type
);
ret
=
null
;
if
(
ret
instanceof
Struct
)
{
((
Struct
)
ret
).
normalize
();
}
}
catch
(
IOException
e
)
{
LOG
.
error
(
"AtlasType.fromV1Json()"
,
e
);
ret
=
null
;
}
}
return
ret
;
}
public
static
<
T
>
T
fromV1Json
(
String
jsonStr
,
TypeReference
<
T
>
type
)
{
T
ret
;
try
{
ret
=
mapperV1
.
readValue
(
jsonStr
,
type
);
}
catch
(
IOException
e
){
LOG
.
error
(
"AtlasType.toV1Json()"
,
e
);
T
ret
=
null
;
ret
=
null
;
if
(
jsonStr
!=
null
)
{
try
{
ret
=
mapperV1
.
readValue
(
jsonStr
,
type
);
}
catch
(
IOException
e
)
{
LOG
.
error
(
"AtlasType.toV1Json()"
,
e
);
ret
=
null
;
}
}
return
ret
;
}
...
...
webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java
View file @
8535e88c
...
...
@@ -18,7 +18,6 @@
package
org
.
apache
.
atlas
.
web
.
resources
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
import
com.sun.jersey.multipart.FormDataParam
;
import
org.apache.atlas.ApplicationProperties
;
import
org.apache.atlas.AtlasClient
;
...
...
@@ -75,7 +74,10 @@ import javax.ws.rs.core.Response;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.HashSet
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.concurrent.locks.ReentrantLock
;
...
...
@@ -186,7 +188,7 @@ public class AdminResource {
try
{
PropertiesConfiguration
configProperties
=
new
PropertiesConfiguration
(
"atlas-buildinfo.properties"
);
ObjectNode
response
=
AtlasJson
.
createV1ObjectNode
();
Map
<
String
,
Object
>
response
=
new
HashMap
<
String
,
Object
>
();
response
.
put
(
"Version"
,
configProperties
.
getString
(
"build.version"
,
"UNKNOWN"
));
response
.
put
(
"Name"
,
configProperties
.
getString
(
"project.name"
,
"apache-atlas"
));
response
.
put
(
"Description"
,
configProperties
.
getString
(
"project.description"
,
...
...
@@ -194,7 +196,7 @@ public class AdminResource {
// todo: add hadoop version?
// response.put("Hadoop", VersionInfo.getVersion() + "-r" + VersionInfo.getRevision());
version
=
Response
.
ok
(
response
).
build
();
version
=
Response
.
ok
(
AtlasJson
.
toV1Json
(
response
)
).
build
();
}
catch
(
ConfigurationException
e
)
{
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
...
...
@@ -215,8 +217,8 @@ public class AdminResource {
LOG
.
debug
(
"==> AdminResource.getStatus()"
);
}
ObjectNode
responseData
=
AtlasJson
.
createV1ObjectNode
(
AtlasClient
.
STATUS
,
serviceState
.
getState
().
toString
());
Response
response
=
Response
.
ok
(
responseData
).
build
();
Map
<
String
,
Object
>
responseData
=
Collections
.
singletonMap
(
AtlasClient
.
STATUS
,
serviceState
.
getState
().
toString
());
Response
response
=
Response
.
ok
(
AtlasJson
.
toV1Json
(
responseData
)
).
build
();
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"<== AdminResource.getStatus()"
);
...
...
@@ -253,7 +255,7 @@ public class AdminResource {
AtlasActionTypes
.
CREATE
,
userName
,
groups
,
httpServletRequest
);
}
ObjectNode
responseData
=
AtlasJson
.
createV1ObjectNode
();
Map
<
String
,
Object
>
responseData
=
new
HashMap
<>
();
responseData
.
put
(
isCSRF_ENABLED
,
AtlasCSRFPreventionFilter
.
isCSRF_ENABLED
);
responseData
.
put
(
BROWSER_USER_AGENT_PARAM
,
AtlasCSRFPreventionFilter
.
BROWSER_USER_AGENTS_DEFAULT
);
...
...
@@ -263,9 +265,9 @@ public class AdminResource {
responseData
.
put
(
isEntityCreateAllowed
,
isEntityCreateAccessAllowed
);
responseData
.
put
(
editableEntityTypes
,
getEditableEntityTypes
(
atlasProperties
));
responseData
.
put
(
"userName"
,
userName
);
responseData
.
put
(
"groups"
,
AtlasJson
.
createV1ArrayNode
(
groups
)
);
responseData
.
put
(
"groups"
,
groups
);
response
=
Response
.
ok
(
responseData
).
build
();
response
=
Response
.
ok
(
AtlasJson
.
toV1Json
(
responseData
)
).
build
();
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"<== AdminResource.getUserProfile()"
);
...
...
webapp/src/main/java/org/apache/atlas/web/resources/EntityResource.java
View file @
8535e88c
...
...
@@ -19,7 +19,6 @@
package
org
.
apache
.
atlas
.
web
.
resources
;
import
com.fasterxml.jackson.databind.node.ArrayNode
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
import
com.google.common.annotations.VisibleForTesting
;
import
com.google.common.base.Preconditions
;
import
org.apache.atlas.AtlasClient
;
...
...
@@ -149,7 +148,7 @@ public class EntityResource {
jsonStrings
=
new
String
[
jsonEntities
.
size
()];
for
(
int
i
=
0
;
i
<
jsonEntities
.
size
();
i
++)
{
jsonStrings
[
i
]
=
jsonEntities
.
get
(
i
).
textValue
(
);
jsonStrings
[
i
]
=
AtlasJson
.
toV1Json
(
jsonEntities
.
get
(
i
)
);
}
}
catch
(
IOException
e
)
{
jsonStrings
=
new
String
[
1
];
...
...
@@ -172,8 +171,8 @@ public class EntityResource {
final
CreateUpdateEntitiesResult
result
=
restAdapters
.
toCreateUpdateEntitiesResult
(
mutationResponse
);
ObjectNode
response
=
getResponse
(
result
);
URI
locationURI
=
getLocationURI
(
guids
);
String
response
=
getResponse
(
result
);
URI
locationURI
=
getLocationURI
(
guids
);
return
Response
.
created
(
locationURI
).
entity
(
response
).
build
();
...
...
@@ -215,28 +214,32 @@ public class EntityResource {
return
locationURI
;
}
private
ObjectNode
getResponse
(
EntityResult
entityResult
)
throws
AtlasBaseException
,
AtlasException
{
private
String
getResponse
(
EntityResult
entityResult
)
throws
AtlasBaseException
,
AtlasException
{
CreateUpdateEntitiesResult
result
=
new
CreateUpdateEntitiesResult
();
result
.
setEntityResult
(
entityResult
);
return
getResponse
(
result
);
}
private
ObjectNode
getResponse
(
CreateUpdateEntitiesResult
result
)
throws
AtlasBaseException
,
AtlasException
{
ObjectNode
response
=
AtlasJson
.
createV1ObjectNode
();
EntityResult
entityResult
=
result
.
getEntityResult
();
GuidMapping
mapping
=
result
.
getGuidMapping
();
response
.
putPOJO
(
AtlasClient
.
REQUEST_ID
,
Servlets
.
getRequestId
());
private
String
getResponse
(
CreateUpdateEntitiesResult
result
)
throws
AtlasBaseException
,
AtlasException
{
Map
<
String
,
Object
>
response
=
new
HashMap
<>();
EntityResult
entityResult
=
result
.
getEntityResult
();
GuidMapping
mapping
=
result
.
getGuidMapping
();
response
.
put
(
AtlasClient
.
REQUEST_ID
,
Servlets
.
getRequestId
());
if
(
entityResult
!=
null
)
{
response
.
putPOJO
(
AtlasClient
.
ENTITIES
,
entityResult
.
getEntities
());
response
.
put
(
AtlasClient
.
ENTITIES
,
entityResult
.
getEntities
());
String
sampleEntityId
=
getSample
(
result
.
getEntityResult
());
if
(
sampleEntityId
!=
null
)
{
response
.
put
POJO
(
AtlasClient
.
DEFINITION
,
getEntity
(
sampleEntityId
));
response
.
put
(
AtlasClient
.
DEFINITION
,
getEntity
(
sampleEntityId
));
}
}
if
(
mapping
!=
null
)
{
response
.
put
POJO
(
AtlasClient
.
GUID_ASSIGNMENTS
,
mapping
);
response
.
put
(
AtlasClient
.
GUID_ASSIGNMENTS
,
mapping
);
}
return
response
;
return
AtlasJson
.
toV1Json
(
response
)
;
}
/**
...
...
@@ -284,7 +287,7 @@ public class EntityResource {
LOG
.
debug
(
"Updated entities: {}"
,
result
.
getEntityResult
());
}
ObjectNode
response
=
getResponse
(
result
);
String
response
=
getResponse
(
result
);
return
Response
.
ok
(
response
).
build
();
}
catch
(
AtlasBaseException
e
)
{
LOG
.
error
(
"Unable to persist entity instance entityDef={}"
,
entityJson
,
e
);
...
...
@@ -386,7 +389,7 @@ public class EntityResource {
LOG
.
debug
(
"Updated entities: {}"
,
result
.
getEntityResult
());
}
ObjectNode
response
=
getResponse
(
result
);
String
response
=
getResponse
(
result
);
return
Response
.
ok
(
response
).
build
();
}
catch
(
AtlasBaseException
e
)
{
LOG
.
error
(
"Unable to partially update entity {} {}:{}.{}"
,
entityJson
,
entityType
,
attribute
,
value
,
e
);
...
...
@@ -475,7 +478,7 @@ public class EntityResource {
LOG
.
debug
(
"Updated entities: {}"
,
result
.
getEntityResult
());
}
ObjectNode
response
=
getResponse
(
result
);
String
response
=
getResponse
(
result
);
return
Response
.
ok
(
response
).
build
();
}
catch
(
AtlasBaseException
e
)
{
LOG
.
error
(
"Unable to update entity by GUID {} {} "
,
guid
,
entityJson
,
e
);
...
...
@@ -520,7 +523,7 @@ public class EntityResource {
LOG
.
debug
(
"Updated entities: {}"
,
result
.
getEntityResult
());
}
ObjectNode
response
=
getResponse
(
result
);
String
response
=
getResponse
(
result
);
return
Response
.
ok
(
response
).
build
();
}
catch
(
AtlasBaseException
e
)
{
LOG
.
error
(
"Unable to add property {} to entity id {} {} "
,
property
,
guid
,
value
,
e
);
...
...
@@ -590,7 +593,7 @@ public class EntityResource {
LOG
.
debug
(
"Deleted entity result: {}"
,
entityResult
);
}
ObjectNode
response
=
getResponse
(
entityResult
);
String
response
=
getResponse
(
entityResult
);
return
Response
.
ok
(
response
).
build
();
}
catch
(
AtlasBaseException
e
)
{
LOG
.
error
(
"Unable to delete entities {} {} {} {} "
,
guids
,
entityType
,
attribute
,
value
,
e
);
...
...
@@ -640,18 +643,20 @@ public class EntityResource {
Referenceable
entity
=
getEntity
(
guid
);
ObjectNode
response
=
AtlasJson
.
createV1ObjectNode
(
AtlasClient
.
REQUEST_ID
,
Servlets
.
getRequestId
());
Map
<
String
,
Object
>
response
=
new
HashMap
<>();
response
.
put
(
AtlasClient
.
REQUEST_ID
,
Servlets
.
getRequestId
());
Response
.
Status
status
=
Response
.
Status
.
NOT_FOUND
;
if
(
entity
!=
null
)
{
response
.
put
POJO
(
AtlasClient
.
DEFINITION
,
entity
);
response
.
put
(
AtlasClient
.
DEFINITION
,
entity
);
status
=
Response
.
Status
.
OK
;
}
else
{
response
.
put
(
AtlasClient
.
ERROR
,
Servlets
.
escapeJsonString
(
String
.
format
(
"An entity with GUID={%s} does not exist"
,
guid
)));
}
return
Response
.
status
(
status
).
entity
(
response
).
build
();
return
Response
.
status
(
status
).
entity
(
AtlasJson
.
toV1Json
(
response
)
).
build
();
}
catch
(
IllegalArgumentException
e
)
{
LOG
.
error
(
"Bad GUID={} "
,
guid
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
));
...
...
@@ -688,13 +693,13 @@ public class EntityResource {
List
<
String
>
entityGUIDS
=
entitiesStore
.
getEntityGUIDS
(
entityType
);
ObjectNode
response
=
AtlasJson
.
createV1ObjectNode
();
Map
<
String
,
Object
>
response
=
new
HashMap
<>
();
response
.
put
(
AtlasClient
.
REQUEST_ID
,
Servlets
.
getRequestId
());
response
.
put
(
AtlasClient
.
TYPENAME
,
entityType
);
response
.
put
POJO
(
AtlasClient
.
RESULTS
,
entityGUIDS
);
response
.
put
(
AtlasClient
.
RESULTS
,
entityGUIDS
);
response
.
put
(
AtlasClient
.
COUNT
,
entityGUIDS
.
size
());
return
Response
.
ok
(
response
).
build
();
return
Response
.
ok
(
AtlasJson
.
toV1Json
(
response
)
).
build
();
}
catch
(
NullPointerException
e
)
{
LOG
.
error
(
"Entity type cannot be null"
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
));
...
...
@@ -780,19 +785,20 @@ public class EntityResource {
entity
=
restAdapters
.
getReferenceable
(
entityInfo
);
}
ObjectNode
response
=
AtlasJson
.
createV1ObjectNode
(
AtlasClient
.
REQUEST_ID
,
Servlets
.
getRequestId
());
Map
<
String
,
Object
>
response
=
new
HashMap
<>();
response
.
put
(
AtlasClient
.
REQUEST_ID
,
Servlets
.
getRequestId
());
Response
.
Status
status
=
Response
.
Status
.
NOT_FOUND
;
if
(
entity
!=
null
)
{
response
.
put
POJO
(
AtlasClient
.
DEFINITION
,
entity
);
response
.
put
(
AtlasClient
.
DEFINITION
,
entity
);
status
=
Response
.
Status
.
OK
;
}
else
{
response
.
put
(
AtlasClient
.
ERROR
,
Servlets
.
escapeJsonString
(
String
.
format
(
"An entity with type={%s}, "
+
"qualifiedName={%s} does not exist"
,
entityType
,
value
)));
}
return
Response
.
status
(
status
).
entity
(
response
).
build
();
return
Response
.
status
(
status
).
entity
(
AtlasJson
.
toV1Json
(
response
)).
build
();
}
catch
(
AtlasBaseException
e
)
{
LOG
.
error
(
"Unable to get instance definition for type={}, qualifiedName={}"
,
entityType
,
value
,
e
);
throw
toWebApplicationException
(
e
);
...
...
@@ -842,12 +848,12 @@ public class EntityResource {
traitNames
.
add
(
classification
.
getTypeName
());
}
ObjectNode
response
=
AtlasJson
.
createV1ObjectNode
();
Map
<
String
,
Object
>
response
=
new
HashMap
<>
();
response
.
put
(
AtlasClient
.
REQUEST_ID
,
Servlets
.
getRequestId
());
response
.
put
POJO
(
AtlasClient
.
RESULTS
,
traitNames
);
response
.
put
(
AtlasClient
.
RESULTS
,
traitNames
);
response
.
put
(
AtlasClient
.
COUNT
,
traitNames
.
size
());
return
Response
.
ok
(
response
).
build
();
return
Response
.
ok
(
AtlasJson
.
toV1Json
(
response
)
).
build
();
}
catch
(
AtlasBaseException
e
)
{
LOG
.
error
(
"Unable to get trait definition for entity {}"
,
guid
,
e
);
throw
toWebApplicationException
(
e
);
...
...
@@ -893,18 +899,18 @@ public class EntityResource {
final
List
<
AtlasClassification
>
classifications
=
entitiesStore
.
getClassifications
(
guid
);
ArrayNode
traits
=
AtlasJson
.
createV1ArrayNode
(
);
List
<
Struct
>
traits
=
new
ArrayList
<>(
classifications
.
size
()
);
for
(
AtlasClassification
classification
:
classifications
)
{
Struct
trait
=
restAdapters
.
getTrait
(
classification
);
traits
.
add
POJO
(
trait
);
traits
.
add
(
trait
);
}
ObjectNode
response
=
AtlasJson
.
createV1ObjectNode
();
Map
<
String
,
Object
>
response
=
new
HashMap
<>
();
response
.
put
(
AtlasClient
.
REQUEST_ID
,
Servlets
.
getRequestId
());
response
.
put
(
AtlasClient
.
RESULTS
,
traits
);
response
.
put
(
AtlasClient
.
COUNT
,
traits
.
size
());
return
Response
.
ok
(
response
).
build
();
return
Response
.
ok
(
AtlasJson
.
toV1Json
(
response
)
).
build
();
}
catch
(
AtlasBaseException
e
)
{
LOG
.
error
(
"Unable to get trait definition for entity {}"
,
guid
,
e
);
throw
toWebApplicationException
(
e
);
...
...
@@ -955,11 +961,11 @@ public class EntityResource {
Struct
traitDefinition
=
restAdapters
.
getTrait
(
classification
);
ObjectNode
response
=
AtlasJson
.
createV1ObjectNode
();
Map
<
String
,
Object
>
response
=
new
HashMap
<>
();
response
.
put
(
AtlasClient
.
REQUEST_ID
,
Servlets
.
getRequestId
());
response
.
put
POJO
(
AtlasClient
.
RESULTS
,
traitDefinition
);
response
.
put
(
AtlasClient
.
RESULTS
,
traitDefinition
);
return
Response
.
ok
(
response
).
build
();
return
Response
.
ok
(
AtlasJson
.
toV1Json
(
response
)
).
build
();
}
catch
(
AtlasBaseException
e
)
{
LOG
.
error
(
"Unable to get trait definition for entity {} and trait {}"
,
guid
,
traitName
,
e
);
...
...
@@ -1019,9 +1025,10 @@ public class EntityResource {
add
(
guid
);
}});
ObjectNode
response
=
AtlasJson
.
createV1ObjectNode
(
AtlasClient
.
REQUEST_ID
,
Servlets
.
getRequestId
());
Map
<
String
,
Object
>
response
=
new
HashMap
<>();
response
.
put
(
AtlasClient
.
REQUEST_ID
,
Servlets
.
getRequestId
());
return
Response
.
created
(
locationURI
).
entity
(
response
).
build
();
return
Response
.
created
(
locationURI
).
entity
(
AtlasJson
.
toV1Json
(
response
)
).
build
();
}
catch
(
AtlasBaseException
e
)
{
LOG
.
error
(
"Unable to add trait for entity={} traitDef={}"
,
guid
,
traitDefinition
,
e
);
throw
toWebApplicationException
(
e
);
...
...
@@ -1072,11 +1079,11 @@ public class EntityResource {
entitiesStore
.
deleteClassifications
(
guid
,
new
ArrayList
<
String
>()
{{
add
(
traitName
);
}});
ObjectNode
response
=
AtlasJson
.
createV1ObjectNode
();
Map
<
String
,
Object
>
response
=
new
HashMap
<>
();
response
.
put
(
AtlasClient
.
REQUEST_ID
,
Servlets
.
getRequestId
());
response
.
put
(
TRAIT_NAME
,
traitName
);
return
Response
.
ok
(
response
).
build
();
return
Response
.
ok
(
AtlasJson
.
toV1Json
(
response
)
).
build
();
}
catch
(
AtlasBaseException
e
)
{
LOG
.
error
(
"Unable to delete trait name={} for entity={}"
,
traitName
,
guid
,
e
);
throw
toWebApplicationException
(
e
);
...
...
@@ -1130,10 +1137,10 @@ public class EntityResource {
List
<
EntityAuditEvent
>
events
=
entityAuditRepository
.
listEvents
(
guid
,
startKey
,
count
);
ObjectNode
response
=
AtlasJson
.
createV1ObjectNode
();
Map
<
String
,
Object
>
response
=
new
HashMap
<>
();
response
.
put
(
AtlasClient
.
REQUEST_ID
,
Servlets
.
getRequestId
());
response
.
put
POJO
(
AtlasClient
.
EVENTS
,
events
);
return
Response
.
ok
(
response
).
build
();
response
.
put
(
AtlasClient
.
EVENTS
,
events
);
return
Response
.
ok
(
AtlasJson
.
toV1Json
(
response
)
).
build
();
}
catch
(
IllegalArgumentException
e
)
{
LOG
.
error
(
"Unable to get audit events for entity guid={} startKey={}"
,
guid
,
startKey
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
));
...
...
webapp/src/main/java/org/apache/atlas/web/resources/TypesResource.java
View file @
8535e88c
...
...
@@ -18,8 +18,6 @@
package
org
.
apache
.
atlas
.
web
.
resources
;
import
com.fasterxml.jackson.databind.node.ArrayNode
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
import
com.sun.jersey.api.client.ClientResponse
;
import
com.sun.jersey.api.core.ResourceContext
;
import
org.apache.atlas.AtlasClient
;
...
...
@@ -52,7 +50,11 @@ import javax.ws.rs.WebApplicationException;
import
javax.ws.rs.core.Context
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.Response
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* This class provides RESTful API for Types.
...
...
@@ -101,8 +103,6 @@ public class TypesResource {
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"TypesResource.submit()"
);
}
ArrayNode
typesResponse
=
AtlasJson
.
createV1ArrayNode
();
try
{
final
String
typeDefinition
=
Servlets
.
getRequestPayload
(
request
);
...
...
@@ -113,17 +113,16 @@ public class TypesResource {
AtlasTypesDef
createTypesDef
=
TypeConverterUtil
.
toAtlasTypesDef
(
typeDefinition
,
typeRegistry
);
AtlasTypesDef
createdTypesDef
=
typesREST
.
createAtlasTypeDefs
(
createTypesDef
);
List
<
String
>
typeNames
=
TypeConverterUtil
.
getTypeNames
(
createdTypesDef
);
List
<
Map
<
String
,
Object
>>
typesResponse
=
new
ArrayList
<>(
typeNames
.
size
());
for
(
int
i
=
0
;
i
<
typeNames
.
size
();
i
++)
{
ObjectNode
typeNode
=
AtlasJson
.
createV1ObjectNode
(
AtlasClient
.
NAME
,
typeNames
.
get
(
i
));
typesResponse
.
add
(
typeNode
);
for
(
String
typeName
:
typeNames
)
{
typesResponse
.
add
(
Collections
.
singletonMap
(
AtlasClient
.
NAME
,
typeName
));
}
ObjectNode
response
=
AtlasJson
.
createV1ObjectNode
();
Map
<
String
,
Object
>
response
=
new
HashMap
<>
();
response
.
put
(
AtlasClient
.
REQUEST_ID
,
Servlets
.
getRequestId
());
response
.
put
(
AtlasClient
.
TYPES
,
typesResponse
);
return
Response
.
status
(
ClientResponse
.
Status
.
CREATED
).
entity
(
response
).
build
();
return
Response
.
status
(
ClientResponse
.
Status
.
CREATED
).
entity
(
AtlasJson
.
toV1Json
(
response
)
).
build
();
}
catch
(
AtlasBaseException
e
)
{
LOG
.
error
(
"Type creation failed"
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
));
...
...
@@ -168,7 +167,6 @@ public class TypesResource {
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"TypesResource.update()"
);
}
ArrayNode
typesResponse
=
AtlasJson
.
createV1ArrayNode
();
try
{
final
String
typeDefinition
=
Servlets
.
getRequestPayload
(
request
);
...
...
@@ -179,17 +177,16 @@ public class TypesResource {
AtlasTypesDef
updateTypesDef
=
TypeConverterUtil
.
toAtlasTypesDef
(
typeDefinition
,
typeRegistry
);
AtlasTypesDef
updatedTypesDef
=
typeDefStore
.
createUpdateTypesDef
(
updateTypesDef
);
List
<
String
>
typeNames
=
TypeConverterUtil
.
getTypeNames
(
updatedTypesDef
);
List
<
Map
<
String
,
Object
>>
typesResponse
=
new
ArrayList
<>(
typeNames
.
size
());
for
(
int
i
=
0
;
i
<
typeNames
.
size
();
i
++)
{
ObjectNode
typeNode
=
AtlasJson
.
createV1ObjectNode
(
AtlasClient
.
NAME
,
typeNames
.
get
(
i
));
typesResponse
.
add
(
typeNode
);
for
(
String
typeName
:
typeNames
)
{
typesResponse
.
add
(
Collections
.
singletonMap
(
AtlasClient
.
NAME
,
typeName
));
}
ObjectNode
response
=
AtlasJson
.
createV1ObjectNode
();
Map
<
String
,
Object
>
response
=
new
HashMap
<>
();
response
.
put
(
AtlasClient
.
REQUEST_ID
,
Servlets
.
getRequestId
());
response
.
put
(
AtlasClient
.
TYPES
,
typesResponse
);
return
Response
.
ok
().
entity
(
response
).
build
();
return
Response
.
ok
().
entity
(
AtlasJson
.
toV1Json
(
response
)
).
build
();
}
catch
(
AtlasBaseException
e
)
{
LOG
.
error
(
"Unable to persist types"
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
));
...
...
@@ -230,16 +227,16 @@ public class TypesResource {
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"TypesResource.getDefinition("
+
typeName
+
")"
);
}
ObjectNode
response
=
AtlasJson
.
createV1ObjectNode
();
Map
<
String
,
Object
>
response
=
new
HashMap
<>
();
try
{
TypesDef
typesDef
=
TypeConverterUtil
.
toTypesDef
(
typeRegistry
.
getType
(
typeName
),
typeRegistry
);;
response
.
put
(
AtlasClient
.
TYPENAME
,
typeName
);
response
.
put
POJO
(
AtlasClient
.
DEFINITION
,
typesDef
);
response
.
put
(
AtlasClient
.
DEFINITION
,
typesDef
);
response
.
put
(
AtlasClient
.
REQUEST_ID
,
Servlets
.
getRequestId
());
return
Response
.
ok
(
response
).
build
();
return
Response
.
ok
(
AtlasJson
.
toV1Json
(
response
)
).
build
();
}
catch
(
AtlasBaseException
e
)
{
LOG
.
error
(
"Unable to get type definition for type {}"
,
typeName
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
));
...
...
@@ -288,15 +285,15 @@ public class TypesResource {
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"TypesResource.getTypesByFilter("
+
typeCategory
+
", "
+
supertype
+
", "
+
notsupertype
+
")"
);
}
ObjectNode
response
=
AtlasJson
.
createV1ObjectNode
();
Map
<
String
,
Object
>
response
=
new
HashMap
<>
();
try
{
List
<
String
>
result
=
TypeConverterUtil
.
getTypeNames
(
typesREST
.
getTypeDefHeaders
(
request
));
response
.
put
POJO
(
AtlasClient
.
RESULTS
,
result
);
response
.
put
(
AtlasClient
.
RESULTS
,
result
);
response
.
put
(
AtlasClient
.
COUNT
,
result
.
size
());
response
.
put
(
AtlasClient
.
REQUEST_ID
,
Servlets
.
getRequestId
());
return
Response
.
ok
(
response
).
build
();
return
Response
.
ok
(
AtlasJson
.
toV1Json
(
response
)
).
build
();
}
catch
(
AtlasBaseException
e
)
{
LOG
.
warn
(
"TypesREST exception: {} {}"
,
e
.
getClass
().
getSimpleName
(),
e
.
getMessage
());
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
));
...
...
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