summaryrefslogtreecommitdiffstats
path: root/ONAP-REST/src/main/java/org
diff options
context:
space:
mode:
authorMichael Mokry <mm117s@att.com>2017-12-11 10:07:43 -0600
committerMichael Mokry <mm117s@att.com>2017-12-11 10:26:55 -0600
commit82e81ac60d97b93847a26accc071e7043d831ab0 (patch)
treed088b473cf9c83a3b1f798e5d5e5499082107c58 /ONAP-REST/src/main/java/org
parent428150834ee60899b9a8da019bae3c8bf009adf1 (diff)
Adding SONAR fixes for
- pushPolicy defect fixes for POLICY-486 - Common Policy Validation feature for POLIYC-449 Change-Id: I8d54aa5a9b819c6eb4427dfa47c4ce963a21c2e0 Issue-ID: POLICY-449,POLICY-486 Signed-off-by: Michael Mokry <mm117s@att.com>
Diffstat (limited to 'ONAP-REST/src/main/java/org')
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ClosedLoopFaultBody.java16
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java553
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/daoimpl/PolicyValidationDaoImpl.java56
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidation.java171
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidationRequestWrapper.java95
5 files changed, 434 insertions, 457 deletions
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ClosedLoopFaultBody.java b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ClosedLoopFaultBody.java
index 3d85f9f93..73909d923 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ClosedLoopFaultBody.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ClosedLoopFaultBody.java
@@ -221,22 +221,6 @@ public class ClosedLoopFaultBody {
this.verificationSignatures = verificationSignatures;
}
- /*public ArrayList<String> getD2Services() {
- return d2Services;
- }
-
- public void setD2Services(ArrayList<String> d2Services) {
- this.d2Services = d2Services;
- }
-
- public ArrayList<String> getSiteNames() {
- return siteNames;
- }
-
- public void setSiteNames(ArrayList<String> siteNames) {
- this.siteNames = siteNames;
- }*/
-
public boolean isvDNS() {
return vDNS;
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java
index 6de0c9b78..de424683d 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java
@@ -342,12 +342,6 @@ public class PolicyRestAdapter {
public void setReadOnly(boolean readOnly) {
this.readOnly = readOnly;
}
- public String getUserGitPath() {
- return gitPath;
- }
- public void setUserGitPath(String gitPath) {
- this.gitPath = gitPath;
- }
public boolean isValidData() {
return isValidData;
}
@@ -629,281 +623,274 @@ public class PolicyRestAdapter {
public void setNewFileName(String newFileName) {
this.newFileName = newFileName;
}
-
- public String getDomain() {
- return domain;
- }
- public void setDomain(String domain) {
- this.domain = domain;
- }
- public OnapName getOnapNameField() {
- return onapNameField;
- }
- public void setOnapNameField(OnapName onapNameField) {
- this.onapNameField = onapNameField;
- }
- public Object getJsonBodyData() {
- return jsonBodyData;
- }
- public void setJsonBodyData(Object jsonBodyData) {
- this.jsonBodyData = jsonBodyData;
- }
- public String getDirPath() {
- return dirPath;
- }
- public void setDirPath(String dirPath) {
- this.dirPath = dirPath;
- }
- public String getConfigBodyPath() {
- return configBodyPath;
- }
- public void setConfigBodyPath(String configBodyPath) {
- this.configBodyPath = configBodyPath;
- }
- public ArrayList<Object> getAttributes() {
- return attributes;
- }
- public void setAttributes(ArrayList<Object> attributes) {
- this.attributes = attributes;
- }
- public ArrayList<Object> getSettings() {
- return settings;
- }
- public void setSettings(ArrayList<Object> settings) {
- this.settings = settings;
- }
- public ArrayList<Object> getRuleAlgorithmschoices() {
- return ruleAlgorithmschoices;
- }
- public void setRuleAlgorithmschoices(ArrayList<Object> ruleAlgorithmschoices) {
- this.ruleAlgorithmschoices = ruleAlgorithmschoices;
- }
- public LinkedHashMap<?, ?> getServiceTypePolicyName() {
- return serviceTypePolicyName;
- }
- public void setServiceTypePolicyName(LinkedHashMap<?, ?> serviceTypePolicyName) {
- this.serviceTypePolicyName = serviceTypePolicyName;
- }
- public LinkedHashMap<?, ?> getVerticaMetrics() {
- return verticaMetrics;
- }
- public void setVerticaMetrics(LinkedHashMap<?, ?> verticaMetrics) {
- this.verticaMetrics = verticaMetrics;
- }
- public LinkedHashMap<?, ?> getDescription() {
- return description;
- }
- public void setDescription(LinkedHashMap<?, ?> description) {
- this.description = description;
- }
- public LinkedHashMap<?, ?> getAttributeFields() {
- return attributeFields;
- }
- public void setAttributeFields(LinkedHashMap<?, ?> attributeFields) {
- this.attributeFields = attributeFields;
- }
- public String getClearTimeOut() {
- return clearTimeOut;
- }
- public void setClearTimeOut(String clearTimeOut) {
- this.clearTimeOut = clearTimeOut;
- }
- public String getTrapMaxAge() {
- return trapMaxAge;
- }
- public void setTrapMaxAge(String trapMaxAge) {
- this.trapMaxAge = trapMaxAge;
- }
- public String getVerificationclearTimeOut() {
- return verificationclearTimeOut;
- }
- public void setVerificationclearTimeOut(String verificationclearTimeOut) {
- this.verificationclearTimeOut = verificationclearTimeOut;
- }
- public Map<String, String> getDynamicLayoutMap() {
- return dynamicLayoutMap;
- }
- public void setDynamicLayoutMap(Map<String, String> dynamicLayoutMap) {
- this.dynamicLayoutMap = dynamicLayoutMap;
- }
- public String getFwPolicyType() {
- return fwPolicyType;
- }
- public void setFwPolicyType(String fwPolicyType) {
- this.fwPolicyType = fwPolicyType;
- }
- public ArrayList<Object> getFwattributes() {
- return fwattributes;
- }
- public void setFwattributes(ArrayList<Object> fwattributes) {
- this.fwattributes = fwattributes;
- }
- public String getParentForChild() {
- return parentForChild;
- }
- public void setParentForChild(String parentForChild) {
- this.parentForChild = parentForChild;
- }
- public String getRuleName() {
- return ruleName;
- }
- public void setRuleName(String ruleName) {
- this.ruleName = ruleName;
- }
- public LinkedHashMap<?, ?> getRuleData() {
- return ruleData;
- }
- public void setRuleData(LinkedHashMap<?, ?> ruleData) {
- this.ruleData = ruleData;
- }
- public LinkedHashMap<?, ?> getRuleListData() {
- return ruleListData;
- }
- public void setRuleListData(LinkedHashMap<?, ?> ruleListData) {
- this.ruleListData = ruleListData;
- }
- public String getSecurityZone() {
- return securityZone;
- }
- public void setSecurityZone(String securityZone) {
- this.securityZone = securityZone;
- }
- public String getActionAttributeValue() {
- return actionAttributeValue;
- }
- public void setActionAttributeValue(String actionAttributeValue) {
- this.actionAttributeValue = actionAttributeValue;
- }
- public String getRuleProvider() {
- return ruleProvider;
- }
- public void setRuleProvider(String ruleProvider) {
- this.ruleProvider = ruleProvider;
- }
- public String getMsLocation() {
- return msLocation;
- }
- public void setMsLocation(String msLocation) {
- this.msLocation = msLocation;
- }
- public Map<String,String> getDrlRuleAndUIParams() {
- return drlRuleAndUIParams;
- }
- public void setDrlRuleAndUIParams(Map<String,String> drlRuleAndUIParams) {
- this.drlRuleAndUIParams = drlRuleAndUIParams;
- }
- public String getActionBody() {
- return actionBody;
- }
- public void setActionBody(String actionBody) {
- this.actionBody = actionBody;
- }
- public String getActionDictHeader() {
- return actionDictHeader;
- }
- public void setActionDictHeader(String actionDictHeader) {
- this.actionDictHeader = actionDictHeader;
- }
- public String getActionDictType() {
- return actionDictType;
- }
- public void setActionDictType(String actionDictType) {
- this.actionDictType = actionDictType;
- }
- public String getActionDictUrl() {
- return actionDictUrl;
- }
- public void setActionDictUrl(String actionDictUrl) {
- this.actionDictUrl = actionDictUrl;
- }
- public String getActionDictMethod() {
- return actionDictMethod;
- }
- public void setActionDictMethod(String actionDictMethod) {
- this.actionDictMethod = actionDictMethod;
- }
- public String getClWarning() {
- return clWarning;
- }
- public void setClWarning(String clWarning) {
- this.clWarning = clWarning;
- }
- public String getNewCLName() {
- return newCLName;
- }
- public void setNewCLName(String newCLName) {
- this.newCLName = newCLName;
- }
- public String getExistingCLName() {
- return existingCLName;
- }
- public void setExistingCLName(String existingCLName) {
- this.existingCLName = existingCLName;
- }
- public YAMLParams getYamlparams() {
- return yamlparams;
- }
- public void setYamlparams(YAMLParams yamlparams) {
- this.yamlparams = yamlparams;
- }
- /**
- * @return the rainyday
- */
- public RainyDayParams getRainyday() {
- return rainyday;
- }
- /**
- * @param rainyday the rainyday to set
- */
- public void setRainyday(RainyDayParams rainyday) {
- this.rainyday = rainyday;
- }
- /**
- * @return the errorCodeList
- */
- public List<String> getErrorCodeList() {
- return errorCodeList;
- }
- /**
- * @param errorCodeList the errorCodeList to set
- */
- public void setErrorCodeList(List<String> errorCodeList) {
- this.errorCodeList = errorCodeList;
- }
- /**
- * @return the treatmentList
- */
- public List<String> getTreatmentList() {
- return treatmentList;
- }
- /**
- * @param treatmentList the treatmentList to set
- */
- public void setTreatmentList(List<String> treatmentList) {
- this.treatmentList = treatmentList;
- }
- /**
- * @return the rainydayMap
- */
- public Map<String,String> getRainydayMap() {
- return rainydayMap;
- }
- /**
- * @param rainydayMap the rainydayMap to set
- */
- public void setRainydayMap(Map<String,String> rainydayMap) {
- this.rainydayMap = rainydayMap;
- }
- /**
- * @return the policyJSON
- */
- public Object getPolicyJSON() {
- return policyJSON;
- }
- /**
- * @param policyJSON the policyJSON to set
- */
- public void setPolicyJSON(Object policyJSON) {
- this.policyJSON = policyJSON;
- }
+ public OnapName getOnapNameField() {
+ return onapNameField;
+ }
+ public void setOnapNameField(OnapName onapNameField) {
+ this.onapNameField = onapNameField;
+ }
+ public Object getJsonBodyData() {
+ return jsonBodyData;
+ }
+ public void setJsonBodyData(Object jsonBodyData) {
+ this.jsonBodyData = jsonBodyData;
+ }
+ public String getDirPath() {
+ return dirPath;
+ }
+ public void setDirPath(String dirPath) {
+ this.dirPath = dirPath;
+ }
+ public String getConfigBodyPath() {
+ return configBodyPath;
+ }
+ public void setConfigBodyPath(String configBodyPath) {
+ this.configBodyPath = configBodyPath;
+ }
+ public ArrayList<Object> getAttributes() {
+ return attributes;
+ }
+ public void setAttributes(ArrayList<Object> attributes) {
+ this.attributes = attributes;
+ }
+ public ArrayList<Object> getSettings() {
+ return settings;
+ }
+ public void setSettings(ArrayList<Object> settings) {
+ this.settings = settings;
+ }
+ public ArrayList<Object> getRuleAlgorithmschoices() {
+ return ruleAlgorithmschoices;
+ }
+ public void setRuleAlgorithmschoices(ArrayList<Object> ruleAlgorithmschoices) {
+ this.ruleAlgorithmschoices = ruleAlgorithmschoices;
+ }
+ public LinkedHashMap<?, ?> getServiceTypePolicyName() {
+ return serviceTypePolicyName;
+ }
+ public void setServiceTypePolicyName(LinkedHashMap<?, ?> serviceTypePolicyName) {
+ this.serviceTypePolicyName = serviceTypePolicyName;
+ }
+ public LinkedHashMap<?, ?> getVerticaMetrics() {
+ return verticaMetrics;
+ }
+ public void setVerticaMetrics(LinkedHashMap<?, ?> verticaMetrics) {
+ this.verticaMetrics = verticaMetrics;
+ }
+ public LinkedHashMap<?, ?> getDescription() {
+ return description;
+ }
+ public void setDescription(LinkedHashMap<?, ?> description) {
+ this.description = description;
+ }
+ public LinkedHashMap<?, ?> getAttributeFields() {
+ return attributeFields;
+ }
+ public void setAttributeFields(LinkedHashMap<?, ?> attributeFields) {
+ this.attributeFields = attributeFields;
+ }
+ public String getClearTimeOut() {
+ return clearTimeOut;
+ }
+ public void setClearTimeOut(String clearTimeOut) {
+ this.clearTimeOut = clearTimeOut;
+ }
+ public String getTrapMaxAge() {
+ return trapMaxAge;
+ }
+ public void setTrapMaxAge(String trapMaxAge) {
+ this.trapMaxAge = trapMaxAge;
+ }
+ public String getVerificationclearTimeOut() {
+ return verificationclearTimeOut;
+ }
+ public void setVerificationclearTimeOut(String verificationclearTimeOut) {
+ this.verificationclearTimeOut = verificationclearTimeOut;
+ }
+ public Map<String, String> getDynamicLayoutMap() {
+ return dynamicLayoutMap;
+ }
+ public void setDynamicLayoutMap(Map<String, String> dynamicLayoutMap) {
+ this.dynamicLayoutMap = dynamicLayoutMap;
+ }
+ public String getFwPolicyType() {
+ return fwPolicyType;
+ }
+ public void setFwPolicyType(String fwPolicyType) {
+ this.fwPolicyType = fwPolicyType;
+ }
+ public ArrayList<Object> getFwattributes() {
+ return fwattributes;
+ }
+ public void setFwattributes(ArrayList<Object> fwattributes) {
+ this.fwattributes = fwattributes;
+ }
+ public String getParentForChild() {
+ return parentForChild;
+ }
+ public void setParentForChild(String parentForChild) {
+ this.parentForChild = parentForChild;
+ }
+ public String getRuleName() {
+ return ruleName;
+ }
+ public void setRuleName(String ruleName) {
+ this.ruleName = ruleName;
+ }
+ public LinkedHashMap<?, ?> getRuleData() {
+ return ruleData;
+ }
+ public void setRuleData(LinkedHashMap<?, ?> ruleData) {
+ this.ruleData = ruleData;
+ }
+ public LinkedHashMap<?, ?> getRuleListData() {
+ return ruleListData;
+ }
+ public void setRuleListData(LinkedHashMap<?, ?> ruleListData) {
+ this.ruleListData = ruleListData;
+ }
+ public String getSecurityZone() {
+ return securityZone;
+ }
+ public void setSecurityZone(String securityZone) {
+ this.securityZone = securityZone;
+ }
+ public String getActionAttributeValue() {
+ return actionAttributeValue;
+ }
+ public void setActionAttributeValue(String actionAttributeValue) {
+ this.actionAttributeValue = actionAttributeValue;
+ }
+ public String getRuleProvider() {
+ return ruleProvider;
+ }
+ public void setRuleProvider(String ruleProvider) {
+ this.ruleProvider = ruleProvider;
+ }
+ public String getMsLocation() {
+ return msLocation;
+ }
+ public void setMsLocation(String msLocation) {
+ this.msLocation = msLocation;
+ }
+ public Map<String,String> getDrlRuleAndUIParams() {
+ return drlRuleAndUIParams;
+ }
+ public void setDrlRuleAndUIParams(Map<String,String> drlRuleAndUIParams) {
+ this.drlRuleAndUIParams = drlRuleAndUIParams;
+ }
+ public String getActionBody() {
+ return actionBody;
+ }
+ public void setActionBody(String actionBody) {
+ this.actionBody = actionBody;
+ }
+ public String getActionDictHeader() {
+ return actionDictHeader;
+ }
+ public void setActionDictHeader(String actionDictHeader) {
+ this.actionDictHeader = actionDictHeader;
+ }
+ public String getActionDictType() {
+ return actionDictType;
+ }
+ public void setActionDictType(String actionDictType) {
+ this.actionDictType = actionDictType;
+ }
+ public String getActionDictUrl() {
+ return actionDictUrl;
+ }
+ public void setActionDictUrl(String actionDictUrl) {
+ this.actionDictUrl = actionDictUrl;
+ }
+ public String getActionDictMethod() {
+ return actionDictMethod;
+ }
+ public void setActionDictMethod(String actionDictMethod) {
+ this.actionDictMethod = actionDictMethod;
+ }
+ public String getClWarning() {
+ return clWarning;
+ }
+ public void setClWarning(String clWarning) {
+ this.clWarning = clWarning;
+ }
+ public String getNewCLName() {
+ return newCLName;
+ }
+ public void setNewCLName(String newCLName) {
+ this.newCLName = newCLName;
+ }
+ public String getExistingCLName() {
+ return existingCLName;
+ }
+ public void setExistingCLName(String existingCLName) {
+ this.existingCLName = existingCLName;
+ }
+ public YAMLParams getYamlparams() {
+ return yamlparams;
+ }
+ public void setYamlparams(YAMLParams yamlparams) {
+ this.yamlparams = yamlparams;
+ }
+ /**
+ * @return the rainyday
+ */
+ public RainyDayParams getRainyday() {
+ return rainyday;
+ }
+ /**
+ * @param rainyday the rainyday to set
+ */
+ public void setRainyday(RainyDayParams rainyday) {
+ this.rainyday = rainyday;
+ }
+ /**
+ * @return the errorCodeList
+ */
+ public List<String> getErrorCodeList() {
+ return errorCodeList;
+ }
+ /**
+ * @param errorCodeList the errorCodeList to set
+ */
+ public void setErrorCodeList(List<String> errorCodeList) {
+ this.errorCodeList = errorCodeList;
+ }
+ /**
+ * @return the treatmentList
+ */
+ public List<String> getTreatmentList() {
+ return treatmentList;
+ }
+ /**
+ * @param treatmentList the treatmentList to set
+ */
+ public void setTreatmentList(List<String> treatmentList) {
+ this.treatmentList = treatmentList;
+ }
+ /**
+ * @return the rainydayMap
+ */
+ public Map<String,String> getRainydayMap() {
+ return rainydayMap;
+ }
+ /**
+ * @param rainydayMap the rainydayMap to set
+ */
+ public void setRainydayMap(Map<String,String> rainydayMap) {
+ this.rainydayMap = rainydayMap;
+ }
+ /**
+ * @return the policyJSON
+ */
+ public Object getPolicyJSON() {
+ return policyJSON;
+ }
+ /**
+ * @param policyJSON the policyJSON to set
+ */
+ public void setPolicyJSON(Object policyJSON) {
+ this.policyJSON = policyJSON;
+ }
}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/daoimpl/PolicyValidationDaoImpl.java b/ONAP-REST/src/main/java/org/onap/policy/rest/daoimpl/PolicyValidationDaoImpl.java
index f6682eb40..8aa04356f 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/daoimpl/PolicyValidationDaoImpl.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/daoimpl/PolicyValidationDaoImpl.java
@@ -20,6 +20,7 @@
package org.onap.policy.rest.daoimpl;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -42,12 +43,13 @@ import org.onap.policy.rest.jpa.PolicyRoles;
import org.onap.policy.xacml.api.XACMLErrorConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
@Component
public class PolicyValidationDaoImpl implements CommonClassDao{
private static final Logger LOGGER = FlexLogger.getLogger(PolicyValidationDaoImpl.class);
+ private static final String DB_CONNECTION_CLOSING_ERROR = "Error While Closing Connection/Statement";
+ private static final String DBTABLE_QUERY_ERROR = "Error While Querying Table";
private static SessionFactory sessionfactory;
public static SessionFactory getSessionfactory() {
@@ -76,12 +78,12 @@ public class PolicyValidationDaoImpl implements CommonClassDao{
Criteria cr = session.createCriteria(className);
data = cr.list();
}catch(Exception e){
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying Table"+e);
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DBTABLE_QUERY_ERROR + e);
}finally{
try{
session.close();
}catch(Exception e){
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e);
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR+e);
}
}
return data;
@@ -106,12 +108,12 @@ public class PolicyValidationDaoImpl implements CommonClassDao{
}
data = cr.list();
} catch (Exception e) {
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying Table"+e);
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DBTABLE_QUERY_ERROR + e);
}finally{
try{
session.close();
}catch(Exception e1){
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1);
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e1);
}
}
return data;
@@ -125,12 +127,12 @@ public class PolicyValidationDaoImpl implements CommonClassDao{
session.persist(entity);
tx.commit();
}catch(Exception e){
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving data to Table"+e);
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Saving data to Table"+e);
}finally{
try{
session.close();
}catch(Exception e1){
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1);
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e1);
}
}
@@ -149,7 +151,7 @@ public class PolicyValidationDaoImpl implements CommonClassDao{
try{
session.close();
}catch(Exception e1){
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1);
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e1);
}
}
@@ -169,7 +171,7 @@ public class PolicyValidationDaoImpl implements CommonClassDao{
try{
session.close();
}catch(Exception e1){
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1);
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e1);
}
}
@@ -207,7 +209,7 @@ public class PolicyValidationDaoImpl implements CommonClassDao{
try{
session.close();
}catch(Exception e1){
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1);
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e1);
}
}
return data;
@@ -240,7 +242,7 @@ public class PolicyValidationDaoImpl implements CommonClassDao{
try{
session.close();
}catch(Exception e1){
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1);
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e1);
}
}
return rolesData;
@@ -249,12 +251,14 @@ public class PolicyValidationDaoImpl implements CommonClassDao{
@Override
public List<Object> checkExistingGroupListforUpdate(String arg0, String arg1) {
- return null;
+ return Collections.emptyList();
}
@Override
- public void deleteAll() {}
+ public void deleteAll() {
+ // Do nothing because this method is not used and is a placeholder to avoid 'Unimplemented Method' error
+ }
@SuppressWarnings("unchecked")
@@ -276,13 +280,13 @@ public class PolicyValidationDaoImpl implements CommonClassDao{
data = hbquery.list();
tx.commit();
} catch (Exception e) {
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying Database Table"+e);
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DBTABLE_QUERY_ERROR + e);
throw e;
}finally{
try{
session.close();
}catch(HibernateException e1){
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1);
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e1);
}
}
return data;
@@ -309,12 +313,12 @@ public class PolicyValidationDaoImpl implements CommonClassDao{
data = cr.list().get(0);
tx.commit();
} catch (Exception e) {
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying Database Table"+e);
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DBTABLE_QUERY_ERROR + e);
}finally{
try{
session.close();
}catch(Exception e1){
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1);
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e1);
}
}
return data;
@@ -322,11 +326,15 @@ public class PolicyValidationDaoImpl implements CommonClassDao{
@Override
- public void updateClAlarms(String arg0, String arg1) {}
+ public void updateClAlarms(String arg0, String arg1) {
+ // Do nothing because this method is not used and is a placeholder to avoid 'Unimplemented Method' error
+ }
@Override
- public void updateClYaml(String arg0, String arg1) {}
+ public void updateClYaml(String arg0, String arg1) {
+ // Do nothing because this method is not used and is a placeholder to avoid 'Unimplemented Method' error
+ }
@Override
@@ -343,7 +351,7 @@ public class PolicyValidationDaoImpl implements CommonClassDao{
try{
session.close();
}catch(Exception e1){
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1);
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e1);
}
}
@@ -360,12 +368,12 @@ public class PolicyValidationDaoImpl implements CommonClassDao{
cr.setProjection(Projections.property(columnName));
data = cr.list();
}catch(Exception e){
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying Table"+e);
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DBTABLE_QUERY_ERROR + e);
}finally{
try{
session.close();
}catch(Exception e){
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e);
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e);
}
}
return data;
@@ -396,12 +404,12 @@ public class PolicyValidationDaoImpl implements CommonClassDao{
entityData = cr.add(disjunction).list();
tx.commit();
} catch (Exception e) {
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Querying Table" +className +e);
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DBTABLE_QUERY_ERROR + className + e);
}finally{
try{
session.close();
}catch(Exception e1){
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error While Closing Connection/Statement"+e1);
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + DB_CONNECTION_CLOSING_ERROR + e1);
}
}
return entityData;
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidation.java b/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidation.java
index 223381afe..e98a41f9e 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidation.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidation.java
@@ -60,6 +60,9 @@ public class PolicyValidation {
public static final String ENFORCER_CONFIG_POLICY= "Enforcer Config";
public static final String MICROSERVICES="Micro Service";
public static final String FIREWALL="Firewall Config";
+ public static final String HTML_ITALICS_LNBREAK = "</i><br>";
+ public static final String SUCCESS = "success";
+ public static final String EMPTY_COMPONENT_ATTR = "Component Attributes: One or more Fields in Component Attributes is Empty.";
private static Map<String, String> mapAttribute = new HashMap<>();
@@ -84,7 +87,7 @@ public class PolicyValidation {
if(policyData.getPolicyName() != null){
String policyNameValidate = PolicyUtils.policySpecialCharValidator(policyData.getPolicyName());
- if(!policyNameValidate.contains("success")){
+ if(!policyNameValidate.contains(SUCCESS)){
responseString.append("PolicyName:" + policyNameValidate + "<br>");
valid = false;
};
@@ -94,7 +97,7 @@ public class PolicyValidation {
}
if(policyData.getPolicyDescription() != null){
String descriptionValidate = PolicyUtils.descriptionValidator(policyData.getPolicyDescription());
- if(!descriptionValidate.contains("success")){
+ if(!descriptionValidate.contains(SUCCESS)){
responseString.append("Description:" + descriptionValidate + "<br>");
valid = false;
}
@@ -107,7 +110,7 @@ public class PolicyValidation {
if(!Strings.isNullOrEmpty(policyData.getOnapName())) {
String onapNameValidate = PolicyUtils.policySpecialCharValidator(policyData.getOnapName());
- if(!onapNameValidate.contains("success")){
+ if(!onapNameValidate.contains(SUCCESS)){
responseString.append("OnapName:" + onapNameValidate + "<br>");
valid = false;
}
@@ -119,7 +122,7 @@ public class PolicyValidation {
if(!Strings.isNullOrEmpty(policyData.getRiskType())) {
String riskTypeValidate = PolicyUtils.policySpecialCharValidator(policyData.getRiskType());
- if(!riskTypeValidate.contains("success")){
+ if(!riskTypeValidate.contains(SUCCESS)){
responseString.append("RiskType:" + riskTypeValidate + "<br>");
valid = false;
}
@@ -130,7 +133,7 @@ public class PolicyValidation {
if(!Strings.isNullOrEmpty(policyData.getRiskLevel())) {
String validateRiskLevel = PolicyUtils.policySpecialCharValidator(policyData.getRiskLevel());
- if(!validateRiskLevel.contains("success")){
+ if(!validateRiskLevel.contains(SUCCESS)){
responseString.append("RiskLevel:" + validateRiskLevel + "<br>");
valid = false;
}
@@ -141,7 +144,7 @@ public class PolicyValidation {
if(!Strings.isNullOrEmpty(policyData.getGuard())) {
String validateGuard = PolicyUtils.policySpecialCharValidator(policyData.getGuard());
- if(!validateGuard.contains("success")){
+ if(!validateGuard.contains(SUCCESS)){
responseString.append("Guard:" + validateGuard + "<br>");
valid = false;
}
@@ -153,7 +156,7 @@ public class PolicyValidation {
if("Base".equalsIgnoreCase(policyData.getConfigPolicyType())){
if(!Strings.isNullOrEmpty(policyData.getConfigName())) {
String configNameValidate = PolicyUtils.policySpecialCharValidator(policyData.getConfigName());
- if(!configNameValidate.contains("success")){
+ if(!configNameValidate.contains(SUCCESS)){
responseString.append("ConfigName:" + configNameValidate + "<br>");
valid = false;
}
@@ -163,7 +166,7 @@ public class PolicyValidation {
}
if(!Strings.isNullOrEmpty(policyData.getConfigType())) {
String configTypeValidate = PolicyUtils.policySpecialCharValidator(policyData.getConfigType());
- if(!configTypeValidate.contains("success")){
+ if(!configTypeValidate.contains(SUCCESS)){
responseString.append("ConfigType:" + configTypeValidate + "<br>");
valid = false;
}
@@ -190,11 +193,9 @@ public class PolicyValidation {
responseString.append("Config Body: Property data is not valid" + "<br>");
valid = false;
}
- } else if (configType.equals("OTHER")) {
- if (configBodyData.equals("")) {
- responseString.append("Config Body: Config Body Should not be Empty" + "<br>");
- valid = false;
- }
+ } else if ("OTHER".equals(configType) && ("".equals(configBodyData))) {
+ responseString.append("Config Body: Config Body Should not be Empty" + "<br>");
+ valid = false;
}
}
}else{
@@ -203,27 +204,25 @@ public class PolicyValidation {
}
}
- if("Firewall Config".equalsIgnoreCase(policyData.getConfigPolicyType())){
+ if(FIREWALL.equalsIgnoreCase(policyData.getConfigPolicyType())){
if(policyData.getConfigName() != null && !policyData.getConfigName().isEmpty()){
String configNameValidate = PolicyUtils.policySpecialCharValidator(policyData.getConfigName());
- if(!configNameValidate.contains("success")){
- responseString.append("<b>ConfigName</b>:<i>" + configNameValidate + "</i><br>");
+ if(!configNameValidate.contains(SUCCESS)){
+ responseString.append("<b>ConfigName</b>:<i>" + configNameValidate + HTML_ITALICS_LNBREAK);
valid = false;
}
}else{
- responseString.append("<b>Config Name</b>:<i> Config Name is required" + "</i><br>");
+ responseString.append("<b>Config Name</b>:<i> Config Name is required" + HTML_ITALICS_LNBREAK);
valid = false;
}
if(policyData.getSecurityZone() == null || policyData.getSecurityZone().isEmpty()){
- responseString.append("<b>Security Zone</b>:<i> Security Zone is required" + "</i><br>");
+ responseString.append("<b>Security Zone</b>:<i> Security Zone is required" + HTML_ITALICS_LNBREAK);
valid = false;
}
}
- if("BRMS_Param".equalsIgnoreCase(policyData.getConfigPolicyType())){
- if(policyData.getRuleName() == null || policyData.getRuleName().isEmpty()){
- responseString.append("<b>BRMS Template</b>:<i>BRMS Template is required</i><br>");
- valid = false;
- }
+ if("BRMS_Param".equalsIgnoreCase(policyData.getConfigPolicyType()) && Strings.isNullOrEmpty(policyData.getRuleName())){
+ responseString.append("<b>BRMS Template</b>:<i>BRMS Template is required" + HTML_ITALICS_LNBREAK);
+ valid = false;
}
if("BRMS_Raw".equalsIgnoreCase(policyData.getConfigPolicyType())){
if(policyData.getConfigBodyData() != null && !policyData.getConfigBodyData().isEmpty()){
@@ -231,44 +230,45 @@ public class PolicyValidation {
// If there are any error other than Annotations then this is not Valid
if(message.contains("[ERR")){
- responseString.append("<b>Raw Rule Validate</b>:<i>Raw Rule has error"+ message +"</i><br>");
+ responseString.append("<b>Raw Rule Validate</b>:<i>Raw Rule has error"+ message + HTML_ITALICS_LNBREAK);
valid = false;
}
}else{
- responseString.append("<b>Raw Rule</b>:<i>Raw Rule is required</i><br>");
+ responseString.append("<b>Raw Rule</b>:<i>Raw Rule is required" + HTML_ITALICS_LNBREAK);
valid = false;
}
}
- if("ClosedLoop_PM".equalsIgnoreCase(policyData.getConfigPolicyType())){
+ if(CLOSEDLOOP_PM.equalsIgnoreCase(policyData.getConfigPolicyType())){
try{
if(Strings.isNullOrEmpty(policyData.getServiceTypePolicyName().get("serviceTypePolicyName").toString())){
- responseString.append("<b>ServiceType PolicyName</b>:<i>ServiceType PolicyName is required</i><br>");
+ responseString.append("<b>ServiceType PolicyName</b>:<i>ServiceType PolicyName is required" + HTML_ITALICS_LNBREAK);
valid = false;
}
}catch(Exception e){
LOGGER.error("ERROR in ClosedLoop_PM PolicyName" , e);
- responseString.append("<b>ServiceType PolicyName</b>:<i>ServiceType PolicyName is required</i><br>");
+ responseString.append("<b>ServiceType PolicyName</b>:<i>ServiceType PolicyName is required" + HTML_ITALICS_LNBREAK);
valid = false;
}
if(policyData.getJsonBody() != null){
- ClosedLoopPMBody pmBody = (ClosedLoopPMBody)mapper.readValue(policyData.getJsonBody(), ClosedLoopPMBody.class);
+
+ ClosedLoopPMBody pmBody = mapper.readValue(policyData.getJsonBody(), ClosedLoopPMBody.class);
if(pmBody.getEmailAddress() != null){
String result = emailValidation(pmBody.getEmailAddress(), responseString.toString());
- if(result != "success"){
+ if(result != SUCCESS){
responseString.append(result + "<br>");
valid = false;
}
}
if((pmBody.isGamma() || pmBody.isMcr() || pmBody.isTrinity() || pmBody.isvDNS() || pmBody.isvUSP()) != true){
- responseString.append("<b>D2/Virtualized Services</b>: <i>Select at least one D2/Virtualized Services</i><br>");
+ responseString.append("<b>D2/Virtualized Services</b>: <i>Select at least one D2/Virtualized Services" + HTML_ITALICS_LNBREAK);
valid = false;
}
if(pmBody.getGeoLink() != null && !pmBody.getGeoLink().isEmpty()){
String result = PolicyUtils.policySpecialCharValidator(pmBody.getGeoLink());
- if(!result.contains("success")){
- responseString.append("<b>GeoLink</b>:<i>" + result + "</i><br>");
+ if(!result.contains(SUCCESS)){
+ responseString.append("<b>GeoLink</b>:<i>" + result + HTML_ITALICS_LNBREAK);
valid = false;
};
}
@@ -278,19 +278,19 @@ public class PolicyValidation {
String value = entry.getValue();
if(!key.contains("Message")){
String attributeValidate = PolicyUtils.policySpecialCharValidator(value);
- if(!attributeValidate.contains("success")){
- responseString.append("<b>Attributes</b>:<i>" + key + " : value has spaces or invalid characters</i><br>");
+ if(!attributeValidate.contains(SUCCESS)){
+ responseString.append("<b>Attributes</b>:<i>" + key + " : value has spaces or invalid characters" + HTML_ITALICS_LNBREAK);
valid = false;
};
}
}
}
}else{
- responseString.append("<b>D2/Virtualized Services</b>:<i>Select atleast one D2/Virtualized Services</i><br>");
+ responseString.append("<b>D2/Virtualized Services</b>:<i>Select atleast one D2/Virtualized Services" + HTML_ITALICS_LNBREAK);
valid = false;
}
}
- if("ClosedLoop_Fault".equalsIgnoreCase(policyData.getConfigPolicyType())){
+ if(CLOSEDLOOP_POLICY.equalsIgnoreCase(policyData.getConfigPolicyType())){
if(policyData.getJsonBody() != null){
// For API we need to get the conditions key from the Json request and check it before deserializing to POJO due to the enum
@@ -299,11 +299,11 @@ public class PolicyValidation {
if(!json.isNull("conditions")){
String apiCondition = (String) json.get("conditions");
if(Strings.isNullOrEmpty(apiCondition)){
- responseString.append("<b>Conditions</b>: <i>Select At least one Condition</i><br>");
+ responseString.append("<b>Conditions</b>: <i>Select At least one Condition" + HTML_ITALICS_LNBREAK);
return responseString;
}
} else {
- responseString.append("<b>Conditions</b>: <i>There were no conditions provided in configBody json</i><br>");
+ responseString.append("<b>Conditions</b>: <i>There were no conditions provided in configBody json" + HTML_ITALICS_LNBREAK);
return responseString;
}
}
@@ -311,79 +311,79 @@ public class PolicyValidation {
ClosedLoopFaultBody faultBody = mapper.readValue(policyData.getJsonBody(), ClosedLoopFaultBody.class);
if(faultBody.getEmailAddress() != null && !faultBody.getEmailAddress().isEmpty()){
String result = emailValidation(faultBody.getEmailAddress(), responseString.toString());
- if(result != "success"){
+ if(result != SUCCESS){
responseString.append(result+ "<br>");
valid = false;
}
}
if((faultBody.isGamma() || faultBody.isMcr() || faultBody.isTrinity() || faultBody.isvDNS() || faultBody.isvUSP()) != true){
- responseString.append("<b>D2/Virtualized Services</b>: <i>Select at least one D2/Virtualized Services</i><br>");
+ responseString.append("<b>D2/Virtualized Services</b>: <i>Select at least one D2/Virtualized Services" + HTML_ITALICS_LNBREAK);
valid = false;
}
if(faultBody.getActions() == null || faultBody.getActions().isEmpty()){
- responseString.append("<b>vPRO Actions</b>: <i>vPRO Actions is required</i><br>");
+ responseString.append("<b>vPRO Actions</b>: <i>vPRO Actions is required" + HTML_ITALICS_LNBREAK);
valid = false;
}
if(faultBody.getClosedLoopPolicyStatus() == null || faultBody.getClosedLoopPolicyStatus().isEmpty()){
- responseString.append("<b>Policy Status</b>: <i>Policy Status is required</i><br>");
+ responseString.append("<b>Policy Status</b>: <i>Policy Status is required" + HTML_ITALICS_LNBREAK);
valid = false;
}
if(faultBody.getConditions() == null){
- responseString.append("<b>Conditions</b>: <i>Select At least one Condition</i><br>");
+ responseString.append("<b>Conditions</b>: <i>Select At least one Condition" + HTML_ITALICS_LNBREAK);
valid = false;
}
if(faultBody.getGeoLink() != null && !faultBody.getGeoLink().isEmpty()){
String result = PolicyUtils.policySpecialCharWithSpaceValidator(faultBody.getGeoLink());
- if(!result.contains("success")){
- responseString.append("<b>GeoLink</b>:<i>" + result + "</i><br>");
+ if(!result.contains(SUCCESS)){
+ responseString.append("<b>GeoLink</b>:<i>" + result + HTML_ITALICS_LNBREAK);
valid = false;
}
}
if(faultBody.getAgingWindow() == 0){
- responseString.append("<b>Aging Window</b>: <i>Aging Window is required</i><br>");
+ responseString.append("<b>Aging Window</b>: <i>Aging Window is required" + HTML_ITALICS_LNBREAK);
valid = false;
}
if(faultBody.getTimeInterval() == 0){
- responseString.append("<b>Time Interval</b>: <i>Time Interval is required</i><br>");
+ responseString.append("<b>Time Interval</b>: <i>Time Interval is required" + HTML_ITALICS_LNBREAK);
valid = false;
}
if(faultBody.getRetrys() == 0){
- responseString.append("<b>Number of Retries</b>: <i>Number of Retries is required</i><br>");
+ responseString.append("<b>Number of Retries</b>: <i>Number of Retries is required" + HTML_ITALICS_LNBREAK);
valid = false;
}
if(faultBody.getTimeOutvPRO() == 0){
- responseString.append("<b>APP-C Timeout</b>: <i>APP-C Timeout is required</i><br>");
+ responseString.append("<b>APP-C Timeout</b>: <i>APP-C Timeout is required" + HTML_ITALICS_LNBREAK);
valid = false;
}
if(faultBody.getTimeOutRuby() == 0){
- responseString.append("<b>TimeOutRuby</b>: <i>TimeOutRuby is required</i><br>");
+ responseString.append("<b>TimeOutRuby</b>: <i>TimeOutRuby is required" + HTML_ITALICS_LNBREAK);
valid = false;
}
if(faultBody.getVnfType() == null || faultBody.getVnfType().isEmpty()){
- responseString.append("<b>Vnf Type</b>: <i>Vnf Type is required</i><br>");
+ responseString.append("<b>Vnf Type</b>: <i>Vnf Type is required" + HTML_ITALICS_LNBREAK);
valid = false;
}
}else{
- responseString.append("<b>D2/Virtualized Services</b>: <i>Select atleast one D2/Virtualized Services</i><br>");
- responseString.append("<b>vPRO Actions</b>: <i>vPRO Actions is required</i><br>");
- responseString.append("<b>Aging Window</b>: <i>Aging Window is required</i><br>");
- responseString.append("<b>Policy Status</b>: <i>Policy Status is required</i><br>");
- responseString.append("<b>Conditions</b>: <i>Select Atleast one Condition</i><br>");
- responseString.append("<b>PEP Name</b>: <i>PEP Name is required</i><br>");
- responseString.append("<b>PEP Action</b>: <i>PEP Action is required</i><br>");
- responseString.append("<b>Time Interval</b>: <i>Time Interval is required</i><br>");
- responseString.append("<b>Number of Retries</b>: <i>Number of Retries is required</i><br>");
- responseString.append("<b>APP-C Timeout</b>: <i>APP-C Timeout is required</i><br>");
- responseString.append("<b>TimeOutRuby</b>: <i>TimeOutRuby is required</i><br>");
- responseString.append("<b>Vnf Type</b>: <i>Vnf Type is required</i><br>");
+ responseString.append("<b>D2/Virtualized Services</b>: <i>Select atleast one D2/Virtualized Services" + HTML_ITALICS_LNBREAK);
+ responseString.append("<b>vPRO Actions</b>: <i>vPRO Actions is required" + HTML_ITALICS_LNBREAK);
+ responseString.append("<b>Aging Window</b>: <i>Aging Window is required" + HTML_ITALICS_LNBREAK);
+ responseString.append("<b>Policy Status</b>: <i>Policy Status is required" + HTML_ITALICS_LNBREAK);
+ responseString.append("<b>Conditions</b>: <i>Select Atleast one Condition" + HTML_ITALICS_LNBREAK);
+ responseString.append("<b>PEP Name</b>: <i>PEP Name is required" + HTML_ITALICS_LNBREAK);
+ responseString.append("<b>PEP Action</b>: <i>PEP Action is required" + HTML_ITALICS_LNBREAK);
+ responseString.append("<b>Time Interval</b>: <i>Time Interval is required" + HTML_ITALICS_LNBREAK);
+ responseString.append("<b>Number of Retries</b>: <i>Number of Retries is required" + HTML_ITALICS_LNBREAK);
+ responseString.append("<b>APP-C Timeout</b>: <i>APP-C Timeout is required" + HTML_ITALICS_LNBREAK);
+ responseString.append("<b>TimeOutRuby</b>: <i>TimeOutRuby is required" + HTML_ITALICS_LNBREAK);
+ responseString.append("<b>Vnf Type</b>: <i>Vnf Type is required" + HTML_ITALICS_LNBREAK);
valid = false;
}
}
- if ("Micro Service".equals(policyData.getConfigPolicyType())){
+ if (MICROSERVICES.equals(policyData.getConfigPolicyType())){
if(!Strings.isNullOrEmpty(policyData.getServiceType())){
pullJsonKeyPairs((JsonNode) policyData.getPolicyJSON());
- MicroServiceModels returnModel = new MicroServiceModels();
+
String service = null;
String version = null;
if (policyData.getServiceType().contains("-v")){
@@ -395,13 +395,12 @@ public class PolicyValidation {
}
if(!Strings.isNullOrEmpty(version)) {
- returnModel = getAttributeObject(service, version);
+ MicroServiceModels returnModel = getAttributeObject(service, version);
if(returnModel != null) {
String annotation = returnModel.getAnnotation();
if (!Strings.isNullOrEmpty(annotation)){
- Map<String, String> rangeMap = new HashMap<>();
- rangeMap = Splitter.on(",").withKeyValueSeparator("=").split(annotation);
+ Map<String, String> rangeMap = Splitter.on(",").withKeyValueSeparator("=").split(annotation);
for (Entry<String, String> rMap : rangeMap.entrySet()){
if (rMap.getValue().contains("range::")){
String value = mapAttribute.get(rMap.getKey().trim());
@@ -424,7 +423,7 @@ public class PolicyValidation {
}
} else {
responseString.append("<b>"+rMap.getKey()+"</b>:<i>" + rMap.getKey()
- + " is required for the MicroService model " + service + "</i><br>");
+ + " is required for the MicroService model " + service + HTML_ITALICS_LNBREAK);
valid = false;
}
@@ -433,20 +432,20 @@ public class PolicyValidation {
}
} else {
responseString.append("<b>Micro Service Model</b>:<i> Invalid Model. The model name, " + service +
- " of version, " + version + " was not found in the dictionary</i><br>");
+ " of version, " + version + " was not found in the dictionary" + HTML_ITALICS_LNBREAK);
valid = false;
}
} else {
- responseString.append("<b>Micro Version</b>:<i> Micro Service Version is required" + "</i><br>");
+ responseString.append("<b>Micro Version</b>:<i> Micro Service Version is required" + HTML_ITALICS_LNBREAK);
valid = false;
}
} else {
- responseString.append("<b>Micro Service</b>:<i> Micro Service is required" + "</i><br>");
+ responseString.append("<b>Micro Service</b>:<i> Micro Service is required" + HTML_ITALICS_LNBREAK);
valid = false;
}
if(Strings.isNullOrEmpty(policyData.getPriority())){
- responseString.append("<b>Priority</b>:<i> Priority is required" + "</i><br>");
+ responseString.append("<b>Priority</b>:<i> Priority is required" + HTML_ITALICS_LNBREAK);
valid = false;
}
}
@@ -454,7 +453,7 @@ public class PolicyValidation {
if (DECISION_POLICY.equalsIgnoreCase(policyData.getPolicyType())){
if(!Strings.isNullOrEmpty(policyData.getOnapName())){
String onapNameValidate = PolicyUtils.policySpecialCharValidator(policyData.getOnapName());
- if(!onapNameValidate.contains("success")){
+ if(!onapNameValidate.contains(SUCCESS)){
responseString.append("OnapName:" + onapNameValidate + "<br>");
valid = false;
}
@@ -570,7 +569,7 @@ public class PolicyValidation {
valid = false;
}else{
for(String blackList: policyData.getYamlparams().getBlackList()){
- if(blackList==null || !("success".equals(PolicyUtils.policySpecialCharValidator(blackList)))){
+ if(blackList==null || !(SUCCESS.equals(PolicyUtils.policySpecialCharValidator(blackList)))){
responseString.append(" Guard Params <b>BlackList</b> Should be valid String" + "<br>");
valid = false;
break;
@@ -585,7 +584,7 @@ public class PolicyValidation {
if(ACTION_POLICY.equalsIgnoreCase(policyData.getPolicyType())){
if(!Strings.isNullOrEmpty(policyData.getActionPerformer())){
String actionPerformer = PolicyUtils.policySpecialCharValidator(policyData.getActionPerformer());
- if(!actionPerformer.contains("success")){
+ if(!actionPerformer.contains(SUCCESS)){
responseString.append("ActionPerformer:" + actionPerformer + "<br>");
valid = false;
}
@@ -601,25 +600,25 @@ public class PolicyValidation {
String key = ((LinkedHashMap<?, ?>) attribute).get("key").toString();
String value = ((LinkedHashMap<?, ?>) attribute).get("value").toString();
if("".equals(key) || "".equals(value)){
- responseString.append("Component Attributes: One or more Fields in Component Attributes is Empty." + "<br>");
+ responseString.append(EMPTY_COMPONENT_ATTR + "<br>");
valid = false;
break;
}
}catch(Exception e){
LOGGER.error("This is a Policy Validation check" +e);
- responseString.append("Component Attributes: One or more Fields in Component Attributes is Empty." + "<br>");
+ responseString.append(EMPTY_COMPONENT_ATTR + "<br>");
valid = false;
break;
}
}
}
}else{
- responseString.append("Component Attributes: One or more Fields in Component Attributes is Empty." + "<br>");
+ responseString.append(EMPTY_COMPONENT_ATTR + "<br>");
valid = false;
}
if(!Strings.isNullOrEmpty(policyData.getActionAttributeValue())){
String actionAttribute = PolicyUtils.policySpecialCharValidator(policyData.getActionAttributeValue());
- if(!actionAttribute.contains("success")){
+ if(!actionAttribute.contains(SUCCESS)){
responseString.append("ActionAttribute:" + actionAttribute + "<br>");
valid = false;
};
@@ -662,11 +661,11 @@ public class PolicyValidation {
value = "Message:" + safePolicyWarningData.getMessage();
}
}
- responseString.append("success" + "@#"+ value);
+ responseString.append(SUCCESS + "@#"+ value);
}
}else{
if(valid){
- responseString.append("success");
+ responseString.append(SUCCESS);
}
}
@@ -681,10 +680,10 @@ public class PolicyValidation {
protected String emailValidation(String email, String response){
if(email != null){
String validateEmail = PolicyUtils.validateEmailAddress(email.replace("\"", ""));
- if(!validateEmail.contains("success")){
- response += "<b>Email</b>:<i>" + validateEmail+ "</i><br>";
+ if(!validateEmail.contains(SUCCESS)){
+ response += "<b>Email</b>:<i>" + validateEmail + HTML_ITALICS_LNBREAK;
}else{
- return "success";
+ return SUCCESS;
}
}
return response;
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidationRequestWrapper.java b/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidationRequestWrapper.java
index 072462297..03c1fb0c7 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidationRequestWrapper.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidationRequestWrapper.java
@@ -63,16 +63,14 @@ public class PolicyValidationRequestWrapper {
policyData = mapper.readValue(root.get("policyData").toString(), PolicyRestAdapter.class);
JsonObject json = null;
- if(root != null){
- json = stringToJsonObject(root.toString());
-
- if(json != null){
- if(json.containsKey("policyJSON")){
- policyData.setPolicyJSON(root.get("policyJSON"));
- }else{
- String jsonBodyData = json.getJsonObject("policyData").get("jsonBodyData").toString();
- policyData.setJsonBody(jsonBodyData);
- }
+ json = stringToJsonObject(root.toString());
+
+ if(json != null){
+ if(json.containsKey("policyJSON")){
+ policyData.setPolicyJSON(root.get("policyJSON"));
+ }else{
+ String jsonBodyData = json.getJsonObject("policyData").get("jsonBodyData").toString();
+ policyData.setJsonBody(jsonBodyData);
}
}
@@ -127,13 +125,13 @@ public class PolicyValidationRequestWrapper {
// Set Matching attributes in RainyDayParams in adapter
RainyDayParams rainyday = new RainyDayParams();
- rainyday.setServiceType(matching.get("ServiceType"));
- rainyday.setVnfType(matching.get("VNFType"));
- rainyday.setBbid(matching.get("BB_ID"));
- rainyday.setWorkstep(matching.get("WorkStep"));
-
-
-
+ if(matching != null) {
+ rainyday.setServiceType(matching.get("ServiceType"));
+ rainyday.setVnfType(matching.get("VNFType"));
+ rainyday.setBbid(matching.get("BB_ID"));
+ rainyday.setWorkstep(matching.get("WorkStep"));
+ }
+
Map<String, String> treatments = parameters.getTreatments();
ArrayList<Object> treatmentsTableChoices = new ArrayList<>();
@@ -153,32 +151,32 @@ public class PolicyValidationRequestWrapper {
// Set Matching attributes in YAMLParams in adapter
YAMLParams yamlparams = new YAMLParams();
- yamlparams.setActor(matching.get("actor"));
- yamlparams.setRecipe(matching.get("recipe"));
- yamlparams.setGuardActiveStart(matching.get("guardActiveStart"));
- yamlparams.setGuardActiveEnd(matching.get("guardActiveEnd"));
-
- if("GUARD_YAML".equals(ruleProvider)){
- yamlparams.setLimit(matching.get("limit"));
- yamlparams.setTimeWindow(matching.get("timeWindow"));
- yamlparams.setTimeUnits(matching.get("timeUnits"));
- }else{
+ if (matching != null) {
+ yamlparams.setActor(matching.get("actor"));
+ yamlparams.setRecipe(matching.get("recipe"));
+ yamlparams.setGuardActiveStart(matching.get("guardActiveStart"));
+ yamlparams.setGuardActiveEnd(matching.get("guardActiveEnd"));
- List<String> blackList = new ArrayList<>();
+ if("GUARD_YAML".equals(ruleProvider)){
+ yamlparams.setLimit(matching.get("limit"));
+ yamlparams.setTimeWindow(matching.get("timeWindow"));
+ yamlparams.setTimeUnits(matching.get("timeUnits"));
+ }else{
+
+ List<String> blackList = new ArrayList<>();
- if(!Strings.isNullOrEmpty(matching.get("blackList"))){
- String[] blackListArray = matching.get("blackList").split(",");
- for(String element : blackListArray){
- blackList.add(element);
- }
- }
-
- yamlparams.setBlackList(blackList);
+ if(!Strings.isNullOrEmpty(matching.get("blackList"))){
+ String[] blackListArray = matching.get("blackList").split(",");
+ for(String element : blackListArray){
+ blackList.add(element);
+ }
+ }
+
+ yamlparams.setBlackList(blackList);
- }
-
+ }
+ }
policyData.setYamlparams(yamlparams);
-;
}
} else if("Action".equals(parameters.getPolicyClass().toString())){
@@ -216,15 +214,16 @@ public class PolicyValidationRequestWrapper {
policyData.setRuleAlgorithmschoices(ruleAlgorithmChoices);
ArrayList<Object> attributeList = new ArrayList<>();
-
- for (String keyField : matching.keySet()) {
- LinkedHashMap<String, String> attributeMap = new LinkedHashMap<>();
- String key = keyField;
- String value = matching.get(keyField);
- attributeMap.put("key", key);
- attributeMap.put("value", value);
- attributeList.add(attributeMap);
- }
+ if (matching != null) {
+ for (String keyField : matching.keySet()) {
+ LinkedHashMap<String, String> attributeMap = new LinkedHashMap<>();
+ String key = keyField;
+ String value = matching.get(keyField);
+ attributeMap.put("key", key);
+ attributeMap.put("value", value);
+ attributeList.add(attributeMap);
+ }
+ }
policyData.setAttributes(attributeList);
policyData.setActionAttributeValue(parameters.getActionAttribute());