sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject svn commit: r1362238 - in /sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client: core/ClientError.java shell/SetCommand.java shell/SqoopCommand.java
Date Mon, 16 Jul 2012 20:26:48 GMT
Author: jarcec
Date: Mon Jul 16 20:26:48 2012
New Revision: 1362238

URL: http://svn.apache.org/viewvc?rev=1362238&view=rev
Log:
SQOOP-495. Support for parameter substitution in the client shell.

(Vasanth kumar RJ via Jarek Jarcec Cecho)

Modified:
    sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/core/ClientError.java
    sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/shell/SetCommand.java
    sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/shell/SqoopCommand.java

Modified: sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/core/ClientError.java
URL: http://svn.apache.org/viewvc/sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/core/ClientError.java?rev=1362238&r1=1362237&r2=1362238&view=diff
==============================================================================
--- sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/core/ClientError.java
(original)
+++ sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/core/ClientError.java
Mon Jul 16 20:26:48 2012
@@ -31,7 +31,10 @@ public enum ClientError implements Error
   CLIENT_0002("The specified function is not recognized"),
 
   /** An error has occurred when parsing options. */
-  CLIENT_0003("An error has occurred when parsing options");
+  CLIENT_0003("An error has occurred when parsing options"),
+
+  /** Unable to resolve the variables. */
+  CLIENT_0004("Unable to resolve the variables");
 
   private final String message;
 

Modified: sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/shell/SetCommand.java
URL: http://svn.apache.org/viewvc/sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/shell/SetCommand.java?rev=1362238&r1=1362237&r2=1362238&view=diff
==============================================================================
--- sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/shell/SetCommand.java
(original)
+++ sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/shell/SetCommand.java
Mon Jul 16 20:26:48 2012
@@ -41,7 +41,7 @@ public class SetCommand extends SqoopCom
       io.out.println();
       return null;
     }
-
+    resolveVariables(args);
     String func = (String)args.get(0);
     if (func.equals("server")) {
       if (serverFunction == null) {

Modified: sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/shell/SqoopCommand.java
URL: http://svn.apache.org/viewvc/sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/shell/SqoopCommand.java?rev=1362238&r1=1362237&r2=1362238&view=diff
==============================================================================
--- sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/shell/SqoopCommand.java
(original)
+++ sqoop/branches/sqoop2/client/src/main/java/org/apache/sqoop/client/shell/SqoopCommand.java
Mon Jul 16 20:26:48 2012
@@ -17,9 +17,18 @@
  */
 package org.apache.sqoop.client.shell;
 
+import groovy.lang.GroovyShell;
+import groovy.lang.MissingPropertyException;
+import groovy.lang.Script;
+
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.LinkedList;
+import java.util.List;
 
+import org.apache.sqoop.client.core.ClientError;
+import org.apache.sqoop.common.SqoopException;
 import org.codehaus.groovy.tools.shell.ComplexCommandSupport;
 import org.codehaus.groovy.tools.shell.Shell;
 
@@ -112,4 +121,20 @@ public abstract class SqoopCommand exten
 
     return help;
   }
+
+  @SuppressWarnings({ "rawtypes", "unchecked" })
+  protected void resolveVariables(List arg) {
+    List temp = new ArrayList();
+    GroovyShell gs = new GroovyShell(getBinding());
+    for(Object obj:arg) {
+      Script scr = gs.parse("\""+(String)obj+"\"");
+      try {
+        temp.add(scr.run().toString());
+      }
+      catch(MissingPropertyException e) {
+        throw new SqoopException(ClientError.CLIENT_0004, e.getMessage(), e);
+      }
+    }
+    Collections.copy(arg, temp);
+  }
 }
\ No newline at end of file



Mime
View raw message