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
b2951a92
Commit
b2951a92
authored
May 01, 2017
by
apoorvnaik
Committed by
Madhan Neethiraj
May 01, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1762: updated error code returned by type create/updated APIs
Signed-off-by:
Madhan Neethiraj
<
madhan@apache.org
>
parent
3a9594e1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
12 deletions
+61
-12
AtlasTypeDefGraphStore.java
.../atlas/repository/store/graph/AtlasTypeDefGraphStore.java
+61
-12
No files found.
repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
View file @
b2951a92
...
...
@@ -137,7 +137,7 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
public
AtlasEnumDef
updateEnumDefByName
(
String
name
,
AtlasEnumDef
enumDef
)
throws
AtlasBaseException
{
AtlasTransientTypeRegistry
ttr
=
lockTypeRegistryAndReleasePostCommit
();
t
tr
.
updateTypeByName
(
name
,
enumDef
);
t
ryUpdateByName
(
name
,
enumDef
,
ttr
);
return
getEnumDefStore
(
ttr
).
updateByName
(
name
,
enumDef
);
}
...
...
@@ -147,7 +147,7 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
public
AtlasEnumDef
updateEnumDefByGuid
(
String
guid
,
AtlasEnumDef
enumDef
)
throws
AtlasBaseException
{
AtlasTransientTypeRegistry
ttr
=
lockTypeRegistryAndReleasePostCommit
();
t
tr
.
updateTypeByGuid
(
guid
,
enumDef
);
t
ryUpdateByGUID
(
guid
,
enumDef
,
ttr
);
return
getEnumDefStore
(
ttr
).
updateByGuid
(
guid
,
enumDef
);
}
...
...
@@ -181,7 +181,7 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
public
AtlasStructDef
updateStructDefByName
(
String
name
,
AtlasStructDef
structDef
)
throws
AtlasBaseException
{
AtlasTransientTypeRegistry
ttr
=
lockTypeRegistryAndReleasePostCommit
();
t
tr
.
updateTypeByName
(
name
,
structDef
);
t
ryUpdateByName
(
name
,
structDef
,
ttr
);
return
getStructDefStore
(
ttr
).
updateByName
(
name
,
structDef
);
}
...
...
@@ -191,7 +191,7 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
public
AtlasStructDef
updateStructDefByGuid
(
String
guid
,
AtlasStructDef
structDef
)
throws
AtlasBaseException
{
AtlasTransientTypeRegistry
ttr
=
lockTypeRegistryAndReleasePostCommit
();
t
tr
.
updateTypeByGuid
(
guid
,
structDef
);
t
ryUpdateByGUID
(
guid
,
structDef
,
ttr
);
return
getStructDefStore
(
ttr
).
updateByGuid
(
guid
,
structDef
);
}
...
...
@@ -226,7 +226,7 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
throws
AtlasBaseException
{
AtlasTransientTypeRegistry
ttr
=
lockTypeRegistryAndReleasePostCommit
();
t
tr
.
updateTypeByName
(
name
,
classificationDef
);
t
ryUpdateByName
(
name
,
classificationDef
,
ttr
);
return
getClassificationDefStore
(
ttr
).
updateByName
(
name
,
classificationDef
);
}
...
...
@@ -237,7 +237,7 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
throws
AtlasBaseException
{
AtlasTransientTypeRegistry
ttr
=
lockTypeRegistryAndReleasePostCommit
();
t
tr
.
updateTypeByGuid
(
guid
,
classificationDef
);
t
ryUpdateByGUID
(
guid
,
classificationDef
,
ttr
);
return
getClassificationDefStore
(
ttr
).
updateByGuid
(
guid
,
classificationDef
);
}
...
...
@@ -271,7 +271,7 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
public
AtlasEntityDef
updateEntityDefByName
(
String
name
,
AtlasEntityDef
entityDef
)
throws
AtlasBaseException
{
AtlasTransientTypeRegistry
ttr
=
lockTypeRegistryAndReleasePostCommit
();
t
tr
.
updateTypeByName
(
name
,
entityDef
);
t
ryUpdateByName
(
name
,
entityDef
,
ttr
);
return
getEntityDefStore
(
ttr
).
updateByName
(
name
,
entityDef
);
}
...
...
@@ -281,7 +281,7 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
public
AtlasEntityDef
updateEntityDefByGuid
(
String
guid
,
AtlasEntityDef
entityDef
)
throws
AtlasBaseException
{
AtlasTransientTypeRegistry
ttr
=
lockTypeRegistryAndReleasePostCommit
();
t
tr
.
updateTypeByGuid
(
guid
,
entityDef
);
t
ryUpdateByGUID
(
guid
,
entityDef
,
ttr
);
return
getEntityDefStore
(
ttr
).
updateByGuid
(
guid
,
entityDef
);
}
...
...
@@ -298,8 +298,8 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
}
AtlasTransientTypeRegistry
ttr
=
lockTypeRegistryAndReleasePostCommit
();
tryTypeCreation
(
typesDef
,
ttr
);
ttr
.
addTypes
(
typesDef
);
AtlasTypesDef
ret
=
addToGraphStore
(
typesDef
,
ttr
);
...
...
@@ -327,7 +327,8 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
ttr
.
updateTypesWithNoRefResolve
(
typesToUpdate
);
}
ttr
.
addTypes
(
typesToCreate
);
// Translate any NOT FOUND errors to BAD REQUEST
tryTypeCreation
(
typesToCreate
,
ttr
);
AtlasTypesDef
ret
=
addToGraphStore
(
typesToCreate
,
ttr
);
...
...
@@ -379,7 +380,16 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
AtlasTransientTypeRegistry
ttr
=
lockTypeRegistryAndReleasePostCommit
();
ttr
.
updateTypes
(
typesDef
);
// Translate any NOT FOUND errors to BAD REQUEST
try
{
ttr
.
updateTypes
(
typesDef
);
}
catch
(
AtlasBaseException
e
)
{
if
(
AtlasErrorCode
.
TYPE_NAME_NOT_FOUND
==
e
.
getAtlasErrorCode
())
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
BAD_REQUEST
,
e
.
getMessage
());
}
else
{
throw
e
;
}
}
AtlasTypesDef
ret
=
updateGraphStore
(
typesDef
,
ttr
);
...
...
@@ -813,6 +823,7 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
}
private
class
TypeRegistryUpdateHook
extends
GraphTransactionInterceptor
.
PostTransactionHook
{
private
final
AtlasTransientTypeRegistry
ttr
;
private
TypeRegistryUpdateHook
(
AtlasTransientTypeRegistry
ttr
)
{
...
...
@@ -820,7 +831,6 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
this
.
ttr
=
ttr
;
}
@Override
public
void
onComplete
(
boolean
isSuccess
)
{
if
(
LOG
.
isDebugEnabled
())
{
...
...
@@ -853,5 +863,44 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
}
}
}
}
private
void
tryUpdateByName
(
String
name
,
AtlasBaseTypeDef
typeDef
,
AtlasTransientTypeRegistry
ttr
)
throws
AtlasBaseException
{
try
{
ttr
.
updateTypeByName
(
name
,
typeDef
);
}
catch
(
AtlasBaseException
e
)
{
if
(
AtlasErrorCode
.
TYPE_NAME_NOT_FOUND
==
e
.
getAtlasErrorCode
())
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
BAD_REQUEST
,
e
.
getMessage
());
}
else
{
throw
e
;
}
}
}
private
void
tryUpdateByGUID
(
String
guid
,
AtlasBaseTypeDef
typeDef
,
AtlasTransientTypeRegistry
ttr
)
throws
AtlasBaseException
{
try
{
ttr
.
updateTypeByGuid
(
guid
,
typeDef
);
}
catch
(
AtlasBaseException
e
)
{
if
(
AtlasErrorCode
.
TYPE_GUID_NOT_FOUND
==
e
.
getAtlasErrorCode
())
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
BAD_REQUEST
,
e
.
getMessage
());
}
else
{
throw
e
;
}
}
}
private
void
tryTypeCreation
(
AtlasTypesDef
typesDef
,
AtlasTransientTypeRegistry
ttr
)
throws
AtlasBaseException
{
// Translate any NOT FOUND errors to BAD REQUEST
try
{
ttr
.
addTypes
(
typesDef
);
}
catch
(
AtlasBaseException
e
)
{
if
(
AtlasErrorCode
.
TYPE_NAME_NOT_FOUND
==
e
.
getAtlasErrorCode
()
||
AtlasErrorCode
.
TYPE_GUID_NOT_FOUND
==
e
.
getAtlasErrorCode
())
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
BAD_REQUEST
,
e
.
getMessage
());
}
else
{
throw
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