aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openecomp/dmaapbc/model
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/openecomp/dmaapbc/model')
-rw-r--r--src/main/java/org/openecomp/dmaapbc/model/ApiError.java56
-rw-r--r--src/main/java/org/openecomp/dmaapbc/model/BrTopic.java65
-rw-r--r--src/main/java/org/openecomp/dmaapbc/model/DR_Node.java78
-rw-r--r--src/main/java/org/openecomp/dmaapbc/model/DR_Pub.java136
-rw-r--r--src/main/java/org/openecomp/dmaapbc/model/DR_Sub.java206
-rw-r--r--src/main/java/org/openecomp/dmaapbc/model/DcaeLocation.java103
-rw-r--r--src/main/java/org/openecomp/dmaapbc/model/Dmaap.java133
-rw-r--r--src/main/java/org/openecomp/dmaapbc/model/DmaapObject.java68
-rw-r--r--src/main/java/org/openecomp/dmaapbc/model/Feed.java279
-rw-r--r--src/main/java/org/openecomp/dmaapbc/model/MR_Client.java121
-rw-r--r--src/main/java/org/openecomp/dmaapbc/model/MR_Cluster.java124
-rw-r--r--src/main/java/org/openecomp/dmaapbc/model/MirrorMaker.java202
-rw-r--r--src/main/java/org/openecomp/dmaapbc/model/ReplicationVector.java104
-rw-r--r--src/main/java/org/openecomp/dmaapbc/model/Topic.java165
14 files changed, 1840 insertions, 0 deletions
diff --git a/src/main/java/org/openecomp/dmaapbc/model/ApiError.java b/src/main/java/org/openecomp/dmaapbc/model/ApiError.java
new file mode 100644
index 0000000..0659f65
--- /dev/null
+++ b/src/main/java/org/openecomp/dmaapbc/model/ApiError.java
@@ -0,0 +1,56 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OpenECOMP - org.openecomp.dmaapbc
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.dmaapbc.model;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class ApiError {
+ private int code;
+ private String message;
+ private String fields;
+
+ public int getCode() {
+ return code;
+ }
+ public void setCode(int rc) {
+ this.code = rc;
+ }
+ public String getMessage() {
+ return message;
+ }
+ public void setMessage(String message) {
+ this.message = message;
+ }
+ public String getFields() {
+ return fields;
+ }
+ public void setFields(String fields) {
+ this.fields = fields;
+ }
+ public String toString() {
+ return String.format( "code=%d msg=%s fields=%s", this.code, this.message, this.fields );
+ }
+ public boolean is2xx() {
+
+ return code >= 200 && code < 300;
+ }
+}
diff --git a/src/main/java/org/openecomp/dmaapbc/model/BrTopic.java b/src/main/java/org/openecomp/dmaapbc/model/BrTopic.java
new file mode 100644
index 0000000..e8a697e
--- /dev/null
+++ b/src/main/java/org/openecomp/dmaapbc/model/BrTopic.java
@@ -0,0 +1,65 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OpenECOMP - org.openecomp.dmaapbc
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.dmaapbc.model;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.log4j.Logger;
+
+@XmlRootElement
+public class BrTopic {
+ static final Logger logger = Logger.getLogger(BrTopic.class);
+
+ private String brSource;
+ private String brTarget;
+ private int topicCount;
+
+ // no-op constructor used by framework
+ public BrTopic() {
+ }
+
+ public String getBrSource() {
+ return brSource;
+ }
+
+ public void setBrSource(String brSource) {
+ this.brSource = brSource;
+ }
+
+ public String getBrTarget() {
+ return brTarget;
+ }
+
+ public void setBrTarget(String brTarget) {
+ this.brTarget = brTarget;
+ }
+
+ public int getTopicCount() {
+ return topicCount;
+ }
+
+ public void setTopicCount(int topicCount) {
+ this.topicCount = topicCount;
+ }
+
+
+
+}
diff --git a/src/main/java/org/openecomp/dmaapbc/model/DR_Node.java b/src/main/java/org/openecomp/dmaapbc/model/DR_Node.java
new file mode 100644
index 0000000..f3ff1fe
--- /dev/null
+++ b/src/main/java/org/openecomp/dmaapbc/model/DR_Node.java
@@ -0,0 +1,78 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OpenECOMP - org.openecomp.dmaapbc
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.dmaapbc.model;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class DR_Node extends DmaapObject {
+ private String fqdn;
+ private String dcaeLocationName;
+ private String hostName;
+ private String version;
+
+ public DR_Node() {
+
+ }
+
+ public DR_Node( String f,
+ String dLN,
+ String hN,
+ String v ) {
+ this.fqdn = f;
+ this.dcaeLocationName = dLN;
+ this.hostName = hN;
+ this.version = v;
+ }
+
+ public String getFqdn() {
+ return fqdn;
+ }
+
+ public void setFqdn(String fqdn) {
+ this.fqdn = fqdn;
+ }
+
+ public String getDcaeLocationName() {
+ return dcaeLocationName;
+ }
+
+ public void setDcaeLocationName(String dcaeLocationName) {
+ this.dcaeLocationName = dcaeLocationName;
+ }
+
+ public String getHostName() {
+ return hostName;
+ }
+
+ public void setHostName(String hostName) {
+ this.hostName = hostName;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+}
diff --git a/src/main/java/org/openecomp/dmaapbc/model/DR_Pub.java b/src/main/java/org/openecomp/dmaapbc/model/DR_Pub.java
new file mode 100644
index 0000000..2e3e894
--- /dev/null
+++ b/src/main/java/org/openecomp/dmaapbc/model/DR_Pub.java
@@ -0,0 +1,136 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OpenECOMP - org.openecomp.dmaapbc
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.dmaapbc.model;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.log4j.Logger;
+import org.openecomp.dmaapbc.util.RandomString;
+
+@XmlRootElement
+public class DR_Pub extends DmaapObject {
+ static final Logger logger = Logger.getLogger(DR_Pub.class);
+ private String dcaeLocationName;
+ private String username;
+ private String userpwd;
+ private String feedId;
+ private String pubId;
+
+
+ public DR_Pub() {
+ status = DmaapObject_Status.EMPTY;
+
+ }
+
+ public DR_Pub( String dLN ) {
+ this.dcaeLocationName = dLN;
+ this.status = DmaapObject_Status.STAGED;
+ }
+
+ public DR_Pub( String dLN,
+ String uN,
+ String uP,
+ String fI,
+ String pI ) {
+ this.dcaeLocationName = dLN;
+ this.username = uN;
+ this.userpwd = uP;
+ this.feedId = fI;
+ this.pubId = pI;
+ this.status = DmaapObject_Status.VALID;
+ }
+
+
+ public DR_Pub( String dLN,
+ String uN,
+ String uP,
+ String fI ) {
+ this.dcaeLocationName = dLN;
+ this.username = uN;
+ this.userpwd = uP;
+ this.feedId = fI;
+ this.pubId = fI + "." + DR_Pub.nextKey();
+ this.status = DmaapObject_Status.VALID;
+ }
+
+
+ public String getDcaeLocationName() {
+ return dcaeLocationName;
+ }
+
+ public void setDcaeLocationName(String dcaeLocationName) {
+ this.dcaeLocationName = dcaeLocationName;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getUserpwd() {
+ return userpwd;
+ }
+
+ public void setUserpwd(String userpwd) {
+ this.userpwd = userpwd;
+ }
+
+ public String getFeedId() {
+ return feedId;
+ }
+
+ public void setFeedId(String feedId) {
+ this.feedId = feedId;
+ }
+
+ public String getPubId() {
+ return pubId;
+ }
+
+ public void setPubId(String pubId) {
+ this.pubId = pubId;
+ }
+
+ public void setNextPubId() {
+ this.pubId = this.feedId + "." + DR_Pub.nextKey();
+ }
+
+ public DR_Pub setRandomUserName() {
+ RandomString r = new RandomString(15);
+ this.username = "tmp_" + r.nextString();
+ return this;
+ }
+ public DR_Pub setRandomPassword() {
+ RandomString r = new RandomString(15);
+ this.userpwd = r.nextString();
+ return this;
+ }
+
+ public static String nextKey() {
+ RandomString ri = new RandomString(5);
+ return ri.nextString();
+
+ }
+
+}
diff --git a/src/main/java/org/openecomp/dmaapbc/model/DR_Sub.java b/src/main/java/org/openecomp/dmaapbc/model/DR_Sub.java
new file mode 100644
index 0000000..0184a14
--- /dev/null
+++ b/src/main/java/org/openecomp/dmaapbc/model/DR_Sub.java
@@ -0,0 +1,206 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OpenECOMP - org.openecomp.dmaapbc
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.dmaapbc.model;
+
+import java.nio.charset.StandardCharsets;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.log4j.Logger;
+import org.json.simple.JSONObject;
+import org.json.simple.parser.JSONParser;
+import org.json.simple.parser.ParseException;
+
+@XmlRootElement
+public class DR_Sub extends DmaapObject {
+ static final Logger logger = Logger.getLogger(DR_Sub.class);
+
+ private String dcaeLocationName;
+ private String username;
+ private String userpwd;
+ private String feedId;
+ private String deliveryURL;
+ private String logURL;
+ private String subId;
+ private boolean use100;
+ private boolean suspended;
+ private String owner;
+
+ public String getOwner() {
+ return owner;
+ }
+
+ public void setOwner(String owner) {
+ this.owner = owner;
+ }
+
+ public boolean isSuspended() {
+ return suspended;
+ }
+
+ public void setSuspended(boolean suspended) {
+ this.suspended = suspended;
+ }
+
+
+
+ public boolean isUse100() {
+ return use100;
+ }
+
+ public void setUse100(boolean use100) {
+ this.use100 = use100;
+ }
+
+ public DR_Sub() {
+
+ }
+
+ public DR_Sub( String dLN,
+ String uN,
+ String uP,
+ String fI,
+ String dU,
+ String lU,
+ boolean u100 ) {
+ this.dcaeLocationName = dLN;
+ this.username = uN;
+ this.userpwd = uP;
+ this.feedId = fI;
+ this.deliveryURL = dU;
+ this.logURL = lU;
+ this.use100 = u100;
+ this.setStatus( DmaapObject_Status.NEW );
+ this.subId = "0";
+ }
+
+ public DR_Sub ( String json ) {
+ logger.info( "DR_Sub:" + json );
+ JSONParser parser = new JSONParser();
+ JSONObject jsonObj;
+
+ try {
+ jsonObj = (JSONObject) parser.parse( json );
+ } catch ( ParseException pe ) {
+ logger.error( "Error parsing provisioning data: " + json );
+ this.setStatus( DmaapObject_Status.INVALID );
+ return;
+ }
+
+ 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") );
+
+ JSONObject del = (JSONObject) jsonObj.get("delivery");
+ this.setDeliveryURL( (String) del.get("url") );
+ this.setUsername( (String) del.get("user"));
+ this.setUserpwd( (String) del.get( "password"));
+ this.setUse100((boolean) del.get( "use100"));
+
+ this.setStatus( DmaapObject_Status.VALID );
+
+ logger.info( "new DR_Sub returning");
+ }
+
+ public String getDcaeLocationName() {
+ return dcaeLocationName;
+ }
+
+ public void setDcaeLocationName(String dcaeLocationName) {
+ this.dcaeLocationName = dcaeLocationName;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getUserpwd() {
+ return userpwd;
+ }
+
+ public void setUserpwd(String userpwd) {
+ this.userpwd = userpwd;
+ }
+
+ public String getFeedId() {
+ return feedId;
+ }
+
+ public void setFeedId(String feedId) {
+ this.feedId = feedId;
+ }
+
+ public String getDeliveryURL() {
+ return deliveryURL;
+ }
+
+ public void setDeliveryURL(String deliveryURL) {
+ this.deliveryURL = deliveryURL;
+ }
+
+ public String getLogURL() {
+ return logURL;
+ }
+
+ public void setLogURL(String logURL) {
+ this.logURL = logURL;
+ }
+
+ public String getSubId() {
+ return subId;
+ }
+
+ public void setSubId(String subId) {
+ this.subId = subId;
+ }
+
+
+
+ public byte[] getBytes() {
+ return toProvJSON().getBytes(StandardCharsets.UTF_8);
+ }
+ // returns the DR_Sub object in JSON that conforms to DR Prov Server expectations
+ public String toProvJSON() {
+
+ // 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...
+ String postJSON = String.format("{\"delivery\": {\"url\": \"%s\", \"user\": \"%s\", \"password\": \"%s\", \"use100\": \"%s\"}, \"metadataOnly\": false, \"groupid\": \"0\"}",
+ this.getDeliveryURL(),
+ this.getUsername(),
+ this.getUserpwd(),
+ this.isUse100() );
+
+ logger.info( postJSON );
+ return postJSON;
+ }
+}
diff --git a/src/main/java/org/openecomp/dmaapbc/model/DcaeLocation.java b/src/main/java/org/openecomp/dmaapbc/model/DcaeLocation.java
new file mode 100644
index 0000000..f0ef481
--- /dev/null
+++ b/src/main/java/org/openecomp/dmaapbc/model/DcaeLocation.java
@@ -0,0 +1,103 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OpenECOMP - org.openecomp.dmaapbc
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.dmaapbc.model;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.log4j.Logger;
+
+@XmlRootElement
+public class DcaeLocation extends DmaapObject {
+ static final Logger logger = Logger.getLogger(MR_Cluster.class);
+ private String clli;
+ private String dcaeLayer;
+ private String dcaeLocationName;
+ private String openStackAvailabilityZone;
+ private String subnet;
+
+
+
+ public DcaeLocation() {
+
+ }
+
+ public DcaeLocation( String c,
+ String dL,
+ String dLN,
+ String oSAZ,
+ String s ) {
+
+ this.clli = c;
+ this.dcaeLayer = dL;
+ this.dcaeLocationName = dLN;
+ this.openStackAvailabilityZone = oSAZ;
+ this.subnet = s;
+ }
+
+ public String getClli() {
+ return clli;
+ }
+
+ public void setClli(String clli) {
+ this.clli = clli;
+ }
+
+ public String getDcaeLayer() {
+ return dcaeLayer;
+ }
+
+ public void setDcaeLayer(String dcaeLayer) {
+ this.dcaeLayer = dcaeLayer;
+ }
+ public boolean isCentral() {
+ return dcaeLayer != null && dcaeLayer.contains("central");
+ }
+ public boolean isLocal() {
+ return dcaeLayer != null && dcaeLayer.contains("local");
+ }
+
+ public String getDcaeLocationName() {
+ return dcaeLocationName;
+ }
+
+ public void setDcaeLocationName(String dcaeLocationName) {
+ this.dcaeLocationName = dcaeLocationName;
+ }
+
+
+
+ public String getOpenStackAvailabilityZone() {
+ return openStackAvailabilityZone;
+ }
+
+ public void setOpenStackAvailabilityZone(String openStackAvailabilityZone) {
+ this.openStackAvailabilityZone = openStackAvailabilityZone;
+ }
+
+ public String getSubnet() {
+ return subnet;
+ }
+
+ public void setSubnet(String subnet) {
+ this.subnet = subnet;
+ }
+
+}
diff --git a/src/main/java/org/openecomp/dmaapbc/model/Dmaap.java b/src/main/java/org/openecomp/dmaapbc/model/Dmaap.java
new file mode 100644
index 0000000..362c184
--- /dev/null
+++ b/src/main/java/org/openecomp/dmaapbc/model/Dmaap.java
@@ -0,0 +1,133 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OpenECOMP - org.openecomp.dmaapbc
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.dmaapbc.model;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.log4j.Logger;
+
+@XmlRootElement
+public class Dmaap extends DmaapObject {
+ static final Logger logger = Logger.getLogger(Dmaap.class);
+
+ private String version;
+ private String topicNsRoot;
+ private String dmaapName;
+ private String drProvUrl;
+ private String bridgeAdminTopic;
+ private String loggingUrl;
+ private String nodeKey;
+ private String accessKeyOwner;
+
+
+
+ // no-op constructor used by framework
+ public Dmaap() {
+
+ }
+
+ public Dmaap( String ver,
+ String tnr,
+ String dn,
+ String dpu,
+ String lu,
+ String bat,
+ String nk,
+ String ako ) {
+ this.version = ver;
+ this.topicNsRoot = tnr;
+ this.dmaapName = dn;
+ this.drProvUrl = dpu;
+ this.bridgeAdminTopic = bat;
+ this.loggingUrl = lu;
+ this.nodeKey = nk;
+ this.accessKeyOwner = ako;
+ this.setStatus( DmaapObject_Status.NEW );
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getTopicNsRoot() {
+ return topicNsRoot;
+ }
+
+ public void setTopicNsRoot(String topicNsRoot) {
+ this.topicNsRoot = topicNsRoot;
+ }
+
+ public String getDmaapName() {
+ return dmaapName;
+ }
+
+ public void setDmaapName(String dmaapName) {
+ this.dmaapName = dmaapName;
+ }
+
+ public String getDrProvUrl() {
+ return drProvUrl;
+ }
+
+ public void setDrProvUrl(String drProvUrl) {
+ this.drProvUrl = drProvUrl;
+ }
+
+
+ public String getNodeKey() {
+ return nodeKey;
+ }
+
+ public void setNodeKey(String nodeKey) {
+ this.nodeKey = nodeKey;
+ }
+
+ public String getAccessKeyOwner() {
+ return accessKeyOwner;
+ }
+
+ public void setAccessKeyOwner(String accessKeyOwner) {
+ this.accessKeyOwner = accessKeyOwner;
+ }
+
+
+ public String getBridgeAdminTopic() {
+ return bridgeAdminTopic;
+ }
+
+ public void setBridgeAdminTopic(String bridgeAdminTopic) {
+ this.bridgeAdminTopic = bridgeAdminTopic;
+ }
+
+ public String getLoggingUrl() {
+ return loggingUrl;
+ }
+
+ public void setLoggingUrl(String loggingUrl) {
+ this.loggingUrl = loggingUrl;
+ }
+
+
+}
diff --git a/src/main/java/org/openecomp/dmaapbc/model/DmaapObject.java b/src/main/java/org/openecomp/dmaapbc/model/DmaapObject.java
new file mode 100644
index 0000000..39d4181
--- /dev/null
+++ b/src/main/java/org/openecomp/dmaapbc/model/DmaapObject.java
@@ -0,0 +1,68 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OpenECOMP - org.openecomp.dmaapbc
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.dmaapbc.model;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.TimeZone;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public abstract class DmaapObject {
+ protected Date lastMod;
+ protected DmaapObject_Status status;
+
+ public Date getLastMod() {
+ return lastMod;
+ }
+
+ public void setLastMod(Date lastMod) {
+ this.lastMod = lastMod;
+ }
+
+ public void setLastMod() {
+ this.lastMod = Calendar.getInstance(TimeZone.getTimeZone("UTC")).getTime();
+ }
+
+ public enum DmaapObject_Status {
+ EMPTY,
+ NEW,
+ STAGED,
+ VALID,
+ INVALID,
+ DELETED
+ }
+ public DmaapObject_Status getStatus() {
+ return status;
+ }
+
+ public void setStatus(DmaapObject_Status status) {
+ this.status = status;
+ }
+
+ public boolean isStatusValid() {
+ if ( this.status == DmaapObject_Status.VALID ) {
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/src/main/java/org/openecomp/dmaapbc/model/Feed.java b/src/main/java/org/openecomp/dmaapbc/model/Feed.java
new file mode 100644
index 0000000..c445b65
--- /dev/null
+++ b/src/main/java/org/openecomp/dmaapbc/model/Feed.java
@@ -0,0 +1,279 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OpenECOMP - org.openecomp.dmaapbc
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.dmaapbc.model;
+
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.log4j.Logger;
+
+
+import org.json.simple.*;
+import org.json.simple.parser.*;
+import org.openecomp.dmaapbc.service.DmaapService;
+import org.openecomp.dmaapbc.util.RandomString;
+
+@XmlRootElement
+public class Feed extends DmaapObject {
+ static final Logger logger = Logger.getLogger(Feed.class);
+
+
+ private String feedId;
+
+ private String feedName;
+ private String feedVersion;
+ private String feedDescription;
+ private String owner;
+ private String asprClassification;
+ private String publishURL;
+ private String subscribeURL;
+ private boolean suspended;
+ private String logURL;
+ private String formatUuid;
+
+ private ArrayList<DR_Pub> pubs;
+ 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.setStatus( DmaapObject_Status.EMPTY );
+
+ }
+
+ public Feed( String name,
+ 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.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();
+ JSONObject jsonObj;
+
+ try {
+ jsonObj = (JSONObject) parser.parse( json );
+ } catch ( ParseException pe ) {
+ 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"));
+ this.setFeedDescription( (String) jsonObj.get("description"));
+ this.setOwner( (String) jsonObj.get("publisher"));
+
+ this.setSuspended( (boolean) jsonObj.get("suspend"));
+ JSONObject links = (JSONObject) jsonObj.get("links");
+ String url = (String) links.get("publish");
+ this.setPublishURL( url );
+ this.setFeedId( url.substring( url.lastIndexOf('/')+1, url.length() ));
+ logger.info( "feedid="+ this.getFeedId() );
+ 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>();
+
+ 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() ));
+
+ }
+ this.setPubs( dr_pub );
+
+ this.setStatus( DmaapObject_Status.VALID );
+
+ }
+
+ public String getFeedId() {
+ return feedId;
+ }
+
+ public void setFeedId(String feedId) {
+ this.feedId = feedId;
+ }
+
+ 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 String getFeedDescription() {
+ return feedDescription;
+ }
+
+ public void setFeedDescription(String feedDescription) {
+ this.feedDescription = feedDescription;
+ }
+
+ public String getOwner() {
+ return owner;
+ }
+
+ public void setOwner(String owner) {
+ this.owner = owner;
+ }
+
+ public String getAsprClassification() {
+ return asprClassification;
+ }
+
+ public void setAsprClassification(String asprClassification) {
+ this.asprClassification = asprClassification;
+ }
+
+ public String getPublishURL() {
+ return publishURL;
+ }
+
+ public void setPublishURL(String publishURL) {
+ this.publishURL = publishURL;
+ }
+
+ public String getLogURL() {
+ return logURL;
+ }
+
+ public void setLogURL(String logURL) {
+ this.logURL = logURL;
+ }
+
+
+
+ public String getFormatUuid() {
+ return formatUuid;
+ }
+
+ public void setFormatUuid(String formatUuid) {
+ this.formatUuid = formatUuid;
+ }
+
+ // 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\", ",
+ this.getFeedName(),
+ this.getFeedVersion(),
+ this.getFeedDescription(),
+ this.isSuspended() ,
+ this.getAsprClassification()
+ );
+ int i;
+ postJSON += "\"endpoint_addrs\": [],\"endpoint_ids\": [";
+ String comma = "";
+ for( i = 0 ; i < pubs.size(); i++) {
+ postJSON += String.format(" %s{\"id\": \"%s\",\"password\": \"%s\"}",
+ comma,
+ pubs.get(i).getUsername(),
+ pubs.get(i).getUserpwd()
+ ) ;
+ comma = ",";
+ }
+ postJSON += "]}}";
+
+ logger.info( "postJSON=" + postJSON);
+ return postJSON;
+ }
+
+ public ArrayList<DR_Pub> getPubs() {
+ return pubs;
+ }
+
+ public void setPubs( ArrayList<DR_Pub> pubs) {
+ this.pubs = pubs;
+ }
+
+ public ArrayList<DR_Sub> getSubs() {
+ return subs;
+ }
+
+ public void setSubs( ArrayList<DR_Sub> subs) {
+ this.subs = subs;
+ }
+
+ public byte[] getBytes() {
+ return toProvJSON().getBytes(StandardCharsets.UTF_8);
+ }
+
+ public static String getSubProvURL( String feedId ) {
+ String ret = new String();
+ ret = new DmaapService().getDmaap().getDrProvUrl() + "/subscribe/" + feedId ;
+ return ret;
+ }
+
+}
diff --git a/src/main/java/org/openecomp/dmaapbc/model/MR_Client.java b/src/main/java/org/openecomp/dmaapbc/model/MR_Client.java
new file mode 100644
index 0000000..684424a
--- /dev/null
+++ b/src/main/java/org/openecomp/dmaapbc/model/MR_Client.java
@@ -0,0 +1,121 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OpenECOMP - org.openecomp.dmaapbc
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.dmaapbc.model;
+
+import java.util.Date;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.log4j.Logger;
+import org.openecomp.dmaapbc.database.DatabaseClass;
+
+@XmlRootElement
+public class MR_Client extends DmaapObject {
+ static final Logger logger = Logger.getLogger(MR_Client.class);
+
+ private String dcaeLocationName;
+ private String topicURL;
+ private String fqtn;
+ private String clientRole;
+ private String[] action;
+ private String mrClientId;
+
+
+ public MR_Client() {
+ this.mrClientId = DatabaseClass.getNextClientId();
+ this.lastMod = new Date();
+ this.setLastMod();
+ logger.debug( "MR_Client constructor " + this.lastMod );
+
+ }
+
+ public MR_Client( String dLN,
+ String f,
+ String cR,
+ String[] a ) {
+ this.dcaeLocationName = dLN;
+ this.fqtn = f;
+ this.clientRole = cR;
+ int i = 0;
+
+ if ( this.action == null ) {
+ this.action = new String[a.length];
+ }
+ for( String aa : a ) {
+ this.action[i++] = new String( aa );
+ }
+ this.setStatus( DmaapObject_Status.NEW );
+ this.mrClientId = DatabaseClass.getNextClientId();
+ this.setLastMod();
+ logger.debug( "MR_Client constructor w initialization " + this.lastMod );
+ }
+
+ public String getDcaeLocationName() {
+ return dcaeLocationName;
+ }
+
+ public void setDcaeLocationName(String dcaeLocationName) {
+ this.dcaeLocationName = dcaeLocationName;
+ }
+
+ public String getFqtn() {
+ return fqtn;
+ }
+
+ public void setFqtn(String fqtn) {
+ this.fqtn = fqtn;
+ }
+
+ public String getClientRole() {
+ return clientRole;
+ }
+
+ public void setClientRole(String clientRole) {
+ this.clientRole = clientRole;
+ }
+
+ public String[] getAction() {
+ return action;
+ }
+
+ public void setAction(String[] action) {
+ this.action = action;
+ }
+
+ public String getMrClientId() {
+ return mrClientId;
+ }
+
+ public void setMrClientId(String mrClientId) {
+ this.mrClientId = mrClientId;
+ }
+
+
+
+ public String getTopicURL() {
+ return topicURL;
+ }
+
+ public void setTopicURL(String topicURL) {
+ this.topicURL = topicURL;
+ }
+
+}
diff --git a/src/main/java/org/openecomp/dmaapbc/model/MR_Cluster.java b/src/main/java/org/openecomp/dmaapbc/model/MR_Cluster.java
new file mode 100644
index 0000000..fcaf007
--- /dev/null
+++ b/src/main/java/org/openecomp/dmaapbc/model/MR_Cluster.java
@@ -0,0 +1,124 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OpenECOMP - org.openecomp.dmaapbc
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.dmaapbc.model;
+
+import java.util.Date;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.log4j.Logger;
+
+
+@XmlRootElement
+public class MR_Cluster extends DmaapObject {
+ static final Logger logger = Logger.getLogger(MR_Cluster.class);
+ private String dcaeLocationName;
+ private String fqdn;
+ private String[] hosts;
+ //private DmaapTimestamp lastMod;
+ private String topicProtocol;
+ private String topicPort;
+
+
+ // TODO: make this a system property
+ private static String defaultTopicProtocol = "https";
+ private static String defaultTopicPort = "3905";
+
+
+
+
+ public MR_Cluster() {
+ this.topicProtocol = defaultTopicProtocol;
+ this.topicPort = defaultTopicPort;
+ this.lastMod = new Date();
+
+ logger.info( "MR_Cluster constructor " + this.lastMod );
+
+ }
+
+ public MR_Cluster( String dLN,
+ String f,
+ String a,
+ String[] h ) {
+ this.dcaeLocationName = dLN;
+ this.fqdn = f;
+ this.hosts[0] = h[0];
+ this.hosts[1] = h[1];
+ this.hosts[2] = h[2];
+ this.topicProtocol = defaultTopicProtocol;
+ this.topicPort = defaultTopicPort;
+
+ logger.info( "MR_Cluster constructor w initialization complete" + this.lastMod );
+ }
+
+ public String getDcaeLocationName() {
+ return dcaeLocationName;
+ }
+
+ public void setDcaeLocationName(String dcaeLocationName) {
+ this.dcaeLocationName = dcaeLocationName;
+ }
+
+ public String getFqdn() {
+ return fqdn;
+ }
+
+ public void setFqdn(String fqdn) {
+ this.fqdn = fqdn;
+ }
+
+ public String[] getHosts() {
+ return hosts;
+ }
+
+ public void setHosts(String[] hosts) {
+ this.hosts = hosts;
+ }
+
+ public String getTopicProtocol() {
+ return topicProtocol;
+ }
+
+ public void setTopicProtocol(String topicProtocol) {
+ this.topicProtocol = topicProtocol;
+ }
+
+ public String getTopicPort() {
+ return topicPort;
+ }
+
+ public void setTopicPort(String topicPort) {
+ this.topicPort = topicPort;
+ }
+
+ public String genTopicURL( String topic ) {
+ StringBuilder str = new StringBuilder( topicProtocol );
+ str.append("://")
+ .append(fqdn)
+ .append(":")
+ .append(topicPort)
+ .append("/events/")
+ .append(topic);
+
+ return str.toString();
+ }
+
+
+}
diff --git a/src/main/java/org/openecomp/dmaapbc/model/MirrorMaker.java b/src/main/java/org/openecomp/dmaapbc/model/MirrorMaker.java
new file mode 100644
index 0000000..828e9e0
--- /dev/null
+++ b/src/main/java/org/openecomp/dmaapbc/model/MirrorMaker.java
@@ -0,0 +1,202 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OpenECOMP - org.openecomp.dmaapbc
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.dmaapbc.model;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.log4j.Logger;
+import org.openecomp.dmaapbc.service.MirrorMakerService;
+
+public class MirrorMaker extends DmaapObject {
+ static final Logger logger = Logger.getLogger(MirrorMaker.class);
+
+ private String sourceCluster;
+ private String targetCluster;
+ private String mmName;
+ private ArrayList<String> topics; //re-using this var name for backwards DB compatibility
+
+ private Set<ReplicationVector> vectors;
+
+
+ public MirrorMaker(){
+
+ }
+
+ public MirrorMaker(String source, String target) {
+ sourceCluster = source;
+ targetCluster = target;
+ mmName = genKey(source, target);
+ vectors = new HashSet<ReplicationVector>();
+ topics = new ArrayList<String>();
+
+ }
+
+ public String getMmName() {
+ return mmName;
+ }
+
+ public void setMmName(String mmName) {
+ this.mmName = mmName;
+ }
+
+
+ public void addVector( String fqtn, String source, String target ) {
+ logger.info( "addVector: fqtn=" + fqtn + " source=" + source + " target=" + target );
+ if ( ! sourceCluster.equals( source ) ){
+ logger.error( "trying to add edge from source " + source + " into Map belonging to " + sourceCluster );
+ }
+ vectors.add(new ReplicationVector( fqtn, source, target ));
+ }
+
+ public void delVector( String fqtn, String source, String target ) {
+ vectors.remove(new ReplicationVector( fqtn, source, target));
+ }
+
+
+
+ public String toJSON() {
+ StringBuilder str = new StringBuilder( "{ \"source\": " + sourceCluster + ",\"topics\": [" );
+ int numTargets = 0;
+ for (ReplicationVector rv: vectors) {
+ if ( numTargets > 0 ) {
+ str.append( ",");
+ }
+ str.append( " \"target\": " + rv.getTargetCluster() + ", \"topic\": " + rv.getFqtn());
+ numTargets++;
+ }
+ str.append( "] }" );
+
+ return str.toString();
+ }
+
+
+ // returns the JSON for MM message containing which Topics to replicate
+ /*
+ * example:
+ *
+ {
+ "messageID":"12349",
+ "updateWhiteList":
+ {
+ "name":"Global1ToGlobal3",
+ "whitelist":"org.openecomp.dcae.topic1,org.openecomp.dcae.topic2"
+ }
+ }
+ */
+ public String updateWhiteList() {
+ StringBuilder str = new StringBuilder( "{ \"messageID\": \"" + MirrorMakerService.genTransactionId() + "\", \"updateWhiteList\": {" );
+ str.append( " \"name\": \"" + this.getMmName() + "\", \"whitelist\": \"" );
+ int numTargets = 0;
+
+ //for (ReplicationVector rv: vectors) {
+ for (String rv: topics) {
+ if ( numTargets > 0 ) {
+ str.append( ",");
+ }
+ //str.append( rv.getFqtn() );
+ str.append( rv );
+ numTargets++;
+ }
+ str.append( "\" } }" );
+
+ return str.toString();
+ }
+
+ // returns the JSON for MM message indicating that a MM agent is needed between two clusters
+ // example:
+ /*
+ *
+ {
+ "messageID":"12345"
+ "createMirrorMaker":
+ {
+ "name":"Global1ToGlobal2",
+ "consumer":"192.168.0.1:2181",
+ "producer":"192.168.0.2:9092"
+ }
+ }
+ */
+ public String createMirrorMaker() {
+ StringBuilder str = new StringBuilder( "{ \"messageID\": \"" + MirrorMakerService.genTransactionId() + "\", \"createMirrorMaker\": {" );
+ str.append( " \"name\": \"" + this.getMmName() + "\", " );
+ str.append( " \"consumer\": \"" + this.sourceCluster + ":2181\", " );
+ str.append( " \"producer\": \"" + this.targetCluster + ":9092\" ");
+
+ str.append( " } }" );
+
+ return str.toString();
+ }
+
+
+ public String getSourceCluster() {
+ return sourceCluster;
+ }
+
+ public void setSourceCluster(String sourceCluster) {
+ this.sourceCluster = sourceCluster;
+ }
+
+ public String getTargetCluster() {
+ return targetCluster;
+ }
+
+ public void setTargetCluster(String targetCluster) {
+ this.targetCluster = targetCluster;
+ }
+
+
+ public Set<ReplicationVector> getVectors() {
+ return vectors;
+ }
+
+ public void setVectors(Set<ReplicationVector> vectors) {
+ this.vectors = vectors;
+ }
+ public ArrayList<String> getTopics() {
+ return topics;
+ }
+
+ //public void setVectors(Set<ReplicationVector> vectors) {
+ public void setTopics(ArrayList<String> topics) {
+ this.topics = topics;
+ }
+
+
+ public static String genKey( String s, String t) {
+ StringBuilder str = new StringBuilder();
+ str.append(s);
+ str.append("-To-");
+ str.append(t);
+ return str.toString();
+ }
+
+
+
+ public void addTopic( String topic ) {
+ topics.add(topic);
+ }
+
+ public int getTopicCount() {
+ return topics.size();
+ }
+}
diff --git a/src/main/java/org/openecomp/dmaapbc/model/ReplicationVector.java b/src/main/java/org/openecomp/dmaapbc/model/ReplicationVector.java
new file mode 100644
index 0000000..60f25e5
--- /dev/null
+++ b/src/main/java/org/openecomp/dmaapbc/model/ReplicationVector.java
@@ -0,0 +1,104 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OpenECOMP - org.openecomp.dmaapbc
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.dmaapbc.model;
+import org.apache.log4j.Logger;
+
+public class ReplicationVector {
+
+
+
+ static final Logger logger = Logger.getLogger(ReplicationVector.class);
+ public enum ReplicationVector_Status {
+ EMPTY,
+ NEW,
+ STAGED,
+ VALID,
+ INVALID,
+ INVALID_DUP,
+ DELETED
+ }
+
+ String fqtn;
+ String sourceCluster;
+ String targetCluster;
+ ReplicationVector_Status status;
+
+ public ReplicationVector(){
+
+ }
+
+ public ReplicationVector(String fqtn, String sourceCluster,
+ String targetCluster) {
+ super();
+ this.fqtn = fqtn;
+ this.sourceCluster = sourceCluster;
+ this.targetCluster = targetCluster;
+ }
+
+ public String getFqtn() {
+ return fqtn;
+ }
+
+ public void setFqtn(String fqtn) {
+ this.fqtn = fqtn;
+ }
+
+ public String getSourceCluster() {
+ return sourceCluster;
+ }
+
+ public void setSourceCluster(String sourceCluster) {
+ this.sourceCluster = sourceCluster;
+ }
+
+ public String getTargetCluster() {
+ return targetCluster;
+ }
+
+ public void setTargetCluster(String targetCluster) {
+ this.targetCluster = targetCluster;
+ }
+
+ public int hashCode() {
+ StringBuilder tmp = new StringBuilder( this.fqtn );
+ tmp.append(this.sourceCluster);
+ tmp.append(this.targetCluster);
+
+ return tmp.toString().hashCode();
+ }
+ private static boolean xeq(String s1, String s2) {
+ if (s1 == null) {
+ return(s2 == null);
+ } else {
+ return(s1.equals(s2));
+ }
+ }
+ public boolean equals(Object o) {
+ if (o == this) {
+ return(true);
+ }
+ if (!(o instanceof ReplicationVector)) {
+ return(false);
+ }
+ ReplicationVector x = (ReplicationVector)o;
+ return(xeq(fqtn, x.fqtn) && xeq(sourceCluster, x.sourceCluster) && xeq(targetCluster, x.targetCluster));
+ }
+}
diff --git a/src/main/java/org/openecomp/dmaapbc/model/Topic.java b/src/main/java/org/openecomp/dmaapbc/model/Topic.java
new file mode 100644
index 0000000..3d9ea6f
--- /dev/null
+++ b/src/main/java/org/openecomp/dmaapbc/model/Topic.java
@@ -0,0 +1,165 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OpenECOMP - org.openecomp.dmaapbc
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.dmaapbc.model;
+
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Date;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.log4j.Logger;
+import org.openecomp.dmaapbc.service.DmaapService;
+
+
+@XmlRootElement
+public class Topic extends DmaapObject {
+ static final Logger logger = Logger.getLogger(Topic.class);
+
+ private String fqtn;
+ private String topicName;
+ private String topicDescription;
+ // I don't think this field is needed for this object. Rather, it applies to each MR_Client
+ //private String dcaeLocationName;
+ private String tnxEnabled;
+ private String owner;
+ private String formatUuid;
+
+ private ArrayList<MR_Client> clients;
+
+
+
+ private static Dmaap dmaap = new DmaapService().getDmaap();
+
+ //
+ // utility function to generate the FQTN of a topic
+ public static String genFqtn( String name ) {
+ String ret = dmaap.getTopicNsRoot() + "." + dmaap.getDmaapName() + "." + name;
+ return ret;
+ }
+
+
+
+ public Topic() {
+ super();
+ this.clients = new ArrayList<MR_Client>();
+ this.lastMod = new Date();
+ this.setLastMod();
+ logger.info( "Topic constructor " + this.lastMod );
+ }
+ public Topic(String fqtn, String topicName, String topicDescription,
+ String tnxEnabled, String owner) {
+ super();
+ this.fqtn = fqtn;
+ this.topicName = topicName;
+ this.topicDescription = topicDescription;
+ //this.dcaeLocationName = dcaeLocationName;
+ this.tnxEnabled = tnxEnabled;
+ this.owner = owner;
+ this.setLastMod();
+ this.setStatus( DmaapObject_Status.NEW );
+ logger.info( "Topic constructor " + this.getLastMod() );
+ }
+ public String getFqtn() {
+ return fqtn;
+ }
+ public void setFqtn(String fqtn) {
+ this.fqtn = fqtn;
+ }
+ public String getTopicName() {
+ return topicName;
+ }
+ public void setTopicName(String topicName) {
+ this.topicName = topicName;
+ }
+ public String getTopicDescription() {
+ return topicDescription;
+ }
+ public void setTopicDescription(String topicDescription) {
+ this.topicDescription = topicDescription;
+ }
+ /*
+ public String getDcaeLocationName() {
+ return dcaeLocationName;
+ }
+ public void setDcaeLocationName(String dcaeLocationName) {
+ this.dcaeLocationName = dcaeLocationName;
+ }
+ */
+ public String getTnxEnabled() {
+ return tnxEnabled;
+ }
+ public void setTnxEnabled(String tnxEnabled) {
+ this.tnxEnabled = tnxEnabled;
+ }
+ public String getOwner() {
+ return owner;
+ }
+ public void setOwner(String owner) {
+ this.owner = owner;
+ }
+
+
+ public void setClients(ArrayList<MR_Client> clients) {
+ this.clients = clients;
+ }
+
+ public ArrayList<MR_Client> getClients() {
+ return clients;
+ }
+
+ public int getNumClients() {
+ if ( this.clients == null ) {
+ return 0;
+ }
+ return this.clients.size();
+ }
+
+
+
+
+ public String getFormatUuid() {
+ return formatUuid;
+ }
+
+
+
+ public void setFormatUuid(String formatUuid) {
+ this.formatUuid = formatUuid;
+ }
+
+
+
+ public String toProvJSON() {
+ StringBuilder str = new StringBuilder();
+ str.append("{ \"topicName\": \"");
+ str.append( this.getFqtn() );
+ str.append( "\", \"topicDescription\": \"");
+ str.append( this.getTopicDescription());
+ str.append( "\", \"partitionCount\": \"2\", \"replicationCount\": \"1\" } ");
+ logger.info( str.toString() );
+ return str.toString();
+ }
+
+ public byte[] getBytes() {
+ return toProvJSON().getBytes(StandardCharsets.UTF_8);
+ }
+}