public void localSync(String topic, Object value,
String type, int position) {
/* Construct op, send it, then process it in the op engine. */
String jsonValue = JSON.toString(value);
ContextVector cv = null;
Operation op = null;
if (null != type) {
try {
op = this.engine.createOp(true, topic, jsonValue, type,
position, -1, null, -1);
cv = op.getContextVector();
} catch (OperationEngineException e) {
log.warning("Bad type: " + type + ", using null type instead.");
type = null;
}
}
Map<String, Object> message = new HashMap<String, Object>();
message.put("topic", topic);
message.put("value", jsonValue);
message.put("type", type);
message.put("position", position);
if (null != cv) {
int[] sites = cv.getSites();
if (null != sites) {
Integer[] Sites = new Integer[sites.length];
for (int i = 0; i < sites.length; ++i)
Sites[i] = sites[i];
message.put("context", Sites);