Update project structure to org.onap
[dmaap/datarouter.git] / datarouter-prov / src / main / java / org / onap / dmaap / datarouter / provisioning / beans / FeedAuthorization.java
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedAuthorization.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedAuthorization.java
new file mode 100644 (file)
index 0000000..49578b8
--- /dev/null
@@ -0,0 +1,96 @@
+/*******************************************************************************\r
+ * ============LICENSE_START==================================================\r
+ * * org.onap.dmaap\r
+ * * ===========================================================================\r
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
+ * * ===========================================================================\r
+ * * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * * you may not use this file except in compliance with the License.\r
+ * * You may obtain a copy of the License at\r
+ * * \r
+ *  *      http://www.apache.org/licenses/LICENSE-2.0\r
+ * * \r
+ *  * Unless required by applicable law or agreed to in writing, software\r
+ * * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * * See the License for the specific language governing permissions and\r
+ * * limitations under the License.\r
+ * * ============LICENSE_END====================================================\r
+ * *\r
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ * *\r
+ ******************************************************************************/\r
+\r
+\r
+package org.onap.dmaap.datarouter.provisioning.beans;\r
+\r
+import java.util.HashSet;\r
+import java.util.Set;\r
+\r
+import org.json.JSONArray;\r
+import org.json.JSONObject;\r
+\r
+/**\r
+ * The representation of a Feed authorization.  This encapsulates the authorization information about a feed.\r
+ * @author Robert Eby\r
+ * @version $Id: FeedAuthorization.java,v 1.2 2013/06/20 14:11:05 eby Exp $\r
+ */\r
+public class FeedAuthorization implements JSONable {\r
+       private String classification;\r
+       private Set<FeedEndpointID> endpoint_ids;\r
+       private Set<String> endpoint_addrs;\r
+\r
+       public FeedAuthorization() {\r
+               this.classification = "";\r
+               this.endpoint_ids = new HashSet<FeedEndpointID>();\r
+               this.endpoint_addrs = new HashSet<String>();\r
+       }\r
+       public String getClassification() {\r
+               return classification;\r
+       }\r
+       public void setClassification(String classification) {\r
+               this.classification = classification;\r
+       }\r
+       public Set<FeedEndpointID> getEndpoint_ids() {\r
+               return endpoint_ids;\r
+       }\r
+       public void setEndpoint_ids(Set<FeedEndpointID> endpoint_ids) {\r
+               this.endpoint_ids = endpoint_ids;\r
+       }\r
+       public Set<String> getEndpoint_addrs() {\r
+               return endpoint_addrs;\r
+       }\r
+       public void setEndpoint_addrs(Set<String> endpoint_addrs) {\r
+               this.endpoint_addrs = endpoint_addrs;\r
+       }\r
+\r
+       @Override\r
+       public JSONObject asJSONObject() {\r
+               JSONObject jo = new JSONObject();\r
+               jo.put("classification", classification);\r
+               JSONArray ja = new JSONArray();\r
+               for (FeedEndpointID eid : endpoint_ids) {\r
+                       ja.put(eid.asJSONObject());\r
+               }\r
+               jo.put("endpoint_ids", ja);\r
+               ja = new JSONArray();\r
+               for (String t : endpoint_addrs) {\r
+                       ja.put(t);\r
+               }\r
+               jo.put("endpoint_addrs", ja);\r
+               return jo;\r
+       }\r
+       @Override\r
+       public boolean equals(Object obj) {\r
+               if (!(obj instanceof FeedAuthorization))\r
+                       return false;\r
+               FeedAuthorization of = (FeedAuthorization) obj;\r
+               if (!classification.equals(of.classification))\r
+                       return false;\r
+               if (!endpoint_ids.equals(of.endpoint_ids))\r
+                       return false;\r
+               if (!endpoint_addrs.equals(of.endpoint_addrs))\r
+                       return false;\r
+               return true;\r
+       }\r
+}\r