From 5906de2465975e42e4983abe411f30fa16050fdf Mon Sep 17 00:00:00 2001 From: efiacor Date: Thu, 16 Apr 2020 14:59:07 +0100 Subject: Fix sonar issues and reporting Signed-off-by: efiacor Change-Id: I29aa54e62d2dfaa6eddb16eb67c325254dfc0e06 Issue-ID: DMAAP-1426 --- .../onap/dmaap/datarouter/node/NodeServlet.java | 4 +- datarouter-prov/pom.xml | 5 - .../onap/dmaap/datarouter/authz/impl/package.html | 10 +- .../org/onap/dmaap/datarouter/authz/package.html | 8 +- .../datarouter/provisioning/StatisticsServlet.java | 7 +- .../datarouter/provisioning/beans/package.html | 12 ++- .../dmaap/datarouter/provisioning/package.html | 22 ++-- .../datarouter/provisioning/utils/package.html | 10 +- datarouter-subscriber/pom.xml | 21 +++- .../subscriber/SampleSubscriberServlet.java | 5 +- .../datarouter/subscriber/SubscriberMain.java | 5 +- .../datarouter/subscriber/SubscriberProps.java | 7 +- .../src/main/resources/docker/Dockerfile | 6 +- .../src/main/resources/log4j.properties | 31 ------ .../src/main/resources/logback.xml | 112 +++++++++++++++++++++ .../src/test/resources/log4j.properties | 31 ------ .../src/test/resources/logback-test.xml | 112 +++++++++++++++++++++ pom.xml | 26 +---- 18 files changed, 301 insertions(+), 133 deletions(-) delete mode 100644 datarouter-subscriber/src/main/resources/log4j.properties create mode 100644 datarouter-subscriber/src/main/resources/logback.xml delete mode 100644 datarouter-subscriber/src/test/resources/log4j.properties create mode 100644 datarouter-subscriber/src/test/resources/logback-test.xml diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeServlet.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeServlet.java index 388b6793..0d030683 100644 --- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeServlet.java +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeServlet.java @@ -424,7 +424,9 @@ public class NodeServlet extends HttpServlet { mw.write("X-DMAAP-DR-ROUTING\t" + t.getRouting() + "\n"); } mw.close(); - meta.renameTo(new File(dbase + ".M")); + if (!meta.renameTo(new File(dbase + ".M"))) { + eelfLogger.error("Rename of file " + dbase + " failed."); + } } resp.setStatus(HttpServletResponse.SC_NO_CONTENT); try { diff --git a/datarouter-prov/pom.xml b/datarouter-prov/pom.xml index 54f6d85b..223261c6 100755 --- a/datarouter-prov/pom.xml +++ b/datarouter-prov/pom.xml @@ -140,11 +140,6 @@ org.apache.httpcomponents httpclient - - org.dom4j - dom4j - 2.1.1 - org.sonatype.http-testing-harness junit-runner diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/impl/package.html b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/impl/package.html index 0d051db3..58055eaa 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/impl/package.html +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/impl/package.html @@ -1,4 +1,4 @@ -#------------------------------------------------------------------------------- + - + + + DMaaP DR Authz Impl package

@@ -55,8 +57,6 @@ class defined in this package, passing it an instance of the ProvDataProvi implementation. -

-

Example:

 
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/package.html b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/package.html
index 3b484500..be7e333e 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/package.html
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/authz/package.html
@@ -1,4 +1,4 @@
-#-------------------------------------------------------------------------------
+
 
-
+
+
 
+  DMaaP DR Authz package
 
 
 

diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/StatisticsServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/StatisticsServlet.java index 76991ca0..c564db86 100755 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/StatisticsServlet.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/StatisticsServlet.java @@ -32,6 +32,8 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.Calendar; import java.util.Date; import java.util.HashMap; @@ -511,10 +513,9 @@ public class StatisticsServlet extends BaseServlet { ResultSet rs = ps.executeQuery()) { if ("csv".equals(outputType)) { resp.setContentType("application/octet-stream"); - Date date = new Date(); - SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-YYYY HH:mm:ss"); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm:ss"); resp.setHeader("Content-Disposition", - "attachment; filename=\"result:" + dateFormat.format(date) + ".csv\""); + "attachment; filename=\"result:" + LocalDateTime.now().format(formatter) + ".csv\""); eventlogger.info("Generating CSV file from Statistics resultset"); rsToCSV(rs, out); } else { diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/package.html b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/package.html index c33902cd..f05b765b 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/package.html +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/package.html @@ -1,4 +1,4 @@ -#------------------------------------------------------------------------------- + - + + + + DMaaP DR Provisioning Beans +

This package provides beans to represent the basic provisioning objects of the Data Router application. -These objects are defined by the document Data Router Release 1 Provisioning API Version 1.2. +These objects are defined by the document Data Router Release 1 Provisioning API Version 1.2.

diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/package.html b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/package.html index af08391a..c6263e15 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/package.html +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/package.html @@ -1,4 +1,4 @@ -#------------------------------------------------------------------------------- + - + + + + DMaaP DR Provisioning Servlets +

This package provides the servlets used by the provisioning server for the Data Router application. -URLs are from the document URLs for DR Release 1 Version 1.2. +URLs are from the document URLs for DR Release 1 Version 1.2.

- +
- - - - + + + + diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/package.html b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/package.html index 09517fea..a110f130 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/package.html +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/package.html @@ -1,4 +1,4 @@ -#------------------------------------------------------------------------------- + - + + + + DMaaP DR Provisioning Utils +

This package provide various helper classes used by the provisioning server. diff --git a/datarouter-subscriber/pom.xml b/datarouter-subscriber/pom.xml index 9390050f..2d97b175 100755 --- a/datarouter-subscriber/pom.xml +++ b/datarouter-subscriber/pom.xml @@ -44,6 +44,14 @@ commons-codec commons-codec + + ch.qos.logback + logback-classic + + + ch.qos.logback + logback-core + javax.servlet javax.servlet-api @@ -141,10 +149,14 @@ commons-io - log4j - log4j - 1.2.17 - compile + com.att.eelf + eelf-core + + + powermock-api-mockito + org.powermock + + @@ -209,6 +221,7 @@ true **/*.properties + **/logback.xml diff --git a/datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/SampleSubscriberServlet.java b/datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/SampleSubscriberServlet.java index 993d3253..34a844c6 100644 --- a/datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/SampleSubscriberServlet.java +++ b/datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/SampleSubscriberServlet.java @@ -23,6 +23,8 @@ package org.onap.dmaap.datarouter.subscriber; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -37,12 +39,11 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.codec.binary.Base64; -import org.apache.log4j.Logger; public class SampleSubscriberServlet extends HttpServlet { - private static Logger logger = Logger.getLogger("org.onap.dmaap.datarouter.subscriber.SampleSubscriberServlet"); + private static EELFLogger logger = EELFManager.getInstance().getLogger(SampleSubscriberServlet.class); private static String outputDirectory; private static String basicAuth; diff --git a/datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/SubscriberMain.java b/datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/SubscriberMain.java index 2e02c88c..6894ddcf 100644 --- a/datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/SubscriberMain.java +++ b/datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/SubscriberMain.java @@ -23,8 +23,9 @@ package org.onap.dmaap.datarouter.subscriber; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import java.util.Arrays; -import org.apache.log4j.Logger; import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.HttpConfiguration; @@ -40,7 +41,7 @@ import org.eclipse.jetty.util.ssl.SslContextFactory; public class SubscriberMain { - private static Logger logger = Logger.getLogger("org.onap.dmaap.datarouter.subscriber.SubscriberMain"); + private static EELFLogger logger = EELFManager.getInstance().getLogger(SubscriberMain.class); /** * Main class for Subscriber. diff --git a/datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/SubscriberProps.java b/datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/SubscriberProps.java index ba7aa7af..49cad503 100644 --- a/datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/SubscriberProps.java +++ b/datarouter-subscriber/src/main/java/org/onap/dmaap/datarouter/subscriber/SubscriberProps.java @@ -23,15 +23,16 @@ package org.onap.dmaap.datarouter.subscriber; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import java.io.IOException; import java.util.Properties; -import org.apache.log4j.Logger; public class SubscriberProps { private static SubscriberProps instance = null; - private static Logger subLogger = Logger.getLogger("org.onap.dmaap.datarouter.subscriber.internal"); + private static EELFLogger logger = EELFManager.getInstance().getLogger(SubscriberProps.class); private Properties properties; private SubscriberProps(String propsPath) throws IOException { @@ -50,7 +51,7 @@ public class SubscriberProps { try { instance = new SubscriberProps(propsPath); } catch (IOException ioe) { - subLogger.error("IO Exception: " + ioe.getMessage(), ioe); + logger.error("IO Exception: " + ioe.getMessage(), ioe); } } return instance; diff --git a/datarouter-subscriber/src/main/resources/docker/Dockerfile b/datarouter-subscriber/src/main/resources/docker/Dockerfile index 20a2ca2b..81c9dcca 100644 --- a/datarouter-subscriber/src/main/resources/docker/Dockerfile +++ b/datarouter-subscriber/src/main/resources/docker/Dockerfile @@ -36,7 +36,7 @@ RUN chmod 0700 startup.sh ENTRYPOINT ["sh", "startup.sh"] RUN groupadd -g 1001 onap \ - && useradd -u 1000 datarouter -g onap \ - && chown -R datarouter:onap /opt/ + && useradd -u 1000 dradmin -g onap \ + && chown -R dradmin:onap /opt/ /var/ -USER datarouter \ No newline at end of file +USER dradmin \ No newline at end of file diff --git a/datarouter-subscriber/src/main/resources/log4j.properties b/datarouter-subscriber/src/main/resources/log4j.properties deleted file mode 100644 index bb66ef42..00000000 --- a/datarouter-subscriber/src/main/resources/log4j.properties +++ /dev/null @@ -1,31 +0,0 @@ -#------------------------------------------------------------------------------- -# ============LICENSE_START================================================== -# * org.onap.dmaap -# * =========================================================================== -# * Copyright � 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==================================================== -# * -# * ECOMP is a trademark and service mark of AT&T Intellectual Property. -# * -#------------------------------------------------------------------------------- - -log4j.rootLogger=info,Root - -log4j.appender.Root=org.apache.log4j.DailyRollingFileAppender -log4j.appender.Root.file=/opt/app/subscriber/logs/subscriber.log -log4j.appender.Root.datePattern='.'yyyyMMdd -log4j.appender.Root.append=true -log4j.appender.Root.layout=org.apache.log4j.PatternLayout -log4j.appender.Root.layout.ConversionPattern=%d %p %t %m%n diff --git a/datarouter-subscriber/src/main/resources/logback.xml b/datarouter-subscriber/src/main/resources/logback.xml new file mode 100644 index 00000000..24ffe67f --- /dev/null +++ b/datarouter-subscriber/src/main/resources/logback.xml @@ -0,0 +1,112 @@ + + + + + + + + + + ${defaultPattern} + + + + + + + + + + + + ${logDirectory}/${generalLogName}.log + + ${logDirectory}/${generalLogName}.%i.log.zip + + 1 + 9 + + + 5MB + + + ${defaultPattern} + + + + + 256 + + + + + ${logDirectory}/${errorLogName}.log + + ERROR + ACCEPT + DENY + + + ${logDirectory}/${errorLogName}.%i.log.zip + + 1 + 9 + + + 5MB + + + ${defaultPattern} + + + + + 256 + + + + + + + + + + + + + + + + + + + + diff --git a/datarouter-subscriber/src/test/resources/log4j.properties b/datarouter-subscriber/src/test/resources/log4j.properties deleted file mode 100644 index b8d349e6..00000000 --- a/datarouter-subscriber/src/test/resources/log4j.properties +++ /dev/null @@ -1,31 +0,0 @@ -#------------------------------------------------------------------------------- -# ============LICENSE_START================================================== -# * org.onap.dmaap -# * =========================================================================== -# * Copyright � 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==================================================== -# * -# * ECOMP is a trademark and service mark of AT&T Intellectual Property. -# * -#------------------------------------------------------------------------------- - -log4j.rootLogger=info,Root - -log4j.appender.Root=org.apache.log4j.DailyRollingFileAppender -log4j.appender.Root.file=./logs/subscriber.log -log4j.appender.Root.datePattern='.'yyyyMMdd -log4j.appender.Root.append=true -log4j.appender.Root.layout=org.apache.log4j.PatternLayout -log4j.appender.Root.layout.ConversionPattern=%d %p %t %m%n diff --git a/datarouter-subscriber/src/test/resources/logback-test.xml b/datarouter-subscriber/src/test/resources/logback-test.xml new file mode 100644 index 00000000..76390505 --- /dev/null +++ b/datarouter-subscriber/src/test/resources/logback-test.xml @@ -0,0 +1,112 @@ + + + + + + + + + + ${defaultPattern} + + + + + + + + + + + + ${logDirectory}/${generalLogName}.log + + ${logDirectory}/${generalLogName}.%i.log.zip + + 1 + 9 + + + 5MB + + + ${defaultPattern} + + + + + 256 + + + + + ${logDirectory}/${errorLogName}.log + + ERROR + ACCEPT + DENY + + + ${logDirectory}/${errorLogName}.%i.log.zip + + 1 + 9 + + + 5MB + + + ${defaultPattern} + + + + + 256 + + + + + + + + + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml index 0f2ebfbd..a72ed462 100755 --- a/pom.xml +++ b/pom.xml @@ -300,7 +300,7 @@ IntegrationSuite.java - --illegal-access=permit + ${surefireArgLine} --illegal-access=permit @@ -374,7 +374,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.0.1 + 3.2.0 false @@ -473,28 +473,6 @@ - - org.jacoco - jacoco-maven-plugin - - - prepare-agent - - prepare-agent - - - - report - - report - - - ${project.build.directory}/code-coverage/jacoco.exec - ${project.reporting.outputDirectory}/jacoco-ut - - - - -- cgit 1.2.3-korg

URL Path Summary 
URL PathSymbolic NameServlet NameAllowed MethodsURL PathSymbolic NameServlet NameAllowed Methods
/