summaryrefslogtreecommitdiffstats
path: root/ONAP-PAP-REST/src/main/java
diff options
context:
space:
mode:
authorGuo Ruijing <ruijing.guo@intel.com>2017-08-24 08:13:53 +0000
committerGuo Ruijing <ruijing.guo@intel.com>2017-08-24 08:27:56 +0000
commitd3b395408111f444da77eb8b1db8b5e008a287de (patch)
treec02ce7c35ddf1017ab039e2b5d96d7f732fc4f88 /ONAP-PAP-REST/src/main/java
parent7ea81288603904f0cb6f57936da44d6a3dd521a6 (diff)
Fix critical sonar for ONAP-PAP-REST
This patch is to fix error-handling sonar issue for ONAP-PAP-REST. Change-Id: Ic5755cc02f282938d098c3a5c9e869318429c2c6 Issue-Id: POLICY-174 Signed-off-by: Guo Ruijing <ruijing.guo@intel.com>
Diffstat (limited to 'ONAP-PAP-REST/src/main/java')
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/XACMLPapServlet.java4
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ClosedLoopPolicy.java2
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ConfigPolicy.java7
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateBrmsParamPolicy.java3
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateNewMicroServiceModel.java2
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDao.java9
6 files changed, 15 insertions, 12 deletions
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 e11538c4e..f4c06c37e 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
@@ -1092,7 +1092,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
String message = "DELETE interface called for PAP " + papResourceName + " but it has an Administrative"
+ " state of " + im.getStateManager().getAdminState()
+ "\n Exception Message: " + ae.getMessage();
- LOGGER.info(message);
+ LOGGER.info(message, ae);
PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR + " " + message);
loggingContext.transactionEnded();
PolicyLogger.audit("Transaction Failed - See Error.log");
@@ -1102,7 +1102,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
String message = "PUT interface called for PAP " + papResourceName + " but it has a Standby Status"
+ " of " + im.getStateManager().getStandbyStatus()
+ "\n Exception Message: " + se.getMessage();
- LOGGER.info(message);
+ LOGGER.info(message, se);
PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR + " " + message);
loggingContext.transactionEnded();
PolicyLogger.audit("Transaction Failed - See Error.log");
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ClosedLoopPolicy.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ClosedLoopPolicy.java
index 3355fab85..2a5e9d3dd 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ClosedLoopPolicy.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ClosedLoopPolicy.java
@@ -76,7 +76,7 @@ public class ClosedLoopPolicy extends Policy {
//Remove the trapMaxAge in Verification Signature
body = body.replace(",\"trapMaxAge\":null", "");
}catch(Exception e){
- LOGGER.debug("No Trap Max Age in JSON body");
+ LOGGER.debug("No Trap Max Age in JSON body", e);
}
this.policyAdapter.setJsonBody(body);
} catch (Exception e) {
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ConfigPolicy.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ConfigPolicy.java
index 1b29c0369..02ba2ef14 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ConfigPolicy.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ConfigPolicy.java
@@ -179,11 +179,8 @@ public class ConfigPolicy extends Policy {
XMLReader reader = parser.getXMLReader();
reader.setErrorHandler(new XMLErrorHandler());
reader.parse(new InputSource(new StringReader(data)));
- } catch (ParserConfigurationException e) {
- return false;
- } catch (SAXException e) {
- return false;
- } catch (IOException e) {
+ } catch (ParserConfigurationException | SAXException | IOException e) {
+ LOGGER.debug(e);
return false;
}
return true;
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateBrmsParamPolicy.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateBrmsParamPolicy.java
index 923e528fa..5abe7ce10 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateBrmsParamPolicy.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateBrmsParamPolicy.java
@@ -231,6 +231,7 @@ public class CreateBrmsParamPolicy extends Policy {
line = line.split("\\/\\*")[0]
+ line.split("\\*\\/")[1].replace("*/", "");
} catch (Exception e) {
+ LOGGER.debug(e);
line = line.split("\\/\\*")[0];
}
} else {
@@ -242,6 +243,7 @@ public class CreateBrmsParamPolicy extends Policy {
try {
line = line.split("\\*\\/")[1].replace("*/", "");
} catch (Exception e) {
+ LOGGER.debug(e);
line = "";
}
}
@@ -275,6 +277,7 @@ public class CreateBrmsParamPolicy extends Policy {
try {
nextComponent = components[i + 1];
} catch (Exception e) {
+ LOGGER.debug(e);
nextComponent = components[i];
}
//If the type is of type String then we add the UI Item and type to the map.
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateNewMicroServiceModel.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateNewMicroServiceModel.java
index fd9e49c7e..aad70e5dd 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateNewMicroServiceModel.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateNewMicroServiceModel.java
@@ -90,7 +90,7 @@ public class CreateNewMicroServiceModel {
File deleteFile = new File(cleanUpFile);
FileUtils.forceDelete(deleteFile);
} catch (IOException e) {
- logger.error("Failed to unzip model file " + randomID);
+ logger.error("Failed to unzip model file " + randomID, e);
}
}else {
tempMap = utils.processEpackage("ExtractDir" + File.separator + randomID+".xmi", MODEL_TYPE.XMI);
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDao.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDao.java
index 98c8137de..d2ed1ad51 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDao.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDao.java
@@ -212,7 +212,7 @@ public class PolicyDBDao {
} catch(Exception e){
PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Exception querying for other registered PolicyDBDaos");
- logger.warn("List of remote PolicyDBDaos will be empty");
+ logger.warn("List of remote PolicyDBDaos will be empty", e);
}
try{
em.getTransaction().commit();
@@ -220,7 +220,7 @@ public class PolicyDBDao {
try{
em.getTransaction().rollback();
} catch(Exception e2){
-
+ logger.debug("List of remote PolicyDBDaos will be empty", e2);
}
}
em.close();
@@ -500,6 +500,7 @@ public class PolicyDBDao {
ourUrl = splitPapUrlUserPass((String)o)[0];
}catch(Exception e){
ourUrl = o;
+ logger.debug(e);
}
if(o == null){
o = "undefined";
@@ -867,6 +868,7 @@ public class PolicyDBDao {
}
} catch(Exception e){
nameAndVersion[0] = originalPolicyName;
+ logger.debug(e);
}
try{
nameAndVersion[1] = policyName.substring(policyName.lastIndexOf('.')+1);
@@ -875,6 +877,7 @@ public class PolicyDBDao {
}
} catch(Exception e){
nameAndVersion[1] = "1";
+ logger.debug(e);
}
return nameAndVersion;
}
@@ -2795,4 +2798,4 @@ public class PolicyDBDao {
}
}
-} \ No newline at end of file
+}