falcon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From venkat...@apache.org
Subject [1/2] git commit: FALCON-212 OozieClient does not propagate user in request to Oozie server. Contributed by Venkatesh Seetharam.
Date Wed, 20 Nov 2013 02:06:15 GMT
Updated Branches:
  refs/heads/branch-0.4 c2731dcfd -> 07e086a9a


FALCON-212 OozieClient does not propagate user in request to Oozie server. Contributed by
Venkatesh Seetharam.


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

Branch: refs/heads/branch-0.4
Commit: a39995dfd41d2c3c13da604bfdc9817b58019f69
Parents: c2731dc
Author: Venkatesh Seetharam <venkatesh@apache.org>
Authored: Tue Nov 19 18:02:53 2013 -0800
Committer: Venkatesh Seetharam <venkatesh@apache.org>
Committed: Tue Nov 19 18:02:53 2013 -0800

----------------------------------------------------------------------
 CHANGES.txt                                            |  3 +++
 .../org/apache/oozie/client/CustomOozieClient.java     | 13 +++++++++++++
 .../java/org/apache/falcon/resource/TestContext.java   |  3 +++
 3 files changed, 19 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/a39995df/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index f6cf839..c6cb77a 100755
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -187,6 +187,9 @@ Release Version: 0.4-incubating
     FALCON-203 Do not generate transitive closure for the dependency graph
     (Haohui Mai via Venkatesh Seetharam)
 
+    FALCON-212 OozieClient does not propagate user in request to
+    Oozie server (Venkatesh Seetharam)
+
 
 
 Release Version: 0.3-incubating

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/a39995df/oozie/src/main/java/org/apache/oozie/client/CustomOozieClient.java
----------------------------------------------------------------------
diff --git a/oozie/src/main/java/org/apache/oozie/client/CustomOozieClient.java b/oozie/src/main/java/org/apache/oozie/client/CustomOozieClient.java
index 2f430ba..c55221e 100644
--- a/oozie/src/main/java/org/apache/oozie/client/CustomOozieClient.java
+++ b/oozie/src/main/java/org/apache/oozie/client/CustomOozieClient.java
@@ -18,7 +18,9 @@
 
 package org.apache.oozie.client;
 
+import org.apache.falcon.security.CurrentUser;
 import org.apache.falcon.util.RuntimeProperties;
+import org.apache.log4j.Logger;
 import org.apache.oozie.client.rest.RestConstants;
 import org.json.simple.JSONObject;
 import org.json.simple.JSONValue;
@@ -37,6 +39,7 @@ import java.util.Properties;
  */
 public class CustomOozieClient extends OozieClient {
 
+    private static final Logger LOG = Logger.getLogger(CustomOozieClient.class);
     private static final Map<String, String> NONE = new HashMap<String, String>();
 
     public CustomOozieClient(String oozieUrl) {
@@ -53,6 +56,16 @@ public class CustomOozieClient extends OozieClient {
 
     @Override
     protected HttpURLConnection createConnection(URL url, String method) throws IOException,
OozieClientException {
+        String strUrl = url.toString();
+        if (!strUrl.contains(OozieClient.USER_NAME)) { // decorate the url with the user
in request
+            String paramSeparator = (strUrl.contains("?")) ? "&" : "?";
+            strUrl += paramSeparator + OozieClient.USER_NAME + "=" + CurrentUser.getUser();
+            url = new URL(strUrl);
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Decorated url with user info: " + url);
+            }
+        }
+
         HttpURLConnection conn = super.createConnection(url, method);
 
         int connectTimeout = Integer.valueOf(RuntimeProperties.get().getProperty("oozie.connect.timeout",
"1000"));

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/a39995df/webapp/src/test/java/org/apache/falcon/resource/TestContext.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/falcon/resource/TestContext.java b/webapp/src/test/java/org/apache/falcon/resource/TestContext.java
index f246948..d224f90 100644
--- a/webapp/src/test/java/org/apache/falcon/resource/TestContext.java
+++ b/webapp/src/test/java/org/apache/falcon/resource/TestContext.java
@@ -33,6 +33,7 @@ import org.apache.falcon.entity.v0.EntityType;
 import org.apache.falcon.entity.v0.SchemaHelper;
 import org.apache.falcon.entity.v0.cluster.Cluster;
 import org.apache.falcon.entity.v0.feed.Feed;
+import org.apache.falcon.security.CurrentUser;
 import org.apache.falcon.util.StartupProperties;
 import org.apache.falcon.workflow.engine.OozieClientFactory;
 import org.apache.hadoop.fs.FileSystem;
@@ -414,6 +415,8 @@ public class TestContext {
     }
 
     public static void prepare(String clusterTemplate) throws Exception {
+        // setup a logged in user
+        CurrentUser.authenticate(REMOTE_USER);
 
         Map<String, String> overlay = new HashMap<String, String>();
         overlay.put("cluster", RandomStringUtils.randomAlphabetic(5));


Mime
View raw message