return(ar.getString(ar.I_JMQCMD_TXN_STATE_UNKNOWN));
}
}
private int runPause(BrokerCmdProperties brokerCmdProps) {
BrokerAdmin broker;
String input = null;
String yes, yesShort, no, noShort;
yes = ar.getString(ar.Q_RESPONSE_YES);
yesShort = ar.getString(ar.Q_RESPONSE_YES_SHORT);
no = ar.getString(ar.Q_RESPONSE_NO);
noShort = ar.getString(ar.Q_RESPONSE_NO_SHORT);
broker = init();
boolean force = brokerCmdProps.forceModeSet();
// Check for the target argument
String commandArg = brokerCmdProps.getCommandArg();
if (CMDARG_BROKER.equals(commandArg)) {
if (broker == null) {
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_PAUSE_BKR_FAIL));
return (1);
}
if (!force)
broker = promptForAuthentication(broker);
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_PAUSE_BKR));
printBrokerInfo(broker);
try {
connectToBroker(broker);
} catch (BrokerAdminException bae) {
handleBrokerAdminException(bae);
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_PAUSE_BKR_FAIL));
return (1);
}
if (!force) {
input = CommonCmdRunnerUtil.getUserInput(ar.getString(ar.Q_PAUSE_BKR_OK), noShort);
Globals.stdOutPrintln("");
}
if (yesShort.equalsIgnoreCase(input) || yes.equalsIgnoreCase(input) || force) {
try {
broker.sendPauseMessage(null);
broker.receivePauseReplyMessage();
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_PAUSE_BKR_SUC));
} catch (BrokerAdminException bae) {
handleBrokerAdminException(bae);
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_PAUSE_BKR_FAIL));
return (1);
}
} else if (noShort.equalsIgnoreCase(input) || no.equalsIgnoreCase(input)) {
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_PAUSE_BKR_NOOP));
return (0);
} else {
Globals.stdOutPrintln(ar.getString(ar.I_UNRECOGNIZED_RES, input));
Globals.stdOutPrintln("");
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_PAUSE_BKR_NOOP));
return (1);
}
} else if (CMDARG_SERVICE.equals(commandArg)) {
if (broker == null) {
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_PAUSE_SVC_FAIL));
return (1);
}
if (!force)
broker = promptForAuthentication(broker);
String svcName = brokerCmdProps.getTargetName();
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_PAUSE_SVC));
printServiceInfo();
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_SPECIFY_BKR));
printBrokerInfo(broker);
try {
connectToBroker(broker);
} catch (BrokerAdminException bae) {
handleBrokerAdminException(bae);
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_PAUSE_SVC_FAIL));
return (1);
}
try {
isAdminService(broker, svcName);
} catch (BrokerAdminException bae) {
if (BrokerAdminException.INVALID_OPERATION == bae.getType())
bae.setBrokerErrorStr
(ar.getString(ar.I_ERROR_MESG) +
ar.getKString(ar.E_CANNOT_PAUSE_SVC, svcName));
handleBrokerAdminException(bae);
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_PAUSE_SVC_FAIL));
return (1);
}
if (!force) {
input = CommonCmdRunnerUtil.getUserInput(ar.getString(ar.Q_PAUSE_SVC_OK), noShort);
Globals.stdOutPrintln("");
}
if (yesShort.equalsIgnoreCase(input) || yes.equalsIgnoreCase(input) || force) {
try {
broker.sendPauseMessage(svcName);
broker.receivePauseReplyMessage();
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_PAUSE_SVC_SUC));
} catch (BrokerAdminException bae) {
handleBrokerAdminException(bae);
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_PAUSE_SVC_FAIL));
return (1);
}
} else if (noShort.equalsIgnoreCase(input) || no.equalsIgnoreCase(input)) {
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_PAUSE_SVC_NOOP));
return (0);
} else {
Globals.stdOutPrintln(ar.getString(ar.I_UNRECOGNIZED_RES, input));
Globals.stdOutPrintln("");
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_PAUSE_SVC_NOOP));
return (1);
}
} else if (CMDARG_DESTINATION.equals(commandArg)) {
String destName, pauseTypeStr;
BrokerCmdPrinter bcp = new BrokerCmdPrinter(2,4);
String[] row = new String[2];
boolean pauseAll = true;
int destTypeMask;
destName = brokerCmdProps.getTargetName();
destTypeMask = getDestTypeMask(brokerCmdProps);
pauseTypeStr = brokerCmdProps.getPauseType();
if (destName != null) {
pauseAll = false;
}
if (broker == null) {
if (pauseAll) {
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_PAUSE_DSTS_FAIL));
} else {
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_PAUSE_DST_FAIL));
}
return (1);
}
if (!force)
broker = promptForAuthentication(broker);
if (pauseAll) {
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_PAUSE_DSTS));
} else {
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_PAUSE_DST));
printDestinationInfo();
}
// Only print out the pause type if it was specified
if (pauseTypeStr != null) {
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_USING_ATTR));
row[0] = ar.getString(ar.I_JMQCMD_PAUSE_DST_TYPE);
row[1] = pauseTypeStr;
bcp.add(row);
bcp.println();
}
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_SPECIFY_BKR));
printBrokerInfo(broker);
try {
connectToBroker(broker);
} catch (BrokerAdminException bae) {
handleBrokerAdminException(bae);
if (pauseAll) {
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_PAUSE_DSTS_FAIL));
} else {
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_PAUSE_DST_FAIL));
}
return (1);
}
if (!force) {
if (pauseAll) {
input = CommonCmdRunnerUtil.getUserInput(ar.getString(ar.Q_PAUSE_DSTS_OK), noShort);
} else {
input = CommonCmdRunnerUtil.getUserInput(ar.getString(ar.Q_PAUSE_DST_OK), noShort);
}
Globals.stdOutPrintln("");
}
if (yesShort.equalsIgnoreCase(input) || yes.equalsIgnoreCase(input) || force) {
try {
int pauseType = getPauseTypeVal(pauseTypeStr);
broker.sendPauseMessage(destName, destTypeMask, pauseType);
broker.receivePauseReplyMessage();
if (pauseAll) {
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_PAUSE_DSTS_SUC));
} else {
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_PAUSE_DST_SUC));
}
} catch (BrokerAdminException bae) {
handleBrokerAdminException(bae);
if (pauseAll) {
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_PAUSE_DSTS_FAIL));
} else {
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_PAUSE_DST_FAIL));
}
return (1);
}
} else if (noShort.equalsIgnoreCase(input) || no.equalsIgnoreCase(input)) {
if (pauseAll) {
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_PAUSE_DSTS_NOOP));
} else {
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_PAUSE_DST_NOOP));
}
return (0);
} else {
Globals.stdOutPrintln(ar.getString(ar.I_UNRECOGNIZED_RES, input));
Globals.stdOutPrintln("");
if (pauseAll) {
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_PAUSE_DSTS_NOOP));
} else {
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_PAUSE_DST_NOOP));
}
return (1);
}
}
broker.close();
return (0);
}