summaryrefslogtreecommitdiffstats
path: root/ONAP-PAP-REST/src/main
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2019-07-08 12:38:53 -0400
committerJim Hahn <jrh3@att.com>2019-07-08 12:38:53 -0400
commit92febb7abd1e6dfe89633d3d92cd70fabf5f0434 (patch)
tree9d9246708bfdca626d208747ee270b1cd222a7c6 /ONAP-PAP-REST/src/main
parent8bfbc4b6241d21252cd98d653f0860a58e64dcc2 (diff)
Fix policy/engine due to sonar changes in common
Fixed breakages due to changes made in policy/common to satisfy sonar. Change-Id: I88090c7549ba19f9eb45fae311e8811e39f30318 Issue-ID: POLICY-1791 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'ONAP-PAP-REST/src/main')
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/ConsoleAndApiService.java10
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/UpdatePdpThread.java24
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/XACMLPapServlet.java60
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/APIRequestHandler.java4
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/DeleteHandler.java6
5 files changed, 52 insertions, 52 deletions
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/ConsoleAndApiService.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/ConsoleAndApiService.java
index 52e4060b5..bde5e5f09 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/ConsoleAndApiService.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/ConsoleAndApiService.java
@@ -35,7 +35,7 @@ import java.util.Set;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.onap.policy.common.logging.ONAPLoggingContext;
+import org.onap.policy.common.logging.OnapLoggingContext;
import org.onap.policy.common.logging.eelf.MessageCodes;
import org.onap.policy.common.logging.eelf.PolicyLogger;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
@@ -79,7 +79,7 @@ public class ConsoleAndApiService {
* @throws IOException Signals that an I/O exception has occurred.
*/
public void doAcPost(HttpServletRequest request, HttpServletResponse response, String groupId,
- ONAPLoggingContext loggingContext, PAPPolicyEngine papEngine) throws IOException {
+ OnapLoggingContext loggingContext, PAPPolicyEngine papEngine) throws IOException {
PolicyDBDaoTransaction doAcPostTransaction = null;
try {
String groupName = request.getParameter("groupName");
@@ -370,7 +370,7 @@ public class ConsoleAndApiService {
* @throws IOException Signals that an I/O exception has occurred.
*/
public void doAcGet(HttpServletRequest request, HttpServletResponse response, String groupId,
- ONAPLoggingContext loggingContext, PAPPolicyEngine papEngine) throws IOException {
+ OnapLoggingContext loggingContext, PAPPolicyEngine papEngine) throws IOException {
try {
String parameterDefault = request.getParameter("default");
String pdpId = request.getParameter("pdpId");
@@ -572,7 +572,7 @@ public class ConsoleAndApiService {
* @throws IOException Signals that an I/O exception has occurred.
*/
public void doAcPut(HttpServletRequest request, HttpServletResponse response, String groupId,
- ONAPLoggingContext loggingContext, PAPPolicyEngine papEngine) throws IOException {
+ OnapLoggingContext loggingContext, PAPPolicyEngine papEngine) throws IOException {
PolicyDBDaoTransaction acPutTransaction = XACMLPapServlet.getPolicyDbDao().getNewTransaction();
try {
String userId = request.getParameter("userId");
@@ -816,7 +816,7 @@ public class ConsoleAndApiService {
* @throws IOException Signals that an I/O exception has occurred.
*/
public void doAcDelete(HttpServletRequest request, HttpServletResponse response, String groupId,
- ONAPLoggingContext loggingContext, PAPPolicyEngine papEngine) throws IOException {
+ OnapLoggingContext loggingContext, PAPPolicyEngine papEngine) throws IOException {
PolicyDBDaoTransaction removePdpOrGroupTransaction = XACMLPapServlet.getPolicyDbDao().getNewTransaction();
try {
// for all DELETE operations the group must exist before the
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/UpdatePdpThread.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/UpdatePdpThread.java
index 11576d314..c912a8047 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/UpdatePdpThread.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/UpdatePdpThread.java
@@ -28,7 +28,7 @@ import java.net.URL;
import java.util.List;
import java.util.Properties;
import java.util.UUID;
-import org.onap.policy.common.logging.ONAPLoggingContext;
+import org.onap.policy.common.logging.OnapLoggingContext;
import org.onap.policy.common.logging.eelf.MessageCodes;
import org.onap.policy.common.logging.eelf.PolicyLogger;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
@@ -39,14 +39,14 @@ import org.onap.policy.xacml.api.pap.OnapPDP;
public class UpdatePdpThread implements Runnable {
private static final Logger LOGGER = FlexLogger.getLogger(UpdatePdpThread.class);
- private ONAPLoggingContext baseLoggingContext = new XACMLPapServlet().getBaseLoggingContext();
+ private OnapLoggingContext baseLoggingContext = new XACMLPapServlet().getBaseLoggingContext();
private static final Logger auditLogger = FlexLogger.getLogger("auditLogger");
private static final String XACMLPAPSERVLET = "XACMLPapServlet";
private static final String MESSAGE = " message: ";
private OnapPDP pdp;
private String requestId;
- private ONAPLoggingContext loggingContext;
+ private OnapLoggingContext loggingContext;
private List<Properties> properties;
@@ -62,11 +62,11 @@ public class UpdatePdpThread implements Runnable {
* @param loggingContext the logging context
* @param properties the properties
*/
- public UpdatePdpThread(OnapPDP pdp, ONAPLoggingContext loggingContext, List<Properties> properties) {
+ public UpdatePdpThread(OnapPDP pdp, OnapLoggingContext loggingContext, List<Properties> properties) {
this.pdp = pdp;
if (loggingContext != null
- && (loggingContext.getRequestID() != null || "".equals(loggingContext.getRequestID()))) {
- this.requestId = loggingContext.getRequestID();
+ && (loggingContext.getRequestId() != null || "".equals(loggingContext.getRequestId()))) {
+ this.requestId = loggingContext.getRequestId();
}
this.loggingContext = loggingContext;
this.properties = properties;
@@ -79,7 +79,7 @@ public class UpdatePdpThread implements Runnable {
// get a new logging context for the thread
try {
if (this.loggingContext == null) {
- loggingContext = new ONAPLoggingContext(baseLoggingContext);
+ loggingContext = new OnapLoggingContext(baseLoggingContext);
}
} catch (Exception e) {
PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, e, XACMLPAPSERVLET,
@@ -95,14 +95,14 @@ public class UpdatePdpThread implements Runnable {
// post to loggingContext to be used later when calling PDP
if (requestId == null || "".equals(requestId)) {
UUID requestId = UUID.randomUUID();
- loggingContext.setRequestID(requestId.toString());
+ loggingContext.setRequestId(requestId.toString());
PolicyLogger
.info("requestID not provided in call to XACMLPapSrvlet (UpdatePDPThread) so we generated one: "
- + loggingContext.getRequestID());
+ + loggingContext.getRequestId());
} else {
- loggingContext.setRequestID(requestId);
+ loggingContext.setRequestId(requestId);
PolicyLogger.info("requestID was provided in call to XACMLPapSrvlet (UpdatePDPThread): "
- + loggingContext.getRequestID());
+ + loggingContext.getRequestId());
}
loggingContext.transactionStarted();
// the Id of the PDP is its URL
@@ -120,7 +120,7 @@ public class UpdatePdpThread implements Runnable {
connection.setRequestProperty("Authorization", "Basic " + encoding);
}
connection.setRequestProperty("Content-Type", "text/x-java-properties");
- connection.setRequestProperty("X-ECOMP-RequestID", loggingContext.getRequestID());
+ connection.setRequestProperty("X-ECOMP-RequestID", loggingContext.getRequestId());
connection.setInstanceFollowRedirects(true);
connection.setDoOutput(true);
if (!writePropertiesToStream(connection)) {
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/XACMLPapServlet.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/XACMLPapServlet.java
index 85315ca54..8dc52b861 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/XACMLPapServlet.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/XACMLPapServlet.java
@@ -20,13 +20,6 @@
package org.onap.policy.pap.xacml.rest;
-import com.att.research.xacml.api.pap.PAPException;
-import com.att.research.xacml.api.pap.PDPPolicy;
-import com.att.research.xacml.api.pap.PDPStatus;
-import com.att.research.xacml.util.FactoryException;
-import com.att.research.xacml.util.XACMLProperties;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.common.base.Splitter;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -59,8 +52,8 @@ import org.onap.policy.common.im.IntegrityMonitor;
import org.onap.policy.common.im.IntegrityMonitorException;
import org.onap.policy.common.im.IntegrityMonitorProperties;
import org.onap.policy.common.im.StandbyStatusException;
-import org.onap.policy.common.logging.ONAPLoggingContext;
-import org.onap.policy.common.logging.ONAPLoggingUtils;
+import org.onap.policy.common.logging.OnapLoggingContext;
+import org.onap.policy.common.logging.OnapLoggingUtils;
import org.onap.policy.common.logging.eelf.MessageCodes;
import org.onap.policy.common.logging.eelf.PolicyLogger;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
@@ -87,6 +80,13 @@ import org.onap.policy.xacml.std.pap.StdPDPGroup;
import org.onap.policy.xacml.std.pap.StdPDPItemSetChangeNotifier.StdItemSetChangeListener;
import org.onap.policy.xacml.std.pap.StdPDPPolicy;
import org.onap.policy.xacml.std.pap.StdPDPStatus;
+import com.att.research.xacml.api.pap.PAPException;
+import com.att.research.xacml.api.pap.PDPPolicy;
+import com.att.research.xacml.api.pap.PDPStatus;
+import com.att.research.xacml.util.FactoryException;
+import com.att.research.xacml.util.XACMLProperties;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Splitter;
/**
* Servlet implementation class XacmlPapServlet.
@@ -158,7 +158,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
* this servlet starts. Its configurable by the admin.
*/
private static transient Thread initiateThread = null;
- private transient ONAPLoggingContext baseLoggingContext = null;
+ private transient OnapLoggingContext baseLoggingContext = null;
private static final String GROUPID = "groupId";
/**
@@ -175,7 +175,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
public void init(ServletConfig config) throws ServletException {
try {
// Logging
- baseLoggingContext = new ONAPLoggingContext();
+ baseLoggingContext = new OnapLoggingContext();
// fixed data that will be the same in all logging output goes here
try {
String hostname = InetAddress.getLocalHost().getCanonicalHostName();
@@ -546,8 +546,8 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
- ONAPLoggingContext loggingContext =
- ONAPLoggingUtils.getLoggingContextForRequest(request, baseLoggingContext);
+ OnapLoggingContext loggingContext =
+ OnapLoggingUtils.getLoggingContextForRequest(request, baseLoggingContext);
setLoggingContext(loggingContext, "doPost", "PAP.post");
PolicyDBDaoTransaction pdpTransaction = null;
try {
@@ -810,8 +810,8 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
- ONAPLoggingContext loggingContext =
- ONAPLoggingUtils.getLoggingContextForRequest(request, baseLoggingContext);
+ OnapLoggingContext loggingContext =
+ OnapLoggingUtils.getLoggingContextForRequest(request, baseLoggingContext);
setLoggingContext(loggingContext, "doGet", "PAP.get");
loggingContext.metricStarted();
XACMLRest.dumpRequest(request);
@@ -1017,8 +1017,8 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
@Override
protected void doPut(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
- ONAPLoggingContext loggingContext =
- ONAPLoggingUtils.getLoggingContextForRequest(request, baseLoggingContext);
+ OnapLoggingContext loggingContext =
+ OnapLoggingUtils.getLoggingContextForRequest(request, baseLoggingContext);
setLoggingContext(loggingContext, "doPut", "PAP.put");
try {
loggingContext.metricStarted();
@@ -1234,8 +1234,8 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
@Override
protected void doDelete(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
- ONAPLoggingContext loggingContext =
- ONAPLoggingUtils.getLoggingContextForRequest(request, baseLoggingContext);
+ OnapLoggingContext loggingContext =
+ OnapLoggingUtils.getLoggingContextForRequest(request, baseLoggingContext);
setLoggingContext(loggingContext, "doDelete", "PAP.delete");
try {
loggingContext.metricStarted();
@@ -1397,7 +1397,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
* @throws IOException
*/
public void updateGroupsFromAPI(HttpServletRequest request, HttpServletResponse response,
- String groupId, ONAPLoggingContext loggingContext) throws IOException {
+ String groupId, OnapLoggingContext loggingContext) throws IOException {
PolicyDBDaoTransaction acPutTransaction = policyDbDao.getNewTransaction();
PolicyLogger.audit("PolicyDBDaoTransaction started for updateGroupsFromAPI");
try {
@@ -1541,7 +1541,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
}
}
- public void changed(ONAPLoggingContext loggingContext) {
+ public void changed(OnapLoggingContext loggingContext) {
// all PDPs in all groups need to be updated/sync'd
Set<OnapPDPGroup> groups;
try {
@@ -1565,7 +1565,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
}
}
- public void groupChanged(OnapPDPGroup group, ONAPLoggingContext loggingContext) {
+ public void groupChanged(OnapPDPGroup group, OnapLoggingContext loggingContext) {
// all PDPs within one group need to be updated/sync'd
for (OnapPDP pdp : group.getOnapPdps()) {
pdpChanged(pdp, loggingContext, getPdpDataByGroup(group));
@@ -1585,7 +1585,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
}
}
- public void pdpChanged(OnapPDP pdp, ONAPLoggingContext loggingContext) {
+ public void pdpChanged(OnapPDP pdp, OnapLoggingContext loggingContext) {
// kick off a thread to do an event notification for each PDP.
// This needs to be on a separate thread so that PDPs that do not
// respond (down, non-existent, etc)
@@ -1604,7 +1604,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
}
}
- private void pdpChanged(OnapPDP pdp, ONAPLoggingContext loggingContext,
+ private void pdpChanged(OnapPDP pdp, OnapLoggingContext loggingContext,
List<Properties> pdpDataByGroup) {
Thread t = new Thread(new UpdatePdpThread(pdp, loggingContext, pdpDataByGroup));
if (CheckPDP.validateID(pdp.getId())) {
@@ -1622,7 +1622,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
return dataToNotify.setPolicyConfigProperties(pdp, papEngine);
}
- private void testService(ONAPLoggingContext loggingContext, HttpServletResponse response)
+ private void testService(OnapLoggingContext loggingContext, HttpServletResponse response)
throws IOException {
LOGGER.info("Test request received");
try {
@@ -1686,13 +1686,13 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
}
}
- private void setLoggingContext(ONAPLoggingContext loggingContext, String methodType,
+ private void setLoggingContext(OnapLoggingContext loggingContext, String methodType,
String serviceName) {
loggingContext.transactionStarted();
loggingContext.setServiceName(serviceName);
- if (loggingContext.getRequestID() == null || "".equals(loggingContext.getRequestID())) {
+ if (loggingContext.getRequestId() == null || "".equals(loggingContext.getRequestId())) {
UUID requestID = UUID.randomUUID();
- loggingContext.setRequestID(requestID.toString());
+ loggingContext.setRequestId(requestID.toString());
PolicyLogger.info("requestID not provided in call to XACMLPapServlet ('" + methodType
+ "') so we generated one");
} else {
@@ -1842,11 +1842,11 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
XACMLPapServlet.msPolicyName = msPolicyName;
}
- public ONAPLoggingContext getBaseLoggingContext() {
+ public OnapLoggingContext getBaseLoggingContext() {
return baseLoggingContext;
}
- public void setBaseLoggingContext(ONAPLoggingContext baseLoggingContext) {
+ public void setBaseLoggingContext(OnapLoggingContext baseLoggingContext) {
this.baseLoggingContext = baseLoggingContext;
}
}
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/APIRequestHandler.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/APIRequestHandler.java
index 5bea62dff..46c2b1160 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/APIRequestHandler.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/APIRequestHandler.java
@@ -23,7 +23,7 @@ package org.onap.policy.pap.xacml.rest.handler;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.onap.policy.common.logging.ONAPLoggingContext;
+import org.onap.policy.common.logging.OnapLoggingContext;
import org.onap.policy.pap.xacml.rest.service.ImportService;
import org.onap.policy.pap.xacml.rest.service.MetricService;
import org.onap.policy.xacml.api.pap.OnapPDPGroup;
@@ -97,7 +97,7 @@ public class APIRequestHandler {
* @param apiflag the apiflag
* @throws IOException Signals that an I/O exception has occurred.
*/
- public void doDelete(HttpServletRequest request, HttpServletResponse response, ONAPLoggingContext loggingContext,
+ public void doDelete(HttpServletRequest request, HttpServletResponse response, OnapLoggingContext loggingContext,
String apiflag) throws IOException {
DeleteHandler deleteHandler = DeleteHandler.getInstance();
if ("deletePapApi".equalsIgnoreCase(apiflag)) {
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/DeleteHandler.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/DeleteHandler.java
index 92e43c62f..fd98279e9 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/DeleteHandler.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/DeleteHandler.java
@@ -31,7 +31,7 @@ import javax.script.SimpleBindings;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
-import org.onap.policy.common.logging.ONAPLoggingContext;
+import org.onap.policy.common.logging.OnapLoggingContext;
import org.onap.policy.common.logging.eelf.MessageCodes;
import org.onap.policy.common.logging.eelf.PolicyLogger;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
@@ -352,7 +352,7 @@ public class DeleteHandler {
* @throws IOException Signals that an I/O exception has occurred.
*/
public void doApiDeleteFromPdp(HttpServletRequest request, HttpServletResponse response,
- ONAPLoggingContext loggingContext) throws IOException {
+ OnapLoggingContext loggingContext) throws IOException {
String groupId = request.getParameter("groupId");
@@ -449,7 +449,7 @@ public class DeleteHandler {
}
}
- private String deletePolicyFromPdpGroup(OnapPDPGroup group, ONAPLoggingContext loggingContext, String userId) {
+ private String deletePolicyFromPdpGroup(OnapPDPGroup group, OnapLoggingContext loggingContext, String userId) {
PolicyDBDaoTransaction acPutTransaction = XACMLPapServlet.getDbDaoTransaction();
String response = null;
loggingContext.setServiceName("API:PAP.DeleteHandler");