incubator-hcatalog-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hashut...@apache.org
Subject svn commit: r1229650 - in /incubator/hcatalog/trunk: CHANGES.txt src/java/org/apache/hcatalog/common/AuthUtils.java src/java/org/apache/hcatalog/common/HCatException.java src/test/org/apache/hcatalog/cli/TestEximSemanticAnalysis.java
Date Tue, 10 Jan 2012 17:34:33 GMT
Author: hashutosh
Date: Tue Jan 10 17:34:33 2012
New Revision: 1229650

URL: http://svn.apache.org/viewvc?rev=1229650&view=rev
Log:
HCATALOG-194: Better error messages for HCatalog access control errors (julienledem via hashutosh)

Modified:
    incubator/hcatalog/trunk/CHANGES.txt
    incubator/hcatalog/trunk/src/java/org/apache/hcatalog/common/AuthUtils.java
    incubator/hcatalog/trunk/src/java/org/apache/hcatalog/common/HCatException.java
    incubator/hcatalog/trunk/src/test/org/apache/hcatalog/cli/TestEximSemanticAnalysis.java

Modified: incubator/hcatalog/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/CHANGES.txt?rev=1229650&r1=1229649&r2=1229650&view=diff
==============================================================================
--- incubator/hcatalog/trunk/CHANGES.txt (original)
+++ incubator/hcatalog/trunk/CHANGES.txt Tue Jan 10 17:34:33 2012
@@ -52,6 +52,8 @@ Trunk (unreleased changes)
   HCAT-63. RPM package integration with Hadoop (khorgath via hashutosh)
 
   IMPROVEMENTS
+  HCAT-194. Better error messages for HCatalog access control errors (julienledem via hashutosh)
 
+
   HCAT-184. Optionally do not generate forrest docs (traviscrawford via hashutosh)
 
   HCAT-187. HCatalog release missing Hive builtins (traviscrawford via hashutosh)

Modified: incubator/hcatalog/trunk/src/java/org/apache/hcatalog/common/AuthUtils.java
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/src/java/org/apache/hcatalog/common/AuthUtils.java?rev=1229650&r1=1229649&r2=1229650&view=diff
==============================================================================
--- incubator/hcatalog/trunk/src/java/org/apache/hcatalog/common/AuthUtils.java (original)
+++ incubator/hcatalog/trunk/src/java/org/apache/hcatalog/common/AuthUtils.java Tue Jan 10
17:34:33 2012
@@ -63,10 +63,10 @@ public class AuthUtils {
       return;
     }
     catch (AccessControlException ace) {
-      throw new HCatException(ErrorType.ERROR_ACCESS_CONTROL, ace);
+      throw new HCatException(ErrorType.ERROR_ACCESS_CONTROL, "for path " + path, ace);
     } catch (org.apache.hadoop.fs.permission.AccessControlException ace){
       // Older hadoop version will throw this @deprecated Exception.
-      throw new HCatException(ErrorType.ERROR_ACCESS_CONTROL, ace);
+      throw new HCatException(ErrorType.ERROR_ACCESS_CONTROL, "for path " + path, ace);
     } catch (IOException ioe){
       throw new SemanticException(ioe);
     }
