You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ma...@apache.org on 2017/01/04 22:47:13 UTC

incubator-atlas git commit: ATLAS-1428: Create of entityDef type fails with type already exists exception

Repository: incubator-atlas
Updated Branches:
  refs/heads/master e5b6438f2 -> cae6522da


ATLAS-1428: Create of entityDef type fails with type already exists exception

Signed-off-by: Madhan Neethiraj <ma...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/cae6522d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/cae6522d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/cae6522d

Branch: refs/heads/master
Commit: cae6522da3a209c0bb32492293553fc6bd23c313
Parents: e5b6438
Author: Sarath Subramanian <ss...@hortonworks.com>
Authored: Wed Jan 4 14:04:40 2017 -0800
Committer: Madhan Neethiraj <ma...@apache.org>
Committed: Wed Jan 4 14:46:59 2017 -0800

----------------------------------------------------------------------
 release-log.txt                                 |  1 +
 .../atlas/web/resources/TypesResource.java      |  5 +--
 .../org/apache/atlas/web/rest/TypesREST.java    | 41 ++++++--------------
 3 files changed, 13 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/cae6522d/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index 3d550b8..580c755 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -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-1428 Create of entityDef type fails with type already exists exception (sarath.kum4r@gmail.com via mneethiraj)
 ATLAS-1421 Regression : HTML is displayed for deleted entities in search-result and entity-details pages (Kalyanikashikar via mneethiraj)
 ATLAS-1417 HIveHook: synchronous execution fails to notify (sumasai via mneethiraj)
 ATLAS-1391 Add exclusion mechanism for Atlas audit (guptaneeru via mneethiraj)

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/cae6522d/webapp/src/main/java/org/apache/atlas/web/resources/TypesResource.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/resources/TypesResource.java b/webapp/src/main/java/org/apache/atlas/web/resources/TypesResource.java
index 9acfb2f..41259c7 100755
--- a/webapp/src/main/java/org/apache/atlas/web/resources/TypesResource.java
+++ b/webapp/src/main/java/org/apache/atlas/web/resources/TypesResource.java
@@ -165,10 +165,7 @@ public class TypesResource {
             response.put(AtlasClient.REQUEST_ID, Servlets.getRequestId());
             response.put(AtlasClient.TYPES, typesResponse);
             return Response.ok().entity(response).build();
-        } catch (TypeExistsException e) {
-            LOG.error("Type already exists", e);
-            throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.CONFLICT));
-        } catch (AtlasException | IllegalArgumentException e) {
+        } catch (AtlasBaseException | IllegalArgumentException e) {
             LOG.error("Unable to persist types", e);
             throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST));
         } catch (WebApplicationException e) {

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/cae6522d/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java b/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java
index 27c2c74..6f7b0fe 100644
--- a/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java
+++ b/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java
@@ -305,12 +305,7 @@ public class TypesREST {
     public AtlasEntityDef createEntityDef(AtlasEntityDef entityDef) throws AtlasBaseException {
         AtlasEntityDef ret = typeDefStore.createEntityDef(entityDef);
 
-        try {
-            ret = typeDefStore.createEntityDef(entityDef);
-            return ret;
-        } catch (AtlasBaseException ex) {
-            throw new WebApplicationException(Servlets.getErrorResponse(ex, Response.Status.BAD_REQUEST));
-        }
+        return ret;
     }
 
     @GET
@@ -336,10 +331,8 @@ public class TypesREST {
     @Consumes(Servlets.JSON_MEDIA_TYPE)
     @Produces(Servlets.JSON_MEDIA_TYPE)
     @Experimental
-    public AtlasEntityDef updateEntityDefByName(@PathParam("name") String name, AtlasEntityDef entityDef) throws Exception {
-        AtlasEntityDef ret = null;
-
-        ret = typeDefStore.updateEntityDefByName(name, entityDef);
+    public AtlasEntityDef updateEntityDefByName(@PathParam("name") String name, AtlasEntityDef entityDef) throws AtlasBaseException {
+        AtlasEntityDef ret = typeDefStore.updateEntityDefByName(name, entityDef);
 
         return ret;
     }
@@ -349,10 +342,8 @@ public class TypesREST {
     @Consumes(Servlets.JSON_MEDIA_TYPE)
     @Produces(Servlets.JSON_MEDIA_TYPE)
     @Experimental
-    public AtlasEntityDef updateEntityDefByGuid(@PathParam("guid") String guid, AtlasEntityDef entityDef) throws Exception {
-        AtlasEntityDef ret = null;
-
-        ret = typeDefStore.updateEntityDefByGuid(guid, entityDef);
+    public AtlasEntityDef updateEntityDefByGuid(@PathParam("guid") String guid, AtlasEntityDef entityDef) throws AtlasBaseException {
+        AtlasEntityDef ret = typeDefStore.updateEntityDefByGuid(guid, entityDef);
 
         return ret;
     }
@@ -361,7 +352,7 @@ public class TypesREST {
     @Path("/entitydef/name/{name}")
     @Produces(Servlets.JSON_MEDIA_TYPE)
     @Experimental
-    public void deleteEntityDef(@PathParam("name") String name) throws Exception {
+    public void deleteEntityDef(@PathParam("name") String name) throws AtlasBaseException {
         typeDefStore.deleteEntityDefByName(name);
     }
 
@@ -369,7 +360,7 @@ public class TypesREST {
     @Path("/entitydef/guid/{guid}")
     @Produces(Servlets.JSON_MEDIA_TYPE)
     @Experimental
-    public void deleteEntityDefByGuid(@PathParam("guid") String guid) throws Exception {
+    public void deleteEntityDefByGuid(@PathParam("guid") String guid) throws AtlasBaseException {
         typeDefStore.deleteEntityDefByGuid(guid);
     }
 
@@ -448,14 +439,8 @@ public class TypesREST {
     @Consumes(Servlets.JSON_MEDIA_TYPE)
     @Produces(Servlets.JSON_MEDIA_TYPE)
     @Experimental
-    public AtlasTypesDef updateAtlasTypeDefs(final AtlasTypesDef typesDef) throws Exception {
-        AtlasTypesDef ret = null;
-
-        try {
-            ret = typeDefStore.updateTypesDef(typesDef);
-        } catch (AtlasBaseException ex) {
-            throw new WebApplicationException(Servlets.getErrorResponse(ex, ex.getAtlasErrorCode().getHttpCode()));
-        }
+    public AtlasTypesDef updateAtlasTypeDefs(final AtlasTypesDef typesDef) throws AtlasBaseException {
+        AtlasTypesDef ret = typeDefStore.updateTypesDef(typesDef);
 
         return ret;
     }
@@ -470,12 +455,8 @@ public class TypesREST {
     @Consumes(Servlets.JSON_MEDIA_TYPE)
     @Produces(Servlets.JSON_MEDIA_TYPE)
     @Experimental
-    public void deleteAtlasTypeDefs(final AtlasTypesDef typesDef) {
-        try {
-            typeDefStore.deleteTypesDef(typesDef);
-        } catch (AtlasBaseException ex) {
-            throw new WebApplicationException(Servlets.getErrorResponse(ex, Response.Status.NOT_MODIFIED));
-        }
+    public void deleteAtlasTypeDefs(final AtlasTypesDef typesDef) throws AtlasBaseException {
+        typeDefStore.deleteTypesDef(typesDef);
     }
 
     /**