return (0);
}
private int runCreate(BrokerCmdProperties brokerCmdProps) {
BrokerAdmin broker;
DestinationInfo destInfo;
String destName;
int destTypeMask;
Properties destAttrs;
broker = init();
if (broker == null) {
Globals.stdErrPrintln(ar.getString(ar.I_JMQCMD_CREATE_DST_FAIL));
return (1);
}
boolean force = brokerCmdProps.forceModeSet();
if (!force)
broker = promptForAuthentication(broker);
destName = brokerCmdProps.getTargetName();
destTypeMask = getDestTypeMask(brokerCmdProps);
destAttrs = brokerCmdProps.getTargetAttrs();
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_CREATE_DST));
BrokerCmdPrinter bcp = new BrokerCmdPrinter(2,4);
String[] row = new String[2];
bcp.setSortNeeded(false);
row[0] = ar.getString(ar.I_JMQCMD_DST_NAME);
row[1] = destName;
bcp.add(row);
row[0] = ar.getString(ar.I_JMQCMD_DST_TYPE);
row[1] = BrokerAdminUtil.getDestinationType(destTypeMask);
bcp.add(row);
/*
// Only print out the flavor type if the destination is a queue.
if (DestType.isQueue(destTypeMask)) {
row[0] = ar.getString(ar.I_JMQCMD_DST_FLAVOR);
row[1] = BrokerAdminUtil.getDestinationFlavor(destTypeMask);
bcp.add(row);
}
*/
// Check for optional destination attributes.
// Note that the same checking is done twice; once for printing
// and once for creating the DestinationInfo object. It can
// be combined, but this is cleaner.
String prop = null;
if ((prop = destAttrs.getProperty
(PROP_NAME_OPTION_MAX_MESG)) != null) {
row[0] = ar.getString(ar.I_JMQCMD_DST_MAX_MSG_ALLOW);
row[1] = prop;
bcp.add(row);
}
if ((prop = destAttrs.getProperty
(PROP_NAME_OPTION_MAX_MESG_BYTE)) != null) {
row[0] = ar.getString(ar.I_JMQCMD_DST_MAX_MSG_BYTES_ALLOW);
row[1] = prop;
bcp.add(row);
}
if ((prop = destAttrs.getProperty
(PROP_NAME_OPTION_MAX_PER_MESG_SIZE)) != null) {
row[0] = ar.getString(ar.I_JMQCMD_DST_MAX_BYTES_PER_MSG_ALLOW);
row[1] = prop;
bcp.add(row);
}
if ((prop = destAttrs.getProperty
(PROP_NAME_MAX_PRODUCERS)) != null) {
row[0] = ar.getString(ar.I_JMQCMD_DST_MAX_PRODUCERS);
row[1] = prop;
bcp.add(row);
}
if ((prop = destAttrs.getProperty
(PROP_NAME_MAX_ACTIVE_CONSUMER_COUNT)) != null) {
row[0] = ar.getString(ar.I_JMQCMD_DST_MAX_ACTIVE_CONSUMER_COUNT);
row[1] = prop;
bcp.add(row);
}
if ((prop = destAttrs.getProperty
(PROP_NAME_MAX_FAILOVER_CONSUMER_COUNT)) != null) {
row[0] = ar.getString(ar.I_JMQCMD_DST_MAX_FAILOVER_CONSUMER_COUNT);
row[1] = prop;
bcp.add(row);
}
if ((prop = destAttrs.getProperty
(PROP_NAME_LIMIT_BEHAVIOUR)) != null) {
row[0] = ar.getString(ar.I_JMQCMD_DST_LIMIT_BEHAVIOUR);
row[1] = prop;
bcp.add(row);
}
if ((prop = destAttrs.getProperty
(PROP_NAME_CONSUMER_FLOW_LIMIT)) != null) {
row[0] = ar.getString(ar.I_JMQCMD_DST_CONS_FLOW_LIMIT);
row[1] = prop;
bcp.add(row);
}
if ((prop = destAttrs.getProperty
(PROP_NAME_IS_LOCAL_DEST)) != null) {
row[0] = ar.getString(ar.I_JMQCMD_DST_IS_LOCAL_DEST);
row[1] = prop;
bcp.add(row);
}
if ((prop = destAttrs.getProperty
(PROP_NAME_LOCAL_DELIVERY_PREF)) != null) {
row[0] = ar.getString(ar.I_JMQCMD_DST_LOCAL_DELIVERY_PREF);
row[1] = prop;
bcp.add(row);
}
if ((prop = destAttrs.getProperty
(PROP_NAME_USE_DMQ)) != null) {
row[0] = ar.getString(ar.I_JMQCMD_DST_USE_DMQ);
row[1] = prop;
bcp.add(row);
}
if ((prop = destAttrs.getProperty
(PROP_NAME_VALIDATE_XML_SCHEMA_ENABLED)) != null) {
row[0] = ar.getString(ar.I_JMQCMD_DST_VALIDATE_XML_SCHEMA_ENABLED);
row[1] = prop;
bcp.add(row);
}
if ((prop = destAttrs.getProperty
(PROP_NAME_XML_SCHEMA_URI_LIST)) != null) {
row[0] = ar.getString(ar.I_JMQCMD_DST_XML_SCHEMA_URI_LIST);
row[1] = prop;
bcp.add(row);
}
bcp.println();
Globals.stdOutPrintln(ar.getString(ar.I_JMQCMD_SPECIFY_BKR));
printBrokerInfo(broker);
try {
SizeString ss;
long byteValue;
destInfo = new DestinationInfo();
destInfo.setType(destTypeMask);
destInfo.setName(destName);
// Check for optional destination attributes
if ((prop = destAttrs.getProperty
(PROP_NAME_OPTION_MAX_MESG_BYTE)) != null) {
try {
ss = new SizeString(prop);
byteValue = ss.getBytes();
destInfo.setMaxMessageBytes(byteValue);
} catch (NumberFormatException nfe) {
/*
* Do nothing. We shouldn't ever get here since
* we do input validation prior to all this.
*/
}
}
if ((prop = destAttrs.getProperty
(PROP_NAME_OPTION_MAX_MESG)) != null) {
destInfo.setMaxMessages(Integer.parseInt(prop));
}
if ((prop = destAttrs.getProperty
(PROP_NAME_OPTION_MAX_PER_MESG_SIZE)) != null) {
try {
ss = new SizeString(prop);
byteValue = ss.getBytes();
destInfo.setMaxMessageSize(byteValue);
} catch (NumberFormatException nfe) {
/*
* Do nothing. We shouldn't ever get here since
* we do input validation prior to all this.
*/
}
}
if ((prop = destAttrs.getProperty
(PROP_NAME_MAX_FAILOVER_CONSUMER_COUNT)) != null) {
destInfo.setMaxFailoverConsumers(Integer.parseInt(prop));
}
if ((prop = destAttrs.getProperty
(PROP_NAME_MAX_ACTIVE_CONSUMER_COUNT)) != null) {
destInfo.setMaxActiveConsumers(Integer.parseInt(prop));
}
if ((prop = destAttrs.getProperty
(PROP_NAME_IS_LOCAL_DEST)) != null) {
destInfo.setScope(Boolean.valueOf(prop).booleanValue());
}
if ((prop = destAttrs.getProperty
(PROP_NAME_LIMIT_BEHAVIOUR)) != null) {
destInfo.setLimitBehavior(getLimitBehavValue(prop));
}
if ((prop = destAttrs.getProperty
(PROP_NAME_LOCAL_DELIVERY_PREF)) != null) {
destInfo.setClusterDeliveryPolicy(getClusterDeliveryPolicy(prop));
}
if ((prop = destAttrs.getProperty
(PROP_NAME_CONSUMER_FLOW_LIMIT)) != null) {
destInfo.setPrefetch(Integer.parseInt(prop));
}
if ((prop = destAttrs.getProperty
(PROP_NAME_MAX_PRODUCERS)) != null) {
destInfo.setMaxProducers(Integer.parseInt(prop));
}
if ((prop = destAttrs.getProperty
(PROP_NAME_USE_DMQ)) != null) {
destInfo.setUseDMQ(Boolean.valueOf(prop).booleanValue());
}
if ((prop = destAttrs.getProperty
(PROP_NAME_VALIDATE_XML_SCHEMA_ENABLED)) != null) {
destInfo.setValidateXMLSchemaEnabled(Boolean.valueOf(prop).booleanValue());
}
if ((prop = destAttrs.getProperty
(PROP_NAME_XML_SCHEMA_URI_LIST)) != null) {
destInfo.setXMLSchemaUriList(prop);
}
if ((prop = destAttrs.getProperty
(PROP_NAME_RELOAD_XML_SCHEMA_ON_FAILURE)) != null) {
destInfo.setReloadXMLSchemaOnFailure(Boolean.valueOf(prop).booleanValue());
}
connectToBroker(broker);
broker.sendCreateDestinationMessage(destInfo);