@@ -75,7 +75,7 @@ public class AuthUtils {
     try {
       ugi = ShimLoader.getHadoopShims().getUGIForConf(conf);
     } catch (LoginException le) {
-      throw new HCatException(ErrorType.ERROR_ACCESS_CONTROL,le);
+      throw new HCatException(ErrorType.ERROR_ACCESS_CONTROL, "for path " + path, le);
     } catch (IOException ioe) {
       throw new SemanticException(ioe);
     }
@@ -89,19 +89,18 @@ public class AuthUtils {
       if(dirPerms.getUserAction().implies(action)){
         return;
       }
-      throw new HCatException(ErrorType.ERROR_ACCESS_CONTROL);
+      throw new HCatException(ErrorType.ERROR_ACCESS_CONTROL, "action " + action + " not
permitted on path " + path + " for user " + user);
     }
     if(ArrayUtils.contains(ugi.getGroupNames(), grp)){
       if(dirPerms.getGroupAction().implies(action)){
         return;
       }
-      throw new HCatException(ErrorType.ERROR_ACCESS_CONTROL);
-
+      throw new HCatException(ErrorType.ERROR_ACCESS_CONTROL, "action " + action + " not
permitted on path " + path + " for group " + grp);
     }
     if(dirPerms.getOtherAction().implies(action)){
       return;
     }
-    throw new HCatException(ErrorType.ERROR_ACCESS_CONTROL);
+    throw new HCatException(ErrorType.ERROR_ACCESS_CONTROL, "action " + action + " not permitted
on path " + path + " for others");
 
 
   }

Modified: incubator/hcatalog/trunk/src/java/org/apache/hcatalog/common/HCatException.java
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/src/java/org/apache/hcatalog/common/HCatException.java?rev=1229650&r1=1229649&r2=1229650&view=diff
==============================================================================
--- incubator/hcatalog/trunk/src/java/org/apache/hcatalog/common/HCatException.java (original)
+++ incubator/hcatalog/trunk/src/java/org/apache/hcatalog/common/HCatException.java Tue Jan
10 17:34:33 2012
@@ -112,7 +112,7 @@ public class HCatException extends IOExc
     }
 
     if( type.appendCauseMessage() ) {
-      if( cause != null && cause.getMessage() != null ) {
+      if( cause != null ) {
         //Add the cause message to buffer
         message.append(". Cause : " + cause.toString());
       }

Modified: incubator/hcatalog/trunk/src/test/org/apache/hcatalog/cli/TestEximSemanticAnalysis.java
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/src/test/org/apache/hcatalog/cli/TestEximSemanticAnalysis.java?rev=1229650&r1=1229649&r2=1229650&view=diff
==============================================================================
--- incubator/hcatalog/trunk/src/test/org/apache/hcatalog/cli/TestEximSemanticAnalysis.java
(original)
+++ incubator/hcatalog/trunk/src/test/org/apache/hcatalog/cli/TestEximSemanticAnalysis.java
Tue Jan 10 17:34:33 2012
@@ -87,9 +87,9 @@ public class TestEximSemanticAnalysis ex
         .run("export table junit_sem_analysis to 'pfile://local:9080/tmp/hcat/exports/junit_sem_analysis'");
 
     assertEquals(10, response.getResponseCode());
-    assertEquals(
-        "FAILED: Error in semantic analysis: org.apache.hcatalog.common.HCatException : 3000
: Permission denied",
-        response.getErrorMessage());
+    assertTrue("Permission denied expected : "+response.getErrorMessage(),
+        response.getErrorMessage().startsWith(
+            "FAILED: Error in semantic analysis: org.apache.hcatalog.common.HCatException
: 3000 : Permission denied"));
     Runtime.getRuntime().exec("rm -rf /tmp/hcat");
     response = hcatDriver.run("drop table junit_sem_analysis");
     if (response.getResponseCode() != 0) {
@@ -121,9 +121,10 @@ public class TestEximSemanticAnalysis ex
         .run("import table junit_sem_analysis from 'pfile://local:9080/tmp/hcat/exports/junit_sem_analysis'");
 
     assertEquals(10, response.getResponseCode());
-    assertEquals(
-        "FAILED: Error in semantic analysis: org.apache.hcatalog.common.HCatException : 3000
: Permission denied",
-        response.getErrorMessage());
+    assertTrue(
+        "Permission denied expected: "+response.getErrorMessage() ,
+        response.getErrorMessage().startsWith(
+            "FAILED: Error in semantic analysis: org.apache.hcatalog.common.HCatException
: 3000 : Permission denied"));
     Runtime.getRuntime().exec("rm -rf /tmp/hcat");
 
     cluster.getFileSystem().setPermission(whPath, FsPermission.valueOf("-rwxrwxrwx"));



Mime
View raw message