throw new SQLException("Invalid string zoneid=(" + zoneid + ")");
}
ByteArrayOutputStream array = new ByteArrayOutputStream();
DeflaterOutputStream out_stream = new DeflaterOutputStream(array);
OutputSerializer os = new OutputSerializer(out_stream);
/* compute how many storable objects exists in zone. */
int amount = 0;
for (RPObject object : content) {
if (object.isStorable()) {
amount++;
}
}
os.write(amount);
boolean empty = true;
for (RPObject object : content) {
if (object.isStorable()) {
object.writeObject(os, DetailLevel.FULL);
empty = false;
}
}
out_stream.close();
/* Setup the stream for a blob */
ByteArrayInputStream inStream = new ByteArrayInputStream(array.toByteArray());
String query;
if (hasRPZone(transaction, zone.getID())) {
query = "update rpzone set data=?, protocol_version=[protocolVersion] where zone_id='[zoneid]'";
} else {
// do not add empty zones
if (empty) {
return;
}
query = "insert into rpzone(zone_id, data, protocol_version) values('[zoneid]', ?, [protocolVersion])";
}
Map<String, Object> params = new HashMap<String, Object>();
params.put("zoneid", zoneid);
params.put("protocolVersion", os.getProtocolVersion());
logger.debug("storeRPZone is executing query " + query);
transaction.execute(query, params, inStream);
}