Commit cae6522d by Sarath Subramanian Committed by Madhan Neethiraj

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

parent e5b6438f
...@@ -9,6 +9,7 @@ ATLAS-1060 Add composite indexes for exact match performance improvements for al ...@@ -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) ATLAS-1127 Modify creation and modification timestamps to Date instead of Long(sumasai)
ALL CHANGES: 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-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-1417 HIveHook: synchronous execution fails to notify (sumasai via mneethiraj)
ATLAS-1391 Add exclusion mechanism for Atlas audit (guptaneeru via mneethiraj) ATLAS-1391 Add exclusion mechanism for Atlas audit (guptaneeru via mneethiraj)
......
...@@ -165,10 +165,7 @@ public class TypesResource { ...@@ -165,10 +165,7 @@ public class TypesResource {
response.put(AtlasClient.REQUEST_ID, Servlets.getRequestId()); response.put(AtlasClient.REQUEST_ID, Servlets.getRequestId());
response.put(AtlasClient.TYPES, typesResponse); response.put(AtlasClient.TYPES, typesResponse);
return Response.ok().entity(response).build(); return Response.ok().entity(response).build();
} catch (TypeExistsException e) { } catch (AtlasBaseException | IllegalArgumentException e) {
LOG.error("Type already exists", e);
throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.CONFLICT));
} catch (AtlasException | IllegalArgumentException e) {
LOG.error("Unable to persist types", e); LOG.error("Unable to persist types", e);
throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST)); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST));
} catch (WebApplicationException e) { } catch (WebApplicationException e) {
......
...@@ -305,12 +305,7 @@ public class TypesREST { ...@@ -305,12 +305,7 @@ public class TypesREST {
public AtlasEntityDef createEntityDef(AtlasEntityDef entityDef) throws AtlasBaseException { public AtlasEntityDef createEntityDef(AtlasEntityDef entityDef) throws AtlasBaseException {
AtlasEntityDef ret = typeDefStore.createEntityDef(entityDef); AtlasEntityDef ret = typeDefStore.createEntityDef(entityDef);
try { return ret;
ret = typeDefStore.createEntityDef(entityDef);
return ret;
} catch (AtlasBaseException ex) {
throw new WebApplicationException(Servlets.getErrorResponse(ex, Response.Status.BAD_REQUEST));
}
} }
@GET @GET
...@@ -336,10 +331,8 @@ public class TypesREST { ...@@ -336,10 +331,8 @@ public class TypesREST {
@Consumes(Servlets.JSON_MEDIA_TYPE) @Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(Servlets.JSON_MEDIA_TYPE) @Produces(Servlets.JSON_MEDIA_TYPE)
@Experimental @Experimental
public AtlasEntityDef updateEntityDefByName(@PathParam("name") String name, AtlasEntityDef entityDef) throws Exception { public AtlasEntityDef updateEntityDefByName(@PathParam("name") String name, AtlasEntityDef entityDef) throws AtlasBaseException {
AtlasEntityDef ret = null; AtlasEntityDef ret = typeDefStore.updateEntityDefByName(name, entityDef);
ret = typeDefStore.updateEntityDefByName(name, entityDef);
return ret; return ret;
} }
...@@ -349,10 +342,8 @@ public class TypesREST { ...@@ -349,10 +342,8 @@ public class TypesREST {
@Consumes(Servlets.JSON_MEDIA_TYPE) @Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(Servlets.JSON_MEDIA_TYPE) @Produces(Servlets.JSON_MEDIA_TYPE)
@Experimental @Experimental
public AtlasEntityDef updateEntityDefByGuid(@PathParam("guid") String guid, AtlasEntityDef entityDef) throws Exception { public AtlasEntityDef updateEntityDefByGuid(@PathParam("guid") String guid, AtlasEntityDef entityDef) throws AtlasBaseException {
AtlasEntityDef ret = null; AtlasEntityDef ret = typeDefStore.updateEntityDefByGuid(guid, entityDef);
ret = typeDefStore.updateEntityDefByGuid(guid, entityDef);
return ret; return ret;
} }
...@@ -361,7 +352,7 @@ public class TypesREST { ...@@ -361,7 +352,7 @@ public class TypesREST {
@Path("/entitydef/name/{name}") @Path("/entitydef/name/{name}")
@Produces(Servlets.JSON_MEDIA_TYPE) @Produces(Servlets.JSON_MEDIA_TYPE)
@Experimental @Experimental
public void deleteEntityDef(@PathParam("name") String name) throws Exception { public void deleteEntityDef(@PathParam("name") String name) throws AtlasBaseException {
typeDefStore.deleteEntityDefByName(name); typeDefStore.deleteEntityDefByName(name);
} }
...@@ -369,7 +360,7 @@ public class TypesREST { ...@@ -369,7 +360,7 @@ public class TypesREST {
@Path("/entitydef/guid/{guid}") @Path("/entitydef/guid/{guid}")
@Produces(Servlets.JSON_MEDIA_TYPE) @Produces(Servlets.JSON_MEDIA_TYPE)
@Experimental @Experimental
public void deleteEntityDefByGuid(@PathParam("guid") String guid) throws Exception { public void deleteEntityDefByGuid(@PathParam("guid") String guid) throws AtlasBaseException {
typeDefStore.deleteEntityDefByGuid(guid); typeDefStore.deleteEntityDefByGuid(guid);
} }
...@@ -448,14 +439,8 @@ public class TypesREST { ...@@ -448,14 +439,8 @@ public class TypesREST {
@Consumes(Servlets.JSON_MEDIA_TYPE) @Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(Servlets.JSON_MEDIA_TYPE) @Produces(Servlets.JSON_MEDIA_TYPE)
@Experimental @Experimental
public AtlasTypesDef updateAtlasTypeDefs(final AtlasTypesDef typesDef) throws Exception { public AtlasTypesDef updateAtlasTypeDefs(final AtlasTypesDef typesDef) throws AtlasBaseException {
AtlasTypesDef ret = null; AtlasTypesDef ret = typeDefStore.updateTypesDef(typesDef);
try {
ret = typeDefStore.updateTypesDef(typesDef);
} catch (AtlasBaseException ex) {
throw new WebApplicationException(Servlets.getErrorResponse(ex, ex.getAtlasErrorCode().getHttpCode()));
}
return ret; return ret;
} }
...@@ -470,12 +455,8 @@ public class TypesREST { ...@@ -470,12 +455,8 @@ public class TypesREST {
@Consumes(Servlets.JSON_MEDIA_TYPE) @Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(Servlets.JSON_MEDIA_TYPE) @Produces(Servlets.JSON_MEDIA_TYPE)
@Experimental @Experimental
public void deleteAtlasTypeDefs(final AtlasTypesDef typesDef) { public void deleteAtlasTypeDefs(final AtlasTypesDef typesDef) throws AtlasBaseException {
try { typeDefStore.deleteTypesDef(typesDef);
typeDefStore.deleteTypesDef(typesDef);
} catch (AtlasBaseException ex) {
throw new WebApplicationException(Servlets.getErrorResponse(ex, Response.Status.NOT_MODIFIED));
}
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment