Merge "Fix Sonar bugs"
authorRam Koya <rk541m@att.com>
Thu, 20 Sep 2018 15:19:19 +0000 (15:19 +0000)
committerGerrit Code Review <gerrit@onap.org>
Thu, 20 Sep 2018 15:19:19 +0000 (15:19 +0000)
20 files changed:
datarouter-node/pom.xml
datarouter-prov/pom.xml
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/BaseServlet.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/SynchronizerTask.java
datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/URLUtilities.java
datarouter-subscriber/pom.xml
docs/data-router/DataRouterUserGuide.rst [new file with mode: 0644]
docs/data-router/administration.rst [new file with mode: 0644]
docs/data-router/architecture.rst [new file with mode: 0644]
docs/data-router/configuration.rst [new file with mode: 0644]
docs/data-router/consumedapis.rst [new file with mode: 0644]
docs/data-router/data-router.rst
docs/data-router/delivery.rst [new file with mode: 0644]
docs/data-router/dr_arch.png [new file with mode: 0644]
docs/data-router/humaninterfaces.rst [new file with mode: 0644]
docs/data-router/logging.rst [new file with mode: 0644]
docs/data-router/release-notes.rst [new file with mode: 0644]
docs/index.rst
pom.xml
version.properties

index f9bdce6..29e3ce4 100755 (executable)
@@ -25,7 +25,7 @@
     <parent>
         <groupId>org.onap.dmaap.datarouter</groupId>
         <artifactId>parent</artifactId>
-        <version>1.0.1-SNAPSHOT</version>
+        <version>1.0.2-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
     <artifactId>datarouter-node</artifactId>
index c9c0c2f..0bb5417 100755 (executable)
@@ -25,7 +25,7 @@
     <parent>\r
         <groupId>org.onap.dmaap.datarouter</groupId>\r
         <artifactId>parent</artifactId>\r
-        <version>1.0.1-SNAPSHOT</version>\r
+        <version>1.0.2-SNAPSHOT</version>\r
         <relativePath>../pom.xml</relativePath>\r
     </parent>\r
     <artifactId>datarouter-prov</artifactId>\r
         <datarouter.prov.image.name>onap/dmaap/datarouter-prov</datarouter.prov.image.name>\r
     </properties>\r
     <dependencies>\r
+        <dependency>\r
+            <groupId>xml-apis</groupId>\r
+            <artifactId>xml-apis</artifactId>\r
+            <version>${xml-apis.version}</version>\r
+        </dependency>\r
         <dependency>\r
             <groupId>dom4j</groupId>\r
             <artifactId>dom4j</artifactId>\r
index 047043b..3838cad 100755 (executable)
@@ -121,7 +121,6 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
     private static final int DEFAULT_POKETIMER2 = 30;
     private static final String DEFAULT_DOMAIN = "onap";
     private static final String DEFAULT_PROVSRVR_NAME = "dmaap-dr-prov";
-    private static final String RESEARCH_SUBNET = "10.42.0.0/16";
     private static final String STATIC_ROUTING_NODES = ""; //Adding new param for static Routing - Rally:US664862-1610
 
     /**
@@ -139,11 +138,11 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
     /**
      * The set of authorized addresses and networks; pulled from the DB (PROV_AUTH_ADDRESSES)
      */
-    private static Set<String> authorizedAddressesAndNetworks = new HashSet<String>();
+    private static Set<String> authorizedAddressesAndNetworks = new HashSet<>();
     /**
      * The set of authorized names; pulled from the DB (PROV_AUTH_SUBJECTS)
      */
-    private static Set<String> authorizedNames = new HashSet<String>();
+    private static Set<String> authorizedNames = new HashSet<>();
     /**
      * The FQDN of the initially "active" provisioning server in this Data Router ecosystem
      */
@@ -199,19 +198,13 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
     /**
      * The standard FQDN of the provisioning server in this Data Router ecosystem
      */
-    public static String provName = "feeds-drtr.web.att.com";
+    private static String provName = "feeds-drtr.web.att.com";
+
     /**
      * The standard FQDN of the ACTIVE provisioning server in this Data Router ecosystem
      */
