diff options
author | Ankitkumar Patel <ankit@research.att.com> | 2018-01-29 22:42:19 -0500 |
---|---|---|
committer | Ankitkumar Patel <ankit@research.att.com> | 2018-01-31 15:57:42 -0500 |
commit | 401b48bc573561f097960a9ca7abe6d788456f28 (patch) | |
tree | a8f089325447333d535adbc9d23dbf182547845e /ONAP-REST | |
parent | 9301fed7c290f52208922f780fdfe4b5a880b5aa (diff) |
Fixed the Sonar technical debt.
Fixed the sonar technical dept primarily for the POLICY-REST module, and
accordingly updated the other policy-engine modules for successful built.
Issue-ID: POLICY-476
Change-Id: I0e9bd7209a7f9af247fa409a1682683082f92698
Signed-off-by: Ankitkumar Patel <ankit@research.att.com>
Diffstat (limited to 'ONAP-REST')
87 files changed, 385 insertions, 455 deletions
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/XACMLRest.java b/ONAP-REST/src/main/java/org/onap/policy/rest/XACMLRest.java index 6bef28dfb..0912515e0 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/XACMLRest.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/XACMLRest.java @@ -46,7 +46,10 @@ import com.att.research.xacml.util.XACMLProperties; public class XACMLRest { private static final Log logger = LogFactory.getLog(XACMLRest.class); private static Properties restProperties = new Properties(); - + + private XACMLRest(){ + // Empty constructor + } /** * This must be called during servlet initialization. It sets up the xacml.?.properties * file as a system property. If the System property is already set, then it does not @@ -96,9 +99,8 @@ public class XACMLRest { Enumeration<String> params = config.getInitParameterNames(); while (params.hasMoreElements()) { String param = params.nextElement(); - if (! param.equals("XACML_PROPERTIES_NAME")) { + if (! "XACML_PROPERTIES_NAME".equals(param)) { String value = config.getInitParameter(param); - //logger.info(param + "=" + config.getInitParameter(param)); PolicyLogger.info(param + "=" + config.getInitParameter(param)); restProperties.setProperty(param, value); } @@ -161,8 +163,7 @@ public class XACMLRest { public static void dumpRequest(HttpServletRequest request) { if (logger.isDebugEnabled()) { // special-case for receiving heartbeat - don't need to repeatedly output all of the information in multiple lines - if (request.getMethod().equals("GET") && "hb".equals(request.getParameter("type")) ) { - //logger.debug("GET type=hb : heartbeat received"); + if ("GET".equals(request.getMethod()) && "hb".equals(request.getParameter("type")) ) { PolicyLogger.debug("GET type=hb : heartbeat received"); return; } @@ -185,7 +186,7 @@ public class XACMLRest { logger.debug(element + ":" + request.getAttribute(element)); } logger.debug("ContextPath: " + request.getContextPath()); - if (request.getMethod().equals("PUT") || request.getMethod().equals("POST")) { + if ("PUT".equals(request.getMethod()) || "POST".equals(request.getMethod())) { // POST and PUT are allowed to have parameters in the content, but in our usage the parameters are always in the Query string. // More importantly, there are cases where the POST and PUT content is NOT parameters (e.g. it might contain a Policy file). // Unfortunately the request.getParameterMap method reads the content to see if there are any parameters, diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/AddressGroupJson.java b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/AddressGroupJson.java index da4671ba4..6f7b88fbe 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/AddressGroupJson.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/AddressGroupJson.java @@ -39,6 +39,7 @@ public class AddressGroupJson { this.name = value; } + @Override public boolean equals(Object obj){ if(obj == null){ return false; @@ -52,8 +53,8 @@ public class AddressGroupJson { } return false; } - - public int hashCode() { + @Override + public int hashCode() { return Integer.valueOf(name.charAt(0)+(name.charAt(1))); } @@ -70,7 +71,7 @@ public class AddressGroupJson { { if(members==null) { - members= new ArrayList<AddressMembersJson>(); + members= new ArrayList<>(); } return this.members; } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/AddressJson.java b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/AddressJson.java index 555994347..00875864e 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/AddressJson.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/AddressJson.java @@ -41,12 +41,5 @@ public class AddressJson { public void setType(String type) { this.type = type; } - - /*public String getValue() { - return value; - } - public void setValue(String value) { - this.value = value; - }*/ } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/AutoPushTabAdapter.java b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/AutoPushTabAdapter.java index 4e5336a05..93d332ce3 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/AutoPushTabAdapter.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/AutoPushTabAdapter.java @@ -21,22 +21,22 @@ package org.onap.policy.rest.adapter; -import java.util.ArrayList; +import java.util.List; public class AutoPushTabAdapter { - private ArrayList<Object> pdpDatas; - private ArrayList<Object> policyDatas; - public ArrayList<Object> getPdpDatas() { + private List<Object> pdpDatas; + private List<Object> policyDatas; + public List<Object> getPdpDatas() { return pdpDatas; } - public void setPdpDatas(ArrayList<Object> pdpDatas) { + public void setPdpDatas(List<Object> pdpDatas) { this.pdpDatas = pdpDatas; } - public ArrayList<Object> getPolicyDatas() { + public List<Object> getPolicyDatas() { return policyDatas; } - public void setPolicyDatas(ArrayList<Object> policyDatas) { + public void setPolicyDatas(List<Object> policyDatas) { this.policyDatas = policyDatas; } } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ClosedLoopPerformanceMetrics.java b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ClosedLoopPerformanceMetrics.java index 32839e97a..97546460a 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ClosedLoopPerformanceMetrics.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ClosedLoopPerformanceMetrics.java @@ -33,4 +33,8 @@ public class ClosedLoopPerformanceMetrics { public static final String CLPM_UIFIELD_GEOLINK = "Geo Link"; public static final String CLPM_UIJSON_GEOLINK = "geoLink"; + + private ClosedLoopPerformanceMetrics() { + // Empty constructor + } } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ClosedLoopPolicy.java b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ClosedLoopPolicy.java index a230db84e..ea1cfb548 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ClosedLoopPolicy.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ClosedLoopPolicy.java @@ -58,4 +58,7 @@ public class ClosedLoopPolicy { public static final String CLFAULT_UIFIELD_POLICY_STATUS_INACTIVE = "InActive"; public static final String CLFAULT_UIJSON_POLICY_STATUS_INACTIVE = "INACTIVE"; + private ClosedLoopPolicy(){ + // Empty constructor + } } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/GridData.java b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/GridData.java index 77bbf0378..4e5b4a313 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/GridData.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/GridData.java @@ -21,34 +21,34 @@ package org.onap.policy.rest.adapter; -import java.util.ArrayList; +import java.util.List; public class GridData { - private ArrayList<Object> attributes; - private ArrayList<Object> transportProtocols; - private ArrayList<Object> appProtocols; + private List<Object> attributes; + private List<Object> transportProtocols; + private List<Object> appProtocols; - public ArrayList<Object> getAttributes() { + public List<Object> getAttributes() { return attributes; } - public void setAttributes(ArrayList<Object> attributes) { + public void setAttributes(List<Object> attributes) { this.attributes = attributes; } - public ArrayList<Object> getAppProtocols() { + public List<Object> getAppProtocols() { return appProtocols; } - public void setAppProtocols(ArrayList<Object> appProtocols) { + public void setAppProtocols(List<Object> appProtocols) { this.appProtocols = appProtocols; } - public ArrayList<Object> getTransportProtocols() { + public List<Object> getTransportProtocols() { return transportProtocols; } - public void setTransportProtocols(ArrayList<Object> transportProtocols) { + public void setTransportProtocols(List<Object> transportProtocols) { this.transportProtocols = transportProtocols; } } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyExportAdapter.java b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyExportAdapter.java index 21efb9b48..2b42207ff 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyExportAdapter.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyExportAdapter.java @@ -21,16 +21,16 @@ package org.onap.policy.rest.adapter; -import java.util.ArrayList; +import java.util.List; public class PolicyExportAdapter { - private ArrayList<Object> policyDatas; + private List<Object> policyDatas; - public ArrayList<Object> getPolicyDatas() { + public List<Object> getPolicyDatas() { return policyDatas; } - public void setPolicyDatas(ArrayList<Object> policyDatas) { + public void setPolicyDatas(List<Object> policyDatas) { this.policyDatas = policyDatas; } } 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 1eb4da890..b4056a3a0 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 @@ -83,15 +83,15 @@ public class PolicyRestAdapter { private Object jsonBodyData; private String dirPath; private String configBodyPath; - private ArrayList<Object> attributes; - private ArrayList<Object> settings; - private ArrayList<Object> ruleAlgorithmschoices; + private List<Object> attributes; + private List<Object> settings; + private List<Object> ruleAlgorithmschoices; - private LinkedHashMap<?, ?> serviceTypePolicyName; + private Map<?, ?> serviceTypePolicyName; - private LinkedHashMap<?, ?> verticaMetrics; - private LinkedHashMap<?, ?> description; - private LinkedHashMap<?, ?> attributeFields; + private Map<?, ?> verticaMetrics; + private Map<?, ?> description; + private Map<?, ?> attributeFields; //ClosedLoop private String clearTimeOut; @@ -101,7 +101,7 @@ public class PolicyRestAdapter { //FireWall private String fwPolicyType; - private ArrayList<Object> fwattributes; + private List<Object> fwattributes; private String parentForChild; private String securityZone; @@ -159,24 +159,24 @@ public class PolicyRestAdapter { private String ttlDate; private Map<String,String> matching; - private ArrayList<Object> triggerSignatures; - private ArrayList<Object> symptomSignatures; + private List<Object> triggerSignatures; + private List<Object> symptomSignatures; private String logicalConnector; private String policyStatus; private String gocServerScope; private String supressionType; - public ArrayList<Object> getTriggerSignatures() { + public List<Object> getTriggerSignatures() { return triggerSignatures; } - public void setTriggerSignatures(ArrayList<Object> triggerSignatures) { + public void setTriggerSignatures(List<Object> triggerSignatures) { this.triggerSignatures = triggerSignatures; } - public ArrayList<Object> getSymptomSignatures() { + public List<Object> getSymptomSignatures() { return symptomSignatures; } - public void setSymptomSignatures(ArrayList<Object> symptomSignatures) { + public void setSymptomSignatures(List<Object> symptomSignatures) { this.symptomSignatures = symptomSignatures; } public String getLogicalConnector() { @@ -647,43 +647,43 @@ public class PolicyRestAdapter { public void setConfigBodyPath(String configBodyPath) { this.configBodyPath = configBodyPath; } - public ArrayList<Object> getAttributes() { + public List<Object> getAttributes() { return attributes; } - public void setAttributes(ArrayList<Object> attributes) { + public void setAttributes(List<Object> attributes) { this.attributes = attributes; } - public ArrayList<Object> getSettings() { + public List<Object> getSettings() { return settings; } - public void setSettings(ArrayList<Object> settings) { + public void setSettings(List<Object> settings) { this.settings = settings; } - public ArrayList<Object> getRuleAlgorithmschoices() { + public List<Object> getRuleAlgorithmschoices() { return ruleAlgorithmschoices; } - public void setRuleAlgorithmschoices(ArrayList<Object> ruleAlgorithmschoices) { + public void setRuleAlgorithmschoices(List<Object> ruleAlgorithmschoices) { this.ruleAlgorithmschoices = ruleAlgorithmschoices; } - public LinkedHashMap<?, ?> getServiceTypePolicyName() { + public Map<?, ?> getServiceTypePolicyName() { return serviceTypePolicyName; } - public void setServiceTypePolicyName(LinkedHashMap<?, ?> serviceTypePolicyName) { + public void setServiceTypePolicyName(Map<?, ?> serviceTypePolicyName) { this.serviceTypePolicyName = serviceTypePolicyName; } - public LinkedHashMap<?, ?> getVerticaMetrics() { + public Map<?, ?> getVerticaMetrics() { return verticaMetrics; } - public void setVerticaMetrics(LinkedHashMap<?, ?> verticaMetrics) { + public void setVerticaMetrics(Map<?, ?> verticaMetrics) { this.verticaMetrics = verticaMetrics; } - public LinkedHashMap<?, ?> getDescription() { + public Map<?, ?> getDescription() { return description; } public void setDescription(LinkedHashMap<?, ?> description) { this.description = description; } - public LinkedHashMap<?, ?> getAttributeFields() { + public Map<?, ?> getAttributeFields() { return attributeFields; } public void setAttributeFields(LinkedHashMap<?, ?> attributeFields) { @@ -719,10 +719,10 @@ public class PolicyRestAdapter { public void setFwPolicyType(String fwPolicyType) { this.fwPolicyType = fwPolicyType; } - public ArrayList<Object> getFwattributes() { + public List<Object> getFwattributes() { return fwattributes; } - public void setFwattributes(ArrayList<Object> fwattributes) { + public void setFwattributes(List<Object> fwattributes) { this.fwattributes = fwattributes; } public String getParentForChild() { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PrefixIPList.java b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PrefixIPList.java index c9b5b0cf1..23ae537bb 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PrefixIPList.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PrefixIPList.java @@ -51,7 +51,7 @@ public class PrefixIPList { { if(members==null) { - members= new ArrayList<AddressMembers>(); + members= new ArrayList<>(); } return this.members; } @@ -60,13 +60,5 @@ public class PrefixIPList { { this.members = members; } - /*public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - }*/ - } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/RainyDayParams.java b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/RainyDayParams.java index 809a8814b..ce31b88ee 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/RainyDayParams.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/RainyDayParams.java @@ -20,7 +20,6 @@ package org.onap.policy.rest.adapter; -import java.util.ArrayList; import java.util.List; public class RainyDayParams { @@ -28,7 +27,7 @@ public class RainyDayParams { private String vnfType; private String bbid; private String workstep; - private ArrayList<Object> treatmentTableChoices; + private List<Object> treatmentTableChoices; private List<String> errorcode; private List<String> treatment; @@ -83,13 +82,13 @@ public class RainyDayParams { /** * @return the treatmentTableChoices */ - public ArrayList<Object> getTreatmentTableChoices() { + public List<Object> getTreatmentTableChoices() { return treatmentTableChoices; } /** * @param treatmentTableChoices the treatmentTableChoices to set */ - public void setTreatmentTableChoices(ArrayList<Object> treatmentTableChoices) { + public void setTreatmentTableChoices(List<Object> treatmentTableChoices) { this.treatmentTableChoices = treatmentTableChoices; } /** diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ServiceGroupJson.java b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ServiceGroupJson.java index 0d06552b1..363f73f7e 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ServiceGroupJson.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ServiceGroupJson.java @@ -38,7 +38,8 @@ public class ServiceGroupJson { public void setName(String value) { this.name = value; } - + + @Override public boolean equals(Object obj){ if(obj == null){ return false; @@ -52,8 +53,9 @@ public class ServiceGroupJson { } return false; } - - public int hashCode() { + + @Override + public int hashCode() { return Integer.valueOf(name.charAt(0)+(name.charAt(1))); } @@ -70,7 +72,7 @@ public class ServiceGroupJson { { if(members==null) { - members= new ArrayList<ServiceMembers>(); + members= new ArrayList<>(); } return this.members; } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ServiceListJson.java b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ServiceListJson.java index f64abb83f..f80f51908 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ServiceListJson.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ServiceListJson.java @@ -38,7 +38,8 @@ public class ServiceListJson { public void setName(String value) { this.name = value; } - + + @Override public boolean equals(Object obj){ if(obj == null){ return false; @@ -52,14 +53,15 @@ public class ServiceListJson { } return false; } - - public int hashCode() { + + @Override + public int hashCode() { if(name!=null){ return Integer.valueOf(name.charAt(0)+(name.charAt(1))); }else{ return 0; } - } + } public String getDescription() { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/Term.java b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/Term.java index 7188e3558..d709f0df3 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/Term.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/Term.java @@ -67,7 +67,7 @@ public class Term { public List<String> getFromZones() { if (fromZones==null) { - fromZones= new ArrayList<String>(); + fromZones= new ArrayList<>(); } return fromZones; } @@ -80,7 +80,7 @@ public class Term { public List<String> getToZones() { if (toZones==null) { - toZones= new ArrayList<String>(); + toZones= new ArrayList<>(); } return toZones; } @@ -113,7 +113,7 @@ public class Term { { if(sourceList==null) { - sourceList= new ArrayList<AddressJson>(); + sourceList= new ArrayList<>(); } return this.sourceList; } @@ -127,7 +127,7 @@ public class Term { { if(destinationList==null) { - destinationList= new ArrayList<AddressJson>(); + destinationList= new ArrayList<>(); } return this.destinationList; } @@ -140,7 +140,7 @@ public class Term { public List<ServicesJson> getSourceServices() { if(sourceServices==null) { - sourceServices= new ArrayList<ServicesJson>(); + sourceServices= new ArrayList<>(); } return this.sourceServices; } @@ -153,7 +153,7 @@ public class Term { public Set<ServicesJson> getDestServices() { if(destServices==null) { - destServices= new HashSet<ServicesJson>(); + destServices= new HashSet<>(); } return this.destServices; } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/TermCollector.java b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/TermCollector.java index cfc91f089..76a80cb1c 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/TermCollector.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/TermCollector.java @@ -90,7 +90,7 @@ public class TermCollector { public Set<Object> getServiceGroups() { if(serviceGroups==null) { - serviceGroups= new HashSet<Object>(); + serviceGroups= new HashSet<>(); } return this.serviceGroups; } @@ -103,7 +103,7 @@ public class TermCollector { public Set<Object> getAddressGroups() { if(addressGroups==null) { - addressGroups= new HashSet<Object>(); + addressGroups= new HashSet<>(); } return this.addressGroups; } @@ -117,7 +117,7 @@ public class TermCollector { if(firewallRuleList==null) { - firewallRuleList= new ArrayList<Term>(); + firewallRuleList= new ArrayList<>(); } return this.firewallRuleList; } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/VendorSpecificData.java b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/VendorSpecificData.java index 740aa838c..a9c645e8a 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/VendorSpecificData.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/VendorSpecificData.java @@ -25,7 +25,7 @@ import java.util.List; public class VendorSpecificData { - private List<IdMap> idMap= new ArrayList<IdMap>(); + private List<IdMap> idMap= new ArrayList<>(); public List<IdMap> getIdMap() { return idMap; diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/dao/PolicyDBException.java b/ONAP-REST/src/main/java/org/onap/policy/rest/dao/PolicyDBException.java index d1ed7f610..df6bf12b2 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/dao/PolicyDBException.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/dao/PolicyDBException.java @@ -29,6 +29,7 @@ public class PolicyDBException extends Exception { private static final long serialVersionUID = -6162444281003852781L; public PolicyDBException() { + // Empty constructor } public PolicyDBException(String message) { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ActionBodyEntity.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ActionBodyEntity.java index 1c1c3f4fe..9336a907b 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ActionBodyEntity.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ActionBodyEntity.java @@ -90,6 +90,7 @@ public class ActionBodyEntity implements Serializable { private boolean deleted = false; public ActionBodyEntity() { + //An empty constructor } @PrePersist @@ -110,7 +111,7 @@ public class ActionBodyEntity implements Serializable { return actionBodyId; } /** - * @param configurationDataId the configurationDataId to set + * @param name the configuration body name to set */ public void setActionBodyName(String name) { this.actionBodyName = name; @@ -126,7 +127,7 @@ public class ActionBodyEntity implements Serializable { return actionBody; } /** - * @param configBody the configBody to set + * @param body the configBody to set */ public void setActionBody(String body) { this.actionBody = body; @@ -213,8 +214,7 @@ public class ActionBodyEntity implements Serializable { return false; } - return ( - actionBodyId == ((ActionBodyEntity) obj).actionBodyId && + return actionBodyId == ((ActionBodyEntity) obj).actionBodyId && actionBodyName.equals(((ActionBodyEntity) obj).actionBodyName) && version == ((ActionBodyEntity) obj).version && actionBody.equals(((ActionBodyEntity) obj).actionBody) && @@ -222,7 +222,6 @@ public class ActionBodyEntity implements Serializable { createdDate.equals(((ActionBodyEntity) obj).createdDate) && modifiedBy.equals(((ActionBodyEntity) obj).modifiedBy) && modifiedDate.equals(((ActionBodyEntity) obj).modifiedDate) && - deleted == ((ActionBodyEntity) obj).deleted - ); + deleted == ((ActionBodyEntity) obj).deleted; } } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ActionList.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ActionList.java index 6be8cd7a8..7d46330f0 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ActionList.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ActionList.java @@ -53,28 +53,25 @@ public class ActionList implements Serializable { @Column(name="description") private String description; -/* - @Temporal(TemporalType.TIMESTAMP) - @Column(name="modified_date", nullable=false) - private Date modifiedDate;*/ public ActionList() { - + //An empty constructor } public ActionList(String string, String userid) { this(domain); } public ActionList(String domain) { - + //An empty constructor } @PrePersist public void prePersist() { - + //An empty function } @PreUpdate public void preUpdate() { + //An empty function } public String getActionName() { return this.actionName; diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ActionPolicyDict.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ActionPolicyDict.java index bf8a73161..fff1bf804 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ActionPolicyDict.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ActionPolicyDict.java @@ -118,7 +118,7 @@ public class ActionPolicyDict implements Serializable { private static Log logger = LogFactory.getLog(ActionPolicyDict.class); public ActionPolicyDict() { - + //An empty constructor } public ActionPolicyDict(String string, String userid) { @@ -138,10 +138,9 @@ public class ActionPolicyDict implements Serializable { public void preUpdate() { this.modifiedDate = new Date(); try { - this.userModifiedBy =XacmlAdminAuthorization.getUserId();; + this.userModifiedBy =XacmlAdminAuthorization.getUserId(); } catch (Exception e) { logger.error("Exception caused While adding Modified by Role"+e); - //PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "ActionPolicyDict", "Exception caused While adding Modified by Role"); } } public int getId() { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/AddressGroup.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/AddressGroup.java index 2a14e709a..c3673f336 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/AddressGroup.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/AddressGroup.java @@ -59,22 +59,23 @@ public class AddressGroup implements Serializable { private String description; public AddressGroup() { - + //An empty constructor } public AddressGroup(String string, String userid) { this(domain); } public AddressGroup(String domain) { - + //An empty constructor } @PrePersist public void prePersist() { - + //An empty function } @PreUpdate public void preUpdate() { + //An empty function } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Attribute.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Attribute.java index 7285e2e36..ea89eeac9 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Attribute.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Attribute.java @@ -151,6 +151,7 @@ public class Attribute implements Serializable { public Attribute() { + //An empty constructor } public Attribute(String domain) { @@ -230,11 +231,7 @@ public class Attribute implements Serializable { public String getXacmlId() { return this.xacmlId; } - -/* @Transient - public Identifier getXacmlIdentifier() { - return new IdentifierImpl(this.xacmlId); - }*/ + public void setXacmlId(String xacmlId) { this.xacmlId = xacmlId; @@ -332,7 +329,7 @@ public class Attribute implements Serializable { @Transient public boolean isDesignator() { - return (this.isDesignator == '1'); + return this.isDesignator == '1'; } @Transient diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/AttributeAssignment.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/AttributeAssignment.java index 7a1be9e7d..75e3d681e 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/AttributeAssignment.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/AttributeAssignment.java @@ -65,6 +65,7 @@ public class AttributeAssignment implements Serializable { private Obadvice obadvice; public AttributeAssignment() { + //An empty constructor } public int getId() { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BRMSParamTemplate.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BRMSParamTemplate.java index 5a78df227..8dd2a5995 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BRMSParamTemplate.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BRMSParamTemplate.java @@ -87,10 +87,11 @@ public class BRMSParamTemplate implements Serializable{ } public BRMSParamTemplate(){ + //An empty constructor } public BRMSParamTemplate(String userid){ - + //An empty constructor } @PrePersist diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Category.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Category.java index 1d0f0e456..275b03e5a 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Category.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Category.java @@ -170,12 +170,12 @@ public class Category implements Serializable { @Transient public boolean isStandard() { - return (this.isStandard == Category.STANDARD); + return this.isStandard == Category.STANDARD; } @Transient public boolean isCustom() { - return (this.isStandard == Category.CUSTOM); + return this.isStandard == Category.CUSTOM; } @Transient diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoopD2Services.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoopD2Services.java index f4ade220e..c69476fac 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoopD2Services.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoopD2Services.java @@ -103,7 +103,7 @@ public class ClosedLoopD2Services implements Serializable{ private static Log LOGGER = LogFactory.getLog(ClosedLoopD2Services.class); public ClosedLoopD2Services(){ - + //An empty constructor } public ClosedLoopD2Services(String string, String userid) { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoopSite.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoopSite.java index 6fbf9fb11..c3acf9a21 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoopSite.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoopSite.java @@ -105,7 +105,7 @@ public class ClosedLoopSite implements Serializable{ private static Log LOGGER = LogFactory.getLog(ClosedLoopSite.class); public ClosedLoopSite(){ - + //An empty constructor } public ClosedLoopSite(String string, String userid) { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoops.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoops.java index bb5b4bda7..53695d81a 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoops.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoops.java @@ -61,7 +61,7 @@ public class ClosedLoops implements Serializable { private String yaml; public ClosedLoops() { - + //An empty constructor } public int getId() { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConfigurationDataEntity.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConfigurationDataEntity.java index 3386e9a51..4c15c525e 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConfigurationDataEntity.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConfigurationDataEntity.java @@ -97,6 +97,7 @@ public class ConfigurationDataEntity implements Serializable { private boolean deleted = false; public ConfigurationDataEntity() { + //An empty constructor } @PrePersist @@ -242,8 +243,7 @@ public class ConfigurationDataEntity implements Serializable { return false; } - return ( - configurationDataId == ((ConfigurationDataEntity) obj).configurationDataId && + return configurationDataId == ((ConfigurationDataEntity) obj).configurationDataId && configurationName.equals(((ConfigurationDataEntity) obj).configurationName) && version == ((ConfigurationDataEntity) obj).version && configType.equals(((ConfigurationDataEntity) obj).configType) && @@ -253,7 +253,6 @@ public class ConfigurationDataEntity implements Serializable { description.equals(((ConfigurationDataEntity) obj).description) && modifiedBy.equals(((ConfigurationDataEntity) obj).modifiedBy) && modifiedDate.equals(((ConfigurationDataEntity) obj).modifiedDate) && - deleted == ((ConfigurationDataEntity) obj).deleted - ); + deleted == ((ConfigurationDataEntity) obj).deleted; } } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConstraintType.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConstraintType.java index eeadeb0fc..77e883907 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConstraintType.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConstraintType.java @@ -69,7 +69,7 @@ public class ConstraintType implements Serializable { private Set<Attribute> attributes = new HashSet<>(); public ConstraintType() { - + //An empty constructor } public ConstraintType(String constraintType) { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConstraintValue.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConstraintValue.java index 57e9af8b8..4943a41c8 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConstraintValue.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConstraintValue.java @@ -60,6 +60,7 @@ public class ConstraintValue implements Serializable { private Attribute attribute; public ConstraintValue() { + //An empty constructor } public ConstraintValue(String property, String value) { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DCAEUsers.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DCAEUsers.java index 27d5d2790..1b08c1cc5 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DCAEUsers.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DCAEUsers.java @@ -57,22 +57,23 @@ public class DCAEUsers implements Serializable { public DCAEUsers() { - + //An empty constructor } public DCAEUsers(String string, String userid) { this(domain); } public DCAEUsers(String domain) { - + //An empty constructor } @PrePersist public void prePersist() { - + //An empty function } @PreUpdate public void preUpdate() { + //An empty function } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DCAEuuid.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DCAEuuid.java index b7f9243bc..dc6960997 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DCAEuuid.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DCAEuuid.java @@ -57,22 +57,23 @@ public class DCAEuuid implements Serializable { public DCAEuuid() { - + //An empty constructor } public DCAEuuid(String string, String userid) { this(domain); } public DCAEuuid(String domain) { - + //An empty constructor } @PrePersist public void prePersist() { - + //An empty function } @PreUpdate public void preUpdate() { + //An empty function } public String getDescription() { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DatabaseLockEntity.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DatabaseLockEntity.java index 7b5a8954e..42418883b 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DatabaseLockEntity.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DatabaseLockEntity.java @@ -35,7 +35,7 @@ public class DatabaseLockEntity implements Serializable { @Column(name="lock_key") private int lock_key = 1; public DatabaseLockEntity(){ - + //An empty constructor } public int getKey(){ return lock_key; diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Datatype.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Datatype.java index 6be1a84ce..15948bd6d 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Datatype.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Datatype.java @@ -222,12 +222,12 @@ public class Datatype implements Serializable { @Transient public boolean isStandard() { - return (this.isStandard == Datatype.STANDARD); + return this.isStandard == Datatype.STANDARD; } @Transient public boolean isCustom() { - return (this.isStandard == Datatype.CUSTOM); + return this.isStandard == Datatype.CUSTOM; } @Transient @@ -237,8 +237,6 @@ public class Datatype implements Serializable { + ", xacmlId=" + xacmlId + ", shortName=" + shortName + ", attributes=" + attributes + ", functions=" + functions + ", arguments=" + arguments + "]"; - - //return "Datatype [shortName=" + shortName + "]"; } } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DecisionSettings.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DecisionSettings.java index 164cc3cef..e0ed676d7 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DecisionSettings.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DecisionSettings.java @@ -110,6 +110,7 @@ public class DecisionSettings implements Serializable { } public DecisionSettings() { + //An empty constructor } public DecisionSettings(String domain) { @@ -144,7 +145,7 @@ public class DecisionSettings implements Serializable { public void preUpdate() { this.modifiedDate = new Date(); try { - this.userModifiedBy = XacmlAdminAuthorization.getUserId();; + this.userModifiedBy = XacmlAdminAuthorization.getUserId(); } catch (Exception e) { PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "DecisionSettings", "Exception caused While adding Modified by Role"); } @@ -186,11 +187,6 @@ public class DecisionSettings implements Serializable { public String getXacmlId() { return this.xacmlId; } - -/* @Transient - public Identifier getXacmlIdentifier() { - return new IdentifierImpl(this.xacmlId); - }*/ public void setXacmlId(String xacmlId) { this.xacmlId = xacmlId; diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DescriptiveScope.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DescriptiveScope.java index 30882fc13..68a00db98 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DescriptiveScope.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DescriptiveScope.java @@ -102,7 +102,7 @@ public class DescriptiveScope implements Serializable { private static Log LOGGER = LogFactory.getLog(DescriptiveScope.class); public DescriptiveScope(){ - + //An empty constructor } public DescriptiveScope(String string, String userid) { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FWTag.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FWTag.java index 71f4d6a6a..ed6981152 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FWTag.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FWTag.java @@ -100,7 +100,7 @@ public class FWTag implements Serializable { private static Log LOGGER = LogFactory.getLog(FWTag.class); public FWTag(){ - + //An empty constructor } public FWTag(String string, String userid) { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FWTagPicker.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FWTagPicker.java index 6f03b4915..6090558ae 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FWTagPicker.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FWTagPicker.java @@ -86,7 +86,7 @@ public class FWTagPicker implements Serializable { private static Log logger = LogFactory.getLog(FWTagPicker.class); public FWTagPicker(){ - + //An empty constructor } public FWTagPicker(String string, String userid) { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FirewallDictionaryList.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FirewallDictionaryList.java index 27f5e75bd..5644d4a3d 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FirewallDictionaryList.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FirewallDictionaryList.java @@ -57,22 +57,6 @@ public class FirewallDictionaryList implements Serializable { @Column(name="serviceList") private String serviceList; - -/* @Temporal(TemporalType.TIMESTAMP) - @Column(name="created_date", updatable=false) - private Date createdDate; - - @Temporal(TemporalType.TIMESTAMP) - @Column(name="modified_date", nullable=false) - private Date modifiedDate; - - @ManyToOne(optional = false) - @JoinColumn(name="created_by") - private UserInfo userCreatedBy; - - @ManyToOne(optional = false) - @JoinColumn(name="modified_by") - private UserInfo userModifiedBy;*/ public int getId() { return this.id; @@ -113,26 +97,9 @@ public class FirewallDictionaryList implements Serializable { public void setServiceList(String serviceList) { this.serviceList = serviceList; } - - - /*public UserInfo getUserCreatedBy() { - return userCreatedBy; - } - - public void setUserCreatedBy(UserInfo userCreatedBy) { - this.userCreatedBy = userCreatedBy; - } - - public UserInfo getUserModifiedBy() { - return userModifiedBy; - } - - public void setUserModifiedBy(UserInfo userModifiedBy) { - this.userModifiedBy = userModifiedBy; - }*/ public FirewallDictionaryList() { - + //An empty constructor } public FirewallDictionaryList(String string, String userid) { @@ -142,23 +109,4 @@ public class FirewallDictionaryList implements Serializable { this.parentItemName = domain; } - /*@PrePersist - public void prePersist() { - Date date = new Date(); - this.createdDate = date; - this.modifiedDate = date; - auditLogger.debug("Added New Term Name: "+this.parentItemName+" by "+this.userCreatedBy); - - } - @PreUpdate - public void preUpdate() { - this.modifiedDate = new Date(); - try { - this.userModifiedBy =XacmlAdminAuthorization.getUserId();; - } catch (Exception e) { - PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "TermList", "Exception caused While adding Modified by Role"); - } - auditLogger.debug("Updated Term Name: "+this.parentItemName+" by "+this.userModifiedBy); - } -*/ } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FunctionArgument.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FunctionArgument.java index 4d712994c..dd4535674 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FunctionArgument.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FunctionArgument.java @@ -57,6 +57,7 @@ public class FunctionArgument implements Serializable { private Datatype datatypeBean; public FunctionArgument() { + //An empty constructor } public FunctionArgument(final FunctionArgument argument) { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FunctionDefinition.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FunctionDefinition.java index c3dfcaa63..d2fa034f1 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FunctionDefinition.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FunctionDefinition.java @@ -81,6 +81,7 @@ public class FunctionDefinition implements Serializable { private List<FunctionArgument> functionArguments; public FunctionDefinition() { + //An empty constructor } public int getId() { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GroupPolicyScopeList.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GroupPolicyScopeList.java index 44f27ba35..55c3bd6ef 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GroupPolicyScopeList.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GroupPolicyScopeList.java @@ -59,22 +59,23 @@ public class GroupPolicyScopeList implements Serializable { private String description; public GroupPolicyScopeList() { - + //An empty constructor } public GroupPolicyScopeList(String string, String userid) { this(domain); } public GroupPolicyScopeList(String domain) { - + //An empty constructor } @PrePersist public void prePersist() { - + //An empty function } @PreUpdate public void preUpdate() { + //An empty function } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GroupServiceList.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GroupServiceList.java index 53fb89d4f..4d1560f0c 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GroupServiceList.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GroupServiceList.java @@ -57,22 +57,23 @@ public class GroupServiceList implements Serializable { public GroupServiceList() { - + //An empty constructor } public GroupServiceList(String string, String userid) { this(domain); } public GroupServiceList(String domain) { - + //An empty constructor } @PrePersist public void prePersist() { - + //An empty function } @PreUpdate public void preUpdate() { + //An empty function } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceAttribute.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceAttribute.java index bb0507123..88db4dd53 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceAttribute.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceAttribute.java @@ -58,22 +58,23 @@ public class MicroServiceAttribute implements Serializable { public MicroServiceAttribute() { - + //An empty constructor } public MicroServiceAttribute(String string, String userid) { this(domain); } public MicroServiceAttribute(String domain) { - + //An empty constructor } @PrePersist public void prePersist() { - + //An empty function } @PreUpdate public void preUpdate() { + //An empty function } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceConfigName.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceConfigName.java index f47b96ed8..90a066b83 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceConfigName.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceConfigName.java @@ -57,22 +57,23 @@ public class MicroServiceConfigName implements Serializable { public MicroServiceConfigName() { - + //An empty constructor } public MicroServiceConfigName(String string, String userid) { this(domain); } public MicroServiceConfigName(String domain) { - + //An empty constructor } @PrePersist public void prePersist() { - + //An empty function } @PreUpdate public void preUpdate() { + //An empty function } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceLocation.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceLocation.java index 4d82a3b20..130de0a83 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceLocation.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceLocation.java @@ -57,22 +57,23 @@ public class MicroServiceLocation implements Serializable { public MicroServiceLocation() { - + //An empty constructor } public MicroServiceLocation(String string, String userid) { this(domain); } public MicroServiceLocation(String domain) { - + //An empty constructor } @PrePersist public void prePersist() { - + //An empty function } @PreUpdate public void preUpdate() { + //An empty function } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceModels.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceModels.java index 513799762..ff4028f2d 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceModels.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceModels.java @@ -117,10 +117,11 @@ public class MicroServiceModels implements Serializable{ } public MicroServiceModels(){ + //An empty constructor } public MicroServiceModels(String userid){ - + //An empty constructor } public String getAttributes() { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ObadviceExpression.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ObadviceExpression.java index 8d5be9742..7b0db3f72 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ObadviceExpression.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ObadviceExpression.java @@ -63,12 +63,6 @@ public class ObadviceExpression implements Serializable { @Column(name="type", nullable=false) private String type; - - /* - @Lob - @Column(name="expression", nullable=false) - private byte[] expression; - */ //bi-directional many-to-one association to Obadvice @ManyToOne diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/OnapName.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/OnapName.java index a4c0c85da..66ee346e1 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/OnapName.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/OnapName.java @@ -97,7 +97,7 @@ public class OnapName implements Serializable { } public OnapName() { - + //An empty constructor } public OnapName(String string, String userid) { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PEPOptions.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PEPOptions.java index c1fff1420..869386f69 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PEPOptions.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PEPOptions.java @@ -104,7 +104,7 @@ public class PEPOptions implements Serializable { private static Log LOGGER = LogFactory.getLog(PEPOptions.class); public PEPOptions(){ - + //An empty constructor } public PEPOptions(String string, String userid) { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPConfigParam.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPConfigParam.java index 1540c8ad8..fb18f7062 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPConfigParam.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPConfigParam.java @@ -58,6 +58,7 @@ public class PIPConfigParam implements Serializable { private PIPConfiguration pipconfiguration; public PIPConfigParam() { + //An empty constructor } public PIPConfigParam(String param) { @@ -125,7 +126,7 @@ public class PIPConfigParam implements Serializable { @Transient public boolean isRequired() { - return (this.required == '1'); + return this.required == '1'; } @Transient diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPConfiguration.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPConfiguration.java index 5d731552b..01f5cfcff 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPConfiguration.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPConfiguration.java @@ -124,6 +124,7 @@ public class PIPConfiguration implements Serializable { private Set<PIPResolver> pipresolvers = new HashSet<>(); public PIPConfiguration() { + //An empty constructor } public PIPConfiguration(PIPConfiguration config, String user) { @@ -316,7 +317,7 @@ public class PIPConfiguration implements Serializable { @Transient public boolean isReadOnly() { - return (this.readOnly == '1'); + return this.readOnly == '1'; } @Transient @@ -330,7 +331,7 @@ public class PIPConfiguration implements Serializable { @Transient public boolean requiresResolvers() { - return (this.requiresResolvers == '1'); + return this.requiresResolvers == '1'; } @Transient @@ -390,21 +391,21 @@ public class PIPConfiguration implements Serializable { // // Go through each property // - for (Object name : properties.keySet()) { - if (name.toString().startsWith(id) == false) { + for (Object nme : properties.keySet()) { + if (nme.toString().startsWith(id) == false) { continue; } - if (name.equals(id + ".classname")) { + if (nme.equals(id + ".classname")) { // // We already saved this // - } else if (name.equals(id + "." + StdConfigurableEngine.PROP_NAME)) { - this.name = properties.getProperty(name.toString()); - } else if (name.equals(id + "." + StdConfigurableEngine.PROP_DESCRIPTION)) { - this.description = properties.getProperty(name.toString()); - } else if (name.equals(id + "." + StdConfigurableEngine.PROP_ISSUER)) { - this.issuer = properties.getProperty(name.toString()); - } else if (name.equals(id + ".resolvers")) { + } else if (nme.equals(id + "." + StdConfigurableEngine.PROP_NAME)) { + this.name = properties.getProperty(nme.toString()); + } else if (nme.equals(id + "." + StdConfigurableEngine.PROP_DESCRIPTION)) { + this.description = properties.getProperty(nme.toString()); + } else if (nme.equals(id + "." + StdConfigurableEngine.PROP_ISSUER)) { + this.issuer = properties.getProperty(nme.toString()); + } else if (nme.equals(id + ".resolvers")) { // // It has resolvers, make sure this is set to true if // it has been already. @@ -414,13 +415,13 @@ public class PIPConfiguration implements Serializable { // Parse the resolvers // Collection<PIPResolver> resolvers = PIPResolver.importResolvers(id + ".resolver", - properties.getProperty(name.toString()), + properties.getProperty(nme.toString()), properties,"super-admin" ); for (PIPResolver resolver : resolvers) { this.addPipresolver(resolver); } - } else if (name.toString().startsWith(id + ".resolver")) { + } else if (nme.toString().startsWith(id + ".resolver")) { // // Ignore, the PIPResolver will parse these values // @@ -428,8 +429,8 @@ public class PIPConfiguration implements Serializable { // // Config Parameter // - this.addPipconfigParam(new PIPConfigParam(name.toString().substring(id.length() + 1), - properties.getProperty(name.toString()))); + this.addPipconfigParam(new PIPConfigParam(nme.toString().substring(id.length() + 1), + properties.getProperty(nme.toString()))); } } // @@ -470,12 +471,12 @@ public class PIPConfiguration implements Serializable { Iterator<PIPResolver> iter = this.pipresolvers.iterator(); while (iter.hasNext()) { PIPResolver resolver = iter.next(); - String id = Integer.toString(resolver.getId()); - Map<String, String> resolverMap = resolver.getConfiguration(prefix + "resolver." + id); + String idd = Integer.toString(resolver.getId()); + Map<String, String> resolverMap = resolver.getConfiguration(prefix + "resolver." + idd); map.putAll(resolverMap); - ids.add(id); + ids.add(idd); } - if (ids.size() > 0) { + if (!ids.isEmpty()) { map.put(prefix + "resolvers", Joiner.on(',').join(ids)); } return map; @@ -512,11 +513,11 @@ public class PIPConfiguration implements Serializable { Iterator<PIPResolver> iter = this.pipresolvers.iterator(); while (iter.hasNext()) { PIPResolver resolver = iter.next(); - String id = Integer.toString(resolver.getId()); - resolver.generateProperties(props, prefix + "resolver." + id); - ids.add(id); + String idd = Integer.toString(resolver.getId()); + resolver.generateProperties(props, prefix + "resolver." + idd); + ids.add(idd); } - if (ids.size() > 0) { + if (!ids.isEmpty()) { props.setProperty(prefix + "resolvers", Joiner.on(',').join(ids)); } return props; diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPResolver.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPResolver.java index daab6d658..4838639f9 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPResolver.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPResolver.java @@ -106,6 +106,7 @@ public class PIPResolver implements Serializable { private Set<PIPResolverParam> pipresolverParams = new HashSet<>(); public PIPResolver() { + //An empty constructor } public PIPResolver(String prefix, Properties properties, String user) throws PIPException { @@ -260,7 +261,7 @@ public class PIPResolver implements Serializable { @Transient public boolean isReadOnly() { - return (this.readOnly == '1'); + return this.readOnly == '1'; } @Transient @@ -293,62 +294,64 @@ public class PIPResolver implements Serializable { // // Go through each property // - for (Object name : properties.keySet()) { - if (name.toString().startsWith(prefix) == false) { + for (Object nme : properties.keySet()) { + if (nme.toString().startsWith(prefix) == false) { continue; } - if (name.equals(prefix + ".classname")) { + if (nme.equals(prefix + ".classname")) { // // We already saved this // - } else if (name.equals(prefix + "." + StdConfigurableEngine.PROP_NAME)) { - this.name = properties.getProperty(name.toString()); - } else if (name.equals(prefix + "." + StdConfigurableEngine.PROP_DESCRIPTION)) { - this.description = properties.getProperty(name.toString()); - } else if (name.equals(prefix + "." + StdConfigurableEngine.PROP_ISSUER)) { - this.issuer = properties.getProperty(name.toString()); + } else if (nme.equals(prefix + "." + StdConfigurableEngine.PROP_NAME)) { + this.name = properties.getProperty(nme.toString()); + } else if (nme.equals(prefix + "." + StdConfigurableEngine.PROP_DESCRIPTION)) { + this.description = properties.getProperty(nme.toString()); + } else if (nme.equals(prefix + "." + StdConfigurableEngine.PROP_ISSUER)) { + this.issuer = properties.getProperty(nme.toString()); } else { - this.addPipresolverParam(new PIPResolverParam(name.toString().substring(prefix.length() + 1), - properties.getProperty(name.toString()))); + this.addPipresolverParam(new PIPResolverParam(nme.toString().substring(prefix.length() + 1), + properties.getProperty(nme.toString()))); } } } @Transient public Map<String, String> getConfiguration(String prefix) { + String pref = prefix; Map<String, String> map = new HashMap<>(); if (prefix.endsWith(".") == false) { - prefix = prefix + "."; + pref = prefix + "."; } - map.put(prefix + "classname", this.classname); - map.put(prefix + "name", this.name); + map.put(pref + "classname", this.classname); + map.put(pref + "name", this.name); if (this.description != null) { - map.put(prefix + "description", this.description); + map.put(pref + "description", this.description); } if (this.issuer != null && this.issuer.isEmpty() != false) { - map.put(prefix + "issuer", this.issuer); + map.put(pref + "issuer", this.issuer); } for (PIPResolverParam param : this.pipresolverParams) { - map.put(prefix + param.getParamName(), param.getParamValue()); + map.put(pref + param.getParamName(), param.getParamValue()); } return map; } @Transient public void generateProperties(Properties props, String prefix) { + String pref = prefix; if (prefix.endsWith(".") == false) { - prefix = prefix + "."; + pref = prefix + "."; } - props.setProperty(prefix + "classname", this.classname); - props.setProperty(prefix + "name", this.name); + props.setProperty(pref + "classname", this.classname); + props.setProperty(pref + "name", this.name); if (this.description != null) { - props.setProperty(prefix + "description", this.description); + props.setProperty(pref + "description", this.description); } if (this.issuer != null && this.issuer.isEmpty() != false) { - props.setProperty(prefix + "issuer", this.issuer); + props.setProperty(pref + "issuer", this.issuer); } for (PIPResolverParam param : this.pipresolverParams) { - props.setProperty(prefix + param.getParamName(), param.getParamValue()); + props.setProperty(pref + param.getParamName(), param.getParamValue()); } } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPResolverParam.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPResolverParam.java index 8dec7915a..3db0e0f0d 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPResolverParam.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPResolverParam.java @@ -58,6 +58,7 @@ public class PIPResolverParam implements Serializable { private PIPResolver pipresolver; public PIPResolverParam() { + // Empty constructor } public PIPResolverParam(String name) { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPType.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPType.java index 0ef4388c4..61ab9ffca 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPType.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPType.java @@ -63,6 +63,7 @@ public class PIPType implements Serializable { private Set<PIPConfiguration> pipconfigurations; public PIPType() { + // Empty constructor } public int getId() { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyAlgorithms.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyAlgorithms.java index 4488fcd30..c21b832b6 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyAlgorithms.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyAlgorithms.java @@ -89,12 +89,12 @@ public class PolicyAlgorithms implements Serializable { @Transient public boolean isStandard() { - return (this.isStandard == PolicyAlgorithms.STANDARD); + return this.isStandard == PolicyAlgorithms.STANDARD; } @Transient public boolean isCustom() { - return (this.isStandard == PolicyAlgorithms.CUSTOM); + return this.isStandard == PolicyAlgorithms.CUSTOM; } public String getXacmlId() { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyEditorScopes.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyEditorScopes.java index bfb4218ab..698ec36da 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyEditorScopes.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyEditorScopes.java @@ -79,7 +79,8 @@ public class PolicyEditorScopes implements Serializable{ @JoinColumn(name="modified_by") private UserInfo userModifiedBy; - public PolicyEditorScopes() { + public PolicyEditorScopes() { + // Empty constructor } public PolicyEditorScopes(String string, String userid) { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyEntity.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyEntity.java index 6c7b8cf6f..c262aec4e 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyEntity.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyEntity.java @@ -310,8 +310,7 @@ public class PolicyEntity implements Serializable { PolicyEntity p = (PolicyEntity) obj; - return ( - policyId == p.policyId && + return policyId == p.policyId && policyName.equals(p.policyName) && scope.equals(p.scope) && version == p.version && @@ -324,8 +323,7 @@ public class PolicyEntity implements Serializable { description.equals(p.description) && modifiedBy.equals(p.modifiedBy) && modifiedDate.equals(p.modifiedDate) && - deleted == p.deleted - ); + deleted == p.deleted; } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyRoles.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyRoles.java index 99d6075a3..e7230d694 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyRoles.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyRoles.java @@ -73,6 +73,7 @@ public class PolicyRoles implements Serializable { private String role; public PolicyRoles() { + // Empty constructor } public int getId() { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeClosedLoop.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeClosedLoop.java index 6fc45eb70..9f437ce28 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeClosedLoop.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeClosedLoop.java @@ -56,22 +56,23 @@ public class PolicyScopeClosedLoop implements Serializable { private String description ; public PolicyScopeClosedLoop() { - + // Empty constructor } public PolicyScopeClosedLoop(String string, String userid) { this(domain); } public PolicyScopeClosedLoop(String domain) { - + // Empty constructor } @PrePersist public void prePersist() { - + // Empty function } @PreUpdate public void preUpdate() { + // Empty function } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeResource.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeResource.java index f9ec94564..9d71600e9 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeResource.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeResource.java @@ -56,22 +56,23 @@ public class PolicyScopeResource implements Serializable { private String description ; public PolicyScopeResource() { - + // Empty constructor } public PolicyScopeResource(String string, String userid) { this(domain); } public PolicyScopeResource(String domain) { - + // Empty constructor } @PrePersist public void prePersist() { - + // Empty function } @PreUpdate public void preUpdate() { + // Empty function } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeService.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeService.java index 84e85570b..ec95d1691 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeService.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeService.java @@ -56,22 +56,23 @@ public class PolicyScopeService implements Serializable { private String description ; public PolicyScopeService() { - + // Empty constructor } public PolicyScopeService(String string, String userid) { this(domain); } public PolicyScopeService(String domain) { - + // Empty constructor } @PrePersist public void prePersist() { - + // Empty function } @PreUpdate public void preUpdate() { + // Empty function } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeType.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeType.java index 48f17b0fc..92252b043 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeType.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeType.java @@ -56,22 +56,23 @@ public class PolicyScopeType implements Serializable { private String description ; public PolicyScopeType() { - + // Empty constructor } public PolicyScopeType(String string, String userid) { this(domain); } public PolicyScopeType(String domain) { - + // Empty constructor } @PrePersist public void prePersist() { - + // Empty function } @PreUpdate public void preUpdate() { + // Empty function } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScore.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScore.java index 3ad4b9b85..a9e776580 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScore.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScore.java @@ -62,7 +62,7 @@ public class PolicyScore implements Serializable { private String PolicyScore; public PolicyScore() { - + // Empty constructor } public PolicyScore(String pName, String pScore) { @@ -70,7 +70,7 @@ public class PolicyScore implements Serializable { } public PolicyScore(String domain) { - + // Empty constructor } public int getId() { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyVersion.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyVersion.java index dd51bee2a..663d34a17 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyVersion.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyVersion.java @@ -21,7 +21,6 @@ package org.onap.policy.rest.jpa; import java.io.Serializable; -//import java.sql.Clob; import java.sql.Timestamp; import java.util.Date; import java.util.Objects; @@ -109,7 +108,7 @@ public class PolicyVersion implements Serializable { } public PolicyVersion(){ - + // Empty constructor } @PrePersist @@ -122,14 +121,6 @@ public class PolicyVersion implements Serializable { @PreUpdate public void preUpdate() { this.modifiedDate = new Date(); - /* - * The modifiedBy must be set via the setModifiedBy() method since PolicyVersion - * has been moved to XACML-REST module for access from the XACML-PAP-REST module - - String userid = ((XacmlAdminUI) UI.getCurrent()).getLoginUserId(); - this.modifiedBy =userid; - * - */ } public int getId() { @@ -200,16 +191,14 @@ public class PolicyVersion implements Serializable { PolicyVersion p = (PolicyVersion) obj; - return ( - id == p.id && + return id == p.id && policyName.equals(p.policyName) && activeVersion == p.activeVersion && higherVersion == p.higherVersion && createdDate.equals(p.createdDate) && createdBy.equals(p.createdBy) && modifiedDate.equals(p.modifiedDate) && - modifiedBy.equals(p.modifiedBy) - ); + modifiedBy.equals(p.modifiedBy); } } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PortList.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PortList.java index 5d2f35414..e696b1d06 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PortList.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PortList.java @@ -59,22 +59,23 @@ public class PortList implements Serializable { private Date modifiedDate;*/ public PortList() { - + // Empty constructor } public PortList(String string, String userid) { this(domain); } public PortList(String domain) { - + // Empty constructor } @PrePersist public void prePersist() { - + // Empty function } @PreUpdate public void preUpdate() { + // Empty function } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PrefixList.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PrefixList.java index 98e940228..16ef24cf7 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PrefixList.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PrefixList.java @@ -56,28 +56,25 @@ public class PrefixList implements Serializable { @Column(name="pl_value", nullable=false) private String prefixListValue; -/* - @Temporal(TemporalType.TIMESTAMP) - @Column(name="modified_date", nullable=false) - private Date modifiedDate;*/ public PrefixList() { - + // Empty constructor } public PrefixList(String string, String userid) { this(domain); } public PrefixList(String domain) { - + // Empty constructor } @PrePersist public void prePersist() { - + // Empty function } @PreUpdate public void preUpdate() { + // Empty function } public String getPrefixListName() { return this.prefixListName; diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ProtocolList.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ProtocolList.java index befea36ed..b74bb4a57 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ProtocolList.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ProtocolList.java @@ -53,28 +53,25 @@ public class ProtocolList implements Serializable { @Column(name="description") private String description; -/* - @Temporal(TemporalType.TIMESTAMP) - @Column(name="modified_date", nullable=false) - private Date modifiedDate;*/ public ProtocolList() { - + // Empty constructor } public ProtocolList(String string, String userid) { this(domain); } public ProtocolList(String domain) { - + // Empty constructor } @PrePersist public void prePersist() { - + // Empty function } @PreUpdate public void preUpdate() { + // Empty function } public String getProtocolName() { return this.protocolName; diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RainyDayTreatments.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RainyDayTreatments.java index 383eb11c2..6761fe963 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RainyDayTreatments.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RainyDayTreatments.java @@ -61,7 +61,7 @@ public class RainyDayTreatments implements Serializable { private String treatments; public RainyDayTreatments() { - + // Empty constructor } public int getId() { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RemoteCatalogValues.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RemoteCatalogValues.java index f0443c0db..7d347951c 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RemoteCatalogValues.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RemoteCatalogValues.java @@ -57,22 +57,23 @@ public class RemoteCatalogValues implements Serializable { public RemoteCatalogValues() { - + // Empty constructor } public RemoteCatalogValues(String string, String userid) { this(domain); } public RemoteCatalogValues(String domain) { - + // Empty constructor } @PrePersist public void prePersist() { - + // Empty function } @PreUpdate public void preUpdate() { + // Empty function } public String getValue() { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RiskType.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RiskType.java index 155372617..a65e41f2e 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RiskType.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RiskType.java @@ -101,7 +101,7 @@ public class RiskType implements Serializable { private static Log LOGGER = LogFactory.getLog(RiskType.class); public RiskType() { - + // Empty constructor } public RiskType(String string, String userid) { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RuleAlgorithms.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RuleAlgorithms.java index 83f6e2d3e..9d0f005be 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RuleAlgorithms.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RuleAlgorithms.java @@ -98,12 +98,12 @@ public class RuleAlgorithms implements Serializable { @Transient public boolean isStandard() { - return (this.isStandard == RuleAlgorithms.STANDARD); + return this.isStandard == RuleAlgorithms.STANDARD; } @Transient public boolean isCustom() { - return (this.isStandard == RuleAlgorithms.CUSTOM); + return this.isStandard == RuleAlgorithms.CUSTOM; } public String getXacmlId() { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/SafePolicyWarning.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/SafePolicyWarning.java index 1f92fe67a..8b017c006 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/SafePolicyWarning.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/SafePolicyWarning.java @@ -65,22 +65,23 @@ public class SafePolicyWarning implements Serializable { this.riskType = riskType; } public SafePolicyWarning() { - + // Empty constructor } public SafePolicyWarning(String string, String userid) { this(domain); } public SafePolicyWarning(String domain) { - + // Empty constructor } @PrePersist public void prePersist() { - + // Empty function } @PreUpdate public void preUpdate() { + // Empty function } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/SecurityZone.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/SecurityZone.java index d8bc33c13..cbbb8962e 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/SecurityZone.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/SecurityZone.java @@ -56,22 +56,23 @@ public class SecurityZone implements Serializable { public SecurityZone() { - + // Empty constructor } public SecurityZone(String string, String userid) { this(domain); } public SecurityZone(String domain) { - + // Empty constructor } @PrePersist public void prePersist() { - + // Empty function } @PreUpdate public void preUpdate() { + // Empty function } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ServiceList.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ServiceList.java index 40e31172e..057b86992 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ServiceList.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ServiceList.java @@ -65,31 +65,25 @@ public class ServiceList implements Serializable { @Column(name="ports") private String servicePorts; - - - -/* - @Temporal(TemporalType.TIMESTAMP) - @Column(name="modified_date", nullable=false) - private Date modifiedDate;*/ public ServiceList() { - + // Empty constructor } public ServiceList(String string, String userid) { this(domain); } public ServiceList(String domain) { - + // Empty constructor } @PrePersist public void prePersist() { - + // Empty function } @PreUpdate public void preUpdate() { + // Empty function } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/TermList.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/TermList.java index c9a27ef15..099257c39 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/TermList.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/TermList.java @@ -128,7 +128,7 @@ public class TermList implements Serializable { private static Log LOGGER = LogFactory.getLog(TermList.class); public TermList() { - + // Empty constructor } private static final Log auditLogger = LogFactory diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VMType.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VMType.java index 01df59201..356ecb7c9 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VMType.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VMType.java @@ -57,22 +57,23 @@ public class VMType implements Serializable { public VMType() { - + // Empty constructor } public VMType(String string, String userid) { this(domain); } public VMType(String domain) { - + // Empty constructor } @PrePersist public void prePersist() { - + // Empty function } @PreUpdate public void preUpdate() { + // Empty function } public String getDescription() { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VNFType.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VNFType.java index cf1e6b85f..d44e4b5b7 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VNFType.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VNFType.java @@ -102,7 +102,7 @@ public class VNFType implements Serializable { private static Log LOGGER = LogFactory.getLog(VNFType.class); public VNFType() { - + // Empty constructor } public String getVnftype() { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VSCLAction.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VSCLAction.java index 5bfab1793..df605ee7d 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VSCLAction.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VSCLAction.java @@ -101,7 +101,7 @@ public class VSCLAction implements Serializable { private static Log LOGGER = LogFactory.getLog(VSCLAction.class); public VSCLAction() { - + // Empty constructor } public VSCLAction(String string, String userid) { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VarbindDictionary.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VarbindDictionary.java index 0ede025bd..376689ee7 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VarbindDictionary.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VarbindDictionary.java @@ -103,7 +103,7 @@ public class VarbindDictionary implements Serializable{ private static Log LOGGER = LogFactory.getLog(VarbindDictionary.class); public VarbindDictionary() { - + // Empty constructor } public VarbindDictionary(String string, String userid) { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/WatchPolicyNotificationTable.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/WatchPolicyNotificationTable.java index 71b35269f..7586dd8bf 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/WatchPolicyNotificationTable.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/WatchPolicyNotificationTable.java @@ -96,10 +96,9 @@ public class WatchPolicyNotificationTable implements Serializable{ return false; } - return(id == ((WatchPolicyNotificationTable)obj).id && + return id == ((WatchPolicyNotificationTable)obj).id && policyName.equals(((WatchPolicyNotificationTable)obj).policyName) && - loginIds.equals(((WatchPolicyNotificationTable)obj).loginIds) - ); + loginIds.equals(((WatchPolicyNotificationTable)obj).loginIds); } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Zone.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Zone.java index eb53c42f1..fe5d62adc 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Zone.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Zone.java @@ -56,22 +56,23 @@ public class Zone implements Serializable { public Zone() { - + // Empty constructor } public Zone(String string, String userid) { this(domain); } public Zone(String domain) { - + // Empty constructor } @PrePersist public void prePersist() { - + // Empty function } @PreUpdate public void preUpdate() { + // Empty function } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/util/MSAttributeObject.java b/ONAP-REST/src/main/java/org/onap/policy/rest/util/MSAttributeObject.java index b5d359fd6..3410dd7f6 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/util/MSAttributeObject.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/util/MSAttributeObject.java @@ -26,18 +26,18 @@ import java.util.Map; public class MSAttributeObject { private String className; - private HashMap<String, String> attribute = new HashMap<>(); - private HashMap<String, String> refAttribute = new HashMap<>(); - private HashMap<String, Object> subClass = new HashMap<>(); + private Map<String, String> attribute = new HashMap<>(); + private Map<String, String> refAttribute = new HashMap<>(); + private Map<String, Object> subClass = new HashMap<>(); private String dependency; - private HashMap<String, String> enumType = new HashMap<>(); - private HashMap<String, String> matchingSet = new HashMap<>(); + private Map<String, String> enumType = new HashMap<>(); + private Map<String, String> matchingSet = new HashMap<>(); private boolean policyTempalate; public Map<String, String> getRefAttribute() { return refAttribute; } - public void setRefAttribute(HashMap<String, String> refAttribute) { + public void setRefAttribute(Map<String, String> refAttribute) { this.refAttribute = refAttribute; } public String getClassName() { @@ -49,13 +49,13 @@ public class MSAttributeObject { public Map<String, String> getAttribute() { return attribute; } - public void setAttribute(HashMap<String, String> attribute) { + public void setAttribute(Map<String, String> attribute) { this.attribute = attribute; } - public HashMap<String, String> getEnumType() { + public Map<String, String> getEnumType() { return enumType; } - public void setEnumType(HashMap<String, String> enumType) { + public void setEnumType(Map<String, String> enumType) { this.enumType = enumType; } public void addAttribute(String key, String value){ @@ -70,13 +70,13 @@ public class MSAttributeObject { public void addAllRefAttribute(Map<String, String> map){ this.refAttribute.putAll(map); } - public HashMap<String, Object> getSubClass() { + public Map<String, Object> getSubClass() { return subClass; } - public void setSubClass(HashMap<String, Object> subClass) { + public void setSubClass(Map<String, Object> subClass) { this.subClass = subClass; } - public void addAllSubClass(HashMap<String, Object> subClass){ + public void addAllSubClass(Map<String, Object> subClass){ this.subClass.putAll(subClass); } public String getDependency() { @@ -88,16 +88,16 @@ public class MSAttributeObject { public void addSingleEnum(String key, String value){ this.enumType.put(key, value); } - public HashMap<String, String> getMatchingSet() { + public Map<String, String> getMatchingSet() { return matchingSet; } - public void setMatchingSet(HashMap<String, String> matchingSet) { + public void setMatchingSet(Map<String, String> matchingSet) { this.matchingSet = matchingSet; } public void addMatchingSet(String key, String value){ this.matchingSet.put(key, value); } - public void addMatchingSet(HashMap<String, String> matchingSet){ + public void addMatchingSet(Map<String, String> matchingSet){ this.matchingSet.putAll(matchingSet); } public boolean isPolicyTempalate() { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/util/MSModelUtils.java b/ONAP-REST/src/main/java/org/onap/policy/rest/util/MSModelUtils.java index fa2c51d18..3880b35d8 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/util/MSModelUtils.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/util/MSModelUtils.java @@ -86,7 +86,7 @@ public class MSModelUtils { }; - public HashMap<String, MSAttributeObject> processEpackage(String file, MODEL_TYPE model){ + public Map<String, MSAttributeObject> processEpackage(String file, MODEL_TYPE model){ if (model == MODEL_TYPE.XMI ){ processXMIEpackage(file); } @@ -97,8 +97,8 @@ public class MSModelUtils { private void processXMIEpackage(String xmiFile){ EPackage root = getEpackage(xmiFile); TreeIterator<EObject> treeItr = root.eAllContents(); - String className = null; - String returnValue = null; + String className; + String returnValue; // Pulling out dependency from file while (treeItr.hasNext()) { @@ -151,15 +151,13 @@ public class MSModelUtils { private void UpdateMatching(HashMap<String, String> tempAttribute, String key) { - Map<String, MSAttributeObject> newClass = null; - - newClass = classMap; + Map<String, MSAttributeObject> newClass = classMap; for (Entry<String, MSAttributeObject> updateClass : newClass.entrySet()){ - HashMap<String, String> valueMap = updateClass.getValue().getMatchingSet(); + Map<String, String> valueMap = updateClass.getValue().getMatchingSet(); String keymap = updateClass.getKey(); if (valueMap.containsKey(key)){ - HashMap<String, String> modifyMap = classMap.get(keymap).getMatchingSet(); + Map<String, String> modifyMap = classMap.get(keymap).getMatchingSet(); modifyMap.remove(key); modifyMap.putAll(tempAttribute); classMap.get(keymap).setMatchingSet(modifyMap); @@ -181,7 +179,7 @@ public class MSModelUtils { m.put("xmi", new XMIResourceFactoryImpl()); Resource resource = resSet.getResource(URI.createFileURI(xmiFile), true); try { - resource.load(Collections.EMPTY_MAP); + resource.load(Collections.emptyMap()); } catch (IOException e) { logger.error("Error loading Encore Resource for new Model" + e); } @@ -210,14 +208,14 @@ public class MSModelUtils { public void getAttributes(String className, String dependency, EPackage root) { List<String> dpendList = new ArrayList<>(); if (dependency!=null){ - dpendList = new ArrayList<String>(Arrays.asList(dependency.split(","))); + dpendList = new ArrayList<>(Arrays.asList(dependency.split(","))); } MSAttributeObject msAttributeObject = new MSAttributeObject(); msAttributeObject.setClassName(className); String extendClass = getSubTypes(root, className); - HashMap<String, String> returnRefList = getRefAttributeList(root, className, extendClass); - HashMap<String, String> returnAttributeList = getAttributeList(root, className, extendClass); - HashMap<String, Object> returnSubList = getSubAttributeList(root, className, extendClass); + Map<String, String> returnRefList = getRefAttributeList(root, className, extendClass); + Map<String, String> returnAttributeList = getAttributeList(root, className, extendClass); + Map<String, Object> returnSubList = getSubAttributeList(root, className, extendClass); HashMap<String, String> returnAnnotation = getAnnotation(root, className, extendClass); msAttributeObject.setAttribute(returnAttributeList); msAttributeObject.setRefAttribute(returnRefList); @@ -234,9 +232,9 @@ public class MSModelUtils { boolean requiredAttribute = false; boolean requiredMatchAttribute = false; HashMap<String, String> annotationSet = new HashMap<>(); - String matching = null; - String range = null; - String dictionary = null; + String matching; + String range; + String dictionary; // Pulling out dependency from file while (treeItr.hasNext()) { @@ -249,7 +247,7 @@ public class MSModelUtils { if (requiredAttribute){ if (obj instanceof EStructuralFeature) { EStructuralFeature eStrucClassifier = (EStructuralFeature) obj; - if (eStrucClassifier.getEAnnotations().size() != 0) { + if (!eStrucClassifier.getEAnnotations().isEmpty()) { matching = annotationValue(eStrucClassifier, ANNOTATION_TYPE.MATCHING, policy); if (matching!=null){ annotationSet.put(eStrucClassifier.getName(), matching); @@ -267,7 +265,7 @@ public class MSModelUtils { } else if (requiredMatchAttribute){ if (obj instanceof EStructuralFeature) { EStructuralFeature eStrucClassifier = (EStructuralFeature) obj; - if (eStrucClassifier.getEAnnotations().size() != 0) { + if (!eStrucClassifier.getEAnnotations().isEmpty()) { matching = annotationValue(eStrucClassifier, ANNOTATION_TYPE.MATCHING, policy); if (matching!=null){ if (obj instanceof EReference){ @@ -285,13 +283,13 @@ public class MSModelUtils { return annotationSet; } - private HashMap<String, Object> getSubAttributeList(EPackage root, String className , String superClass) { + private Map<String, Object> getSubAttributeList(EPackage root, String className , String superClass) { TreeIterator<EObject> treeItr = root.eAllContents(); boolean requiredAttribute = false; - HashMap<String, Object> subAttribute = new HashMap<String, Object>(); + Map<String, Object> subAttribute = new HashMap<>(); int rollingCount = 0; int processClass = 0; - boolean annotation = false; + boolean annotation; // Pulling out dependency from file while (treeItr.hasNext() && rollingCount < 2) { @@ -312,7 +310,7 @@ public class MSModelUtils { if (requiredAttribute) { if (obj instanceof EStructuralFeature) { EStructuralFeature eStrucClassifier = (EStructuralFeature) obj; - if (eStrucClassifier.getEAnnotations().size() != 0) { + if (!eStrucClassifier.getEAnnotations().isEmpty()) { annotation = annotationTest(eStrucClassifier, configuration, onap); if (annotation && obj instanceof EReference) { EClass refType = ((EReference) obj).getEReferenceType(); @@ -348,7 +346,7 @@ public class MSModelUtils { return ":required-false"; } - public JSONObject buildJavaObject(HashMap<String, String> map, String attributeType){ + public JSONObject buildJavaObject(Map<String, String> map){ JSONObject returnValue = new JSONObject(map); @@ -356,14 +354,14 @@ public class MSModelUtils { } - public HashMap<String, String> getRefAttributeList(EPackage root, String className, String superClass){ + public Map<String, String> getRefAttributeList(EPackage root, String className, String superClass){ TreeIterator<EObject> treeItr = root.eAllContents(); boolean requiredAttribute = false; HashMap<String, String> refAttribute = new HashMap<>(); int rollingCount = 0; int processClass = 0; - boolean annotation = false; + boolean annotation; // Pulling out dependency from file while (treeItr.hasNext()) { EObject obj = treeItr.next(); @@ -382,7 +380,7 @@ public class MSModelUtils { if (requiredAttribute) { if (obj instanceof EStructuralFeature) { EStructuralFeature eStrucClassifier = (EStructuralFeature) obj; - if (eStrucClassifier.getEAnnotations().size() != 0) { + if (!eStrucClassifier.getEAnnotations().isEmpty()) { annotation = annotationTest(eStrucClassifier, configuration, onap); if ( annotation && obj instanceof EReference) { EClass refType = ((EReference) obj).getEReferenceType(); @@ -408,10 +406,10 @@ public class MSModelUtils { } private boolean annotationTest(EStructuralFeature eStrucClassifier, String annotation, String type) { - String annotationType = null; - EAnnotation eAnnotation = null; - String onapType = null; - String onapValue = null; + String annotationType; + EAnnotation eAnnotation; + String onapType; + String onapValue; EList<EAnnotation> value = eStrucClassifier.getEAnnotations(); @@ -432,9 +430,9 @@ public class MSModelUtils { private String annotationValue(EStructuralFeature eStrucClassifier, ANNOTATION_TYPE annotation, String type) { - String annotationType = null; - EAnnotation eAnnotation = null; - String onapType = null; + String annotationType; + EAnnotation eAnnotation; + String onapType; String onapValue = null; EList<EAnnotation> value = eStrucClassifier.getEAnnotations(); @@ -501,15 +499,15 @@ public class MSModelUtils { return returnSubTypes; } - public HashMap<String, String> getAttributeList(EPackage root, String className, String superClass){ + public Map<String, String> getAttributeList(EPackage root, String className, String superClass){ TreeIterator<EObject> treeItr = root.eAllContents(); boolean requiredAttribute = false; HashMap<String, String> refAttribute = new HashMap<>(); - boolean annotation = false; - boolean dictionaryTest = false; - String defaultValue = null; - String eType = null; + boolean annotation; + boolean dictionaryTest; + String defaultValue; + String eType; // Pulling out dependency from file while (treeItr.hasNext()) { @@ -526,7 +524,7 @@ public class MSModelUtils { if (requiredAttribute){ if (obj instanceof EStructuralFeature) { EStructuralFeature eStrucClassifier = (EStructuralFeature) obj; - if (eStrucClassifier.getEAnnotations().size() != 0) { + if (!eStrucClassifier.getEAnnotations().isEmpty()) { annotation = annotationTest(eStrucClassifier, configuration, onap); dictionaryTest = annotationTest(eStrucClassifier, dictionary, policy); EClassifier refType = ((EStructuralFeature) obj).getEType(); @@ -578,9 +576,9 @@ public class MSModelUtils { return returnValue; } - public Map<String, String> buildSubList(HashMap<String, String> subClassAttributes, HashMap<String, MSAttributeObject> classMap, String className){ + public Map<String, String> buildSubList(Map<String, String> subClassAttributes, Map<String, MSAttributeObject> classMap, String className){ Map<String, String> missingValues = new HashMap<>(); - Map<String, String> workingMap = new HashMap<>(); + Map<String, String> workingMap; boolean enumType; for ( Entry<String, String> map : classMap.get(className).getRefAttribute().entrySet()){ @@ -604,10 +602,10 @@ public class MSModelUtils { return missingValues; } - public Map<String, HashMap<String, String>> recursiveReference(HashMap<String, MSAttributeObject> classMap, String className){ + public Map<String, Map<String, String>> recursiveReference(Map<String, MSAttributeObject> classMap, String className){ - Map<String, HashMap<String, String>> returnObject = new HashMap<>(); - HashMap<String, String> returnClass = getRefclass(classMap, className); + Map<String, Map<String, String>> returnObject = new HashMap<>(); + Map<String, String> returnClass = getRefclass(classMap, className); returnObject.put(className, returnClass); for (Entry<String, String> reAttribute :returnClass.entrySet()){ if (reAttribute.getValue().split(":")[1].contains("MANY")){ @@ -622,16 +620,16 @@ public class MSModelUtils { } - public String createJson(HashMap<String, Object> subClassAttributes, HashMap<String, MSAttributeObject> classMap, String className) { + public String createJson(Map<String, Object> subClassAttributes, Map<String, MSAttributeObject> classMap, String className) { boolean enumType; - Map<String, HashMap<String, String>> myObject = new HashMap<>(); + Map<String, Map<String, String>> myObject = new HashMap<>(); for ( Entry<String, String> map : classMap.get(className).getRefAttribute().entrySet()){ String value = map.getValue().split(":")[0]; if (value!=null){ enumType = classMap.get(className).getEnumType().containsKey(value); if (!enumType){ if (map.getValue().split(":")[1].contains("MANY")){ - Map<String, HashMap<String, String>> testRecursive = recursiveReference(classMap, map.getValue().split(":")[0] ); + Map<String, Map<String, String>> testRecursive = recursiveReference(classMap, map.getValue().split(":")[0] ); myObject.putAll(testRecursive); } } @@ -644,7 +642,7 @@ public class MSModelUtils { return json; } - public HashMap<String, String> getRefclass(HashMap<String, MSAttributeObject> classMap, String className){ + public Map<String, String> getRefclass(Map<String, MSAttributeObject> classMap, String className){ HashMap<String, String> missingValues = new HashMap<>(); if (classMap.get(className).getAttribute()!=null || !classMap.get(className).getAttribute().isEmpty()){ @@ -658,12 +656,12 @@ public class MSModelUtils { return missingValues; } - public String createSubAttributes(ArrayList<String> dependency, HashMap<String, MSAttributeObject> classMap, String modelName) { + public String createSubAttributes(List<String> dependency, Map<String, MSAttributeObject> classMap, String modelName) { HashMap <String, Object> workingMap = new HashMap<>(); - MSAttributeObject tempObject = new MSAttributeObject(); + MSAttributeObject tempObject; if (dependency!=null){ - if (dependency.size()==0){ + if (dependency.isEmpty()){ return "{}"; } dependency.add(modelName); @@ -679,15 +677,15 @@ public class MSModelUtils { return returnValue; } - public ArrayList<String> getFullDependencyList(ArrayList<String> dependency, HashMap<String,MSAttributeObject > classMap) { + public List<String> getFullDependencyList(List<String> dependency, Map<String,MSAttributeObject > classMap) { ArrayList<String> returnList = new ArrayList<>(); - ArrayList<String> workingList = new ArrayList<>(); + ArrayList<String> workingList; returnList.addAll(dependency); for (String element : dependency ){ if (classMap.containsKey(element)){ MSAttributeObject value = classMap.get(element); String rawValue = StringUtils.replaceEach(value.getDependency(), new String[]{"[", "]"}, new String[]{"", ""}); - workingList = new ArrayList<String>(Arrays.asList(rawValue.split(","))); + workingList = new ArrayList<>(Arrays.asList(rawValue.split(","))); for(String depend : workingList){ if (!returnList.contains(depend) && !depend.isEmpty()){ returnList.add(depend.trim()); 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 e98a41f9e..df4fbf62d 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 @@ -76,7 +76,9 @@ public class PolicyValidation { /* * This is an empty constructor */ - public PolicyValidation(){} + public PolicyValidation(){ + // Empty constructor + } public StringBuilder validatePolicy(PolicyRestAdapter policyData) throws IOException{ @@ -178,17 +180,17 @@ public class PolicyValidation { String configBodyData = policyData.getConfigBodyData(); String configType = policyData.getConfigType(); if (configType != null) { - if (configType.equals("JSON")) { + if ("JSON".equals(configType)) { if (!PolicyUtils.isJSONValid(configBodyData)) { responseString.append("Config Body: JSON Content is not valid" + "<br>"); valid = false; } - } else if (configType.equals("XML")) { + } else if ("XML".equals(configType)) { if (!PolicyUtils.isXMLValid(configBodyData)) { responseString.append("Config Body: XML Content data is not valid" + "<br>"); valid = false; } - } else if (configType.equals("PROPERTIES")) { + } else if ("PROPERTIES".equals(configType)) { if (!PolicyUtils.isPropValid(configBodyData)||configBodyData.equals("")) { responseString.append("Config Body: Property data is not valid" + "<br>"); valid = false; @@ -384,8 +386,8 @@ public class PolicyValidation { if(!Strings.isNullOrEmpty(policyData.getServiceType())){ pullJsonKeyPairs((JsonNode) policyData.getPolicyJSON()); - String service = null; - String version = null; + String service; + String version; if (policyData.getServiceType().contains("-v")){ service = policyData.getServiceType().split("-v")[0]; version = policyData.getServiceType().split("-v")[1]; @@ -678,15 +680,17 @@ public class PolicyValidation { } protected String emailValidation(String email, String response){ + String res = response; if(email != null){ String validateEmail = PolicyUtils.validateEmailAddress(email.replace("\"", "")); if(!validateEmail.contains(SUCCESS)){ - response += "<b>Email</b>:<i>" + validateEmail + HTML_ITALICS_LNBREAK; - }else{ + res += "<b>Email</b>:<i>" + validateEmail + HTML_ITALICS_LNBREAK; + } + else { return SUCCESS; } } - return response; + return res; } private MicroServiceModels getAttributeObject(String name, String version) { 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 03c1fb0c7..ac97fb0ee 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 @@ -62,7 +62,7 @@ public class PolicyValidationRequestWrapper { JsonNode root = mapper.readTree(request.getReader()); policyData = mapper.readValue(root.get("policyData").toString(), PolicyRestAdapter.class); - JsonObject json = null; + JsonObject json; json = stringToJsonObject(root.toString()); if(json != null){ @@ -181,14 +181,14 @@ public class PolicyValidationRequestWrapper { } else if("Action".equals(parameters.getPolicyClass().toString())){ - ArrayList<Object> ruleAlgorithmChoices = new ArrayList<Object>(); + ArrayList<Object> ruleAlgorithmChoices = new ArrayList<>(); List<String> dynamicLabelRuleAlgorithms = parameters.getDynamicRuleAlgorithmLabels(); List<String> dynamicFieldFunctionRuleAlgorithms = parameters.getDynamicRuleAlgorithmFunctions(); List<String> dynamicFieldOneRuleAlgorithms = parameters.getDynamicRuleAlgorithmField1(); List<String> dyrnamicFieldTwoRuleAlgorithms = parameters.getDynamicRuleAlgorithmField2(); - if (dynamicLabelRuleAlgorithms != null && dynamicLabelRuleAlgorithms.size() > 0) { + if (dynamicLabelRuleAlgorithms != null && !dynamicLabelRuleAlgorithms.isEmpty()) { int i = dynamicLabelRuleAlgorithms.size() - 1; for (String labelAttr : dynamicLabelRuleAlgorithms) { @@ -349,14 +349,10 @@ public class PolicyValidationRequestWrapper { } - private JsonObject stringToJsonObject(String value) - throws JsonException, IllegalStateException { - - try{ - JsonReader jsonReader = Json.createReader(new StringReader(value)); - JsonObject object = jsonReader.readObject(); - jsonReader.close(); - return object; + private JsonObject stringToJsonObject(String value) { + + try(JsonReader jsonReader = Json.createReader(new StringReader(value))){ + return jsonReader.readObject(); } catch(JsonException| IllegalStateException e){ LOGGER.info(XACMLErrorConstants.ERROR_DATA_ISSUE+ "Improper JSON format... may or may not cause issues in validating the policy: " + value, e); return null; |