diff options
author | Driptaroop Das <driptaroop.das@in.ibm.com> | 2019-01-23 13:40:24 +0530 |
---|---|---|
committer | Driptaroop Das <driptaroop.das@in.ibm.com> | 2019-01-23 13:40:33 +0530 |
commit | 0b5b03f6dffd505e36748041fedfe65b92365697 (patch) | |
tree | 6dcefe80d84d5ade8a12fe61ed8187e0f3cff996 /src | |
parent | ccda7ee6355fe767fe6091d9943d9b295c29ee99 (diff) |
Multiple fixes - Feed.java
Multiple fixes - Feed.java
Issue-ID: DMAAP-995
Change-Id: Id67df8f786fa8376a43d4cf623ef6b3b160f09e4
Signed-off-by: Driptaroop Das <driptaroop.das@in.ibm.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/onap/dmaap/dbcapi/model/Feed.java | 98 |
1 files changed, 47 insertions, 51 deletions
diff --git a/src/main/java/org/onap/dmaap/dbcapi/model/Feed.java b/src/main/java/org/onap/dmaap/dbcapi/model/Feed.java index b78377b..b3c7332 100644 --- a/src/main/java/org/onap/dmaap/dbcapi/model/Feed.java +++ b/src/main/java/org/onap/dmaap/dbcapi/model/Feed.java @@ -48,52 +48,32 @@ public class Feed extends DmaapObject { private String formatUuid; private ArrayList<DR_Pub> pubs; - private ArrayList<DR_Sub> subs; + private ArrayList<DR_Sub> subs; - - - public boolean isSuspended() { - return suspended; - } - - public void setSuspended(boolean suspended) { - this.suspended = suspended; - } - - public String getSubscribeURL() { - return subscribeURL; - } - public void setSubscribeURL(String subscribeURL) { - this.subscribeURL = subscribeURL; - } - - - public Feed() { - this.pubs = new ArrayList<DR_Pub>(); - this.subs = new ArrayList<DR_Sub>(); + this.pubs = new ArrayList<>(); + this.subs = new ArrayList<>(); this.setStatus( DmaapObject_Status.EMPTY ); - + } - + public Feed( String name, - String version, - String description, - String owner, - String aspr - ) { + String version, + String description, + String owner, + String aspr) { this.feedName = name; this.feedVersion = version; this.feedDescription = description; this.owner = owner; this.asprClassification = aspr; - this.pubs = new ArrayList<DR_Pub>(); - this.subs = new ArrayList<DR_Sub>(); + this.pubs = new ArrayList<>(); + this.subs = new ArrayList<>(); this.setStatus( DmaapObject_Status.NEW ); - + } - + // expects a String in JSON format, with known fields to populate Feed object public Feed ( String json ) { JSONParser parser = new JSONParser(); @@ -101,10 +81,10 @@ public class Feed extends DmaapObject { try { jsonObj = (JSONObject) parser.parse( json ); } catch ( ParseException pe ) { - logger.error( "Error parsing provisioning data: " + json ); - this.setStatus( DmaapObject_Status.INVALID ); - return; - } + logger.error( "Error parsing provisioning data: " + json ); + this.setStatus( DmaapObject_Status.INVALID ); + return; + } this.setFeedName( (String) jsonObj.get("name")); this.setFeedVersion( (String) jsonObj.get("version")); @@ -117,30 +97,48 @@ public class Feed extends DmaapObject { this.setPublishURL( url ); this.setFeedId( url.substring( url.lastIndexOf('/')+1, url.length() )); logger.info( "feedid="+ this.getFeedId() ); - this.setSubscribeURL( (String) links.get("subscribe") ); + this.setSubscribeURL( (String) links.get("subscribe") ); this.setLogURL( (String) links.get("log") ); JSONObject auth = (JSONObject) jsonObj.get("authorization"); this.setAsprClassification( (String) auth.get("classification")); JSONArray pubs = (JSONArray) auth.get( "endpoint_ids"); int i; - ArrayList<DR_Pub> dr_pub = new ArrayList<DR_Pub>(); - this.subs = new ArrayList<DR_Sub>(); + ArrayList<DR_Pub> dr_pub = new ArrayList<>(); + this.subs = new ArrayList<>(); for( i = 0; i < pubs.size(); i++ ) { JSONObject entry = (JSONObject) pubs.get(i); - dr_pub.add( new DR_Pub( "someLocation", - (String) entry.get("id"), - (String) entry.get("password"), - this.getFeedId(), - this.getFeedId() + "." + DR_Pub.nextKey() )); - + dr_pub.add( new DR_Pub( "someLocation", + (String) entry.get("id"), + (String) entry.get("password"), + this.getFeedId(), + this.getFeedId() + "." + DR_Pub.nextKey() )); + } this.setPubs( dr_pub ); - + this.setStatus( DmaapObject_Status.VALID ); } + + + public boolean isSuspended() { + return suspended; + } + + public void setSuspended(boolean suspended) { + this.suspended = suspended; + } + + public String getSubscribeURL() { + return subscribeURL; + } + + public void setSubscribeURL(String subscribeURL) { + this.subscribeURL = subscribeURL; + } + public String getFeedId() { return feedId; } @@ -218,8 +216,7 @@ public class Feed extends DmaapObject { // returns the Feed object in JSON that conforms to DR Prov Server expectations public String toProvJSON() { - ArrayList<DR_Pub> pubs = this.getPubs(); - String postJSON = String.format("{\"name\": \"%s\", \"version\": \"%s\", \"description\": \"%s\", \"suspend\": %s, \"authorization\": { \"classification\": \"%s\", ", + String postJSON = String.format("{\"name\": \"%s\", \"version\": \"%s\", \"description\": \"%s\", \"suspend\": %s, \"authorization\": { \"classification\": \"%s\", ", this.getFeedName(), this.getFeedVersion(), this.getFeedDescription(), @@ -264,8 +261,7 @@ public class Feed extends DmaapObject { } public static String getSubProvURL( String feedId ) { - String ret = new DmaapService().getDmaap().getDrProvUrl() + "/subscribe/" + feedId ; - return ret; + return new DmaapService().getDmaap().getDrProvUrl() + "/subscribe/" + feedId; } @Override |