You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hawq.apache.org by sh...@apache.org on 2015/12/15 01:22:04 UTC

incubator-hawq git commit: HAWQ-191. CR fixes - Remove Analyzer plugin from PXF

Repository: incubator-hawq
Updated Branches:
  refs/heads/master de474ea5b -> cefe2fe46


HAWQ-191. CR fixes - Remove Analyzer plugin from PXF


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

Branch: refs/heads/master
Commit: cefe2fe46489c1fec50bf54680c1ef5ea0dd7db8
Parents: de474ea
Author: Shivram Mani <sh...@gmail.com>
Authored: Mon Dec 14 16:22:00 2015 -0800
Committer: Shivram Mani <sh...@gmail.com>
Committed: Mon Dec 14 16:22:00 2015 -0800

----------------------------------------------------------------------
 .../pxf/service/rest/InvalidPathResource.java   | 49 +++++---------------
 1 file changed, 11 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/cefe2fe4/pxf/pxf-service/src/main/java/org/apache/hawq/pxf/service/rest/InvalidPathResource.java
----------------------------------------------------------------------
diff --git a/pxf/pxf-service/src/main/java/org/apache/hawq/pxf/service/rest/InvalidPathResource.java b/pxf/pxf-service/src/main/java/org/apache/hawq/pxf/service/rest/InvalidPathResource.java
index 1dee254..d3da48e 100644
--- a/pxf/pxf-service/src/main/java/org/apache/hawq/pxf/service/rest/InvalidPathResource.java
+++ b/pxf/pxf-service/src/main/java/org/apache/hawq/pxf/service/rest/InvalidPathResource.java
@@ -117,14 +117,21 @@ public class InvalidPathResource {
     private Response wrongPath(String path) {
 
         String errmsg;
-        String version = parseVersion(path);
+
+        List<PathSegment> pathSegments = rootUri.getPathSegments();
+
+        if(pathSegments.isEmpty()) {
+            return sendErrorMessage(getUnknownPathMsg());
+        }
+
+        String version = pathSegments.get(0).getPath();
+        String endPoint = (pathSegments.size() > 1) ? pathSegments.get(1).getPath() : null;
 
         Log.debug("REST request: " + rootUri.getAbsolutePath() + ". " +
                 "Version " + version + ", supported version is " + Version.PXF_PROTOCOL_VERSION);
 
-        if(version.equals(Version.PXF_PROTOCOL_VERSION)) { // api with incorrect path
-            String endPoint = parseEndpoint(path);
-            if (retiredEndPoints.contains(endPoint)) {
+        if(version.equals(Version.PXF_PROTOCOL_VERSION)) { // api with correct version but incorrect path
+            if (retiredEndPoints.contains(endPoint)) { // api with retired endpoint
                 errmsg = getRetiredPathMsg(endPoint);
             } else {
                 errmsg = getUnknownPathMsg();
@@ -149,40 +156,6 @@ public class InvalidPathResource {
     }
 
     /**
-     * Parses the version part from the path.
-     * The the absolute path is
-     * http://<host>:<port>/pxf/<version>/<rest of path>
-     *
-     * path - the path part after /pxf/
-     * returns the first element after /pxf/
-     */
-    private String parseVersion(String path) {
-
-        int slash = path.indexOf('/');
-        if (slash == -1) {
-            return path;
-        }
-
-        return path.substring(0, slash);
-    }
-
-    /**
-     * Parses the version part from the path.
-     * The the absolute path is
-     * http://<host>:<port>/pxf/<version>/<rest of path>
-     *
-     * path - the endpoint part after /pxf/
-     * returns the first element after /pxf/
-     */
-    private String parseEndpoint(String path) {
-        List<PathSegment> pathSegments = rootUri.getPathSegments();
-        if(pathSegments.size() < 2) {
-            return null;
-        }
-        return pathSegments.get(1).getPath();
-    }
-
-    /**
      * Returns unknown path message, with the path's special characters masked.
      */
     private String getUnknownPathMsg() {