X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdbcapi%2Fmodel%2FDR_Sub.java;h=9b6e2d74b5d654094475c1dd5904c23545964148;hb=d6ac6f8b10e90411dd650d6f7a9ee51179e39bfc;hp=a5d9999783f2ee7ecd21e2f0fbd59c250a7097d6;hpb=b1812207d5f27a299b519aa213fd175043ae2b19;p=dmaap%2Fdbcapi.git diff --git a/src/main/java/org/onap/dmaap/dbcapi/model/DR_Sub.java b/src/main/java/org/onap/dmaap/dbcapi/model/DR_Sub.java index a5d9999..9b6e2d7 100644 --- a/src/main/java/org/onap/dmaap/dbcapi/model/DR_Sub.java +++ b/src/main/java/org/onap/dmaap/dbcapi/model/DR_Sub.java @@ -42,6 +42,13 @@ public class DR_Sub extends DmaapObject { private boolean use100; private boolean suspended; private String owner; + private boolean guaranteedDelivery; + private boolean guaranteedSequence; + private boolean privilegedSubscriber; + + // NOTE: the following fields are optional in the API but not stored in the DB + private String feedName; + private String feedVersion; public DR_Sub() { @@ -81,13 +88,32 @@ public class DR_Sub extends DmaapObject { 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") ); @@ -95,6 +121,8 @@ public class DR_Sub extends DmaapObject { this.setUserpwd( (String) del.get( "password")); this.setUse100((boolean) del.get( "use100")); + + this.setStatus( DmaapObject_Status.VALID ); logger.info( "new DR_Sub returning"); @@ -183,6 +211,47 @@ public class DR_Sub extends DmaapObject { } + 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 String getFeedName() { + return feedName; + } + + public void setFeedName(String feedName) { + this.feedName = feedName; + } + + public String getFeedVersion() { + return feedVersion; + } + + public void setFeedVersion(String feedVersion) { + this.feedVersion = feedVersion; + } public byte[] getBytes(String provApi) { if ( "AT&T".equals(provApi)) { @@ -193,18 +262,21 @@ public class DR_Sub extends DmaapObject { // 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\"}" + 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"); + + ", \"privilegedSubscriber\": %s " + + "}" + ,this.suspended + ,this.getDeliveryURL() + ,this.getUsername() + ,this.getUserpwd() + ,this.isUse100() + ,"false" + ,"0" + ,"true" + ,this.isPrivilegedSubscriber() + ); logger.info( postJSON ); return postJSON; @@ -225,21 +297,22 @@ public class DR_Sub extends DmaapObject { // 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\"}" + 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", - "false", - "false"); + + ", \"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;