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
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
57 deletions
+66
-57
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
+0
-0
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
This diff is collapsed.
Click to expand it.
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