if (client.startsWith("?")) {
// for example "/node/heron/topic/Hello/?content=World!"
throw new XmlBlasterException(this.glob, ErrorCode.USER_ILLEGALARGUMENT, ME + ".set", "Please pass a command which has a valid message oid added, '" + cmd.getCommand() + "' is too short, aborted request.");
}
I_XmlBlaster xmlBlaster = glob.getAuthenticate().getXmlBlaster();
// /node/heron/topic/?hello
// /node/heron/topic/hello/?content=Hello world
String oidTmp = cmd.getUserNameLevel();
if (oidTmp == null || oidTmp.length() < 1)
throw new XmlBlasterException(this.glob, ErrorCode.USER_ILLEGALARGUMENT, ME + ".set", "Please pass a command which has a valid message oid added, '" + cmd.getCommand() + "' is too short, aborted request.");
String oid = oidTmp;
if (oidTmp.startsWith("?"))
throw new XmlBlasterException(this.glob, ErrorCode.USER_ILLEGALARGUMENT, ME + ".set", "Please pass a command which has a valid message oid added, '" + cmd.getCommand() + "' is too short, aborted request.");
String xmlKey = "<key oid='" + oid + "'/>";
String qos = "<qos/>";
// The returned array is a clone, we may manipulate it
MsgUnitRaw[] msgUnitArrRaw = xmlBlaster.get(addressServer, sessionId, xmlKey, qos);
if (msgUnitArrRaw.length < 1) {
log.info(cmd.getCommand() + " Message oid=" + oid + " not found");
return null;
}
// /node/heron/topic/hello/?content=Hello world
String key = cmd.getKey(); // -> "content"
//String value = cmd.getValue(); // -> "Hello world"
if (!key.equalsIgnoreCase("content"))
throw new XmlBlasterException(glob, ErrorCode.USER_ADMIN_INVALID, ME,
"Only the 'content' can currently be changed on messages," +
" try something like '?content=Hello world'");
/*
for (int ii=0; ii<msgUnitArr.length; ii++) {
// Shallow clone: Setting new content. We keep the original key, but kill the original QoS
PublishQos publishQos = new PublishQos(glob);
msgUnitArrRaw[ii] = new MsgUnitRaw(msgUnitArr[ii].getKey(), value.getBytes(), publishQos.toXml());
}
*/
String[] retArr = xmlBlaster.publishArr(addressServer, sessionId, msgUnitArrRaw);
log.info(cmd.getCommand() + " published " + msgUnitArrRaw.length + " messages");
StringBuffer sb = new StringBuffer(retArr.length * 60);
for (int ii=0; ii<retArr.length; ii++) {
sb.append(retArr[ii]);