ATLAS-861 1 table out of 50,000 tables is left unimported throwing exception during deserialization (sumasai via shwethags)
diff --git a/release-log.txt b/release-log.txt
index 18c9173..c21b43a 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -6,6 +6,7 @@
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-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)
diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/DataTypes.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/DataTypes.java
index 3783c23..425e163 100755
--- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/DataTypes.java
+++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/DataTypes.java
@@ -22,17 +22,19 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
-
import org.apache.atlas.AtlasException;
import org.apache.atlas.typesystem.IReferenceableInstance;
import org.apache.atlas.typesystem.persistence.Id;
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.BigInteger;
import java.nio.charset.Charset;
import java.security.MessageDigest;
-import java.text.ParseException;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
@@ -405,6 +407,8 @@
super(name, null);
}
+ private static final DateTimeFormatter utcDateFormat = ISODateTimeFormat.dateTime();
+
@Override
public Date convert(Object val, Multiplicity m) throws AtlasException {
if (val != null) {
@@ -412,8 +416,8 @@
return (Date) val;
} else if (val instanceof String) {
try {
- return TypeSystem.getInstance().getDateFormat().parse((String) val);
- } catch (ParseException ne) {
+ return utcDateFormat.parseDateTime((String)val).toDate();
+ } catch (Exception ne) {
throw new ValueConversionException(this, val, ne);
}
} else if (val instanceof Number) {
@@ -427,7 +431,7 @@
@Override
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);
}
diff --git a/typesystem/src/test/java/org/apache/atlas/typesystem/types/TypeSystemTest.java b/typesystem/src/test/java/org/apache/atlas/typesystem/types/TypeSystemTest.java
index 4a285a6..96946ea 100755
--- a/typesystem/src/test/java/org/apache/atlas/typesystem/types/TypeSystemTest.java
+++ b/typesystem/src/test/java/org/apache/atlas/typesystem/types/TypeSystemTest.java
@@ -33,7 +33,9 @@
import scala.actors.threadpool.Arrays;
import java.util.Collections;
+import java.util.Date;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import static org.apache.atlas.typesystem.types.utils.TypesUtil.createClassTypeDef;
@@ -46,6 +48,9 @@
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
public void setUp() throws Exception {
super.setup();
@@ -284,4 +289,20 @@
//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);
+ }
}