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
8cd6a644
Commit
8cd6a644
authored
8 years ago
by
Vimal Sharma
Committed by
Madhan Neethiraj
8 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1566: replace GSON ser-de with ObjectMapper ser-de
Signed-off-by:
Madhan Neethiraj
<
madhan@apache.org
>
parent
ea38942b
master
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
14 deletions
+53
-14
AtlasClient.java
client/src/main/java/org/apache/atlas/AtlasClient.java
+27
-0
AtlasType.java
intg/src/main/java/org/apache/atlas/type/AtlasType.java
+21
-7
release-log.txt
release-log.txt
+1
-0
TestEntitiesREST.java
.../java/org/apache/atlas/web/adapters/TestEntitiesREST.java
+4
-7
No files found.
client/src/main/java/org/apache/atlas/AtlasClient.java
View file @
8cd6a644
...
...
@@ -35,6 +35,10 @@ import org.apache.atlas.typesystem.types.utils.TypesUtil;
import
org.apache.commons.configuration.Configuration
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.hadoop.security.UserGroupInformation
;
import
org.codehaus.jackson.annotate.JsonAutoDetect
;
import
org.codehaus.jackson.annotate.JsonIgnore
;
import
org.codehaus.jackson.annotate.JsonIgnoreProperties
;
import
org.codehaus.jackson.map.annotate.JsonSerialize
;
import
org.codehaus.jettison.json.JSONArray
;
import
org.codehaus.jettison.json.JSONException
;
import
org.codehaus.jettison.json.JSONObject
;
...
...
@@ -44,6 +48,9 @@ import org.slf4j.LoggerFactory;
import
javax.ws.rs.HttpMethod
;
import
javax.ws.rs.core.MultivaluedMap
;
import
javax.ws.rs.core.Response
;
import
javax.xml.bind.annotation.XmlAccessType
;
import
javax.xml.bind.annotation.XmlAccessorType
;
import
javax.xml.bind.annotation.XmlRootElement
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collection
;
...
...
@@ -51,6 +58,9 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.Map
;
import
static
org
.
codehaus
.
jackson
.
annotate
.
JsonAutoDetect
.
Visibility
.
NONE
;
import
static
org
.
codehaus
.
jackson
.
annotate
.
JsonAutoDetect
.
Visibility
.
PUBLIC_ONLY
;
/**
* Client for metadata.
*/
...
...
@@ -243,6 +253,11 @@ public class AtlasClient extends AtlasBaseClient {
}
}
@JsonAutoDetect
(
getterVisibility
=
PUBLIC_ONLY
,
setterVisibility
=
PUBLIC_ONLY
,
fieldVisibility
=
NONE
)
@JsonSerialize
(
include
=
JsonSerialize
.
Inclusion
.
NON_NULL
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
@XmlRootElement
@XmlAccessorType
(
XmlAccessType
.
PROPERTY
)
public
static
class
EntityResult
{
public
static
final
String
OP_CREATED
=
"created"
;
public
static
final
String
OP_UPDATED
=
"updated"
;
...
...
@@ -274,14 +289,26 @@ public class AtlasClient extends AtlasBaseClient {
return
list
;
}
public
Map
<
String
,
List
<
String
>>
getEntities
(){
return
entities
;
}
public
void
setEntities
(
Map
<
String
,
List
<
String
>>
entities
){
this
.
entities
=
entities
;
}
@JsonIgnore
public
List
<
String
>
getCreatedEntities
()
{
return
get
(
OP_CREATED
);
}
@JsonIgnore
public
List
<
String
>
getUpdateEntities
()
{
return
get
(
OP_UPDATED
);
}
@JsonIgnore
public
List
<
String
>
getDeletedEntities
()
{
return
get
(
OP_DELETED
);
}
...
...
This diff is collapsed.
Click to expand it.
intg/src/main/java/org/apache/atlas/type/AtlasType.java
View file @
8cd6a644
...
...
@@ -18,22 +18,25 @@
package
org
.
apache
.
atlas
.
type
;
import
com.google.gson.Gson
;
import
com.google.gson.GsonBuilder
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.model.TypeCategory
;
import
org.apache.atlas.model.typedef.AtlasBaseTypeDef
;
import
org.codehaus.jackson.map.ObjectMapper
;
import
java.io.IOException
;
import
java.util.List
;
/**
* base class that declares interface for all Atlas types.
*/
public
abstract
class
AtlasType
{
private
static
final
Gson
GSON
=
new
GsonBuilder
().
serializeNulls
().
setDateFormat
(
AtlasBaseTypeDef
.
SERIALIZED_DATE_FORMAT_STR
).
create
();
private
static
final
ObjectMapper
mapper
=
new
ObjectMapper
();
private
final
String
typeName
;
private
final
TypeCategory
typeCategory
;
...
...
@@ -93,12 +96,23 @@ public abstract class AtlasType {
return
this
;
}
public
static
String
toJson
(
Object
obj
)
{
return
GSON
.
toJson
(
obj
);
String
ret
;
try
{
ret
=
mapper
.
writeValueAsString
(
obj
);
}
catch
(
IOException
e
){
ret
=
null
;
}
return
ret
;
}
public
static
<
T
>
T
fromJson
(
String
jsonStr
,
Class
<
T
>
type
)
{
return
GSON
.
fromJson
(
jsonStr
,
type
);
T
ret
;
try
{
ret
=
mapper
.
readValue
(
jsonStr
,
type
);
}
catch
(
IOException
e
){
ret
=
null
;
}
return
ret
;
}
}
This diff is collapsed.
Click to expand it.
release-log.txt
View file @
8cd6a644
...
...
@@ -9,6 +9,7 @@ ATLAS-1060 Add composite indexes for exact match performance improvements for al
ATLAS-1127 Modify creation and modification timestamps to Date instead of Long(sumasai)
ALL CHANGES:
ATLAS-1566 replace GSON ser-de with ObjectMapper ser-de (svimal2016 via mneethiraj)
ATLAS-1551 auto update of reverse references in V1 API (dkantor)
ATLAS-1565 Create EntityREST endpoints for delete operations (sarathkumarsubramanian via svimal2106)
ATLAS-1547 Added tests for hard delete (mneethiraj)
...
...
This diff is collapsed.
Click to expand it.
webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java
View file @
8cd6a644
...
...
@@ -17,8 +17,6 @@
*/
package
org
.
apache
.
atlas
.
web
.
adapters
;
import
com.fasterxml.jackson.databind.DeserializationFeature
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.RepositoryMetadataModule
;
import
org.apache.atlas.RequestContext
;
...
...
@@ -36,6 +34,7 @@ import org.apache.atlas.model.typedef.AtlasTypesDef;
import
org.apache.atlas.repository.graph.AtlasGraphProvider
;
import
org.apache.atlas.repository.store.bootstrap.AtlasTypeDefStoreInitializer
;
import
org.apache.atlas.store.AtlasTypeDefStore
;
import
org.apache.atlas.type.AtlasType
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.web.rest.EntityREST
;
...
...
@@ -254,11 +253,9 @@ public class TestEntitiesREST {
AtlasEntity
serDeserEntity
(
AtlasEntity
entity
)
throws
IOException
{
//Convert from json to object and back to trigger the case where it gets translated to a map for attributes instead of AtlasEntity
ObjectMapper
mapper
=
new
ObjectMapper
();
mapper
.
configure
(
DeserializationFeature
.
FAIL_ON_UNKNOWN_PROPERTIES
,
false
);
String
entityJson
=
mapper
.
writeValueAsString
(
entity
);
//JSON from String to Object
AtlasEntity
newEntity
=
mapper
.
readValue
(
entityJson
,
AtlasEntity
.
class
);
String
jsonString
=
AtlasType
.
toJson
(
entity
);
AtlasEntity
newEntity
=
AtlasType
.
fromJson
(
jsonString
,
AtlasEntity
.
class
);
return
newEntity
;
}
...
...
This diff is collapsed.
Click to expand it.
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