http://git-wip-us.apache.org/repos/asf/sqoop/blob/a32d8d1c/client/src/main/java/org/apache/sqoop/client/shell/SubmissionCommand.java ---------------------------------------------------------------------- diff --git a/client/src/main/java/org/apache/sqoop/client/shell/SubmissionCommand.java b/client/src/main/java/org/apache/sqoop/client/shell/SubmissionCommand.java index 39a2b31..2e1fb03 100644 --- a/client/src/main/java/org/apache/sqoop/client/shell/SubmissionCommand.java +++ b/client/src/main/java/org/apache/sqoop/client/shell/SubmissionCommand.java @@ -18,10 +18,13 @@ package org.apache.sqoop.client.shell; import org.apache.sqoop.client.core.ClientError; +import org.apache.sqoop.client.core.Constants; import org.apache.sqoop.common.SqoopException; import org.codehaus.groovy.tools.shell.Shell; +import java.text.MessageFormat; import java.util.List; +import java.util.ResourceBundle; /** * @@ -32,38 +35,41 @@ public class SubmissionCommand extends SqoopCommand { private SubmissionStopFunction stopFunction; private SubmissionStatusFunction statusFunction; + public SubmissionCommand(Shell shell) { - super(shell, "submission", "\\sub", - new String[] {"start", "stop", "status"}, - "Submission", "info"); + super(shell, Constants.CMD_SUBMISSION, Constants.CMD_SUBMISSION_SC, + new String[] {Constants.FN_START, Constants.FN_STOP, + Constants.FN_STATUS}, + Constants.PRE_SUBMISSION, Constants.SUF_INFO); } public Object execute(List args) { + String usageMsg = MessageFormat.format(getResource().getString(Constants + .RES_SUBMISSION_USAGE), getUsage()); if (args.size() == 0) { - io.out.println("Usage: submission " + getUsage()); + io.out.println(usageMsg); io.out.println(); return null; } String func = (String)args.get(0); - if (func.equals("start")) { + if (func.equals(Constants.FN_START)) { if (startFunction == null) { startFunction = new SubmissionStartFunction(io); } return startFunction.execute(args); - } else if (func.equals("stop")) { + } else if (func.equals(Constants.FN_STOP)) { if (stopFunction == null) { stopFunction = new SubmissionStopFunction(io); } return stopFunction.execute(args); - } else if (func.equals("status")) { + } else if (func.equals(Constants.FN_STATUS)) { if (statusFunction == null) { statusFunction = new SubmissionStatusFunction(io); } return statusFunction.execute(args); } else { - String msg = "Usage: status " + getUsage(); - throw new SqoopException(ClientError.CLIENT_0002, msg); + throw new SqoopException(ClientError.CLIENT_0002, usageMsg); } } }
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a32d8d1c/client/src/main/java/org/apache/sqoop/client/shell/SubmissionStartFunction.java ---------------------------------------------------------------------- diff --git a/client/src/main/java/org/apache/sqoop/client/shell/SubmissionStartFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/SubmissionStartFunction.java index 74ce905..ba05dbb 100644 --- a/client/src/main/java/org/apache/sqoop/client/shell/SubmissionStartFunction.java +++ b/client/src/main/java/org/apache/sqoop/client/shell/SubmissionStartFunction.java @@ -19,6 +19,7 @@ package org.apache.sqoop.client.shell; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.OptionBuilder; +import org.apache.sqoop.client.core.Constants; import org.apache.sqoop.client.core.RequestCache; import org.apache.sqoop.client.utils.SubmissionDisplayer; import org.apache.sqoop.model.MSubmission; @@ -30,7 +31,6 @@ import java.util.List; * */ public class SubmissionStartFunction extends SqoopFunction { - private static final String JID = "jid"; private IO io; @@ -39,21 +39,21 @@ public class SubmissionStartFunction extends SqoopFunction { this.io = io; this.addOption(OptionBuilder - .withDescription("Job ID") - .withLongOpt(JID) + .withDescription(getResource().getString(Constants.RES_PROMPT_JOB_ID)) + .withLongOpt(Constants.OPT_JID) .hasArg() - .create(JID.charAt(0))); + .create(Constants.OPT_JID_CHAR)); } public Object execute(List<String> args) { CommandLine line = parseOptions(this, 1, args); - if (!line.hasOption(JID)) { - io.out.println("Required argument --jid is missing."); + if (!line.hasOption(Constants.OPT_JID)) { + io.out.println(getResource().getString(Constants.RES_ARGS_JID_MISSING)); return null; } MSubmission submission = - RequestCache.createSubmission(line.getOptionValue(JID)); + RequestCache.createSubmission(line.getOptionValue(Constants.OPT_JID)); SubmissionDisplayer.display(io, submission); return null; http://git-wip-us.apache.org/repos/asf/sqoop/blob/a32d8d1c/client/src/main/java/org/apache/sqoop/client/shell/SubmissionStatusFunction.java ---------------------------------------------------------------------- diff --git a/client/src/main/java/org/apache/sqoop/client/shell/SubmissionStatusFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/SubmissionStatusFunction.java index 4d683c0..dd63cd1 100644 --- a/client/src/main/java/org/apache/sqoop/client/shell/SubmissionStatusFunction.java +++ b/client/src/main/java/org/apache/sqoop/client/shell/SubmissionStatusFunction.java @@ -19,6 +19,7 @@ package org.apache.sqoop.client.shell; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.OptionBuilder; +import org.apache.sqoop.client.core.Constants; import org.apache.sqoop.client.core.RequestCache; import org.apache.sqoop.client.utils.SubmissionDisplayer; import org.apache.sqoop.model.MSubmission; @@ -30,7 +31,6 @@ import java.util.List; * */ public class SubmissionStatusFunction extends SqoopFunction { - private static final String JID = "jid"; private IO io; @@ -39,21 +39,21 @@ public class SubmissionStatusFunction extends SqoopFunction { this.io = io; this.addOption(OptionBuilder - .withDescription("Job ID") - .withLongOpt(JID) + .withDescription(getResource().getString(Constants.RES_PROMPT_JOB_ID)) + .withLongOpt(Constants.OPT_JID) .hasArg() - .create(JID.charAt(0))); + .create(Constants.OPT_JID_CHAR)); } public Object execute(List<String> args) { CommandLine line = parseOptions(this, 1, args); - if (!line.hasOption(JID)) { - io.out.println("Required argument --jid is missing."); + if (!line.hasOption(Constants.OPT_JID)) { + io.out.println(getResource().getString(Constants.RES_ARGS_JID_MISSING)); return null; } MSubmission submission = - RequestCache.readSubmission(line.getOptionValue(JID)); + RequestCache.readSubmission(line.getOptionValue(Constants.OPT_JID)); SubmissionDisplayer.display(io, submission); return null; http://git-wip-us.apache.org/repos/asf/sqoop/blob/a32d8d1c/client/src/main/java/org/apache/sqoop/client/shell/SubmissionStopFunction.java ---------------------------------------------------------------------- diff --git a/client/src/main/java/org/apache/sqoop/client/shell/SubmissionStopFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/SubmissionStopFunction.java index 97628f7..e71f8bf 100644 --- a/client/src/main/java/org/apache/sqoop/client/shell/SubmissionStopFunction.java +++ b/client/src/main/java/org/apache/sqoop/client/shell/SubmissionStopFunction.java @@ -19,6 +19,7 @@ package org.apache.sqoop.client.shell; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.OptionBuilder; +import org.apache.sqoop.client.core.Constants; import org.apache.sqoop.client.core.RequestCache; import org.apache.sqoop.client.utils.SubmissionDisplayer; import org.apache.sqoop.model.MSubmission; @@ -30,7 +31,6 @@ import java.util.List; * */ public class SubmissionStopFunction extends SqoopFunction { - private static final String JID = "jid"; private IO io; @@ -39,21 +39,21 @@ public class SubmissionStopFunction extends SqoopFunction { this.io = io; this.addOption(OptionBuilder - .withDescription("Job ID") - .withLongOpt(JID) - .hasArg() - .create(JID.charAt(0))); + .withDescription(getResource().getString(Constants.RES_PROMPT_JOB_ID)) + .withLongOpt(Constants.OPT_JID) + .hasArg() + .create(Constants.OPT_JID_CHAR)); } public Object execute(List<String> args) { CommandLine line = parseOptions(this, 1, args); - if (!line.hasOption(JID)) { - io.out.println("Required argument --jid is missing."); + if (!line.hasOption(Constants.OPT_JID)) { + io.out.println(getResource().getString(Constants.RES_ARGS_JID_MISSING)); return null; } MSubmission submission = - RequestCache.deleteSubmission(line.getOptionValue(JID)); + RequestCache.deleteSubmission(line.getOptionValue(Constants.OPT_JID)); SubmissionDisplayer.display(io, submission); return null; http://git-wip-us.apache.org/repos/asf/sqoop/blob/a32d8d1c/client/src/main/java/org/apache/sqoop/client/shell/UpdateCommand.java ---------------------------------------------------------------------- diff --git a/client/src/main/java/org/apache/sqoop/client/shell/UpdateCommand.java b/client/src/main/java/org/apache/sqoop/client/shell/UpdateCommand.java index 5bac209..d73b40e 100644 --- a/client/src/main/java/org/apache/sqoop/client/shell/UpdateCommand.java +++ b/client/src/main/java/org/apache/sqoop/client/shell/UpdateCommand.java @@ -18,10 +18,13 @@ package org.apache.sqoop.client.shell; import org.apache.sqoop.client.core.ClientError; +import org.apache.sqoop.client.core.Constants; import org.apache.sqoop.common.SqoopException; import org.codehaus.groovy.tools.shell.Shell; +import java.text.MessageFormat; import java.util.List; +import java.util.ResourceBundle; /** * @@ -32,32 +35,33 @@ public class UpdateCommand extends SqoopCommand { private UpdateJobFunction jobFunction; public UpdateCommand(Shell shell) { - super(shell, "update", "\\up", - new String[] {"connection", "job"}, - "Update", "info"); + super(shell, Constants.CMD_UPDATE, Constants.CMD_UPDATE_SC, + new String[] {Constants.FN_CONNECTION, Constants.FN_JOB}, + Constants.PRE_UPDATE, Constants.SUF_INFO); } public Object execute(List args) { + String usageMsg = MessageFormat.format(getResource().getString(Constants + .RES_UPDATE_USAGE), getUsage()); if (args.size() == 0) { - io.out.println("Usage: create " + getUsage()); + io.out.println(usageMsg); io.out.println(); return null; } String func = (String)args.get(0); - if (func.equals("connection")) { + if (func.equals(Constants.FN_CONNECTION)) { if (connectionFunction == null) { connectionFunction = new UpdateConnectionFunction(io); } return connectionFunction.execute(args); - } else if (func.equals("job")) { + } else if (func.equals(Constants.FN_JOB)) { if (jobFunction == null) { jobFunction = new UpdateJobFunction(io); } return jobFunction.execute(args); } else { - String msg = "Usage: update " + getUsage(); - throw new SqoopException(ClientError.CLIENT_0002, msg); + throw new SqoopException(ClientError.CLIENT_0002, usageMsg); } } } http://git-wip-us.apache.org/repos/asf/sqoop/blob/a32d8d1c/client/src/main/java/org/apache/sqoop/client/shell/UpdateConnectionFunction.java ---------------------------------------------------------------------- diff --git a/client/src/main/java/org/apache/sqoop/client/shell/UpdateConnectionFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/UpdateConnectionFunction.java index 4e55dba..dd0df24 100644 --- a/client/src/main/java/org/apache/sqoop/client/shell/UpdateConnectionFunction.java +++ b/client/src/main/java/org/apache/sqoop/client/shell/UpdateConnectionFunction.java @@ -21,6 +21,7 @@ import jline.ConsoleReader; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.OptionBuilder; import org.apache.sqoop.client.core.ClientError; +import org.apache.sqoop.client.core.Constants; import org.apache.sqoop.common.SqoopException; import org.apache.sqoop.json.ConnectionBean; import org.apache.sqoop.model.MConnection; @@ -28,6 +29,7 @@ import org.apache.sqoop.validation.Status; import org.codehaus.groovy.tools.shell.IO; import java.io.IOException; +import java.text.MessageFormat; import java.util.List; import java.util.ResourceBundle; @@ -39,30 +41,30 @@ import static org.apache.sqoop.client.core.RequestCache.*; */ public class UpdateConnectionFunction extends SqoopFunction { - private static final String XID = "xid"; private IO io; + @SuppressWarnings("static-access") public UpdateConnectionFunction(IO io) { this.io = io; this.addOption(OptionBuilder - .withDescription("Connection ID") - .withLongOpt(XID) + .withDescription(getResource().getString(Constants.RES_PROMPT_CONN_ID)) + .withLongOpt(Constants.OPT_XID) .hasArg() - .create(XID.charAt(0))); + .create(Constants.OPT_XID_CHAR)); } public Object execute(List<String> args) { CommandLine line = parseOptions(this, 1, args); - if (!line.hasOption(XID)) { - io.out.println("Required argument --xid is missing."); + if (!line.hasOption(Constants.OPT_XID)) { + io.out.println(getResource().getString(Constants.RES_ARGS_XID_MISSING)); return null; } try { - updateConnection(line.getOptionValue(XID)); + updateConnection(line.getOptionValue(Constants.OPT_XID)); } catch (IOException ex) { throw new SqoopException(ClientError.CLIENT_0005, ex); } @@ -71,7 +73,8 @@ public class UpdateConnectionFunction extends SqoopFunction { } private void updateConnection(String connectionId) throws IOException { - io.out.println("Updating connection with id " + connectionId); + io.out.println(MessageFormat.format(getResource().getString(Constants + .RES_UPDATE_UPDATING_CONN), connectionId)); ConsoleReader reader = new ConsoleReader(); @@ -86,7 +89,8 @@ public class UpdateConnectionFunction extends SqoopFunction { Status status = Status.FINE; - io.out.println("Please update connection metadata:"); + io.out.println(getResource().getString(Constants + .RES_PROMPT_UPDATE_CONN_METADATA)); do { // Print error introduction if needed @@ -104,8 +108,8 @@ public class UpdateConnectionFunction extends SqoopFunction { status = updateConnectionApplyValidations(connection); } while(!status.canProceed()); - io.out.println("Connection was successfully updated with status " - + status.name()); + io.out.println(MessageFormat.format(getResource().getString(Constants + .RES_UPDATE_CONN_SUCCESSFUL), status.name())); } http://git-wip-us.apache.org/repos/asf/sqoop/blob/a32d8d1c/client/src/main/java/org/apache/sqoop/client/shell/UpdateJobFunction.java ---------------------------------------------------------------------- diff --git a/client/src/main/java/org/apache/sqoop/client/shell/UpdateJobFunction.java b/client/src/main/java/org/apache/sqoop/client/shell/UpdateJobFunction.java index f7cdf26..4fac977 100644 --- a/client/src/main/java/org/apache/sqoop/client/shell/UpdateJobFunction.java +++ b/client/src/main/java/org/apache/sqoop/client/shell/UpdateJobFunction.java @@ -21,6 +21,7 @@ import jline.ConsoleReader; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.OptionBuilder; import org.apache.sqoop.client.core.ClientError; +import org.apache.sqoop.client.core.Constants; import org.apache.sqoop.common.SqoopException; import org.apache.sqoop.json.JobBean; import org.apache.sqoop.model.MJob; @@ -28,6 +29,7 @@ import org.apache.sqoop.validation.Status; import org.codehaus.groovy.tools.shell.IO; import java.io.IOException; +import java.text.MessageFormat; import java.util.List; import java.util.ResourceBundle; @@ -39,30 +41,30 @@ import static org.apache.sqoop.client.core.RequestCache.*; */ public class UpdateJobFunction extends SqoopFunction { - private static final String JID = "jid"; private IO io; + @SuppressWarnings("static-access") public UpdateJobFunction(IO io) { this.io = io; this.addOption(OptionBuilder - .withDescription("Job ID") - .withLongOpt(JID) + .withDescription(getResource().getString(Constants.RES_PROMPT_JOB_ID)) + .withLongOpt(Constants.OPT_JID) .hasArg() - .create(JID.charAt(0))); + .create(Constants.OPT_JID_CHAR)); } public Object execute(List<String> args) { CommandLine line = parseOptions(this, 1, args); - if (!line.hasOption(JID)) { - io.out.println("Required argument --jid is missing."); + if (!line.hasOption(Constants.OPT_JID)) { + io.out.println(getResource().getString(Constants.RES_ARGS_JID_MISSING)); return null; } try { - updateJob(line.getOptionValue(JID)); + updateJob(line.getOptionValue(Constants.OPT_JID)); } catch (IOException ex) { throw new SqoopException(ClientError.CLIENT_0005, ex); } @@ -71,7 +73,8 @@ public class UpdateJobFunction extends SqoopFunction { } private void updateJob(String jobId) throws IOException { - io.out.println("Updating job with id " + jobId); + io.out.println(MessageFormat.format(getResource().getString(Constants + .RES_UPDATE_UPDATING_JOB), jobId)); ConsoleReader reader = new ConsoleReader(); @@ -86,7 +89,7 @@ public class UpdateJobFunction extends SqoopFunction { Status status = Status.FINE; - io.out.println("Please update job metadata:"); + io.out.println(getResource().getString(Constants.RES_PROMPT_UPDATE_JOB_METADATA)); do { // Print error introduction if needed @@ -103,7 +106,7 @@ public class UpdateJobFunction extends SqoopFunction { status = updateJobApplyValidations(job); } while(!status.canProceed()); - io.out.println("Job was successfully updated with status " - + status.name()); + io.out.println(MessageFormat.format(getResource().getString(Constants + .RES_UPDATE_JOB_SUCCESSFUL), status.name())); } } http://git-wip-us.apache.org/repos/asf/sqoop/blob/a32d8d1c/client/src/main/resources/client-resource.properties ---------------------------------------------------------------------- diff --git a/client/src/main/resources/client-resource.properties b/client/src/main/resources/client-resource.properties index 201efe9..a65b37e 100644 --- a/client/src/main/resources/client-resource.properties +++ b/client/src/main/resources/client-resource.properties @@ -21,3 +21,147 @@ object-name.label = Name object-name.help = Non unique name of the entity to help you remember \ it's purpose + + +############################# +# Messages +# +# Missing args +# +args.xid_missing = Required argument --xid is missing. +args.jid_missing = Required argument --jid is missing. +args.cid_missing = Required argument --cid is missing. +args.type_missing = Required argument --type is missing. +args.name_missing = Required argument --name is missing. +args.value_missing = Required argument --value is missing. + + +## Generic description of various ids, types etc +prmpt.conn_id = Connection ID +prompt.connector_id = Connector ID +prompt.job_id = Job ID +prompt.job_type = Job type + +## Prompt messages for updating, filling metadata info + +prompt.update_conn_metadata = Please update connection metadata: +prompt.update_job_metadata = Please update job metadata: +prompt.fill_conn_metadata = Please fill following values to create new \ +connection object +prompt.fill_job_metadata = Please fill following values to create new \ +job object + + + + +## Updating messages +updating.conn = Updating connection with id {0} +updating.job = Updating job with id {0} + +# +# Clone command +clone.usage = Usage: clone {0} +clone.conn_successful = Connection was successfully created with validation \ + status {0} and persistent id {1} +clone.job_successful = Job was successfully created with validation \ + status {0} and persistent id {1} +clone.cloning_conn = Cloning connection with id {0} +clone.cloning_job = Cloning job with id {0} + +# +# Create command +create.usage = Usage: create {0} +create.conn_successful = New connection was successfully created with \ + validation status {0} and persistent id {1} +create.job_successful = New job was successfully created with validation \ + status {0} and persistent id {1} +## Creating messages +create.creating_conn = Creating connection for connector with id {0} +create.creating_job = Creating job for connection with id {0} + +# +# Delete command +delete.usage = Usage: delete {0} + + +# +# Help command +help.usage = [<command>] +help.description = Display this help message +help.cmd_usage = Usage: @|bold {0} |@ {1} +help.message = Display the list of commands or the help text for \ + @|bold command|@. +help.info = For information about @|green Sqoop|@, visit: \ + @|cyan http://sqoop.apache.org/|@ +help.avail_commands = Available commands: +help.cmd_description = @|bold {0} ({1}|@) {2} +help.specific_cmd_info = For help on a specific command type: \ + help @|bold command|@ + +unrecognized.cmd = Unrecognized command {0} + +# +# Set command +set.usage = Usage: set {0} +set.prompt_opt_name = Client option name +set.prompt_opt_value = New option value +set.verbose_changed = Verbose option was changed to {0} +set.unknown_opt_ignored = Unknown option {0}. Ignoring... +set.host_description = Host name to invoke server resources +set.port_description = Port number to invoke server resources +set.webapp_description = Web app to invoke server resources +set.server_usage = Usage: set server +set.server_successful = Server is set successfully + + +show.usage = Usage: show {0} + +show.prompt_display_all_conns = Display all connections +show.prompt_display_conn_xid = Display the connection with xid +show.conn_usage = Usage: show connection +show.prompt_conns_to_show = @|bold {0} connection(s) to show: |@ +show.prompt_conn_info = Connection with id {0} and name: ${1} + +show.prompt_display_all_connectors = Display all connectors +show.prompt_display_connector_cid = Display the connector with xid +show.connector_usage = Usage: show connector +show.prompt_connectors_to_show = @|bold {0} connection(s) to show: |@ +show.prompt_connector_info = Connector with id {0}:\n Name: ${1} \n \ +Class: {2}\n Version: {3} + +show.framework_usage = Usage: show framework +show.prompt_framework_opts = @|bold Framework specific options: |@\nPersistent id: {0} + +show.prompt_display_all_jobs = Display all jobs +show.prompt_display_job_jid = Display jobwith given jid +show.job_usage = Usage: show job +show.prompt_jobs_to_show = @|bold {0} job(s) to show: |@ +show.prompt_job_info = Job with id {0} and name: ${1} + +show.prompt_display_all_servers = Display all server information +show.prompt_display_server_host = Display server host name +show.prompt_display_server_port = Display server port number +show.prompt_display_server_webapp = Display server web app name +show.server_usage = Usage: show server +show.prompt_server_host = @|bold Server host:|@ {0} +show.prompt_server_port = @|bold Server port:|@ {0} +show.prompt_server_webapp = @|bold Server webapp:|@ {0} + +show.prompt_display_all_versions = Display all versions +show.prompt_display_version_server = Display server version +show.prompt_display_version_client = Display client version +show.prompt_display_version_protocol = Display protocol version +show.version_usage = Usage: show version +show.prompt_version_client_server = @|bold {0} version:|@\n Sqoop {1} \ +revision {2} \n Compiled by {3} on {4} +show.prompt_version_protocol = @|bold Protocol version:|@\n {0} + +sqoop.shell_banner = @|green Sqoop Shell:|@ Type '@|bold help|@' or '@|bold \h|@' for help. +sqoop.prompt_shell_loadrc = Loading resource file {0} +sqoop.prompt_shell_loadedrc = Resource file loaded. + +submission.usage = Usage: submission {0} + +update.usage = Usage: update {0} +update.conn_successful = Connection was successfully updated with status {0} +update.job_successful = Job was successfully updated with status {0}
