}
QueryRecordsPushTopic records = OBJECT_MAPPER.readValue(callback.getResponse(),
QueryRecordsPushTopic.class);
if (records.getTotalSize() == 1) {
PushTopic topic = records.getRecords().get(0);
LOG.info("Found existing topic {}: {}", topicName, topic);
// check if we need to update topic query, notifyForFields or notifyForOperations
if (!query.equals(topic.getQuery())
|| (config.getNotifyForFields() != null
&& !config.getNotifyForFields().equals(topic.getNotifyForFields()))
|| (config.getNotifyForOperations() != null
&& !config.getNotifyForOperations().equals(topic.getNotifyForOperations()))
) {
if (!config.isUpdateTopic()) {
String msg = "Query doesn't match existing Topic and updateTopic is set to false";
throw new CamelException(msg);
}
// otherwise update the topic
updateTopic(topic.getId());
}
} else {
createTopic();
}