Commit 48b05f36 by Madhan Neethiraj

ATLAS-1613: fix for bigdecimal value handling to avoid casting to long; fixed…

ATLAS-1613: fix for bigdecimal value handling to avoid casting to long; fixed incorrect HTTP status code for an error
parent 44df46cf
...@@ -74,7 +74,7 @@ public enum AtlasErrorCode { ...@@ -74,7 +74,7 @@ public enum AtlasErrorCode {
EMPTY_RESULTS(404, "ATLAS4044E", "No result found for {0}"), EMPTY_RESULTS(404, "ATLAS4044E", "No result found for {0}"),
INSTANCE_GUID_NOT_FOUND(404, "ATLAS4045E", "Given instance guid {0} is invalid/not found"), INSTANCE_GUID_NOT_FOUND(404, "ATLAS4045E", "Given instance guid {0} is invalid/not found"),
INSTANCE_LINEAGE_QUERY_FAILED(404, "ATLAS4047E", "Instance lineage query failed {0}"), INSTANCE_LINEAGE_QUERY_FAILED(404, "ATLAS4047E", "Instance lineage query failed {0}"),
INSTANCE_CRUD_INVALID_PARAMS(404, "ATLAS4049E", "Invalid instance creation/updation parameters passed : {0}"), INSTANCE_CRUD_INVALID_PARAMS(400, "ATLAS4049E", "Invalid instance creation/updation parameters passed : {0}"),
CLASSIFICATION_NOT_FOUND(404, "ATLAS4048E", "Given classification {0} was invalid"), CLASSIFICATION_NOT_FOUND(404, "ATLAS4048E", "Given classification {0} was invalid"),
INSTANCE_BY_UNIQUE_ATTRIBUTE_NOT_FOUND(404, "ATLAS40410E", "Instance {0} with unique attribute {1} does not exist"), INSTANCE_BY_UNIQUE_ATTRIBUTE_NOT_FOUND(404, "ATLAS40410E", "Instance {0} with unique attribute {1} does not exist"),
......
...@@ -365,11 +365,13 @@ public class AtlasBuiltInTypes { ...@@ -365,11 +365,13 @@ public class AtlasBuiltInTypes {
if (obj != null) { if (obj != null) {
if (obj instanceof BigInteger) { if (obj instanceof BigInteger) {
return (BigInteger) obj; return (BigInteger) obj;
} else if (obj instanceof BigDecimal) {
return ((BigDecimal) obj).toBigInteger();
} else if (obj instanceof Number) { } else if (obj instanceof Number) {
return BigInteger.valueOf(((Number) obj).longValue()); return BigInteger.valueOf(((Number) obj).longValue());
} else { } else {
try { try {
return new BigInteger(obj.toString()); return new BigDecimal(obj.toString()).toBigInteger();
} catch (NumberFormatException excp) { } catch (NumberFormatException excp) {
// ignore // ignore
} }
...@@ -409,8 +411,10 @@ public class AtlasBuiltInTypes { ...@@ -409,8 +411,10 @@ public class AtlasBuiltInTypes {
if (obj != null) { if (obj != null) {
if (obj instanceof BigDecimal) { if (obj instanceof BigDecimal) {
return (BigDecimal) obj; return (BigDecimal) obj;
} else if (obj instanceof BigInteger) {
return new BigDecimal((BigInteger) obj);
} else if (obj instanceof Number) { } else if (obj instanceof Number) {
return BigDecimal.valueOf(((Number) obj).longValue()); return BigDecimal.valueOf(((Number) obj).doubleValue());
} else { } else {
try { try {
return new BigDecimal(obj.toString()); return new BigDecimal(obj.toString());
......
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