summaryrefslogtreecommitdiffstats
path: root/integrity-audit/src/main/java/org
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2017-12-05 15:24:13 +0000
committerGerrit Code Review <gerrit@onap.org>2017-12-05 15:24:13 +0000
commit496a8e0a4d4b53136a8612ad4e3369a3c6562674 (patch)
tree774684ebac4e75b4dadb869ec5459e9453e97a5c /integrity-audit/src/main/java/org
parent9eade238b6079eb9afc8bc3de251f32aa7407ed6 (diff)
parentd0099f039b0dbf8f14ec2d273290a7c8ff58cb1c (diff)
Merge "Fix bug where paramsAreBad doesn't update string"
Diffstat (limited to 'integrity-audit/src/main/java/org')
-rw-r--r--integrity-audit/src/main/java/org/onap/policy/common/ia/DbDAO.java2
-rw-r--r--integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAudit.java109
2 files changed, 59 insertions, 52 deletions
diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDAO.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDAO.java
index db633400..99503854 100644
--- a/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDAO.java
+++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDAO.java
@@ -95,7 +95,7 @@ public class DbDAO {
* @throws IntegrityAuditPropertiesException
*/
private void validateProperties(String resourceName, String persistenceUnit, Properties properties) throws IntegrityAuditPropertiesException{
- String badparams="";
+ StringBuilder badparams= new StringBuilder();
if(IntegrityAudit.parmsAreBad(resourceName, persistenceUnit, properties, badparams)){
String msg = "DbDAO: Bad parameters: badparams" + badparams;
throw new IntegrityAuditPropertiesException(msg);
diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAudit.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAudit.java
index 50fc6932..424e603d 100644
--- a/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAudit.java
+++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAudit.java
@@ -67,7 +67,7 @@ public class IntegrityAudit {
public IntegrityAudit(String resourceName, String persistenceUnit, Properties properties) throws IntegrityAuditException {
logger.info("Constructor: Entering and checking for nulls");
- String parmList = "";
+ StringBuilder parmList = new StringBuilder();
if (parmsAreBad(resourceName, persistenceUnit, properties, parmList)) {
logger.error("Constructor: Parms contain nulls; cannot run audit for resourceName="
+ resourceName + ", persistenceUnit=" + persistenceUnit
@@ -117,73 +117,80 @@ public class IntegrityAudit {
* Makes sure we don't try to run the audit with bad parameters.
*/
public static boolean parmsAreBad(String resourceName, String persistenceUnit,
- Properties properties, String badparams) {
+ Properties properties, StringBuilder badparams) {
boolean parmsAreBad = false;
if(resourceName == null || resourceName.isEmpty()){
- badparams = badparams.concat("resourceName ");
+ badparams = badparams.append("resourceName ");
parmsAreBad = true;
}
if(persistenceUnit == null || persistenceUnit.isEmpty()){
- badparams = badparams.concat("persistenceUnit ");
+ badparams = badparams.append("persistenceUnit ");
parmsAreBad = true;
}
- String dbDriver = properties.getProperty(IntegrityAuditProperties.DB_DRIVER).trim();
- if(dbDriver == null || dbDriver.isEmpty()){
- badparams = badparams.concat("dbDriver ");
+ if(properties == null || properties.isEmpty()){
+ badparams = badparams.append("properties ");
parmsAreBad = true;
}
-
- String dbUrl = properties.getProperty(IntegrityAuditProperties.DB_URL).trim();
- if(dbUrl == null || dbUrl.isEmpty()){
- badparams = badparams.concat("dbUrl ");
- parmsAreBad = true;
- }
-
- String dbUser = properties.getProperty(IntegrityAuditProperties.DB_USER).trim();
- if(dbUser == null || dbUser.isEmpty()){
- badparams = badparams.concat("dbUser ");
- parmsAreBad = true;
- }
-
- String dbPwd = properties.getProperty(IntegrityAuditProperties.DB_PWD).trim();
- if(dbPwd == null){ //may be empty
- badparams = badparams.concat("dbPwd ");
- parmsAreBad = true;
- }
-
- String siteName = properties.getProperty(IntegrityAuditProperties.SITE_NAME).trim();
- if(siteName == null || siteName.isEmpty()){
- badparams = badparams.concat("siteName ");
- parmsAreBad = true;
- }
-
- String nodeType = properties.getProperty(IntegrityAuditProperties.NODE_TYPE).trim();
- if(nodeType == null || nodeType.isEmpty()){
- badparams = badparams.concat("nodeType ");
- parmsAreBad = true;
- } else {
- if (!isNodeTypeEnum(nodeType)) {
- String nodetypes = "nodeType must be one of[";
- for (NodeTypeEnum n : NodeTypeEnum.values()) {
- nodetypes = nodetypes.concat(n.toString() + " ");
- }
- badparams = badparams.concat(nodetypes + "] ");
+ else{
+ String dbDriver = properties.getProperty(IntegrityAuditProperties.DB_DRIVER);
+ if(dbDriver == null || dbDriver.isEmpty()){
+ badparams = badparams.append("dbDriver ");
parmsAreBad = true;
}
- }
- if(properties.getProperty(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS) != null){ //It is allowed to be null
- try{
- Integer.parseInt(properties.getProperty(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS).trim());
- }catch(NumberFormatException nfe){
- badparams = badparams.concat(", auditPeriodSeconds="
- + properties.getProperty(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS).trim());
+
+ String dbUrl = properties.getProperty(IntegrityAuditProperties.DB_URL);
+ if(dbUrl == null || dbUrl.isEmpty()){
+ badparams = badparams.append("dbUrl ");
parmsAreBad = true;
}
- }
+
+ String dbUser = properties.getProperty(IntegrityAuditProperties.DB_USER);
+ if(dbUser == null || dbUser.isEmpty()){
+ badparams = badparams.append("dbUser ");
+ parmsAreBad = true;
+ }
+
+ String dbPwd = properties.getProperty(IntegrityAuditProperties.DB_PWD);
+ if(dbPwd == null){ //may be empty
+ badparams = badparams.append("dbPwd ");
+ parmsAreBad = true;
+ }
+
+ String siteName = properties.getProperty(IntegrityAuditProperties.SITE_NAME);
+ if(siteName == null || siteName.isEmpty()){
+ badparams = badparams.append("siteName ");
+ parmsAreBad = true;
+ }
+
+ String nodeType = properties.getProperty(IntegrityAuditProperties.NODE_TYPE);
+ if(nodeType == null || nodeType.isEmpty()){
+ badparams = badparams.append("nodeType ");
+ parmsAreBad = true;
+ } else {
+ nodeType = nodeType.trim();
+ if (!isNodeTypeEnum(nodeType)) {
+ String nodetypes = "nodeType must be one of[";
+ for (NodeTypeEnum n : NodeTypeEnum.values()) {
+ nodetypes = nodetypes.concat(n.toString() + " ");
+ }
+ badparams = badparams.append(nodetypes + "] ");
+ parmsAreBad = true;
+ }
+ }
+ if(properties.getProperty(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS) != null){ //It is allowed to be null
+ try{
+ Integer.parseInt(properties.getProperty(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS).trim());
+ }catch(NumberFormatException nfe){
+ badparams = badparams.append(", auditPeriodSeconds="
+ + properties.getProperty(IntegrityAuditProperties.AUDIT_PERIOD_SECONDS).trim());
+ parmsAreBad = true;
+ }
+ }
+ } // End else
logger.debug("parmsAreBad: exit:"
+ "\nresourceName: " + resourceName
+ "\npersistenceUnit: " + persistenceUnit