hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odiache...@apache.org
Subject incubator-hawq git commit: HAWQ-340. Make getVersion API return JSON format.
Date Fri, 22 Jan 2016 23:58:26 GMT
Repository: incubator-hawq
Updated Branches:
  refs/heads/HAWQ-340 [created] 64a2338f4


HAWQ-340. Make getVersion API return JSON format.


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/64a2338f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/64a2338f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/64a2338f

Branch: refs/heads/HAWQ-340
Commit: 64a2338f4b5051fec36f25721189dbb386d2e9d6
Parents: bee0137
Author: Oleksandr Diachenko <odiachenko@pivotal.io>
Authored: Fri Jan 22 15:58:06 2016 -0800
Committer: Oleksandr Diachenko <odiachenko@pivotal.io>
Committed: Fri Jan 22 15:58:06 2016 -0800

----------------------------------------------------------------------
 pxf/build.gradle                                | 36 +++++++++++++++++++-
 pxf/gradle.properties                           |  1 +
 .../hawq/pxf/service/rest/VersionResource.java  |  8 +++--
 .../pxf/service/rest/VersionResourceTest.java   |  2 +-
 4 files changed, 42 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/64a2338f/pxf/build.gradle
----------------------------------------------------------------------
diff --git a/pxf/build.gradle b/pxf/build.gradle
index 0d260d4..2281c8e 100644
--- a/pxf/build.gradle
+++ b/pxf/build.gradle
@@ -17,6 +17,8 @@
  * under the License.
  */
 
+import org.apache.tools.ant.filters.ReplaceTokens
+
 buildscript {
     repositories {
         // mavenCentral without https:
@@ -122,6 +124,39 @@ subprojects { subProject ->
 }
 
 project('pxf-service') {
+
+
+    task generateSources {
+        doFirst {
+            copy {
+                from('src/main/java') {
+                    include '**/*.java'
+                    filter(ReplaceTokens,
+                        tokens:['pxfProtocolVersion': project.pxfProtocolVersion ])}
+                into "tmp/generatedSources"
+            }
+        }
+    }
+
+    task cleanGeneratedSources {
+        doFirst {
+            delete "tmp"
+        }
+    }
+
+    gradle.projectsEvaluated {
+        compileJava.dependsOn(generateSources)
+        clean.dependsOn(cleanGeneratedSources)
+    }
+
+    sourceSets {
+        main {
+            java {
+                srcDirs = ["tmp/generatedSources"]
+            }
+        }
+    }
+
     apply plugin: 'war'
     tasks.war {
         archiveName = 'pxf.war'
@@ -137,7 +172,6 @@ project('pxf-service') {
             }
         }
     }
-
     dependencies {
         compile(project(':pxf-api'))
         compile 'com.sun.jersey:jersey-core:1.9'

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/64a2338f/pxf/gradle.properties
----------------------------------------------------------------------
diff --git a/pxf/gradle.properties b/pxf/gradle.properties
index 6a7b2d6..6827b89 100644
--- a/pxf/gradle.properties
+++ b/pxf/gradle.properties
@@ -23,3 +23,4 @@ hiveVersion=1.2.1
 hbaseVersionJar=1.1.2
 hbaseVersionRPM=1.1.2
 tomcatVersion=7.0.62
+pxfProtocolVersion=v14
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/64a2338f/pxf/pxf-service/src/main/java/org/apache/hawq/pxf/service/rest/VersionResource.java
----------------------------------------------------------------------
diff --git a/pxf/pxf-service/src/main/java/org/apache/hawq/pxf/service/rest/VersionResource.java
b/pxf/pxf-service/src/main/java/org/apache/hawq/pxf/service/rest/VersionResource.java
index 6f326d6..127e2e6 100644
--- a/pxf/pxf-service/src/main/java/org/apache/hawq/pxf/service/rest/VersionResource.java
+++ b/pxf/pxf-service/src/main/java/org/apache/hawq/pxf/service/rest/VersionResource.java
@@ -21,6 +21,7 @@ package org.apache.hawq.pxf.service.rest;
 
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.ResponseBuilder;
@@ -33,7 +34,7 @@ import org.apache.commons.logging.LogFactory;
  * version e.g. {@code ...pxf/v14/Bridge}
  */
 class Version {
-    final static String PXF_PROTOCOL_VERSION = "v14";
+	final static String PXF_PROTOCOL_VERSION = "@pxfProtocolVersion@";
 }
 
 /**
@@ -58,11 +59,12 @@ public class VersionResource {
      * @return response with the PXF protocol version
      */
     @GET
+    @Produces("application/json")
     public Response getProtocolVersion() {
 
         ResponseBuilder b = Response.ok();
-        b.entity("PXF protocol version " + Version.PXF_PROTOCOL_VERSION);
-        b.type(MediaType.TEXT_PLAIN_TYPE);
+        b.entity("{ \"version: \"" + Version.PXF_PROTOCOL_VERSION + "\"}");
+        b.type(MediaType.APPLICATION_JSON_TYPE);
         return b.build();
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/64a2338f/pxf/pxf-service/src/test/java/org/apache/hawq/pxf/service/rest/VersionResourceTest.java
----------------------------------------------------------------------
diff --git a/pxf/pxf-service/src/test/java/org/apache/hawq/pxf/service/rest/VersionResourceTest.java
b/pxf/pxf-service/src/test/java/org/apache/hawq/pxf/service/rest/VersionResourceTest.java
index 58ca4e3..383d855 100644
--- a/pxf/pxf-service/src/test/java/org/apache/hawq/pxf/service/rest/VersionResourceTest.java
+++ b/pxf/pxf-service/src/test/java/org/apache/hawq/pxf/service/rest/VersionResourceTest.java
@@ -36,7 +36,7 @@ public class VersionResourceTest {
 
         assertEquals(Response.Status.OK,
                 Response.Status.fromStatusCode(result.getStatus()));
-        assertEquals("PXF protocol version " + Version.PXF_PROTOCOL_VERSION,
+        assertEquals("{ \"version: \"" + Version.PXF_PROTOCOL_VERSION + "\"}",
                 result.getEntity().toString());
     }
 }


Mime
View raw message