private boolean use100;
private boolean suspended;
private String owner;
+ private boolean guaranteedDelivery;
+ private boolean guaranteedSequence;
+ private boolean privilegedSubscriber;
public DR_Sub() {
this.setOwner( (String) jsonObj.get("subscriber"));
this.setSuspended( (boolean) jsonObj.get("suspend"));
- JSONObject links = (JSONObject) jsonObj.get("links");
- String url = (String) links.get("feed");
- this.setFeedId( url.substring( url.lastIndexOf('/')+1, url.length() ));
- url = (String) links.get("self");
- this.setSubId( url.substring( url.lastIndexOf('/')+1, url.length() ));
- logger.info( "feedid="+ this.getFeedId() );
- this.setLogURL( (String) links.get("log") );
+ try {
+ JSONObject links = (JSONObject) jsonObj.get("links");
+ String url = (String) links.get("feed");
+ this.setFeedId( url.substring( url.lastIndexOf('/')+1, url.length() ));
+ url = (String) links.get("self");
+ this.setSubId( url.substring( url.lastIndexOf('/')+1, url.length() ));
+ logger.info( "feedid="+ this.getFeedId() );
+ this.setLogURL( (String) links.get("log") );
+ } catch (NullPointerException npe ) {
+
+ }
+ try {
+ this.setGuaranteedDelivery( (boolean) jsonObj.get("guaranteed_delivery"));
+ } catch( NullPointerException npe ) {
+ this.setGuaranteedDelivery(false);
+ }
+ try {
+ this.setGuaranteedSequence( (boolean) jsonObj.get("guaranteed_sequence"));
+ } catch( NullPointerException npe ) {
+ this.setGuaranteedSequence(false);
+ }
+ try {
+ this.setPrivilegedSubscriber((boolean) jsonObj.get("privilegedSubscriber"));
+ } catch( NullPointerException npe ) {
+ this.setPrivilegedSubscriber(false);
+ }
JSONObject del = (JSONObject) jsonObj.get("delivery");
this.setDeliveryURL( (String) del.get("url") );
this.setUserpwd( (String) del.get( "password"));
this.setUse100((boolean) del.get( "use100"));
+
+
this.setStatus( DmaapObject_Status.VALID );
logger.info( "new DR_Sub returning");
}
+ public boolean isGuaranteedDelivery() {
+ return guaranteedDelivery;
+ }
+
+ public void setGuaranteedDelivery(boolean guaranteedDelivery) {
+ this.guaranteedDelivery = guaranteedDelivery;
+ }
+
+ public boolean isGuaranteedSequence() {
+ return guaranteedSequence;
+ }
+
+ public void setGuaranteedSequence(boolean guaranteedSequence) {
+ this.guaranteedSequence = guaranteedSequence;
+ }
+
+ public boolean isPrivilegedSubscriber() {
+ return privilegedSubscriber;
+ }
+
+ public void setPrivilegedSubscriber(boolean privilegedSubscriber) {
+ this.privilegedSubscriber = privilegedSubscriber;
+ }
- public byte[] getBytes() {
+ public byte[] getBytes(String provApi) {
+ if ( "AT&T".equals(provApi)) {
+ return toProvJSONforATT().getBytes(StandardCharsets.UTF_8);
+ }
return toProvJSON().getBytes(StandardCharsets.UTF_8);
}
- // returns the DR_Sub object in JSON that conforms to DR Prov Server expectations
- public String toProvJSON() {
+ // returns the DR_Sub object in JSON that conforms to ONAP DR Prov Server expectations
+ public String toProvJSON() {
+ // this is the original DR API that was contributed to ONAP
+ String postJSON = String.format("{\"suspend\": %s, \"delivery\":"
+ + "{\"url\": \"%s\", \"user\": \"%s\", \"password\": \"%s\", \"use100\": %s }"
+ + ", \"metadataOnly\": %s, \"groupid\": \"%s\", \"follow_redirect\": %s "
+ + ", \"privilegedSubscriber\": %s "
+ + "}"
+ ,this.suspended
+ ,this.getDeliveryURL()
+ ,this.getUsername()
+ ,this.getUserpwd()
+ ,this.isUse100()
+ ,"false"
+ ,"0"
+ ,"true"
+ ,this.isPrivilegedSubscriber()
+ );
+ logger.info( postJSON );
+ return postJSON;
+ }
+ // returns the DR_Sub object in JSON that conforms to AT&T DR Prov Server expectations
+ // In Jan, 2019, the DR API used internally at AT&T diverged, so this function can be used in
+ // that runtime environment
+ public String toProvJSONforATT() {
// in DR 3.0, API v2.1 a new groupid field is added. We are not using this required field so just set it to 0.
// we send this regardless of DR Release because older versions of DR seem to safely ignore it
// and soon those versions won't be around anyway...
// We are setting it to "true" because that is the general behavior desired in OpenDCAE.
// But it is really a no-op for OpenDCAE because we've deployed DR with the SYSTEM-level parameter for FOLLOW_REDIRECTS set to true.
// In the event we abandon that, then setting the sub attribute to true will be a good thing.
+ // Update Jan, 2019: added guaranteed_delivery and guaranteed_sequence with value false for
+ // backwards compatibility
// TODO:
// - introduce Bus Controller API support for these attributes
// - store the default values in the DB
- String postJSON = String.format("{\"suspend\": \"%s\", \"delivery\": {\"url\": \"%s\", \"user\": \"%s\", \"password\": \"%s\", \"use100\": \"%s\"}, \"metadataOnly\": %s, \"groupid\": \"%s\", \"follow_redirect\": %s }",
- this.suspended,
- this.getDeliveryURL(),
- this.getUsername(),
- this.getUserpwd(),
- this.isUse100(),
- "false",
- "0",
- "true");
+ String postJSON = String.format("{\"suspend\": %s, \"delivery\":"
+ + "{\"url\": \"%s\", \"user\": \"%s\", \"password\": \"%s\", \"use100\": %s}"
+ + ", \"metadataOnly\": %s, \"groupid\": \"%s\", \"follow_redirect\": %s "
+ + ", \"guaranteed_delivery\": %s, \"guaranteed_sequence\": %s"
+ + "}"
+ ,this.suspended
+ ,this.getDeliveryURL()
+ ,this.getUsername()
+ ,this.getUserpwd()
+ ,this.isUse100()
+ ,"false"
+ ,"0"
+ ,"true"
+ ,this.isGuaranteedDelivery()
+ ,this.isGuaranteedSequence()
+ );
logger.info( postJSON );
return postJSON;