*/
public void update(JSONObject json) throws CNSModelConstructionException, CMBException {
if (!json.has("http")) {
String errorMessage = "Topic Delivery Policy missing policy for http";
logger.error("event=update_cns_topic_delivery_policy message=" + errorMessage);
throw new CMBException(CNSErrorCodes.CNS_InvalidParameter, errorMessage);
}
String errorMessage = "";
boolean error = false;
try {
CNSRetryPolicy ldefaultHealthyRetryPolicy = null;
CNSRetryPolicy ldefaultSicklyRetryPolicy = null;
CNSThrottlePolicy ldefaultThrottlePolicy = null;
boolean ldisableSubscriptionOverrides = false;
JSONObject json2 = json.getJSONObject("http");
if (json2.has("defaultHealthyRetryPolicy") && (json2.get("defaultHealthyRetryPolicy") != JSONObject.NULL)) {
try {
ldefaultHealthyRetryPolicy = new CNSRetryPolicy(json2.getJSONObject("defaultHealthyRetryPolicy"));
} catch (Exception e) {
if(e instanceof CNSModelConstructionException) {
String message = ((CNSModelConstructionException) e).getErrormessage();
errorMessage = "DeliveryPolicy: defaultHealthyRetryPolicy." + message;
error = true;
}
}
} else {
ldefaultHealthyRetryPolicy = new CNSRetryPolicy();
}
if ((json2.has("defaultSicklyRetryPolicy")) &&(json2.get("defaultSicklyRetryPolicy") != JSONObject.NULL)) {
try {
ldefaultSicklyRetryPolicy = new CNSRetryPolicy(json2.getJSONObject("defaultSicklyRetryPolicy"));
} catch (Exception e) {
if (e instanceof CNSModelConstructionException) {
String message = ((CNSModelConstructionException) e).getErrormessage();
errorMessage = "DeliveryPolicy: defaultSicklyRetryPolicy." + message;
error = true;
}
}
} else {
ldefaultSicklyRetryPolicy = null;
}
if ((json2.has("disableSubscriptionOverrides"))) {
try {
ldisableSubscriptionOverrides = json2.getBoolean("disableSubscriptionOverrides");
} catch (Exception e) {
errorMessage = "DeliveryPolicy: disableSubscriptionOverrides must be a boolean";
error = true;
}
} else {
ldisableSubscriptionOverrides = false;
}
if ((json2.has("defaultThrottlePolicy")) && (json2.get("defaultThrottlePolicy") != JSONObject.NULL)) {
try {
ldefaultThrottlePolicy = new CNSThrottlePolicy(json2.getJSONObject("defaultThrottlePolicy"));
} catch (Exception e) {
if (e instanceof CNSModelConstructionException) {
String message = ((CNSModelConstructionException) e).getErrormessage();
errorMessage = "DeliveryPolicy: defaultThrottlePolicy." + message;
error = true;
}
}
} else {
ldefaultThrottlePolicy = new CNSThrottlePolicy();
}
if (!error) {
defaultHealthyRetryPolicy = ldefaultHealthyRetryPolicy;
defaultSicklyRetryPolicy = ldefaultSicklyRetryPolicy;
disableSubscriptionOverrides = ldisableSubscriptionOverrides;
defaultThrottlePolicy = ldefaultThrottlePolicy;
}
} catch (Exception e) {
logger.error("event=update_cns_topic_delivery_policy", e);
throw new CMBException(CNSErrorCodes.CNS_InvalidParameter,"DeliveryPolicy: JSON exception");
}
if (error) {
logger.error("event=update_cns_topic_delivery_policy message=" + errorMessage);
throw new CMBException(CNSErrorCodes.CNS_InvalidParameter, errorMessage);
}
}