ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gna...@apache.org
Subject ambari git commit: Revert "AMBARI-18045. Pig view - Pig script creation fails.(gauravn7)"
Date Sat, 06 Aug 2016 12:51:31 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 61b37d815 -> e5d35e752


Revert "AMBARI-18045. Pig view - Pig script creation fails.(gauravn7)"

This reverts commit 61b37d815b77fa9d9946db62190e724ca6cdfbbd.


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

Branch: refs/heads/trunk
Commit: e5d35e752448a9c40e73bc0b7d21b3ccc1846da0
Parents: 61b37d8
Author: Gaurav Nagar <gnagar@hortonworks.com>
Authored: Sat Aug 6 18:21:07 2016 +0530
Committer: Gaurav Nagar <gnagar@hortonworks.com>
Committed: Sat Aug 6 18:21:07 2016 +0530

----------------------------------------------------------------------
 .../ambari/server/api/DateJsonDeserializer.java | 93 --------------------
 .../ambari/server/api/GsonJsonProvider.java     |  4 +-
 .../ambari/server/api/TestDateDeserializer.java | 89 -------------------
 3 files changed, 1 insertion(+), 185 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e5d35e75/ambari-server/src/main/java/org/apache/ambari/server/api/DateJsonDeserializer.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/DateJsonDeserializer.java
b/ambari-server/src/main/java/org/apache/ambari/server/api/DateJsonDeserializer.java
deleted file mode 100644
index 69fed88..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/DateJsonDeserializer.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ambari.server.api;
-
-
-import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonParseException;
-import com.google.gson.JsonSyntaxException;
-import com.google.gson.internal.bind.util.ISO8601Utils;
-
-import java.lang.reflect.Type;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.ParsePosition;
-import java.util.Date;
-import java.util.Locale;
-
-/**
- * Custom deserializer for date conversion.
- * This will support following formats:
- * <ul>
- *   <li> Epoch </li>
- *   <li> Local Date </li>
- *   <li> US Date </li>
- *   <li> ISO8601 Date </li>
- * </ul>
- */
-public class DateJsonDeserializer implements JsonDeserializer<Date> {
-
-  /**
-   * Date Format for US Date.
-   */
-  private static final DateFormat EN_US_FORMAT = DateFormat.getDateTimeInstance(2, 2, Locale.US);
-
-  /**
-   * Date Format for local Date
-   */
-  private static final DateFormat LOCAL_FORMAT = DateFormat.getDateTimeInstance(2, 2);
-
-  @Override
-  public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
throws JsonParseException {
-    if (json.isJsonNull()) {
-      return null;
-    }
-
-    return deserializeToDate(json);
-  }
-
-  /**
-   * Convert {@link JsonElement} to {@link Date} object
-   *
-   * @param json
-   * @return
-   * @throws JsonSyntaxException
-   */
-  private synchronized Date deserializeToDate(JsonElement json) throws JsonSyntaxException
{
-    try {
-      return new Date(json.getAsJsonPrimitive().getAsLong());
-    } catch (Exception ex1) {
-      try {
-        return LOCAL_FORMAT.parse(json.getAsJsonPrimitive().getAsString());
-      } catch (ParseException ex2) {
-        try {
-          return EN_US_FORMAT.parse(json.getAsJsonPrimitive().getAsString());
-        } catch (ParseException ex3) {
-          try {
-            return ISO8601Utils.parse(json.getAsJsonPrimitive().getAsString(), new ParsePosition(0));
-          } catch (ParseException ex4) {
-            throw new JsonSyntaxException(json.getAsJsonPrimitive().getAsString(), ex4);
-          }
-        }
-      }
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/e5d35e75/ambari-server/src/main/java/org/apache/ambari/server/api/GsonJsonProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/GsonJsonProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/api/GsonJsonProvider.java
index 53f07f9..8ba9ff7 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/GsonJsonProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/GsonJsonProvider.java
@@ -35,7 +35,6 @@ import javax.ws.rs.ext.Provider;
 import java.io.*;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
-import java.util.Date;
 
 @Provider
 @Consumes({MediaType.APPLICATION_JSON, "text/json"})
@@ -47,8 +46,7 @@ public class GsonJsonProvider implements MessageBodyReader<Object>,
 
   static final Gson gson = new GsonBuilder()
 //      .setPrettyPrinting()
-    .registerTypeAdapter(Date.class, new DateJsonDeserializer())
-    .create();
+      .create();
 
   @Override
   public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations,
MediaType mediaType) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/e5d35e75/ambari-server/src/test/java/org/apache/ambari/server/api/TestDateDeserializer.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/TestDateDeserializer.java
b/ambari-server/src/test/java/org/apache/ambari/server/api/TestDateDeserializer.java
deleted file mode 100644
index 244094a..0000000
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/TestDateDeserializer.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ambari.server.api;
-
-import com.google.gson.Gson;
-import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonNull;
-import com.google.gson.JsonParser;
-import com.google.gson.JsonPrimitive;
-import com.google.gson.JsonSyntaxException;
-import com.google.gson.internal.bind.util.ISO8601Utils;
-import org.junit.Test;
-import org.mockito.Mockito;
-
-import java.lang.reflect.Type;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.ParsePosition;
-import java.util.Date;
-import java.util.Locale;
-
-import static org.junit.Assert.assertEquals;
-
-public class TestDateDeserializer {
-
-  Gson gson = new Gson();
-  DateJsonDeserializer deserializer = new DateJsonDeserializer();
-
-  @Test
-  public void testDeserializeWithEpochDate() {
-    String date = "1470301497";
-    assertEquals(parseDate(date), new Date(1470301497));
-  }
-
-  @Test
-  public void testDeserializeWithLocalDate() throws ParseException {
-    String date = "12 Aug, 2016 11:02:47 PM";
-    assertEquals(parseDate(date), DateFormat.getDateTimeInstance(2, 2).parse(date));
-  }
-
-  @Test
-  public void testDeserializeWithUSDate() throws ParseException {
-    String date = "Aug 12, 2016 11:01:21 PM";
-    assertEquals(parseDate(date), DateFormat.getDateTimeInstance(2, 2, Locale.US).parse(date));
-  }
-
-  @Test
-  public void testDeserializeWithISODate() throws ParseException {
-    String dateString = "2016-07-07T15:15:15Z";
-    assertEquals(parseDate(dateString), ISO8601Utils.parse(dateString, new ParsePosition(0)));
-  }
-
-  @Test(expected = JsonSyntaxException.class)
-  public void testDeserializeWithInvalidDate() {
-    String date = "nopattern";
-    parseDate(date);
-  }
-
-  @Test
-  public void testDeserializeWithNullDate() {
-    String json = "{\"date\" : null}";
-    JsonElement jsonDate = new JsonParser().parse(json).getAsJsonObject().get("date");
-    Date date = deserializer.deserialize(jsonDate,
-      Mockito.mock(Type.class), Mockito.mock(JsonDeserializationContext.class));
-    assertEquals(date, null);
-  }
-
-  private Date parseDate(String date) {
-    return deserializer.deserialize(new JsonPrimitive(date),
-      Mockito.mock(Type.class), Mockito.mock(JsonDeserializationContext.class));
-  }
-}


Mime
View raw message