Commit 1c9b8b41 by Shwetha GS

ATLAS-861 1 table out of 50,000 tables is left unimported throwing exception…

ATLAS-861 1 table out of 50,000 tables is left unimported throwing exception during deserialization (sumasai via shwethags)
parent a4ceec90
...@@ -6,6 +6,7 @@ INCOMPATIBLE CHANGES: ...@@ -6,6 +6,7 @@ INCOMPATIBLE CHANGES:
ALL CHANGES: ALL CHANGES:
ATLAS-861 1 table out of 50,000 tables is left unimported throwing exception during deserialization (sumasai via shwethags)
ATLAS-1065 UI: Full text search view same as DSL's (kevalbhat18 via shwethags) ATLAS-1065 UI: Full text search view same as DSL's (kevalbhat18 via shwethags)
ATLAS-1066 Falcon fails to post entity to Atlas due to kafka exception (mneethiraj via shwethags) ATLAS-1066 Falcon fails to post entity to Atlas due to kafka exception (mneethiraj via shwethags)
ATLAS-1064 UI: Pagination for full text search results (Kalyanikashikar via shwethags) ATLAS-1064 UI: Pagination for full text search results (Kalyanikashikar via shwethags)
......
...@@ -22,17 +22,19 @@ import com.google.common.collect.ImmutableCollection; ...@@ -22,17 +22,19 @@ import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import org.apache.atlas.AtlasException; import org.apache.atlas.AtlasException;
import org.apache.atlas.typesystem.IReferenceableInstance; import org.apache.atlas.typesystem.IReferenceableInstance;
import org.apache.atlas.typesystem.persistence.Id; import org.apache.atlas.typesystem.persistence.Id;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.ISODateTimeFormat;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.BigInteger; import java.math.BigInteger;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.text.ParseException;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.Iterator; import java.util.Iterator;
...@@ -405,6 +407,8 @@ public class DataTypes { ...@@ -405,6 +407,8 @@ public class DataTypes {
super(name, null); super(name, null);
} }
private static final DateTimeFormatter utcDateFormat = ISODateTimeFormat.dateTime();
@Override @Override
public Date convert(Object val, Multiplicity m) throws AtlasException { public Date convert(Object val, Multiplicity m) throws AtlasException {
if (val != null) { if (val != null) {
...@@ -412,8 +416,8 @@ public class DataTypes { ...@@ -412,8 +416,8 @@ public class DataTypes {
return (Date) val; return (Date) val;
} else if (val instanceof String) { } else if (val instanceof String) {
try { try {
return TypeSystem.getInstance().getDateFormat().parse((String) val); return utcDateFormat.parseDateTime((String)val).toDate();
} catch (ParseException ne) { } catch (Exception ne) {
throw new ValueConversionException(this, val, ne); throw new ValueConversionException(this, val, ne);
} }
} else if (val instanceof Number) { } else if (val instanceof Number) {
...@@ -427,7 +431,7 @@ public class DataTypes { ...@@ -427,7 +431,7 @@ public class DataTypes {
@Override @Override
public void output(Date val, Appendable buf, String prefix, Set<Date> inProcess) throws AtlasException { public void output(Date val, Appendable buf, String prefix, Set<Date> inProcess) throws AtlasException {
TypeUtils.outputVal(val == null ? "<null>" : TypeSystem.getInstance().getDateFormat().format(val), buf, TypeUtils.outputVal(val == null ? "<null>" : utcDateFormat.print(new DateTime(val).withZone(DateTimeZone.UTC)), buf,
prefix); prefix);
} }
......
...@@ -33,7 +33,9 @@ import org.testng.annotations.Test; ...@@ -33,7 +33,9 @@ import org.testng.annotations.Test;
import scala.actors.threadpool.Arrays; import scala.actors.threadpool.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.List; import java.util.List;
import static org.apache.atlas.typesystem.types.utils.TypesUtil.createClassTypeDef; import static org.apache.atlas.typesystem.types.utils.TypesUtil.createClassTypeDef;
...@@ -46,6 +48,9 @@ import static org.testng.Assert.fail; ...@@ -46,6 +48,9 @@ import static org.testng.Assert.fail;
public class TypeSystemTest extends BaseTest { public class TypeSystemTest extends BaseTest {
public static final long TEST_DATE_IN_LONG = 1418265358440L;
public static final String TEST_DATE_STRING = "2014-12-11T02:35:58.440Z";
@BeforeClass @BeforeClass
public void setUp() throws Exception { public void setUp() throws Exception {
super.setup(); super.setup();
...@@ -284,4 +289,20 @@ public class TypeSystemTest extends BaseTest { ...@@ -284,4 +289,20 @@ public class TypeSystemTest extends BaseTest {
//expected //expected
} }
} }
@Test(expectedExceptions = ValueConversionException.class)
public void testConvertInvalidDate() throws Exception {
DataTypes.DATE_TYPE.convert("", Multiplicity.OPTIONAL);
}
@Test()
public void testConvertValidDate() throws Exception {
Date date = DataTypes.DATE_TYPE.convert(TEST_DATE_STRING, Multiplicity.OPTIONAL);
Assert.assertEquals(date, new Date(TEST_DATE_IN_LONG));
StringBuilder buf = new StringBuilder();
DataTypes.DATE_TYPE.output(new Date(TEST_DATE_IN_LONG), buf, "", new HashSet<Date>());
Assert.assertEquals(buf.toString(), TEST_DATE_STRING);
}
} }
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