-    public static String activeProvName = "feeds-drtr.web.att.com";
-    /**
-     * Special subnet that is allowed access to /internal
-     */
-    private static String researchSubnet = RESEARCH_SUBNET;
-    /**
-     * Special subnet that is allowed access to /internal to Lab Machine
-     */
-    private static String researchSubnet1 = RESEARCH_SUBNET;
+    private static String activeProvName = "feeds-drtr.web.att.com";
+
     private static String staticRoutingNodes = STATIC_ROUTING_NODES; //Adding new param for static Routing - Rally:US664862-1610
 
     /**
@@ -389,13 +382,6 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
             if (loopback != null && ip.equals(loopback)) {
                 return true;
             }
-            // Also allow the "special subnet" access
-            if (addressMatchesNetwork(ip, researchSubnet1)) {
-                return true;
-            }
-            if (addressMatchesNetwork(ip, researchSubnet)) {
-                return true;
-            }
         } catch (UnknownHostException e) {
             // ignore
         }
@@ -473,7 +459,6 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
         provDomain = getString(map, Parameters.PROV_DOMAIN, DEFAULT_DOMAIN);
         provName = getString(map, Parameters.PROV_NAME, DEFAULT_PROVSRVR_NAME);
         activeProvName = getString(map, Parameters.PROV_ACTIVE_NAME, provName);
-        researchSubnet = getString(map, Parameters.PROV_SPECIAL_SUBNET, RESEARCH_SUBNET);
         staticRoutingNodes = getString(map, Parameters.STATIC_ROUTING_NODES,
             ""); //Adding new param for static Routing - Rally:US664862-1610
         initialActivePod = getString(map, Parameters.ACTIVE_POD, "");
@@ -630,6 +615,13 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
         }
     }
 
+    public static String getProvName() {
+        return provName;
+    }
+
+    public static String getActiveProvName() {
+        return activeProvName;
+    }
 
     /**
      * Get an array of all node names in the DR network.
@@ -784,7 +776,7 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
     }
 
     private static Set<String> getSet(Map<String, String> map, String name) {
-        Set<String> set = new HashSet<String>();
+        Set<String> set = new HashSet<>();
         String s = map.get(name);
         if (s != null) {
             String[] pp = s.split("\\|");
@@ -807,7 +799,7 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
     public class ContentHeader {
 
         private String type = "";
-        private Map<String, String> map = new HashMap<String, String>();
+        private Map<String, String> map = new HashMap<>();
 
         ContentHeader() {
             this("", "1.0");
index e1eeb78..f9d0867 100644 (file)
@@ -302,7 +302,7 @@ public class SynchronizerTask extends TimerTask {
             String thisPod = myaddr.getHostName();
             Set<String> pods = new TreeSet<>(Arrays.asList(BaseServlet.getPods()));
             if (pods.contains(thisPod)) {
-                InetAddress pserver = InetAddress.getByName(BaseServlet.activeProvName);
+                InetAddress pserver = InetAddress.getByName(BaseServlet.getActiveProvName());
                 newstate = myaddr.equals(pserver) ? ACTIVE : STANDBY;
                 if (logger.isDebugEnabled() && System.currentTimeMillis() >= nextMsg) {
                     logger.debug("Active POD = " + pserver + ", Current state is " + stnames[newstate]);
index d0178fd..0c6afdd 100644 (file)
@@ -45,7 +45,7 @@ public class URLUtilities {
      * @return the URL\r
      */\r
     public static String generateFeedURL(int feedid) {\r
-        return "https://" + BaseServlet.provName + "/feed/" + feedid;\r
+        return "https://" + BaseServlet.getProvName() + "/feed/" + feedid;\r
     }\r
 \r
     /**\r
@@ -55,7 +55,7 @@ public class URLUtilities {
      * @return the URL\r
      */\r
     public static String generatePublishURL(int feedid) {\r
-        return "https://" + BaseServlet.provName + "/publish/" + feedid;\r
+        return "https://" + BaseServlet.getProvName() + "/publish/" + feedid;\r
     }\r
 \r
     /**\r
@@ -65,7 +65,7 @@ public class URLUtilities {
      * @return the URL\r
      */\r
     public static String generateSubscribeURL(int feedid) {\r
-        return "https://" + BaseServlet.provName + "/subscribe/" + feedid;\r
+        return "https://" + BaseServlet.getProvName() + "/subscribe/" + feedid;\r
     }\r
 \r
     /**\r
@@ -75,7 +75,7 @@ public class URLUtilities {
      * @return the URL\r
      */\r
     public static String generateFeedLogURL(int feedid) {\r
-        return "https://" + BaseServlet.provName + "/feedlog/" + feedid;\r
+        return "https://" + BaseServlet.getProvName() + "/feedlog/" + feedid;\r
     }\r
 \r
     /**\r
@@ -85,7 +85,7 @@ public class URLUtilities {
      * @return the URL\r
      */\r
     public static String generateSubscriptionURL(int subid) {\r
-        return "https://" + BaseServlet.provName + "/subs/" + subid;\r
+        return "https://" + BaseServlet.getProvName() + "/subs/" + subid;\r
     }\r
 \r
     /**\r
@@ -95,7 +95,7 @@ public class URLUtilities {
      * @return the URL\r
      */\r
     public static String generateSubLogURL(int subid) {\r
-        return "https://" + BaseServlet.provName + "/sublog/" + subid;\r
+        return "https://" + BaseServlet.getProvName() + "/sublog/" + subid;\r
     }\r
 \r
     /**\r
index cc1d486..87b82f1 100755 (executable)
@@ -25,7 +25,7 @@
     <parent>
         <groupId>org.onap.dmaap.datarouter</groupId>
         <artifactId>parent</artifactId>
-        <version>1.0.1-SNAPSHOT</version>
+        <version>1.0.2-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
     <artifactId>datarouter-subscriber</artifactId>
diff --git a/docs/data-router/DataRouterUserGuide.rst b/docs/data-router/DataRouterUserGuide.rst
new file mode 100644 (file)
index 0000000..8f7b9ef
--- /dev/null
@@ -0,0 +1,25 @@
+===========================
+Data Router (DR) User Guide
+===========================
+
+Standalone Mode
+---------------
+
+Installation
+============
+
+1. Find the datarouter project on the gerrit website: https://gerrit.onap.org/r/#/admin/projects/dmaap/datarouter
+
+2. Clone the repo onto your server using the clone command found on the datarouter page on gerrit.
+
+3. cd into the docker-compose directory and run docker-compose up.
+
+Configurations
+==============
+
+Using the Data Router
+---------------------
+
+For information on how to use the Data Router refer to the Data Router API guide at:
+
+    :ref:`data_router_api_guide`
\ No newline at end of file
diff --git a/docs/data-router/administration.rst b/docs/data-router/administration.rst
new file mode 100644 (file)
index 0000000..b050a1f
--- /dev/null
@@ -0,0 +1,14 @@
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. http://creativecommons.org/licenses/by/4.0
+
+Administration
+==============
+
+
+Processes
+---------
+NA
+
+Actions
+-------
+NA
diff --git a/docs/data-router/architecture.rst b/docs/data-router/architecture.rst
new file mode 100644 (file)
index 0000000..b18f7bb
--- /dev/null
@@ -0,0 +1,25 @@
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. http://creativecommons.org/licenses/by/4.0
+
+Architecture
+============
+
+
+Capabilities
+------------
+Data Router is a RESTful web service used for the transfer of data across networks any larger than a Message Router message (> 1Mb).
+
+Usage Scenarios
+---------------
+    Data Router endpoints are used to create/view/delete Feeds, Subscribers and Published files. Clients can use the Data Router endpoints
+    to publish a file to a feed and subscribe to this feed to receive the file.
+
+Interactions
+------------
+Data Router REST service uses the Data Router API to allow users to publish to and subscribe to a feed, in order to send and receive files.
+
+
+
+   |image0|
+
+   .. |image0| image:: dr_arch.png
diff --git a/docs/data-router/configuration.rst b/docs/data-router/configuration.rst
new file mode 100644 (file)
index 0000000..2a7096a
--- /dev/null
@@ -0,0 +1,7 @@
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. http://creativecommons.org/licenses/by/4.0
+
+Configuration
+=============
+
+NA
\ No newline at end of file
diff --git a/docs/data-router/consumedapis.rst b/docs/data-router/consumedapis.rst
new file mode 100644 (file)
index 0000000..aa1a8bd
--- /dev/null
@@ -0,0 +1,7 @@
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. http://creativecommons.org/licenses/by/4.0
+
+Consumed APIs
+=============
+
+Data Router does not consume any API
index ecce209..aaee385 100755 (executable)
@@ -1,10 +1,15 @@
+.. _data_router_api_guide:\r
+\r
 ==========================\r
 Data Router (DR) API Guide\r
 ==========================\r
 Introduction\r
 ------------\r
 \r
-The DataRouter(DR) provisioning API is an HTTPS-based, REST-like API for creating and managing DR feeds and subscriptions. The Data Routing System project is intended to provide a common framework by which data producers can make data available to data consumers and a way for potential consumers to find feeds with the data they require.\r
+The DataRouter(DR) provisioning API is an HTTPS-based, REST-like API for creating and managing DR feeds\r
+and subscriptions. The Data Routing System project is intended to provide a common framework by which\r
+data producers can make data available to data consumers and a way for potential consumers to find feeds\r
+with the data they require.\r
 \r
 \r
 HTTP Service APIs\r
diff --git a/docs/data-router/delivery.rst b/docs/data-router/delivery.rst
new file mode 100644 (file)
index 0000000..775841a
--- /dev/null
@@ -0,0 +1,32 @@
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. http://creativecommons.org/licenses/by/4.0
+
+Delivery
+==============
+
+Data Router is comprised of a datarouter-provisioning container, a datarouter-node container and a mariadb container.
+
+.. blockdiag::
+
+
+   blockdiag layers {
+   orientation = portrait
+   MARIADB -> DR-PROV;
+   DR-PROV -> DR-NODE;
+   group l1 {
+       color = blue;
+       label = "dr-prov Container";
+       DR-PROV;
+       }
+   group l2 {
+       color = yellow;
+       label = "dr-node Container";
+       DR-NODE;
+       }
+   group l3 {
+       color = orange;
+       label = "MariaDb Container";
+       MARIADB;
+       }
+
+   }
diff --git a/docs/data-router/dr_arch.png b/docs/data-router/dr_arch.png
new file mode 100644 (file)
index 0000000..1655eda
Binary files /dev/null and b/docs/data-router/dr_arch.png differ
diff --git a/docs/data-router/humaninterfaces.rst b/docs/data-router/humaninterfaces.rst
new file mode 100644 (file)
index 0000000..71a2b73
--- /dev/null
@@ -0,0 +1,10 @@
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. http://creativecommons.org/licenses/by/4.0
+
+Human Interfaces
+================
+
+Data Router does not have human interfaces
+
+
+
diff --git a/docs/data-router/logging.rst b/docs/data-router/logging.rst
new file mode 100644 (file)
index 0000000..ac6aa95
--- /dev/null
@@ -0,0 +1,25 @@
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. http://creativecommons.org/licenses/by/4.0
+
+Logging
+=======
+
+
+Where to Access Information
+---------------------------
+Data Router uses logback framework to generate logs.
+
+Error / Warning Messages
+------------------------
+Currently Data Router does not have any unique error codes. However the following are the common HTTP error codes that
+could possibly occur in Data Router:
+
+    OK = 200 : The normal response from a successful update or get of a feed or subscription
+    CREATED = 201 : the normal response from successfully creating or subscribing to a feed.
+    NO_CONTENT = 204 : the normal response from a successful publish attempt and on successfully deleting a feed or subscription
+    MOVED_PERMANENTLY = 301 :the normal redirect response from prov to a publisher
+    BAD_REQUEST = 400: Usually indicates that either Json object in request body is incorrect in some way, or an Invalid parameter value was included in query string.
+    UNAUTHORIZED = 401 : Usually indicated either request was missing Authorization header, or indicates incorrect Username/password credentials
+    FORBIDDEN = 403 : Usually indicates the request originated from an unauthorized IP address, or that a client certificate was not a part of authorized list.
+    NOT_FOUND = 404 : Usually indicates an incorrect URI
+    METHOD_NOT_ALLOWED = 405 : Indicates an HTTP method is not accepted for given URI
\ No newline at end of file
diff --git a/docs/data-router/release-notes.rst b/docs/data-router/release-notes.rst
new file mode 100644 (file)
index 0000000..f69ea2c
--- /dev/null
@@ -0,0 +1,29 @@
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. http://creativecommons.org/licenses/by/4.0
+
+Release-notes
+==============
+
+Version: 1.0.1
+--------------
+
+:Release Date: 2018-09-20
+
+
+New Features:
+
+ - Implements a RESTful HTTPS API for creating feeds to publish files to and subscribe to,
+   as well as perform CRUD operations on these feeds.
+ - Implements a RESTful HTTPS API for subscribing to feeds and perform CRUD operations on these subscriptions.
+ - Implements a RESTful HTTPS API for publishing to feeds and perform CRUD operations on these published files.
+
+
+
+Bug Fixes
+NA
+
+Known Issues
+NA
+
+Other
+NA
\ No newline at end of file
index f7dae49..99f0f28 100644 (file)
@@ -14,15 +14,24 @@ The DataRouter(DR)provisioning API is an HTTPS-based,REST-like API for creating
 HTTP Service APIs\r
 ------------------\r
 \r
-DMaaP Message Router utilizes an HTTP REST API to service all transactions. HTTP and REST standards are followed so\r
-clients as varied as CURL, Java applications and even Web Browsers will\r
-work to interact with the Data Router.\r
+DMaaP Data Router utilizes an HTTPS REST API to service all transactions. HTTPS and REST standards are followed so\r
+clients as varied as CURL, Java applications and even Web Browsers will work to interact with the Data Router.\r
 \r
 \r
 \r
 .. toctree::\r
-   :maxdepth: 3\r
+   :maxdepth: 1\r
    \r
-   data-router/data-router\r
+   data-router/data-router.rst\r
+   data-router/administration.rst\r
+   data-router/architecture.rst\r
+   data-router/configuration.rst\r
+   data-router/consumedapis.rst\r
+   data-router/DataRouterUserGuide.rst\r
+   data-router/delivery.rst\r
+   data-router/humaninterfaces.rst\r
+   data-router/logging.rst\r
+   data-router/release-notes.rst\r
+\r
 \r
 \r
diff --git a/pom.xml b/pom.xml
index afbbf92..17744ad 100755 (executable)
--- a/pom.xml
+++ b/pom.xml
@@ -25,7 +25,7 @@
     <groupId>org.onap.dmaap.datarouter</groupId>
     <artifactId>parent</artifactId>
     <name>dmaap-datarouter</name>
-    <version>1.0.1-SNAPSHOT</version>
+    <version>1.0.2-SNAPSHOT</version>
     <packaging>pom</packaging>
     <url>https://github.com/att/DMAAP_DATAROUTER</url>
     <parent>
@@ -49,6 +49,7 @@
         <jetty.websocket.version>8.2.0.v20160908</jetty.websocket.version>
         <javax.mail-api.version>1.5.5</javax.mail-api.version>
         <dom4j.version>1.6</dom4j.version>
+        <xml-apis.version>1.4.01</xml-apis.version>
         <thoughtworks.version>1.4.10</thoughtworks.version>
         <google.guava.version>26.0-jre</google.guava.version>
         <qos.logback.version>1.2.3</qos.logback.version>
index 30cdf7e..b042a35 100644 (file)
@@ -27,7 +27,7 @@
 \r
 major=1\r
 minor=0\r
-patch=1\r
+patch=2\r
 \r
 base_version=${major}.${minor}.${patch}\r
 \r