sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject sqoop git commit: SQOOP-2139: Sqoop2: Change create role API from PUT to POST
Date Fri, 27 Feb 2015 21:32:32 GMT
Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 418b9a70f -> 9f14dd10d


SQOOP-2139: Sqoop2: Change create role API from PUT to POST

(Richard Zhou via Abraham Elmahrek)


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

Branch: refs/heads/sqoop2
Commit: 9f14dd10d65a8b1ea1bcf3cfaba1aca106c6d410
Parents: 418b9a7
Author: Abraham Elmahrek <abe@apache.org>
Authored: Fri Feb 27 13:31:58 2015 -0800
Committer: Abraham Elmahrek <abe@apache.org>
Committed: Fri Feb 27 13:32:21 2015 -0800

----------------------------------------------------------------------
 .../sqoop/client/request/AuthorizationResourceRequest.java  | 2 +-
 .../apache/sqoop/handler/AuthorizationRequestHandler.java   | 9 +++++++--
 .../java/org/apache/sqoop/server/AuthorizationServlet.java  | 7 ++++++-
 3 files changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/9f14dd10/client/src/main/java/org/apache/sqoop/client/request/AuthorizationResourceRequest.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/request/AuthorizationResourceRequest.java
b/client/src/main/java/org/apache/sqoop/client/request/AuthorizationResourceRequest.java
index cdd8e73..0bb9a7f 100644
--- a/client/src/main/java/org/apache/sqoop/client/request/AuthorizationResourceRequest.java
+++ b/client/src/main/java/org/apache/sqoop/client/request/AuthorizationResourceRequest.java
@@ -63,7 +63,7 @@ public class AuthorizationResourceRequest extends ResourceRequest {
     RoleBean roleBean = new RoleBean(role);
     // Extract all config inputs including sensitive inputs
     JSONObject roleJson = roleBean.extract(false);
-    super.put(serverUrl + RESOURCE + ROLES + CREATE, roleJson.toJSONString());
+    super.post(serverUrl + RESOURCE + ROLES + CREATE, roleJson.toJSONString());
   }
 
   public void dropRole(String serverUrl, MRole role) {

http://git-wip-us.apache.org/repos/asf/sqoop/blob/9f14dd10/server/src/main/java/org/apache/sqoop/handler/AuthorizationRequestHandler.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/handler/AuthorizationRequestHandler.java
b/server/src/main/java/org/apache/sqoop/handler/AuthorizationRequestHandler.java
index 361d14b..5562592 100644
--- a/server/src/main/java/org/apache/sqoop/handler/AuthorizationRequestHandler.java
+++ b/server/src/main/java/org/apache/sqoop/handler/AuthorizationRequestHandler.java
@@ -90,14 +90,19 @@ public class AuthorizationRequestHandler implements RequestHandler {
           default:
             throw new SqoopException(ServerError.SERVER_0003, "Invalid action in url" + url);
         }
+      case POST:
+        switch (action) {
+          case CREATE:                              //url: /authorization/roles/create
+            return createRole(ctx);
+          default:
+            throw new SqoopException(ServerError.SERVER_0003, "Invalid action in url" + url);
+        }
       case PUT:
         String[] urlElements = ctx.getUrlElements();
         Action first_level_action = Action.fromString(urlElements[urlElements.length - 2]);
         switch (first_level_action) {
           case ROLES:
             switch (action) {
-              case CREATE:                              //url: /authorization/roles/create
-                return createRole(ctx);
               case GRANT:                               //url: /authorization/roles/grant
                 return grantRevokeRole(ctx, true);
               case REVOKE:                              //url: /authorization/roles/revoke

http://git-wip-us.apache.org/repos/asf/sqoop/blob/9f14dd10/server/src/main/java/org/apache/sqoop/server/AuthorizationServlet.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/server/AuthorizationServlet.java b/server/src/main/java/org/apache/sqoop/server/AuthorizationServlet.java
index 65c434d..4af26d9 100644
--- a/server/src/main/java/org/apache/sqoop/server/AuthorizationServlet.java
+++ b/server/src/main/java/org/apache/sqoop/server/AuthorizationServlet.java
@@ -23,7 +23,7 @@ import org.apache.sqoop.json.JsonBean;
 /**
  * Provides operations for authorization
  *
- * PUT /authorization/roles/create
+ * POST /authorization/roles/create
  * Create new role with {name}
  *
  * DELETE /authorization/role/{role-name}
@@ -73,6 +73,11 @@ public class AuthorizationServlet extends SqoopProtocolServlet {
   }
 
   @Override
+  protected JsonBean handlePostRequest(RequestContext ctx) throws Exception {
+    return authorizationRequestHandler.handleEvent(ctx);
+  }
+
+  @Override
   protected JsonBean handlePutRequest(RequestContext ctx) throws Exception {
     return authorizationRequestHandler.handleEvent(ctx);
   }


Mime
View raw message