command = (String)attrMap.get("_command");
else
command = "";
String destLiteral = null;
Destination destination = null;
List additionalDestinations = null;
if (attrMap != null)
destLiteral = (String)attrMap.get("_destination");
if (destLiteral != null) {
if (destLiteral.indexOf(',') < 0) {
destination = new Destination(new SessionName(this.glob, destLiteral));
destination.forceQueuing(true); // to ensure it works even if this comes before manager
}
else {
StringTokenizer tokenizer = new StringTokenizer(destLiteral, ","); // comma separated list
destination = new Destination(new SessionName(this.glob, tokenizer.nextToken().trim()));
destination.forceQueuing(true);
additionalDestinations = new ArrayList();
while (tokenizer.hasMoreTokens()) {
Destination tmp = new Destination(new SessionName(this.glob, tokenizer.nextToken().trim()));
tmp.forceQueuing(true);
}
}
}
// this is used to register the owner of this object (typically the DbWatcher)
if ("INITIAL_DATA_RESPONSE".equals(command) || "STATEMENT".equals(command)) {
PublishQos qos = null;
if (destination != null) {
qos = new PublishQos(this.glob, destination);
if (additionalDestinations != null) {
for (int i=0; i < additionalDestinations.size(); i++)
qos.addDestination((Destination)additionalDestinations.get(i));
}
}
else
qos = new PublishQos(this.glob);
qos.setSubscribable(true);
// to force to fill the client properties map !!
ClientPropertiesInfo tmpInfo = new ClientPropertiesInfo(attrMap);
new ClientPropertiesInfo(qos.getData().getClientProperties(), tmpInfo);
addStringPropToQos(attrMap, qos.getData());
PublishKey key = null;
if (changeKey != null && changeKey.length() > 0)
key = new PublishKey(this.glob, changeKey);
else
key = new PublishKey(this.glob, "dbWatcherUnspecified");
key.setContentMime("text/xml");
MsgUnit msg = new MsgUnit(key, out, qos);
PublishReturnQos prq = this.con.publish(msg);
String id = (prq.getRcvTimestamp()!=null)?prq.getRcvTimestamp().toString():"queued";
if (log.isLoggable(Level.FINE)) log.fine("Published '" + prq.getKeyOid() + "' '" + id + "'");
return id;
}
if (this.eraseOnDrop && "DROP".equals(command)) {
String oid = this.glob.getMsgKeyFactory().readObject(pk).getOid();
EraseKey ek = new EraseKey(glob, oid);
EraseQos eq = new EraseQos(glob);
con.erase(ek, eq);
log.info("Topic '" + pk + "' is erased:" + out);
return "0";
}
if (this.eraseOnDelete && "DELETE".equals(command)) {
String oid = this.glob.getMsgKeyFactory().readObject(pk).getOid();
EraseKey ek = new EraseKey(glob, oid);
EraseQos eq = new EraseQos(glob);
con.erase(ek, eq);
log.info("Topic '" + pk + "' is erased:" + out);
return "0";
}
if (log.isLoggable(Level.FINER))
log.finer("Topic '" + pk + "' is published: " + out);
try {
String oid = (String)attrMap.remove(ContribConstants.TOPIC_NAME); // consume it since only used to inform this method
if (destination != null) {
pk = this.adminKey;
}
if (oid != null)
pk = "<key oid='" + oid + "'/>";
MsgUnit msgUnit = new MsgUnit(pk, out, this.publishQos);
String tmp = msgUnit.getKeyData().getContentMime();
// FIXME pass this in the map and set only if explicitly set in the map
if (tmp == null || tmp.equals("text/plain")) {
msgUnit.getKeyData().setContentMime("text/xml");
}
if (destination != null)
((MsgQosData)msgUnit.getQosData()).addDestination(destination);