aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrb7147 <rb7147@att.com>2017-07-26 10:11:15 -0400
committerrb7147 <rb7147@att.com>2017-07-26 11:53:31 -0400
commitd80880b097d08f9ab9dda54355216890a4b345dc (patch)
tree6c7b6caec61dbada2201f7ee14c8c1e027106d6d
parente92ff832cf993db876f22b2d27562fedf59f5043 (diff)
[POLICY-117] Resolve the Policy Critical issues
Change-Id: Ice72d7fa40151bff5db42f5dd632f04a3853b094 Signed-off-by: rb7147 <rb7147@att.com>
-rw-r--r--ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/compiler/ControlLoopCompiler.java6
-rw-r--r--ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/builder/impl/ControlLoopPolicyBuilderImpl.java5
-rw-r--r--ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/builder/impl/ControlLoopGuardBuilderImpl.java5
-rw-r--r--ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/XACMLPdpLoader.java12
-rw-r--r--ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/XACMLPdpRegisterThread.java2
-rw-r--r--ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/XACMLPdpServlet.java284
-rw-r--r--ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/CreateUpdatePolicyServiceImpl.java4
-rw-r--r--ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/PAPServices.java8
-rw-r--r--ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/config/PDPApiAuth.java283
-rw-r--r--ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/NotificationController.java14
-rw-r--r--ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/NotificationServer.java10
-rw-r--r--ECOMP-PDP/src/main/java/org/openecomp/policy/xacml/action/FindAction.java25
-rw-r--r--ECOMP-PDP/src/main/java/org/openecomp/policy/xacml/custom/EcompFunctionDefinitionFactory.java5
-rw-r--r--ECOMP-PDP/src/main/java/org/openecomp/policy/xacml/pdp/std/functions/FunctionDefinitionCustomRegexpMatch.java10
-rw-r--r--ECOMP-REST/src/main/java/org/openecomp/policy/rest/XACMLRest.java2
-rw-r--r--ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ConstraintType.java6
-rw-r--r--ECOMP-REST/src/main/java/org/openecomp/policy/rest/util/MSModelUtils.java2
-rw-r--r--ECOMP-SDK-APP/src/main/java/org/openecomp/portalapp/scheduler/Register.java2
-rw-r--r--ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/components/XACMLPDPPolicyTest.java49
-rw-r--r--LogParser/src/main/java/org/openecomp/xacml/parser/ParseLog.java390
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSParamController.java1
-rw-r--r--POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PDPController.java1
-rw-r--r--POLICY-SDK-APP/src/test/java/org/openecomp/policy/admin/PolicyManagerServletTest.java11
-rw-r--r--POLICY-SDK-APP/src/test/java/org/openecomp/policy/controller/CreateDcaeMicroServiceControllerTest.java1
-rw-r--r--PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ActionPolicyClient.java2
-rw-r--r--PolicyEngineClient/src/main/java/org/openecomp/policyEngine/BrmsParamPolicyClient.java10
26 files changed, 609 insertions, 541 deletions
diff --git a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/compiler/ControlLoopCompiler.java b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/compiler/ControlLoopCompiler.java
index 2f01307af..e0000c02d 100644
--- a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/compiler/ControlLoopCompiler.java
+++ b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/compiler/ControlLoopCompiler.java
@@ -46,7 +46,11 @@ import org.yaml.snakeyaml.constructor.Constructor;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
-public class ControlLoopCompiler {
+public class ControlLoopCompiler implements Serializable{
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
private static Logger LOGGER = FlexLogger.getLogger(ControlLoopCompiler.class.getName());
public static ControlLoopPolicy compile(ControlLoopPolicy policy, ControlLoopCompilerCallback callback) throws CompilerException {
diff --git a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/builder/impl/ControlLoopPolicyBuilderImpl.java b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/builder/impl/ControlLoopPolicyBuilderImpl.java
index 523054dce..036fd75d2 100644
--- a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/builder/impl/ControlLoopPolicyBuilderImpl.java
+++ b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/builder/impl/ControlLoopPolicyBuilderImpl.java
@@ -26,6 +26,8 @@ import java.util.UUID;
import org.openecomp.policy.asdc.Resource;
import org.openecomp.policy.asdc.Service;
+import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
+import org.openecomp.policy.common.logging.flexlogger.Logger;
import org.openecomp.policy.controlloop.compiler.CompilerException;
import org.openecomp.policy.controlloop.compiler.ControlLoopCompiler;
import org.openecomp.policy.controlloop.compiler.ControlLoopCompilerCallback;
@@ -45,7 +47,7 @@ import org.yaml.snakeyaml.DumperOptions.FlowStyle;
import org.yaml.snakeyaml.Yaml;
public class ControlLoopPolicyBuilderImpl implements ControlLoopPolicyBuilder {
-
+ private static Logger logger = FlexLogger.getLogger(ControlLoopPolicyBuilderImpl.class.getName());
private ControlLoopPolicy policy;
public ControlLoopPolicyBuilderImpl(String controlLoopName, Integer timeout) throws BuilderException {
@@ -253,6 +255,7 @@ public class ControlLoopPolicyBuilderImpl implements ControlLoopPolicyBuilder {
try {
ControlLoopCompiler.compile(policy, callback);
} catch (CompilerException e) {
+ logger.error(e.getMessage() + e);
callback.results.addMessage(new MessageImpl(e.getMessage(), MessageLevel.EXCEPTION));
}
//
diff --git a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/builder/impl/ControlLoopGuardBuilderImpl.java b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/builder/impl/ControlLoopGuardBuilderImpl.java
index bd6a3e42f..2e5711914 100644
--- a/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/builder/impl/ControlLoopGuardBuilderImpl.java
+++ b/ECOMP-ControlloopPolicy/src/main/java/org/openecomp/policy/controlloop/policy/guard/builder/impl/ControlLoopGuardBuilderImpl.java
@@ -21,6 +21,8 @@ package org.openecomp.policy.controlloop.policy.guard.builder.impl;
import java.util.LinkedList;
+import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
+import org.openecomp.policy.common.logging.flexlogger.Logger;
import org.openecomp.policy.controlloop.compiler.CompilerException;
import org.openecomp.policy.controlloop.compiler.ControlLoopCompilerCallback;
import org.openecomp.policy.controlloop.guard.compiler.ControlLoopGuardCompiler;
@@ -39,7 +41,7 @@ import org.yaml.snakeyaml.DumperOptions.FlowStyle;
import org.yaml.snakeyaml.Yaml;
public class ControlLoopGuardBuilderImpl implements ControlLoopGuardBuilder {
-
+ private static Logger logger = FlexLogger.getLogger(ControlLoopGuardBuilderImpl.class.getName());
private ControlLoopGuard cLGuard;
public ControlLoopGuardBuilderImpl(Guard guard) {
@@ -229,6 +231,7 @@ public class ControlLoopGuardBuilderImpl implements ControlLoopGuardBuilder {
try {
ControlLoopGuardCompiler.compile(cLGuard, callback);
} catch (CompilerException e) {
+ logger.error(e.getMessage() + e);
callback.results.addMessage(new MessageImpl(e.getMessage(), MessageLevel.EXCEPTION));
}
//
diff --git a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/XACMLPdpLoader.java b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/XACMLPdpLoader.java
index 0766ac469..5288d30aa 100644
--- a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/XACMLPdpLoader.java
+++ b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/XACMLPdpLoader.java
@@ -116,7 +116,7 @@ public class XACMLPdpLoader {
LOGGER.debug("Status: " + status);
}
} catch (ConcurrentModificationException e) {
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e.getMessage());
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e.getMessage() + e);
} catch (Exception e) {
String error = "Failed to load Policy Cache properties file: "
+ e.getMessage();
@@ -256,7 +256,7 @@ public class XACMLPdpLoader {
} catch (Exception e){
// This Happens if a any issue with the error policyFile. Lets remove it.
try {
- LOGGER.error("Corrupted policy file, deleting: " + location);
+ LOGGER.error("Corrupted policy file, deleting: " + location + e);
Files.delete(Paths.get(location));
properties.remove(id + ".file");
rougeFile = true;
@@ -290,6 +290,7 @@ public class XACMLPdpLoader {
try{
urlConnection = url.openConnection();
} catch (IOException e){
+ LOGGER.error("Exception Occured while opening connection" +e);
papUrls.failed();
papUrls.getNext();
break;
@@ -309,6 +310,7 @@ public class XACMLPdpLoader {
outFile.toFile())) {
IOUtils.copy(urlConnection.getInputStream(), fos);
} catch(IOException e){
+ LOGGER.error("Exception Occured while Copying input stream" +e);
papUrls.failed();
papUrls.getNext();
break;
@@ -321,7 +323,7 @@ public class XACMLPdpLoader {
policy = DOMPolicyDef.load(fis);
}catch(Exception e){
try {
- LOGGER.error("Corrupted policy file, deleting: " + location);
+ LOGGER.error("Corrupted policy file, deleting: " + location +e);
Files.delete(outFile);
error = true;
errorCount++;
@@ -589,7 +591,7 @@ public class XACMLPdpLoader {
Files.createFile(policyProperties);
} catch (IOException e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Failed to create policy properties file: "
- + policyProperties.toAbsolutePath().toString());
+ + policyProperties.toAbsolutePath().toString() +e);
throw new PAPException(
"Failed to create policy properties file: "
+ policyProperties.toAbsolutePath().toString());
@@ -612,7 +614,7 @@ public class XACMLPdpLoader {
Files.createFile(pipConfigProperties);
} catch (IOException e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Failed to create pip properties file: "
- + pipConfigProperties.toAbsolutePath().toString());
+ + pipConfigProperties.toAbsolutePath().toString() +e);
throw new PAPException("Failed to create pip properties file: "
+ pipConfigProperties.toAbsolutePath().toString());
}
diff --git a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/XACMLPdpRegisterThread.java b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/XACMLPdpRegisterThread.java
index e9b665823..6bc8a6461 100644
--- a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/XACMLPdpRegisterThread.java
+++ b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/XACMLPdpRegisterThread.java
@@ -261,7 +261,7 @@ public class XACMLPdpRegisterThread implements Runnable {
try {
is = connection.getInputStream();
} catch (Exception e1) {
- // ignore this
+ LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Failed to get Input Stream: " + e1);
}
if (is != null) {
is.close();
diff --git a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/XACMLPdpServlet.java b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/XACMLPdpServlet.java
index 12dfbd23b..bad8e6638 100644
--- a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/XACMLPdpServlet.java
+++ b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/XACMLPdpServlet.java
@@ -162,7 +162,7 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable {
this.pipConfigProperties = pips;
}
}
- public static volatile BlockingQueue<PutRequest> queue = null;
+ protected static volatile BlockingQueue<PutRequest> queue = null;
// For notification Delay.
private static int notificationDelay = 0;
public static int getNotificationDelay(){
@@ -277,7 +277,7 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable {
logger.info("Creating IntegrityMonitor");
im = IntegrityMonitor.getInstance(pdpResourceName, properties);
} catch (Exception e) {
- PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, e, "Failed to create IntegrityMonitor");
+ PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, e, "Failed to create IntegrityMonitor" +e);
throw new ServletException(e);
}
@@ -415,7 +415,11 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable {
PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, message + e);
loggingContext.transactionEnded();
PolicyLogger.audit("Transaction Failed - See Error.log");
- response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, message);
+ try{
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, message);
+ }catch(Exception e1){
+ logger.error("Exception occured while sending error in response" +e1);
+ }
return;
}
//
@@ -427,28 +431,36 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable {
//
if (cache != null && request.getContentType().equals("text/x-java-properties")) {
loggingContext.setServiceName("PDP.putConfig");
- if (request.getContentLength() > Integer.parseInt(XACMLProperties.getProperty("MAX_CONTENT_LENGTH", DEFAULT_MAX_CONTENT_LENGTH))) {
- String message = "Content-Length larger than server will accept.";
- logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + message);
+ try{
+ if (request.getContentLength() > Integer.parseInt(XACMLProperties.getProperty("MAX_CONTENT_LENGTH", DEFAULT_MAX_CONTENT_LENGTH))) {
+ String message = "Content-Length larger than server will accept.";
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + message);
+ loggingContext.transactionEnded();
+ PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, message);
+ PolicyLogger.audit("Transaction Failed - See Error.log");
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST, message);
+ im.endTransaction();
+ return;
+ }
+ this.doPutConfig(cache, request, response, loggingContext);
loggingContext.transactionEnded();
- PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, message);
- PolicyLogger.audit("Transaction Failed - See Error.log");
- response.sendError(HttpServletResponse.SC_BAD_REQUEST, message);
+ PolicyLogger.audit("Transaction ended");
+
im.endTransaction();
- return;
+ }catch(Exception e){
+ logger.error("Exception Occured while getting Max Content lenght"+e);
}
- this.doPutConfig(cache, request, response, loggingContext);
- loggingContext.transactionEnded();
- PolicyLogger.audit("Transaction ended");
-
- im.endTransaction();
} else {
String message = "Invalid cache: '" + cache + "' or content-type: '" + request.getContentType() + "'";
logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + message);
PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, message);
loggingContext.transactionEnded();
PolicyLogger.audit("Transaction Failed - See Error.log");
- response.sendError(HttpServletResponse.SC_BAD_REQUEST, message);
+ try{
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST, message);
+ }catch(Exception e1){
+ logger.error("Exception occured while sending error in response" +e1);
+ }
im.endTransaction();
return;
}
@@ -552,7 +564,11 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable {
PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, e, "Failed to process new configuration");
loggingContext.transactionEnded();
PolicyLogger.audit("Transaction Failed - See Error.log");
- response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
+ try{
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
+ }catch(Exception e1){
+ logger.error("Exception occured while sending error in response" +e1);
+ }
return;
}
@@ -613,29 +629,40 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable {
//No forward progress is being made
String message = "GET:/pdp/test called and PDP " + pdpResourceName + " is not making forward progress."
+ " Exception Message: " + fpe.getMessage();
- PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, message );
+ PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, message + fpe);
loggingContext.transactionEnded();
PolicyLogger.audit("Transaction Failed - See Error.log");
- // PolicyLogger.audit(MessageCodes.ERROR_SYSTEM_ERROR, message );
- response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, message);
+ try{
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, message);
+ }catch(Exception e1){
+ logger.error("Exception occured while sending error in response" +e1);
+ }
return;
}catch (AdministrativeStateException ase){
//Administrative State is locked
String message = "GET:/pdp/test called and PDP " + pdpResourceName + " Administrative State is LOCKED "
+ " Exception Message: " + ase.getMessage();
- PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, message );
+ PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, message + ase);
loggingContext.transactionEnded();
PolicyLogger.audit("Transaction Failed - See Error.log");
- response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, message);
+ try{
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, message);
+ }catch(Exception e1){
+ logger.error("Exception occured while sending error in response" +e1);
+ }
return;
}catch (StandbyStatusException sse){
//Administrative State is locked
String message = "GET:/pdp/test called and PDP " + pdpResourceName + " Standby Status is NOT PROVIDING SERVICE "
+ " Exception Message: " + sse.getMessage();
- PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, message );
+ PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, message + sse);
loggingContext.transactionEnded();
PolicyLogger.audit("Transaction Failed - See Error.log");
- response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, message);
+ try{
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, message);
+ }catch(Exception e1){
+ logger.error("Exception occured while sending error in response" +e1);
+ }
return;
} catch (Exception e) {
//A subsystem is not making progress or is not responding
@@ -661,9 +688,13 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable {
failedNodeList = "UnknownSubSystem";
}
response.addHeader("X-ECOMP-SubsystemFailure", failedNodeList);
- response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, message);
+ try{
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, message);
+ }catch(Exception e1){
+ logger.error("Exception occured while sending error in response" +e1);
+ }
loggingContext.transactionEnded();
- PolicyLogger.audit("Transaction Failed - See Error.log");
+ PolicyLogger.audit("Transaction Failed - See Error.log" + e);
return;
}
}
@@ -676,8 +707,12 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable {
String message = e.toString();
PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, message);
loggingContext.transactionEnded();
- PolicyLogger.audit("Transaction Failed - See Error.log");
- response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, message);
+ PolicyLogger.audit("Transaction Failed - See Error.log" +e);
+ try{
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, message);
+ }catch(Exception e1){
+ logger.error("Exception occured while sending error in response" +e1);
+ }
return;
}
//
@@ -708,7 +743,11 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable {
PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, e, "Failed to copy property file");
loggingContext.transactionEnded();
PolicyLogger.audit("Transaction Failed - See Error.log");
- response.sendError(400, "Failed to copy Property file");
+ try{
+ response.sendError(400, "Failed to copy Property file");
+ }catch(Exception e1){
+ logger.error("Exception occured while sending error in response" +e1);
+ }
}
} else if ("hb".equals(type)) {
@@ -720,7 +759,11 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable {
// convert response object to JSON and include in the response
synchronized(pdpStatusLock) {
ObjectMapper mapper = new ObjectMapper();
- mapper.writeValue(response.getOutputStream(), status);
+ try{
+ mapper.writeValue(response.getOutputStream(), status);
+ }catch(Exception e1){
+ logger.error("Exception occured while writing output stream" +e1);
+ }
}
response.setStatus(HttpServletResponse.SC_OK);
loggingContext.transactionEnded();
@@ -732,7 +775,11 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable {
PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, "Invalid type value: " + type);
loggingContext.transactionEnded();
PolicyLogger.audit("Transaction Failed - See Error.log");
- response.sendError(HttpServletResponse.SC_BAD_REQUEST, "type not 'config' or 'hb'");
+ try{
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST, "type not 'config' or 'hb'");
+ }catch(Exception e1){
+ logger.error("Exception occured while sending error in response" +e1);
+ }
}
if (returnHB) {
synchronized(pdpStatusLock) {
@@ -758,7 +805,7 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable {
ECOMPLoggingContext loggingContext = ECOMPLoggingUtils.getLoggingContextForRequest(request, baseLoggingContext);
loggingContext.transactionStarted();
loggingContext.setServiceName("PDP.decide");
- if ((loggingContext.getRequestID() == null) || (loggingContext.getRequestID() == "")){
+ if ((loggingContext.getRequestID() == null) || ("".equals(loggingContext.getRequestID()))){
UUID requestID = UUID.randomUUID();
loggingContext.setRequestID(requestID.toString());
PolicyLogger.info("requestID not provided in call to XACMLPdpSrvlet (doPost) so we generated one");
@@ -781,7 +828,11 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable {
PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, message + e);
loggingContext.transactionEnded();
PolicyLogger.audit("Transaction Failed - See Error.log");
- response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, message);
+ try{
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, message);
+ }catch(Exception e1){
+ logger.error("Exception occured while sending error in response" +e1);
+ }
return;
}
//
@@ -792,7 +843,11 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable {
PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, "Request from PEP at " + request.getRequestURI() + " for service when PDP has No Root Policies loaded");
loggingContext.transactionEnded();
PolicyLogger.audit("Transaction Failed - See Error.log");
- response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
+ try{
+ response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
+ }catch(Exception e1){
+ logger.error("Exception occured while sending error in response" +e1);
+ }
im.endTransaction();
return;
}
@@ -810,30 +865,43 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable {
PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, "Must specify a Content-Type");
loggingContext.transactionEnded();
PolicyLogger.audit("Transaction Failed - See Error.log");
- response.sendError(HttpServletResponse.SC_BAD_REQUEST, "no content-type given");
+ try{
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST, "no content-type given");
+ }catch(Exception e1){
+ logger.error("Exception occured while sending error in response" +e1);
+ }
im.endTransaction();
return;
}
//
// Limit the Content-Length to something reasonable
//
- if (request.getContentLength() > Integer.parseInt(XACMLProperties.getProperty("MAX_CONTENT_LENGTH", "32767"))) {
- String message = "Content-Length larger than server will accept.";
- logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + message);
- PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, message);
- loggingContext.transactionEnded();
- PolicyLogger.audit("Transaction Failed - See Error.log");
- response.sendError(HttpServletResponse.SC_BAD_REQUEST, message);
- im.endTransaction();
- return;
+ try{
+ if (request.getContentLength() > Integer.parseInt(XACMLProperties.getProperty("MAX_CONTENT_LENGTH", "32767"))) {
+ String message = "Content-Length larger than server will accept.";
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + message);
+ PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, message);
+ loggingContext.transactionEnded();
+ PolicyLogger.audit("Transaction Failed - See Error.log");
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST, message);
+ im.endTransaction();
+ return;
+ }
+ }catch(Exception e){
+ logger.error("Exception occured while getting max content length"+e);
}
+
if (request.getContentLength() <= 0) {
String message = "Content-Length is negative";
logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + message);
PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, message);
loggingContext.transactionEnded();
PolicyLogger.audit("Transaction Failed - See Error.log");
- response.sendError(HttpServletResponse.SC_BAD_REQUEST, message);
+ try{
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST, message);
+ }catch(Exception e1){
+ logger.error("Exception occured while sending error in response" +e1);
+ }
im.endTransaction();
return;
}
@@ -847,7 +915,11 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable {
loggingContext.transactionEnded();
PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, message);
PolicyLogger.audit("Transaction Failed - See Error.log");
- response.sendError(HttpServletResponse.SC_BAD_REQUEST, message);
+ try{
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST, message);
+ }catch(Exception e1){
+ logger.error("Exception occured while sending error in response" +e1);
+ }
im.endTransaction();
return;
}
@@ -891,7 +963,11 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable {
PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "Could not parse request");
loggingContext.transactionEnded();
PolicyLogger.audit("Transaction Failed - See Error.log");
- response.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());
+ try{
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());
+ }catch(Exception e1){
+ logger.error("Exception occured while sending error in response" +e1);
+ }
im.endTransaction();
return;
}
@@ -901,7 +977,11 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable {
PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, message);
loggingContext.transactionEnded();
PolicyLogger.audit("Transaction Failed - See Error.log");
- response.sendError(HttpServletResponse.SC_BAD_REQUEST, message);
+ try{
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST, message);
+ }catch(Exception e1){
+ logger.error("Exception occured while sending error in response" +e1);
+ }
im.endTransaction();
return;
}
@@ -914,7 +994,11 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable {
PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, message);
loggingContext.transactionEnded();
PolicyLogger.audit("Transaction Failed - See Error.log");
- response.sendError(HttpServletResponse.SC_BAD_REQUEST, message);
+ try{
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST, message);
+ }catch(Exception e1){
+ logger.error("Exception occured while sending error in response" +e1);
+ }
im.endTransaction();
return;
}
@@ -972,7 +1056,11 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable {
PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, message);
loggingContext.transactionEnded();
PolicyLogger.audit("Transaction Failed - See Error.log");
- response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, message);
+ try{
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, message);
+ }catch(Exception e1){
+ logger.error("Exception occured while sending error in response" +e1);
+ }
im.endTransaction();
return;
}
@@ -997,7 +1085,11 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable {
//
if (pdpResponse == null) {
requestLogger.info(lTimeStart + "=" + "{}");
- throw new PDPException("Failed to get response from PDP engine.");
+ try{
+ throw new PDPException("Failed to get response from PDP engine.");
+ }catch(Exception e1){
+ logger.error("Exception occured while throwing Exception" +e1);
+ }
}
//
// Set our content-type
@@ -1008,53 +1100,57 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable {
// return to our caller as well as dump to our loggers.
//
String outgoingResponseString = "";
- if (contentType.getMimeType().equalsIgnoreCase(ContentType.APPLICATION_JSON.getMimeType())) {
- //
- // Get it as a String. This is not very efficient but we need to log our
- // results for auditing.
- //
- outgoingResponseString = JSONResponse.toString(pdpResponse, logger.isDebugEnabled());
- if (logger.isDebugEnabled()) {
- logger.debug(outgoingResponseString);
+ try{
+ if (contentType.getMimeType().equalsIgnoreCase(ContentType.APPLICATION_JSON.getMimeType())) {
//
- // Get rid of whitespace
+ // Get it as a String. This is not very efficient but we need to log our
+ // results for auditing.
//
- outgoingResponseString = JSONResponse.toString(pdpResponse, false);
- }
- } else if ( contentType.getMimeType().equalsIgnoreCase(ContentType.APPLICATION_XML.getMimeType()) ||
- contentType.getMimeType().equalsIgnoreCase("application/xacml+xml")) {
- //
- // Get it as a String. This is not very efficient but we need to log our
- // results for auditing.
- //
- outgoingResponseString = DOMResponse.toString(pdpResponse, logger.isDebugEnabled());
- if (logger.isDebugEnabled()) {
- logger.debug(outgoingResponseString);
+ outgoingResponseString = JSONResponse.toString(pdpResponse, logger.isDebugEnabled());
+ if (logger.isDebugEnabled()) {
+ logger.debug(outgoingResponseString);
+ //
+ // Get rid of whitespace
+ //
+ outgoingResponseString = JSONResponse.toString(pdpResponse, false);
+ }
+ } else if ( contentType.getMimeType().equalsIgnoreCase(ContentType.APPLICATION_XML.getMimeType()) ||
+ contentType.getMimeType().equalsIgnoreCase("application/xacml+xml")) {
//
- // Get rid of whitespace
+ // Get it as a String. This is not very efficient but we need to log our
+ // results for auditing.
//
- outgoingResponseString = DOMResponse.toString(pdpResponse, false);
+ outgoingResponseString = DOMResponse.toString(pdpResponse, logger.isDebugEnabled());
+ if (logger.isDebugEnabled()) {
+ logger.debug(outgoingResponseString);
+ //
+ // Get rid of whitespace
+ //
+ outgoingResponseString = DOMResponse.toString(pdpResponse, false);
+ }
+ }
+ // adding the jmx values for NA, Permit and Deny
+ //
+ if (outgoingResponseString.contains("NotApplicable") || outgoingResponseString.contains("Decision not a Permit")){
+ monitor.pdpEvaluationNA();
}
- }
- // adding the jmx values for NA, Permit and Deny
- //
- if (outgoingResponseString.contains("NotApplicable") || outgoingResponseString.contains("Decision not a Permit")){
- monitor.pdpEvaluationNA();
- }
- if (outgoingResponseString.contains("Permit") && !outgoingResponseString.contains("Decision not a Permit")){
- monitor.pdpEvaluationPermit();
- }
+ if (outgoingResponseString.contains("Permit") && !outgoingResponseString.contains("Decision not a Permit")){
+ monitor.pdpEvaluationPermit();
+ }
- if (outgoingResponseString.contains("Deny")){
- monitor.pdpEvaluationDeny();
+ if (outgoingResponseString.contains("Deny")){
+ monitor.pdpEvaluationDeny();
+ }
+ //
+ // lTimeStart is used as an ID within the requestLogger to match up
+ // request's with responses.
+ //
+ requestLogger.info(lTimeStart + "=" + outgoingResponseString);
+ response.getWriter().print(outgoingResponseString);
+ }catch(Exception e){
+ logger.error("Exception Occured"+e );
}
- //
- // lTimeStart is used as an ID within the requestLogger to match up
- // request's with responses.
- //
- requestLogger.info(lTimeStart + "=" + outgoingResponseString);
- response.getWriter().print(outgoingResponseString);
}
catch (Exception e) {
String message = "Exception executing request: " + e;
@@ -1062,7 +1158,11 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable {
PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, e, message);
loggingContext.transactionEnded();
PolicyLogger.audit("Transaction Failed - See Error.log");
- response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, message);
+ try{
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, message);
+ }catch(Exception e1){
+ logger.error("Exception occured while sending error in response" +e1);
+ }
return;
}
@@ -1159,7 +1259,7 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable {
Class<?> createUpdateclass = Class.forName(createUpdateResourceName);
createUpdatePolicyConstructor = createUpdateclass.getConstructor(PolicyParameters.class, String.class, boolean.class);
}catch(Exception e){
- PolicyLogger.error(MessageCodes.MISS_PROPERTY_ERROR, "createUpdatePolicy.impl.className", "xacml.pdp.init");
+ PolicyLogger.error(MessageCodes.MISS_PROPERTY_ERROR, "createUpdatePolicy.impl.className", "xacml.pdp.init" +e);
throw new ServletException("Could not find the Class name : " +createUpdateResourceName + "\n" +e.getMessage());
}
}
diff --git a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/CreateUpdatePolicyServiceImpl.java b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/CreateUpdatePolicyServiceImpl.java
index 6112c42ce..cf2171137 100644
--- a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/CreateUpdatePolicyServiceImpl.java
+++ b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/CreateUpdatePolicyServiceImpl.java
@@ -222,9 +222,9 @@ public class CreateUpdatePolicyServiceImpl implements CreateUpdatePolicyService
return false;
}
if (policyParameters.getPolicyName().contains(".")) {
- policyName = policyParameters.getPolicyName().substring(policyParameters.getPolicyName().lastIndexOf(".") + 1,
+ policyName = policyParameters.getPolicyName().substring(policyParameters.getPolicyName().lastIndexOf('.') + 1,
policyParameters.getPolicyName().length());
- policyScope = policyParameters.getPolicyName().substring(0,policyParameters.getPolicyName().lastIndexOf("."));
+ policyScope = policyParameters.getPolicyName().substring(0,policyParameters.getPolicyName().lastIndexOf('.'));
LOGGER.info("Name is " + policyName + " scope is " + policyScope);
} else {
message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.";
diff --git a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/PAPServices.java b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/PAPServices.java
index 66a557056..aea058d37 100644
--- a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/PAPServices.java
+++ b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/PAPServices.java
@@ -230,7 +230,7 @@ public class PAPServices {
try {
throw new Exception(XACMLErrorConstants.ERROR_DATA_ISSUE +"PAPs List is empty.");
} catch (Exception e) {
- LOGGER.error(e.getMessage());
+ LOGGER.error(e.getMessage() + e);
}
}else {
int papsCount = 0;
@@ -319,7 +319,7 @@ public class PAPServices {
try {
throw new Exception(XACMLErrorConstants.ERROR_DATA_ISSUE +"ERROR in connecting to the PAP ", e);
} catch (Exception e1) {
- LOGGER.error(e1.getMessage());
+ LOGGER.error(e1.getMessage() + e1);
}
}
@@ -328,7 +328,7 @@ public class PAPServices {
try {
throw new Exception(XACMLErrorConstants.ERROR_DATA_ISSUE +"ERROR in connecting to the PAP ");
} catch (Exception e) {
- LOGGER.error(e.getMessage());
+ LOGGER.error(e.getMessage() + e);
}
}
}
@@ -390,7 +390,7 @@ public class PAPServices {
scanner.close();
} catch (IOException e1) {
- LOGGER.error(e1.getMessage());
+ LOGGER.error(e1.getMessage() + e1);
}
response = "Transaction ID: " + requestID + " --Dictionary Items Retrieved " + json;
} else if ("getMetrics".equals(operation)) {
diff --git a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/config/PDPApiAuth.java b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/config/PDPApiAuth.java
index c4573cc0d..5c3dcad60 100644
--- a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/config/PDPApiAuth.java
+++ b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/config/PDPApiAuth.java
@@ -22,7 +22,6 @@ package org.openecomp.policy.pdp.rest.config;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
@@ -35,7 +34,8 @@ import java.util.StringTokenizer;
import org.openecomp.policy.api.PolicyEngineException;
import org.openecomp.policy.common.logging.eelf.MessageCodes;
-import org.openecomp.policy.common.logging.eelf.PolicyLogger;
+import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
+import org.openecomp.policy.common.logging.flexlogger.Logger;
import org.openecomp.policy.rest.XACMLRestProperties;
import org.openecomp.policy.utils.AAFPolicyClient;
import org.openecomp.policy.utils.AAFPolicyException;
@@ -45,144 +45,145 @@ import org.openecomp.policy.xacml.api.XACMLErrorConstants;
import com.att.research.xacml.util.XACMLProperties;
public class PDPApiAuth {
- private static String environment = null;
- private static Path clientPath = null;
- private static Map<String,ArrayList<String>> clientMap = null;
- private static Long oldModified = null;
- private static AAFPolicyClient aafClient = null;
-
- private PDPApiAuth(){
- // Private Constructor
- }
-
- /*
- * Set Property by reading the properties File.
- */
- public static void setProperty() {
- environment = XACMLProperties.getProperty("ENVIRONMENT", "DEVL");
- String clientFile = XACMLProperties.getProperty(XACMLRestProperties.PROP_PEP_IDFILE);
- if(clientFile!=null){
- clientPath = Paths.get(clientFile);
- }
- try {
- aafClient = AAFPolicyClient.getInstance(XACMLProperties.getProperties());
- } catch (AAFPolicyException | IOException e) {
- PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, e, "AAF Client Not instantiated properly.");
- }
- }
-
- /*
- * Return Environment value of the PDP servlet.
- */
- public static String getEnvironment() {
- if(environment==null){
- setProperty();
- }
- return environment;
- }
+ private static final Logger LOGGER = FlexLogger.getLogger(PDPApiAuth.class);
- /*
- * Security check for authentication and authorizations.
- */
- public static boolean checkPermissions(String clientEncoding, String requestID,
- String resource) {
- try{
- String[] userNamePass = PolicyUtils.decodeBasicEncoding(clientEncoding);
- if(userNamePass==null || userNamePass.length==0){
- String usernameAndPassword = null;
- byte[] decodedBytes = Base64.getDecoder().decode(clientEncoding);
- usernameAndPassword = new String(decodedBytes, "UTF-8");
- StringTokenizer tokenizer = new StringTokenizer(usernameAndPassword, ":");
- String username = tokenizer.nextToken();
- String password = tokenizer.nextToken();
- userNamePass= new String[]{username, password};
- }
- PolicyLogger.info("User " + userNamePass[0] + " is Accessing Policy Engine API.");
- Boolean result = false;
- // Check Backward Compatibility.
- try{
- result = clientAuth(userNamePass);
- }catch(Exception e){
- PolicyLogger.error(MessageCodes.ERROR_PERMISSIONS, e, "");
- }
- if(!result){
- try{
- String aafPolicyNameSpace = XACMLProperties.getProperty("policy.aaf.namespace");
- String aafResource = XACMLProperties.getProperty("policy.aaf.resource");
- if(!userNamePass[0].contains("@") && aafPolicyNameSpace!= null){
- userNamePass[0] = userNamePass[0] + "@" + aafPolicyNameSpace;
- }
- if(aafResource != null){
- resource = aafResource + resource;
- }
- PolicyLogger.info("Contacting AAF in : " + environment);
- result = aafClient.checkAuthPerm(userNamePass[0], userNamePass[1], resource, environment, ".*");
- }catch (NullPointerException e){
- result = false;
- }
- }
- return result;
- }catch(Exception e){
- PolicyLogger.error(MessageCodes.ERROR_PERMISSIONS, e, "");
- return false;
- }
- }
+ private static String environment = null;
+ private static Path clientPath = null;
+ private static Map<String,ArrayList<String>> clientMap = null;
+ private static Long oldModified = null;
+ private static AAFPolicyClient aafClient = null;
- private static Boolean clientAuth(String[] userNamePass) throws Exception{
- if(clientPath==null){
- setProperty();
- }
- if (Files.notExists(clientPath)) {
- return false;
- }else if(clientPath.toString().endsWith(".properties")) {
- try {
- readProps(clientPath);
- if (clientMap.containsKey(userNamePass[0]) && clientMap.get(userNamePass[0]).get(0).equals(userNamePass[1])) {
- return true;
- }
- }catch(PolicyEngineException e){
- return false;
- }
- }
- return false;
- }
-
- private static Map<String, ArrayList<String>> readProps(Path clientPath) throws PolicyEngineException{
- if(oldModified!=null){
- Long newModified = clientPath.toFile().lastModified();
- if (newModified == oldModified) {
- return clientMap;
- }
- }
- InputStream in;
- Properties clientProp = new Properties();
- try {
- in = new FileInputStream(clientPath.toFile());
- clientProp.load(in);
- } catch (IOException e) {
- PolicyLogger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e);
- throw new PolicyEngineException(XACMLErrorConstants.ERROR_SYSTEM_ERROR +"Cannot Load the Properties file", e);
- }
- // Read the Properties and Load the Clients and their scopes.
- clientMap = new HashMap<>();
- //
- for (Object propKey : clientProp.keySet()) {
- String clientID = (String)propKey;
- String clientValue = clientProp.getProperty(clientID);
- if (clientValue != null) {
- if (clientValue.contains(",")) {
- ArrayList<String> clientValues = new ArrayList<String>(Arrays.asList(clientValue.split("\\s*,\\s*")));
- if(clientValues.get(0)!=null || clientValues.get(1)!=null || clientValues.get(0).isEmpty() || clientValues.get(1).isEmpty()){
- clientMap.put(clientID, clientValues);
- }
- }
- }
- }
- if (clientMap.isEmpty()) {
- PolicyLogger.debug(XACMLErrorConstants.ERROR_PERMISSIONS + "No Clients ID , Client Key and Scopes are available. Cannot serve any Clients !!");
- throw new PolicyEngineException("Empty Client file");
- }
- oldModified = clientPath.toFile().lastModified();
- return clientMap;
- }
-}
+ private PDPApiAuth(){
+ // Private Constructor
+ }
+
+ /*
+ * Set Property by reading the properties File.
+ */
+ public static void setProperty() {
+ environment = XACMLProperties.getProperty("ENVIRONMENT", "DEVL");
+ String clientFile = XACMLProperties.getProperty(XACMLRestProperties.PROP_PEP_IDFILE);
+ if(clientFile!=null){
+ clientPath = Paths.get(clientFile);
+ }
+ try {
+ aafClient = AAFPolicyClient.getInstance(XACMLProperties.getProperties());
+ } catch (AAFPolicyException | IOException e) {
+ LOGGER.error(MessageCodes.ERROR_SYSTEM_ERROR, e, "AAF Client Not instantiated properly.");
+ }
+ }
+
+ /*
+ * Return Environment value of the PDP servlet.
+ */
+ public static String getEnvironment() {
+ if(environment==null){
+ setProperty();
+ }
+ return environment;
+ }
+
+ /*
+ * Security check for authentication and authorizations.
+ */
+ public static boolean checkPermissions(String clientEncoding, String requestID,
+ String resource) {
+ try{
+ String[] userNamePass = PolicyUtils.decodeBasicEncoding(clientEncoding);
+ if(userNamePass==null || userNamePass.length==0){
+ String usernameAndPassword = null;
+ byte[] decodedBytes = Base64.getDecoder().decode(clientEncoding);
+ usernameAndPassword = new String(decodedBytes, "UTF-8");
+ StringTokenizer tokenizer = new StringTokenizer(usernameAndPassword, ":");
+ String username = tokenizer.nextToken();
+ String password = tokenizer.nextToken();
+ userNamePass= new String[]{username, password};
+ }
+ LOGGER.info("User " + userNamePass[0] + " is Accessing Policy Engine API.");
+ Boolean result = false;
+ // Check Backward Compatibility.
+ try{
+ result = clientAuth(userNamePass);
+ }catch(Exception e){
+ LOGGER.error(MessageCodes.ERROR_PERMISSIONS, e);
+ }
+ if(!result){
+ String aafPolicyNameSpace = XACMLProperties.getProperty("policy.aaf.namespace");
+ String aafResource = XACMLProperties.getProperty("policy.aaf.resource");
+ if(!userNamePass[0].contains("@") && aafPolicyNameSpace!= null){
+ userNamePass[0] = userNamePass[0] + "@" + aafPolicyNameSpace;
+ }else{
+ LOGGER.info("No AAF NameSpace specified in properties");
+ }
+ if(aafResource != null){
+ resource = aafResource + resource;
+ }else{
+ LOGGER.info("No AAF Resource specified in properties");
+ }
+ LOGGER.info("Contacting AAF in : " + environment);
+ result = aafClient.checkAuthPerm(userNamePass[0], userNamePass[1], resource, environment, ".*");
+ }
+ return result;
+ }catch(Exception e){
+ LOGGER.error(MessageCodes.ERROR_PERMISSIONS, e);
+ return false;
+ }
+ }
+
+ private static Boolean clientAuth(String[] userNamePass){
+ if(clientPath==null){
+ setProperty();
+ }
+ if (!clientPath.toFile().exists()) {
+ return false;
+ }else if(clientPath.toString().endsWith(".properties")) {
+ try {
+ readProps(clientPath);
+ if (clientMap.containsKey(userNamePass[0]) && clientMap.get(userNamePass[0]).get(0).equals(userNamePass[1])) {
+ return true;
+ }
+ }catch(PolicyEngineException e){
+ LOGGER.error(MessageCodes.ERROR_PERMISSIONS, e);
+ return false;
+ }
+ }
+ return false;
+ }
+
+ private static Map<String, ArrayList<String>> readProps(Path clientPath) throws PolicyEngineException{
+ if(oldModified!=null){
+ Long newModified = clientPath.toFile().lastModified();
+ if (newModified == oldModified) {
+ return clientMap;
+ }
+ }
+ InputStream in;
+ Properties clientProp = new Properties();
+ try {
+ in = new FileInputStream(clientPath.toFile());
+ clientProp.load(in);
+ } catch (IOException e) {
+ LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR , e);
+ throw new PolicyEngineException(XACMLErrorConstants.ERROR_SYSTEM_ERROR +"Cannot Load the Properties file", e);
+ }
+ // Read the Properties and Load the Clients and their scopes.
+ clientMap = new HashMap<>();
+ //
+ for (Object propKey : clientProp.keySet()) {
+ String clientID = (String)propKey;
+ String clientValue = clientProp.getProperty(clientID);
+ if (clientValue != null && clientValue.contains(",")) {
+ ArrayList<String> clientValues = new ArrayList<>(Arrays.asList(clientValue.split("\\s*,\\s*")));
+ if(clientValues.get(0)!=null || clientValues.get(1)!=null || clientValues.get(0).isEmpty() || clientValues.get(1).isEmpty()){
+ clientMap.put(clientID, clientValues);
+ }
+ }
+ }
+ if (clientMap.isEmpty()) {
+ LOGGER.debug(XACMLErrorConstants.ERROR_PERMISSIONS + "No Clients ID , Client Key and Scopes are available. Cannot serve any Clients !!");
+ throw new PolicyEngineException("Empty Client file");
+ }
+ oldModified = clientPath.toFile().lastModified();
+ return clientMap;
+ }
+} \ No newline at end of file
diff --git a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/NotificationController.java b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/NotificationController.java
index 214151d16..57678461d 100644
--- a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/NotificationController.java
+++ b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/NotificationController.java
@@ -22,12 +22,10 @@ package org.openecomp.policy.pdp.rest.notifications;
import java.io.File;
import java.io.FileFilter;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.file.Files;
@@ -172,7 +170,7 @@ public class NotificationController {
NotificationServer.setUpdate(notificationJSON);
ManualNotificationUpdateThread.setUpdate(notificationJSON);
} catch (JsonProcessingException e) {
- LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e.getMessage());
+ LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e.getMessage() +e);
}
}
}
@@ -182,7 +180,7 @@ public class NotificationController {
try {
NotificationServer.sendNotification(notificationJSON, propNotificationType, pdpURL);
} catch (Exception e) {
- LOGGER.info(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error in sending the Event Notification: "+ e.getMessage());
+ LOGGER.info(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error in sending the Event Notification: "+ e.getMessage() + e);
}
notificationFlag = false;
}
@@ -321,7 +319,7 @@ public class NotificationController {
try {
json = om.writeValueAsString(record);
} catch (JsonProcessingException e) {
- LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e.getMessage());
+ LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e.getMessage() + e);
}
LOGGER.info(json);
return json;
@@ -408,11 +406,7 @@ public class NotificationController {
IOUtils.copy(is, os);
break;
}
- } catch (MalformedURLException e) {
- LOGGER.error(e + e.getMessage());
- } catch(FileNotFoundException e){
- LOGGER.error(e + e.getMessage());
- } catch (IOException e) {
+ } catch (Exception e) {
LOGGER.error(e + e.getMessage());
}
papUrls.getNext();
diff --git a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/NotificationServer.java b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/NotificationServer.java
index 55ab760af..9bd2e1f20 100644
--- a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/NotificationServer.java
+++ b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/NotificationServer.java
@@ -95,7 +95,7 @@ public class NotificationServer {
session.getBasicRemote().sendText(update);
session.close();
} catch (IOException e) {
- LOGGER.info(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error in sending the Event Notification: "+ e.getMessage());
+ LOGGER.info(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error in sending the Event Notification: "+ e.getMessage() + e);
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error sending Message update");
}
}
@@ -142,13 +142,13 @@ public class NotificationServer {
} catch (MalformedURLException e1) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error creating the UEB publisher" + e1.getMessage());
} catch (GeneralSecurityException e1) {
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error creating the UEB publisher" + e1.getMessage());
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error creating the UEB publisher" + e1.getMessage() +e1);
}
if(pub != null){
try {
pub.send( "MyPartitionKey", notification );
} catch (IOException e) {
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error sending notification update" + e.getMessage());
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error sending notification update" + e.getMessage() + e);
}
// close the publisher. The batching publisher does not send events
// immediately, so you MUST use close to send any remaining messages.
@@ -203,7 +203,7 @@ public class NotificationServer {
publisher.close();
} catch (Exception e) {
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error sending notification update" + e.getMessage());
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error sending notification update" + e.getMessage() + e);
}
}
@@ -211,7 +211,7 @@ public class NotificationServer {
try {
session.getBasicRemote().sendText(notification);
} catch (IOException e) {
- LOGGER.info(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error in sending the Event Notification: "+ e.getMessage());
+ LOGGER.info(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error in sending the Event Notification: "+ e.getMessage() + e);
}
}
NotificationService.sendNotification(notification);
diff --git a/ECOMP-PDP/src/main/java/org/openecomp/policy/xacml/action/FindAction.java b/ECOMP-PDP/src/main/java/org/openecomp/policy/xacml/action/FindAction.java
index 2bcb903e8..5419b8946 100644
--- a/ECOMP-PDP/src/main/java/org/openecomp/policy/xacml/action/FindAction.java
+++ b/ECOMP-PDP/src/main/java/org/openecomp/policy/xacml/action/FindAction.java
@@ -20,7 +20,6 @@
package org.openecomp.policy.xacml.action;
import java.io.BufferedReader;
-import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
@@ -35,7 +34,6 @@ import javax.json.Json;
import javax.json.JsonReader;
import org.apache.http.HttpResponse;
-import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
@@ -272,11 +270,8 @@ public class FindAction {
output = output + out;
}
response = output;
- } catch (ClientProtocolException e) {
- LOGGER.error(e.getMessage());
- response = e.getMessage();
- } catch (IOException e) {
- LOGGER.error(e.getMessage());
+ } catch (Exception e) {
+ LOGGER.error(e.getMessage()+e);
response = e.getMessage();
} finally {
httpClient.getConnectionManager().shutdown();
@@ -313,11 +308,8 @@ public class FindAction {
output = output + out;
}
response = output;
- } catch (ClientProtocolException e) {
- LOGGER.error(e.getMessage());
- response = e.getMessage();
- } catch (IOException e) {
- LOGGER.error(e.getMessage());
+ }catch (Exception e) {
+ LOGGER.error(e.getMessage() +e);
response = e.getMessage();
} finally {
httpClient.getConnectionManager().shutdown();
@@ -353,13 +345,10 @@ public class FindAction {
output = output + out;
}
response = output;
- } catch (ClientProtocolException e) {
- LOGGER.error(e.getMessage());
+ } catch (Exception e) {
+ LOGGER.error(e.getMessage() +e);
response = e.getMessage();
- } catch (IOException e) {
- LOGGER.error(e.getMessage());
- response = e.getMessage();
- } finally {
+ }finally {
httpClient.getConnectionManager().shutdown();
}
}
diff --git a/ECOMP-PDP/src/main/java/org/openecomp/policy/xacml/custom/EcompFunctionDefinitionFactory.java b/ECOMP-PDP/src/main/java/org/openecomp/policy/xacml/custom/EcompFunctionDefinitionFactory.java
index 202468feb..2cb8e67ae 100644
--- a/ECOMP-PDP/src/main/java/org/openecomp/policy/xacml/custom/EcompFunctionDefinitionFactory.java
+++ b/ECOMP-PDP/src/main/java/org/openecomp/policy/xacml/custom/EcompFunctionDefinitionFactory.java
@@ -24,6 +24,8 @@ import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.Map;
+import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
+import org.openecomp.policy.common.logging.flexlogger.Logger;
import org.openecomp.policy.xacml.pdp.std.functions.FunctionDefinitionCustomRegexpMatch;
import com.att.research.xacml.api.Identifier;
@@ -34,6 +36,7 @@ import com.att.research.xacmlatt.pdp.policy.FunctionDefinitionFactory;
import com.att.research.xacmlatt.pdp.std.StdFunctions;
public class EcompFunctionDefinitionFactory extends FunctionDefinitionFactory {
+ private static Logger logger = FlexLogger.getLogger(EcompFunctionDefinitionFactory.class);
private static Map<Identifier,FunctionDefinition> mapFunctionDefinitions = new HashMap<>();
private static boolean needMapInit = true;
@@ -60,7 +63,7 @@ public class EcompFunctionDefinitionFactory extends FunctionDefinitionFactory {
try {
register((FunctionDefinition)(field.get(null)));
} catch (IllegalAccessException ex) {
-
+ logger.error(ex.getMessage() +ex);
}
}
}
diff --git a/ECOMP-PDP/src/main/java/org/openecomp/policy/xacml/pdp/std/functions/FunctionDefinitionCustomRegexpMatch.java b/ECOMP-PDP/src/main/java/org/openecomp/policy/xacml/pdp/std/functions/FunctionDefinitionCustomRegexpMatch.java
index 5b84ab0f6..5c11f8c43 100644
--- a/ECOMP-PDP/src/main/java/org/openecomp/policy/xacml/pdp/std/functions/FunctionDefinitionCustomRegexpMatch.java
+++ b/ECOMP-PDP/src/main/java/org/openecomp/policy/xacml/pdp/std/functions/FunctionDefinitionCustomRegexpMatch.java
@@ -22,6 +22,9 @@ package org.openecomp.policy.xacml.pdp.std.functions;
import java.util.List;
+import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
+import org.openecomp.policy.common.logging.flexlogger.Logger;
+
import com.att.research.xacml.api.DataType;
import com.att.research.xacml.api.DataTypeException;
import com.att.research.xacml.api.Identifier;
@@ -46,7 +49,7 @@ import com.att.research.xacmlatt.pdp.std.functions.FunctionDefinitionBase;
* @param <I> the java class for the data type of the function Input arguments
*/
public class FunctionDefinitionCustomRegexpMatch<I> extends FunctionDefinitionBase<Boolean, I> {
-
+ private static Logger logger = FlexLogger.getLogger(FunctionDefinitionCustomRegexpMatch.class);
/**
* Constructor - need dataTypeArgs input because of java Generic type-erasure during compilation.
@@ -70,7 +73,7 @@ public class FunctionDefinitionCustomRegexpMatch<I> extends FunctionDefinitionBa
// get the regular expression
FunctionArgument regexpArgument = arguments.get(0);
- ConvertedArgument<String> convertedArgument = new ConvertedArgument<String>(regexpArgument, DataTypes.DT_STRING, false);
+ ConvertedArgument<String> convertedArgument = new ConvertedArgument<>(regexpArgument, DataTypes.DT_STRING, false);
if ( ! convertedArgument.isOk()) {
return ExpressionResult.newError(getFunctionStatus(convertedArgument.getStatus()));
}
@@ -82,7 +85,7 @@ public class FunctionDefinitionCustomRegexpMatch<I> extends FunctionDefinitionBa
// now get the element to match
FunctionArgument elementArgument = arguments.get(1);
- ConvertedArgument<I> convertedElement = new ConvertedArgument<I>(elementArgument, this.getDataTypeArgs(), false);
+ ConvertedArgument<I> convertedElement = new ConvertedArgument<>(elementArgument, this.getDataTypeArgs(), false);
if ( ! convertedElement.isOk()) {
return ExpressionResult.newError(getFunctionStatus(convertedElement.getStatus()));
}
@@ -93,6 +96,7 @@ public class FunctionDefinitionCustomRegexpMatch<I> extends FunctionDefinitionBa
try {
elementValueString = this.getDataTypeArgs().toStringValue(elementValueObject);
} catch (DataTypeException e) {
+ logger.error(e.getMessage() +e);
String message = e.getMessage();
if (e.getCause() != null) {
message = e.getCause().getMessage();
diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/XACMLRest.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/XACMLRest.java
index 2a6654815..050d03bce 100644
--- a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/XACMLRest.java
+++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/XACMLRest.java
@@ -199,7 +199,7 @@ public class XACMLRest {
logger.debug("Content available: " + request.getInputStream().available());
}
} catch (Exception e) {
- logger.debug("Content: inputStream exception: " + e.getMessage() + "; (May not be relevant)");
+ logger.debug("Content: inputStream exception: " + e.getMessage() + "; (May not be relevant)" +e);
}
} else {
logger.debug("Parameters:");
diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ConstraintType.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ConstraintType.java
index d7f5a720f..60923d5a8 100644
--- a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ConstraintType.java
+++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ConstraintType.java
@@ -51,7 +51,7 @@ public class ConstraintType implements Serializable {
defaults.put(RANGE_TYPE, "Set a range of min and/or max integer/double values the attribute can be set to during policy creation.");
defaults.put(REGEXP_TYPE, "Define a regular expression the attribute must match against during policy creation.");
}
- protected static final String[] RANGE_TYPES = {"minExclusive", "minInclusive", "maxExclusive", "maxInclusive"};
+ private static final String[] RANGE_TYPES = {"minExclusive", "minInclusive", "maxExclusive", "maxInclusive"};
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@@ -114,4 +114,8 @@ public class ConstraintType implements Serializable {
this.attributes = attributes;
}
+ public static String[] getRangeTypes() {
+ return RANGE_TYPES;
+ }
+
}
diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/util/MSModelUtils.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/util/MSModelUtils.java
index 670657ae3..711abe59c 100644
--- a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/util/MSModelUtils.java
+++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/util/MSModelUtils.java
@@ -183,7 +183,7 @@ public class MSModelUtils {
try {
resource.load(Collections.EMPTY_MAP);
} catch (IOException e) {
- logger.error("Error loading Encore Resource for new Model");
+ logger.error("Error loading Encore Resource for new Model" + e);
}
EPackage root = (EPackage) resource.getContents().get(0);
diff --git a/ECOMP-SDK-APP/src/main/java/org/openecomp/portalapp/scheduler/Register.java b/ECOMP-SDK-APP/src/main/java/org/openecomp/portalapp/scheduler/Register.java
index d710c41fc..5793fac5a 100644
--- a/ECOMP-SDK-APP/src/main/java/org/openecomp/portalapp/scheduler/Register.java
+++ b/ECOMP-SDK-APP/src/main/java/org/openecomp/portalapp/scheduler/Register.java
@@ -55,7 +55,7 @@ public class Register implements Registerable {
if (SystemProperties.getProperty(SystemProperties.LOG_CRON) != null)
getScheduleTriggers().add(logRegistry.getTrigger());
} catch (IllegalStateException ies) {
- logger.info(EELFLoggerDelegate.debugLogger, ("Log Cron not available"));
+ logger.info(EELFLoggerDelegate.debugLogger, ("Log Cron not available") + ies);
}
}
diff --git a/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/components/XACMLPDPPolicyTest.java b/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/components/XACMLPDPPolicyTest.java
deleted file mode 100644
index 96163b20e..000000000
--- a/ECOMP-XACML/src/test/java/org/openecomp/policy/xacml/test/components/XACMLPDPPolicyTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ECOMP-XACML
- * ================================================================================
- * 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.policy.xacml.test.components;
-
-import org.junit.Test;
-import org.junit.Before;
-import org.junit.After;
-
-import org.junit.Assert;
-
-public class XACMLPDPPolicyTest {
-
-
- @Before
- public void init(){
-
- }
-
- @After
- public void cleanUp(){
-
- }
-
- @Test
- public void testDummy(){
-
- Assert.assertTrue(true);
-
- }
-
-}
diff --git a/LogParser/src/main/java/org/openecomp/xacml/parser/ParseLog.java b/LogParser/src/main/java/org/openecomp/xacml/parser/ParseLog.java
index 73ecf797e..b0a5f677d 100644
--- a/LogParser/src/main/java/org/openecomp/xacml/parser/ParseLog.java
+++ b/LogParser/src/main/java/org/openecomp/xacml/parser/ParseLog.java
@@ -78,7 +78,7 @@ public class ParseLog {
private static String errorlogFile;
private static String JDBC_URL;
private static String JDBC_USER;
- private static String JDBC_PASSWORD = "";
+ private static String JDBC_PASSWORD;
private static String JDBC_DRIVER;
private static int maxLength = 255; //Max length that is allowed in the DB table
private static String resourceName;
@@ -108,212 +108,222 @@ public class ParseLog {
}
- private static void startDebugLogParser(File fileLog) throws Exception{
- if(debuglogFile != null && !debuglogFile.isEmpty()){
-
- // pull the last line number
- String dataFileName = "debug.log";
- String filesRead = PullLastLineRead(fileLog, dataFileName);
- if (filesRead!= null){
- filesRead = filesRead.replaceAll("(\\r\\n|\\n)", "<br />");
- debuglastNumberRead= Integer.parseInt(filesRead.trim());
- }else{
- debuglastNumberRead = 0;
- }
-
- debugStartFileSize = countLines(debuglogFile);
- if (debugStartFileSize < debuglastNumberRead ){
- logger.error("Filed Rolled: set Last debug number read to 0");
- debuglastNumberRead = 0;
- }
-
- isMissingLogFile = false;
- Path debugfilePath = Paths.get(debuglogFile);
- File debugfile = new File(debuglogFile);
- debugStartFileSize = debugfile.length();
- // start process debug.log file
-
- Runnable runnable = new Runnable (){
- boolean isStop = false;
-
- public void run(){
- while (!isStop){
-
- if (debugfile.isFile()){
- // log4jlogger must use .info
- Stream<String> lines = null;
+ private static void startDebugLogParser(File fileLog){
+ try{
+ if(debuglogFile != null && !debuglogFile.isEmpty()){
+
+ // pull the last line number
+ String dataFileName = "debug.log";
+ String filesRead = PullLastLineRead(fileLog, dataFileName);
+ if (filesRead!= null){
+ filesRead = filesRead.replaceAll("(\\r\\n|\\n)", "<br />");
+ debuglastNumberRead= Integer.parseInt(filesRead.trim());
+ }else{
+ debuglastNumberRead = 0;
+ }
+
+ debugStartFileSize = countLines(debuglogFile);
+ if (debugStartFileSize < debuglastNumberRead ){
+ logger.error("Filed Rolled: set Last debug number read to 0");
+ debuglastNumberRead = 0;
+ }
+
+ isMissingLogFile = false;
+ Path debugfilePath = Paths.get(debuglogFile);
+ File debugfile = new File(debuglogFile);
+ debugStartFileSize = debugfile.length();
+ // start process debug.log file
+
+ Runnable runnable = new Runnable (){
+ boolean isStop = false;
+
+ public void run(){
+ while (!isStop){
+
+ if (debugfile.isFile()){
+ // log4jlogger must use .info
+ Stream<String> lines = null;
+ try {
+ lines = Files.lines(debugfilePath, Charset.defaultCharset()).onClose(() -> log4jlogger.info("Last-"+dataFileName+"-line-Read:" + debuglastNumberRead)).skip(debuglastNumberRead);
+ lines.forEachOrdered(line -> process(line, type, LOGTYPE.DEBUG));
+ } catch (IOException e) {
+ logger.error("Error processing line in " + dataFileName + ":" + e);
+ logger.error("break the loop.");
+ isStop = true;
+ }finally{
+ if(lines != null){
+ lines.close();
+ }
+ }
+ }
try {
- lines = Files.lines(debugfilePath, Charset.defaultCharset()).onClose(() -> log4jlogger.info("Last-"+dataFileName+"-line-Read:" + debuglastNumberRead)).skip(debuglastNumberRead);
- lines.forEachOrdered(line -> process(line, type, LOGTYPE.DEBUG));
- } catch (IOException e) {
+ Thread.sleep(sleepTimer);
+ debugStartFileSize = countLines(debuglogFile);
+ } catch (InterruptedException | IOException e) {
logger.error("Error processing line in " + dataFileName + ":" + e);
logger.error("break the loop.");
isStop = true;
- }finally{
- if(lines != null){
- lines.close();
- }
}
- }
- try {
- Thread.sleep(sleepTimer);
- debugStartFileSize = countLines(debuglogFile);
- } catch (InterruptedException | IOException e) {
- logger.error("Error processing line in " + dataFileName + ":" + e);
- logger.error("break the loop.");
- isStop = true;
- }
-
- logger.debug("File Line Count of debug.log: " + debugStartFileSize + " value read in: " + debuglastNumberRead);
- if (debugStartFileSize < debuglastNumberRead ){
- logger.debug("Failed Rolled: set Last number read to 0");
- debuglastNumberRead = 0;
- }
- }
- }
- };
-
- Thread thread = new Thread(runnable);
- thread.start();
-
- }
- }
- private static void startErrorLogParser(File fileLog) throws Exception{
-
- if(errorlogFile != null && !errorlogFile.isEmpty()){
-
- // pull the last line number
- String dataFileName = "error.log";
- String filesRead = PullLastLineRead(fileLog, dataFileName);
- if (filesRead!= null){
- filesRead = filesRead.replaceAll("(\\r\\n|\\n)", "<br />");
- errorlastNumberRead= Integer.parseInt(filesRead.trim());
- }else{
- errorlastNumberRead = 0;
- }
-
- errorStartFileSize = countLines(errorlogFile);
- if (errorStartFileSize < errorlastNumberRead ){
- logger.error("Filed Rolled: set Last error number read to 0");
- errorlastNumberRead = 0;
+ logger.debug("File Line Count of debug.log: " + debugStartFileSize + " value read in: " + debuglastNumberRead);
+ if (debugStartFileSize < debuglastNumberRead ){
+ logger.debug("Failed Rolled: set Last number read to 0");
+ debuglastNumberRead = 0;
+ }
+ }
+ }
+ };
+
+ Thread thread = new Thread(runnable);
+ thread.start();
+
}
-
- isMissingLogFile = false;
- Path errorfilePath = Paths.get(errorlogFile);
- File errorfile = new File(errorlogFile);
- errorStartFileSize = errorfile.length();
- // start process error.log file
- Runnable runnable = new Runnable (){
- boolean isStop = false;
- public void run(){
-
- while (!isStop){
- if (errorfile.isFile()){
- // log4jlogger must use .info
- Stream<String> lines = null;
- try{
- lines = Files.lines(errorfilePath, Charset.defaultCharset()).onClose(() -> log4jlogger.info("Last-"+dataFileName+"-line-Read:" + errorlastNumberRead)).skip(errorlastNumberRead);
- lines.forEachOrdered(line -> process(line, type, LOGTYPE.ERROR));
- } catch (IOException e) {
+ }catch(Exception e){
+ logger.error("Exception occured in DebugLogParser" +e);
+ }
+ }
+
+ private static void startErrorLogParser(File fileLog){
+ try{
+ if(errorlogFile != null && !errorlogFile.isEmpty()){
+
+ // pull the last line number
+ String dataFileName = "error.log";
+ String filesRead = PullLastLineRead(fileLog, dataFileName);
+ if (filesRead!= null){
+ filesRead = filesRead.replaceAll("(\\r\\n|\\n)", "<br />");
+ errorlastNumberRead= Integer.parseInt(filesRead.trim());
+ }else{
+ errorlastNumberRead = 0;
+ }
+
+ errorStartFileSize = countLines(errorlogFile);
+ if (errorStartFileSize < errorlastNumberRead ){
+ logger.error("Filed Rolled: set Last error number read to 0");
+ errorlastNumberRead = 0;
+ }
+
+ isMissingLogFile = false;
+ Path errorfilePath = Paths.get(errorlogFile);
+ File errorfile = new File(errorlogFile);
+ errorStartFileSize = errorfile.length();
+ // start process error.log file
+ Runnable runnable = new Runnable (){
+ boolean isStop = false;
+ public void run(){
+
+ while (!isStop){
+ if (errorfile.isFile()){
+ // log4jlogger must use .info
+ Stream<String> lines = null;
+ try{
+ lines = Files.lines(errorfilePath, Charset.defaultCharset()).onClose(() -> log4jlogger.info("Last-"+dataFileName+"-line-Read:" + errorlastNumberRead)).skip(errorlastNumberRead);
+ lines.forEachOrdered(line -> process(line, type, LOGTYPE.ERROR));
+ } catch (IOException e) {
+ logger.error("Error processing line in " + dataFileName + ":" + e);
+ logger.error("break the loop.");
+ isStop = true;
+ }finally{
+ if(lines != null){
+ lines.close();
+ }
+ }
+ }
+ try {
+ Thread.sleep(sleepTimer);
+ errorStartFileSize = countLines(errorlogFile);
+ } catch (InterruptedException | IOException e) {
logger.error("Error processing line in " + dataFileName + ":" + e);
logger.error("break the loop.");
isStop = true;
- }finally{
- if(lines != null){
- lines.close();
- }
}
- }
- try {
- Thread.sleep(sleepTimer);
- errorStartFileSize = countLines(errorlogFile);
- } catch (InterruptedException | IOException e) {
- logger.error("Error processing line in " + dataFileName + ":" + e);
- logger.error("break the loop.");
- isStop = true;
- }
-
- logger.debug("File Line Count of error.log: " + errorStartFileSize + " value read in: " + errorlastNumberRead);
- if (errorStartFileSize < errorlastNumberRead ){
- logger.debug("Failed Rolled: set Last error number read to 0");
- errorlastNumberRead = 0;
- }
- }
- }
- };
-
- Thread thread = new Thread(runnable);
- thread.start();
- }
+
+ logger.debug("File Line Count of error.log: " + errorStartFileSize + " value read in: " + errorlastNumberRead);
+ if (errorStartFileSize < errorlastNumberRead ){
+ logger.debug("Failed Rolled: set Last error number read to 0");
+ errorlastNumberRead = 0;
+ }
+ }
+ }
+ };
+
+ Thread thread = new Thread(runnable);
+ thread.start();
+ }
+ }catch(Exception e){
+ logger.error("Exception occured in startErrorLogParser" +e);
+ }
}
- private static void startAPIRestLogParser(File fileLog) throws Exception{
-
- if(logFile != null && !logFile.isEmpty()){
-
- // pull the last line number
- String dataFileName = type.toLowerCase()+"-rest.log";
- String filesRead = PullLastLineRead(fileLog, dataFileName);
- if (filesRead!= null){
- filesRead = filesRead.replaceAll("(\\r\\n|\\n)", "<br />");
- lastNumberRead= Integer.parseInt(filesRead.trim());
- }else{
- lastNumberRead = 0;
- }
- startFileSize = countLines(logFile);
- if (startFileSize < lastNumberRead ){
- logger.error("Filed Rolled: set Last number read to 0");
- lastNumberRead = 0;
- }
-
- isMissingLogFile = false;
- Path filePath = Paths.get(logFile);
- File file = new File(logFile);
- startFileSize = file.length();
- // start process pap/pdp-rest.log file
- Runnable runnable = new Runnable () {
- boolean isStop = false;
- public void run(){
- while (!isStop){
-
- if (file.isFile()){
- // log4jlogger must use .info
- Stream<String> lines = null;;
+ private static void startAPIRestLogParser(File fileLog){
+ try{
+ if(logFile != null && !logFile.isEmpty()){
+
+ // pull the last line number
+ String dataFileName = type.toLowerCase()+"-rest.log";
+ String filesRead = PullLastLineRead(fileLog, dataFileName);
+ if (filesRead!= null){
+ filesRead = filesRead.replaceAll("(\\r\\n|\\n)", "<br />");
+ lastNumberRead= Integer.parseInt(filesRead.trim());
+ }else{
+ lastNumberRead = 0;
+ }
+ startFileSize = countLines(logFile);
+ if (startFileSize < lastNumberRead ){
+ logger.error("Filed Rolled: set Last number read to 0");
+ lastNumberRead = 0;
+ }
+
+ isMissingLogFile = false;
+ Path filePath = Paths.get(logFile);
+ File file = new File(logFile);
+ startFileSize = file.length();
+ // start process pap/pdp-rest.log file
+ Runnable runnable = new Runnable () {
+ boolean isStop = false;
+ public void run(){
+ while (!isStop){
+
+ if (file.isFile()){
+ // log4jlogger must use .info
+ Stream<String> lines = null;;
+ try {
+ lines = Files.lines(filePath, Charset.defaultCharset()).onClose(() -> log4jlogger.info("Last-"+dataFileName+"-line-Read:" + lastNumberRead)).skip(lastNumberRead);
+ lines.forEachOrdered(line -> process(line, type, LOGTYPE.INFO));
+ } catch (IOException e) {
+ logger.error("Error processing line in " + dataFileName + ":" + e);
+ logger.error("break the loop.");
+ isStop = true;
+ }finally{
+ if(lines != null){
+ lines.close();
+ }
+ }
+ }
try {
- lines = Files.lines(filePath, Charset.defaultCharset()).onClose(() -> log4jlogger.info("Last-"+dataFileName+"-line-Read:" + lastNumberRead)).skip(lastNumberRead);
- lines.forEachOrdered(line -> process(line, type, LOGTYPE.INFO));
- } catch (IOException e) {
+ Thread.sleep(sleepTimer);
+ startFileSize = countLines(logFile);
+ } catch (InterruptedException | IOException e) {
logger.error("Error processing line in " + dataFileName + ":" + e);
logger.error("break the loop.");
isStop = true;
- }finally{
- if(lines != null){
- lines.close();
- }
- }
- }
- try {
- Thread.sleep(sleepTimer);
- startFileSize = countLines(logFile);
- } catch (InterruptedException | IOException e) {
- logger.error("Error processing line in " + dataFileName + ":" + e);
- logger.error("break the loop.");
- isStop = true;
- }
-
- logger.debug("File Line Count of " + dataFileName+": " + startFileSize + " value read in: " + lastNumberRead);
- if (startFileSize < lastNumberRead ){
- logger.debug("Failed Rolled: set Last number read to 0");
- lastNumberRead = 0;
- }
- }
- }
- };
-
- Thread thread = new Thread(runnable);
- thread.start();
- }
+ }
+
+ logger.debug("File Line Count of " + dataFileName+": " + startFileSize + " value read in: " + lastNumberRead);
+ if (startFileSize < lastNumberRead ){
+ logger.debug("Failed Rolled: set Last number read to 0");
+ lastNumberRead = 0;
+ }
+ }
+ }
+ };
+
+ Thread thread = new Thread(runnable);
+ thread.start();
+ }
+ }catch(Exception e){
+ logger.error("Exception occured in StartAPIRestLogParser" +e);
+ }
}
public static int countLines(String filename) throws IOException {
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSParamController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSParamController.java
index 4f4838dc7..18ad9fc58 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSParamController.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/CreateBRMSParamController.java
@@ -53,7 +53,6 @@ import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.servlet.ModelAndView;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonNode;
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PDPController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PDPController.java
index 6ef7165b3..c2c0bc867 100644
--- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PDPController.java
+++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PDPController.java
@@ -48,7 +48,6 @@ import org.openecomp.portalsdk.core.web.support.UserUtils;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.servlet.ModelAndView;
import com.att.research.xacml.api.pap.PAPException;
import com.att.research.xacml.api.pap.PDPPolicy;
diff --git a/POLICY-SDK-APP/src/test/java/org/openecomp/policy/admin/PolicyManagerServletTest.java b/POLICY-SDK-APP/src/test/java/org/openecomp/policy/admin/PolicyManagerServletTest.java
index a25027679..9fd1801ae 100644
--- a/POLICY-SDK-APP/src/test/java/org/openecomp/policy/admin/PolicyManagerServletTest.java
+++ b/POLICY-SDK-APP/src/test/java/org/openecomp/policy/admin/PolicyManagerServletTest.java
@@ -139,6 +139,7 @@ public class PolicyManagerServletTest extends Mockito{
}
}
+ @SuppressWarnings("static-access")
@Test
public void testDescribePolicy(){
PolicyManagerServlet servlet = new PolicyManagerServlet();
@@ -159,6 +160,7 @@ public class PolicyManagerServletTest extends Mockito{
}
+ @SuppressWarnings("static-access")
@Test
public void testPolicyScopeList(){
PolicyManagerServlet servlet = new PolicyManagerServlet();
@@ -186,6 +188,7 @@ public class PolicyManagerServletTest extends Mockito{
}
}
+ @SuppressWarnings("static-access")
@Test
public void editBasePolicyTest(){
PolicyManagerServlet servlet = new PolicyManagerServlet();
@@ -210,6 +213,7 @@ public class PolicyManagerServletTest extends Mockito{
}
}
+ @SuppressWarnings("static-access")
@Test
public void editBRMSParamPolicyTest(){
List<Object> policyData = new ArrayList<>();
@@ -255,6 +259,7 @@ public class PolicyManagerServletTest extends Mockito{
}
}
+ @SuppressWarnings("static-access")
@Test
public void editBRMSRawPolicyTest(){
List<Object> policyData = new ArrayList<>();
@@ -300,6 +305,7 @@ public class PolicyManagerServletTest extends Mockito{
}
}
+ @SuppressWarnings("static-access")
@Test
public void editClosedLoopFaultPolicyTest(){
List<Object> policyData = new ArrayList<>();
@@ -345,6 +351,7 @@ public class PolicyManagerServletTest extends Mockito{
}
}
+ @SuppressWarnings("static-access")
@Test
public void editClosedLoopPMPolicyTest(){
List<Object> policyData = new ArrayList<>();
@@ -390,6 +397,7 @@ public class PolicyManagerServletTest extends Mockito{
}
}
+ @SuppressWarnings("static-access")
@Test
public void editMicroServicePolicyTest(){
GroupPolicyScopeList groupData = new GroupPolicyScopeList();
@@ -443,6 +451,7 @@ public class PolicyManagerServletTest extends Mockito{
}
}
+ @SuppressWarnings("static-access")
@Test
public void editFirewallPolicyTest(){
List<Object> policyData = new ArrayList<>();
@@ -488,6 +497,7 @@ public class PolicyManagerServletTest extends Mockito{
}
}
+ @SuppressWarnings("static-access")
@Test
public void editActionPolicyTest(){
List<Object> policyData = new ArrayList<>();
@@ -531,6 +541,7 @@ public class PolicyManagerServletTest extends Mockito{
}
}
+ @SuppressWarnings("static-access")
@Test
public void editDecisionPolicyTest(){
List<Object> policyData = new ArrayList<>();
diff --git a/POLICY-SDK-APP/src/test/java/org/openecomp/policy/controller/CreateDcaeMicroServiceControllerTest.java b/POLICY-SDK-APP/src/test/java/org/openecomp/policy/controller/CreateDcaeMicroServiceControllerTest.java
index ca915440e..b4619b852 100644
--- a/POLICY-SDK-APP/src/test/java/org/openecomp/policy/controller/CreateDcaeMicroServiceControllerTest.java
+++ b/POLICY-SDK-APP/src/test/java/org/openecomp/policy/controller/CreateDcaeMicroServiceControllerTest.java
@@ -169,7 +169,6 @@ public class CreateDcaeMicroServiceControllerTest {
//expect: uniqueKeys should contain a string value
CreateDcaeMicroServiceController controllerA = new CreateDcaeMicroServiceController();
String str = "testing\\.byCorrectWay\\.OfDATA";
- String value = null;
assertEquals(1, controllerA.stringBetweenDots(str));
//expect: uniqueKeys should not contain a string value
diff --git a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ActionPolicyClient.java b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ActionPolicyClient.java
index 18de85bd4..d1081b106 100644
--- a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ActionPolicyClient.java
+++ b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ActionPolicyClient.java
@@ -102,7 +102,7 @@ public class ActionPolicyClient {
System.out.println("Error! " + response.getResponseMessage());
}
} catch (Exception e) {
- System.err.println(e.getMessage());
+ System.err.println(e.getMessage() + e);
}
}
diff --git a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/BrmsParamPolicyClient.java b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/BrmsParamPolicyClient.java
index 790c8e893..5810106c1 100644
--- a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/BrmsParamPolicyClient.java
+++ b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/BrmsParamPolicyClient.java
@@ -80,21 +80,13 @@ public class BrmsParamPolicyClient {
PolicyChangeResponse response = policyEngine.updatePolicy(policyParameters);
if(response.getResponseCode()==200){
-
System.out.println(response.getResponseMessage());
-
System.out.println("Policy Created Successfully!");
-
}else{
-
System.out.println("Error! " + response.getResponseMessage());
-
}
-
} catch (Exception e) {
-
- System.err.println(e.getMessage());
-
+ System.err.println(e.getMessage() + e);
}
}