aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateNewMicroServiceModel.java22
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/elk/client/PolicyElasticData.java36
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/XACMLRest.java13
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/adapter/AddressGroupJson.java7
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/adapter/AddressJson.java7
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/adapter/AutoPushTabAdapter.java14
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ClosedLoopPerformanceMetrics.java4
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ClosedLoopPolicy.java3
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/adapter/GridData.java20
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyExportAdapter.java8
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java56
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PrefixIPList.java10
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/adapter/RainyDayParams.java7
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ServiceGroupJson.java10
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ServiceListJson.java10
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/adapter/Term.java12
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/adapter/TermCollector.java6
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/adapter/VendorSpecificData.java2
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/dao/PolicyDBException.java1
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ActionBodyEntity.java11
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ActionList.java11
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ActionPolicyDict.java5
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/AddressGroup.java7
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Attribute.java9
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/AttributeAssignment.java1
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BRMSParamTemplate.java3
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Category.java4
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoopD2Services.java2
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoopSite.java2
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoops.java2
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConfigurationDataEntity.java7
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConstraintType.java2
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConstraintValue.java1
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DCAEUsers.java7
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DCAEuuid.java7
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DatabaseLockEntity.java2
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Datatype.java6
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DecisionSettings.java8
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DescriptiveScope.java2
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FWTag.java2
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FWTagPicker.java2
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FirewallDictionaryList.java54
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FunctionArgument.java1
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/FunctionDefinition.java1
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GroupPolicyScopeList.java7
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/GroupServiceList.java7
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceAttribute.java7
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceConfigName.java7
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceLocation.java7
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/MicroServiceModels.java3
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ObadviceExpression.java6
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/OnapName.java2
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PEPOptions.java2
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPConfigParam.java3
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPConfiguration.java49
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPResolver.java51
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPResolverParam.java1
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PIPType.java1
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyAlgorithms.java4
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyEditorScopes.java3
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyEntity.java6
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyRoles.java1
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeClosedLoop.java7
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeResource.java7
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeService.java7
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScopeType.java7
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyScore.java4
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyVersion.java17
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PortList.java7
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PrefixList.java11
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ProtocolList.java11
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RainyDayTreatments.java2
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RemoteCatalogValues.java7
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RiskType.java2
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/RuleAlgorithms.java4
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/SafePolicyWarning.java7
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/SecurityZone.java7
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ServiceList.java14
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/TermList.java2
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VMType.java7
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VNFType.java2
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VSCLAction.java2
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/VarbindDictionary.java2
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/WatchPolicyNotificationTable.java5
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Zone.java7
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/util/MSAttributeObject.java30
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/util/MSModelUtils.java106
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidation.java22
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidationRequestWrapper.java18
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPDP.java39
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyAdapter.java42
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java66
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyNotificationMail.java10
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java9
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/components/HumanPolicyComponent.java17
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/ActionPolicyController.java13
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateBRMSParamController.java10
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateBRMSRawController.java8
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateClosedLoopFaultController.java42
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java163
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateFirewallController.java116
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreatePolicyController.java12
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/DashboardController.java30
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/DecisionPolicyController.java34
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PDPController.java88
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java6
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyExportAndImportController.java48
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/CommonClassDaoImpl.java3
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPGroupContainer.java2
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPPolicyContainer.java4
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/utils/ConfigurableRESTUtils.java7
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/utils/UserUtils.java70
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/utils/XACMLPolicyWriterWithPapNotify.java6
-rw-r--r--POLICY-SDK-APP/src/test/java/org/onap/policy/admin/CheckPDPTest.java41
-rw-r--r--POLICY-SDK-APP/src/test/resources/empty.properties21
-rw-r--r--POLICY-SDK-APP/src/test/resources/test.properties1
-rw-r--r--POLICY-SDK-APP/src/test/resources/testbad.properties21
-rw-r--r--POLICY-SDK-APP/src/test/resources/testnotenoughvalues.properties21
119 files changed, 929 insertions, 922 deletions
diff --git a/.gitignore b/.gitignore
index 632972456..6ab843b8e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,6 +4,7 @@
.classpath
.jupiter
.pydevproject
+.idea
target
.metadata/
ASTRAGateway/policyEngineLog.log
@@ -30,6 +31,8 @@ XACML-PDP-REST/catalina.base_IS_UNDEFINED/logs/Policy/XACML-PDP-REST/metrics.log
XACML-REST/IntegrityMonitor.log
/bin/
*.checkstyle
+*.iml
+*.log
BRMSGateway/logs/
BRMSGateway/sql/
BRMSGateway/src/test/resources/META-INF/generatedCreate.ddl
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateNewMicroServiceModel.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateNewMicroServiceModel.java
index aad70e5dd..af7895695 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateNewMicroServiceModel.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateNewMicroServiceModel.java
@@ -70,7 +70,7 @@ public class CreateNewMicroServiceModel {
this.newModel.setUserCreatedBy(userInfo);
String cleanUpFile = null;
- HashMap<String, MSAttributeObject> tempMap = new HashMap<>();
+ Map<String, MSAttributeObject> tempMap = new HashMap<>();
//Need to delete the file
if (importFile.contains(".zip")){
extractFolder(randomID + ".zip");
@@ -143,16 +143,14 @@ public class CreateNewMicroServiceModel {
int currentByte;
byte data[] = new byte[BUFFER];
-
- FileOutputStream fos = new FileOutputStream(destFile);
- BufferedOutputStream dest = new BufferedOutputStream(fos,
- BUFFER);
-
- while ((currentByte = is.read(data, 0, BUFFER)) != -1) {
- dest.write(data, 0, currentByte);
- }
- dest.flush();
- dest.close();
+ try(FileOutputStream fos = new FileOutputStream(destFile);
+ BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER)) {
+
+ while ((currentByte = is.read(data, 0, BUFFER)) != -1) {
+ dest.write(data, 0, currentByte);
+ }
+ dest.flush();
+ }
is.close();
}
@@ -177,7 +175,7 @@ public class CreateNewMicroServiceModel {
Map<String, String> successMap = new HashMap<>();
MSAttributeObject mainClass = null;
- ArrayList<String> dependency = null;
+ List<String> dependency = null;
String subAttribute = null;
if (!classMap.containsKey(this.newModel.getModelName())){
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/elk/client/PolicyElasticData.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/elk/client/PolicyElasticData.java
index cde05383d..e56e82cbf 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/elk/client/PolicyElasticData.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/elk/client/PolicyElasticData.java
@@ -41,10 +41,10 @@ public class PolicyElasticData {
private String jsonBody;
private Object jsonBodyData;
- private LinkedHashMap<?, ?> serviceTypePolicyName;
- private LinkedHashMap<?, ?> verticaMetrics;
- private LinkedHashMap<?, ?> description;
- private LinkedHashMap<?, ?> attributeFields;
+ private Map<?, ?> serviceTypePolicyName;
+ private Map<?, ?> verticaMetrics;
+ private Map<?, ?> description;
+ private Map<?, ?> attributeFields;
//Safe Policy
private String policyScope;
@@ -55,8 +55,8 @@ public class PolicyElasticData {
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;
public String gocServerScope;
@@ -86,7 +86,7 @@ public class PolicyElasticData {
//FireWall
private String fwPolicyType;
- private ArrayList<Object> fwattributes;
+ private List<Object> fwattributes;
private String parentForChild;
private String securityZone;
@@ -262,7 +262,7 @@ public class PolicyElasticData {
public void setJsonBody(String jsonBody) {
this.jsonBody = jsonBody;
}
- public LinkedHashMap<?, ?> getServiceTypePolicyName() {
+ public Map<?, ?> getServiceTypePolicyName() {
return serviceTypePolicyName;
}
@@ -270,7 +270,7 @@ public class PolicyElasticData {
this.serviceTypePolicyName = serviceTypePolicyName;
}
- public LinkedHashMap<?, ?> getVerticaMetrics() {
+ public Map<?, ?> getVerticaMetrics() {
return verticaMetrics;
}
@@ -278,15 +278,15 @@ public class PolicyElasticData {
this.verticaMetrics = verticaMetrics;
}
- public LinkedHashMap<?, ?> getDescription() {
+ public Map<?, ?> getDescription() {
return description;
}
- public void setDescription(LinkedHashMap<?, ?> description) {
+ public void setDescription(Map<?, ?> description) {
this.description = description;
}
- public LinkedHashMap<?, ?> getAttributeFields() {
+ public Map<?, ?> getAttributeFields() {
return attributeFields;
}
@@ -335,13 +335,13 @@ public class PolicyElasticData {
public void setMatching(Map<String, String> matching) {
this.matching = matching;
}
- public ArrayList<Object> getTriggerSignatures() {
+ public List<Object> getTriggerSignatures() {
return triggerSignatures;
}
public void setTriggerSignatures(ArrayList<Object> triggerSignatures) {
this.triggerSignatures = triggerSignatures;
}
- public ArrayList<Object> getSymptomSignatures() {
+ public List<Object> getSymptomSignatures() {
return symptomSignatures;
}
public void setSymptomSignatures(ArrayList<Object> symptomSignatures) {
@@ -422,16 +422,16 @@ public class PolicyElasticData {
public List<String> getBrmsDependency() {
return brmsDependency;
}
- public void setBrmsDependency(ArrayList<String> brmsDependency) {
+ public void setBrmsDependency(List<String> brmsDependency) {
this.brmsDependency = brmsDependency;
}
- public LinkedHashMap<?, ?> getRuleData() {
+ public Map<?, ?> getRuleData() {
return ruleData;
}
public void setRuleData(LinkedHashMap<?, ?> ruleData) {
this.ruleData = ruleData;
}
- public LinkedHashMap<?, ?> getRuleListData() {
+ public Map<?, ?> getRuleListData() {
return ruleListData;
}
public void setRuleListData(LinkedHashMap<?, ?> ruleListData) {
@@ -473,7 +473,7 @@ public class PolicyElasticData {
public void setFwPolicyType(String fwPolicyType) {
this.fwPolicyType = fwPolicyType;
}
- public ArrayList<Object> getFwattributes() {
+ public List<Object> getFwattributes() {
return fwattributes;
}
public void setFwattributes(ArrayList<Object> fwattributes) {
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;
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPDP.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPDP.java
index 49eb80802..643320496 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPDP.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPDP.java
@@ -44,6 +44,18 @@ import org.onap.policy.xacml.api.XACMLErrorConstants;
import com.att.research.xacml.util.XACMLProperties;
+/**
+ * What is not good about this class is that once a value has been set for pdpProperties path
+ * you cannot change it. That may be ok for a highly controlled production environment in which
+ * nothing changes, but not a very good implementation.
+ *
+ * The reset() method has been added to assist with the above problem in order to
+ * acquire >80% JUnit code coverage.
+ *
+ * This static class doesn't really check a PDP, it simply loads a properties file and tried
+ * to ensure that a valid URL exists for a PDP along with user/password.
+ *
+ */
public class CheckPDP {
private static Path pdpPath = null;
private static Long oldModified = null;
@@ -57,6 +69,12 @@ public class CheckPDP {
public static Map<String, String> getPdpMap() {
return pdpMap;
}
+
+ private static void reset() {
+ pdpPath = null;
+ oldModified = null;
+ pdpMap = null;
+ }
public static boolean validateID(String id) {
// ReadFile
@@ -66,6 +84,9 @@ public class CheckPDP {
LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e);
return false;
}
+ if (pdpMap == null) {
+ return false;
+ }
// Check ID
return pdpMap.containsKey(id);
}
@@ -83,15 +104,12 @@ public class CheckPDP {
}
if (pdpPath == null) {
pdpPath = Paths.get(pdpFile);
- if (!pdpPath.toFile().exists()) {
+ if (!pdpPath.toString().endsWith(".properties") || !pdpPath.toFile().exists()) {
LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "File doesn't exist in the specified Path : " + pdpPath.toString());
-
- }
- if (pdpPath.toString().endsWith(".properties")) {
- readProps();
- } else {
- LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Not a .properties file " + pdpFile);
+ CheckPDP.reset();
+ return;
}
+ readProps();
}
// Check if File is updated recently
else {
@@ -120,13 +138,14 @@ public class CheckPDP {
for (String propKey : sorted) {
loadPDPProperties(propKey, pdpProp);
}
- if (pdpMap == null || pdpMap.isEmpty()) {
- LOGGER.debug(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Cannot Proceed without PDP_URLs");
- }
in.close();
} catch (IOException e) {
LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e);
}
+ if (pdpMap == null || pdpMap.isEmpty()) {
+ LOGGER.debug(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Cannot Proceed without PDP_URLs");
+ CheckPDP.reset();
+ }
}
private static void loadPDPProperties(String propKey, Properties pdpProp){
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyAdapter.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyAdapter.java
index 545143a22..42010f147 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyAdapter.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyAdapter.java
@@ -41,33 +41,26 @@ public class PolicyAdapter {
private static final Logger LOGGER = FlexLogger.getLogger(PolicyAdapter.class);
public void configure(PolicyRestAdapter policyAdapter, PolicyEntity entity) {
- String policyNameValue;
- String configPolicyName = null ;
if(extendedOptions(policyAdapter, entity)){
return;
}
+ String policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf('_'));
+ String configPolicyName = null ;
if(policyAdapter.getPolicyName().startsWith("Config_PM")){
- policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf('_'));
configPolicyName = "ClosedLoop_PM";
}else if(policyAdapter.getPolicyName().startsWith("Config_Fault")){
- policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf('_'));
configPolicyName = "ClosedLoop_Fault";
}else if(policyAdapter.getPolicyName().startsWith("Config_FW")){
- policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf('_'));
configPolicyName = "Firewall Config";
}else if(policyAdapter.getPolicyName().startsWith("Config_BRMS_Raw")){
- policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf('_'));
configPolicyName = "BRMS_Raw";
}else if(policyAdapter.getPolicyName().startsWith("Config_BRMS_Param")){
- policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf('_'));
configPolicyName = "BRMS_Param";
}else if(policyAdapter.getPolicyName().startsWith("Config_MS")){
- policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf('_'));
configPolicyName = "Micro Service";
}else if(policyAdapter.getPolicyName().startsWith("Action") || policyAdapter.getPolicyName().startsWith("Decision") ){
- policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf('_'));
+ // No configPolicyName is applicable
}else{
- policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf('_'));
configPolicyName = "Base";
}
if (policyNameValue != null) {
@@ -78,41 +71,32 @@ public class PolicyAdapter {
}
if("Action".equalsIgnoreCase(policyAdapter.getPolicyType())){
- ActionPolicyController actionController = new ActionPolicyController();
- actionController.prePopulateActionPolicyData(policyAdapter, entity);
+ new ActionPolicyController().prePopulateActionPolicyData(policyAdapter, entity);
}
if("Decision".equalsIgnoreCase(policyAdapter.getPolicyType())){
- DecisionPolicyController decisionController = new DecisionPolicyController();
- decisionController.prePopulateDecisionPolicyData(policyAdapter, entity);
+ new DecisionPolicyController().prePopulateDecisionPolicyData(policyAdapter, entity);
}
if("Config".equalsIgnoreCase(policyAdapter.getPolicyType())){
if("Base".equalsIgnoreCase(policyAdapter.getConfigPolicyType())){
- CreatePolicyController baseController = new CreatePolicyController();
- baseController.prePopulateBaseConfigPolicyData(policyAdapter, entity);
+ new CreatePolicyController().prePopulateBaseConfigPolicyData(policyAdapter, entity);
}
else if("BRMS_Raw".equalsIgnoreCase(policyAdapter.getConfigPolicyType())){
- CreateBRMSRawController brmsController = new CreateBRMSRawController();
- brmsController.prePopulateBRMSRawPolicyData(policyAdapter, entity);
+ new CreateBRMSRawController().prePopulateBRMSRawPolicyData(policyAdapter, entity);
}
else if("BRMS_Param".equalsIgnoreCase(policyAdapter.getConfigPolicyType())){
- CreateBRMSParamController paramController = new CreateBRMSParamController();
- paramController.prePopulateBRMSParamPolicyData(policyAdapter, entity);
+ new CreateBRMSParamController().prePopulateBRMSParamPolicyData(policyAdapter, entity);
}
else if("ClosedLoop_Fault".equalsIgnoreCase(policyAdapter.getConfigPolicyType())){
- CreateClosedLoopFaultController newFaultTemplate = new CreateClosedLoopFaultController();
- newFaultTemplate.prePopulateClosedLoopFaultPolicyData(policyAdapter, entity);
+ new CreateClosedLoopFaultController().prePopulateClosedLoopFaultPolicyData(policyAdapter, entity);
}
else if("ClosedLoop_PM".equalsIgnoreCase(policyAdapter.getConfigPolicyType())){
- CreateClosedLoopPMController pmController = new CreateClosedLoopPMController();
- pmController.prePopulateClosedLoopPMPolicyData(policyAdapter, entity);
+ new CreateClosedLoopPMController().prePopulateClosedLoopPMPolicyData(policyAdapter, entity);
}
else if("Micro Service".equalsIgnoreCase(policyAdapter.getConfigPolicyType())){
- CreateDcaeMicroServiceController msController = new CreateDcaeMicroServiceController();
- msController.prePopulateDCAEMSPolicyData(policyAdapter, entity);
+ new CreateDcaeMicroServiceController().prePopulateDCAEMSPolicyData(policyAdapter, entity);
}
else if("Firewall Config".equalsIgnoreCase(policyAdapter.getConfigPolicyType())){
- CreateFirewallController firewallController = new CreateFirewallController();
- firewallController.prePopulateFWPolicyData(policyAdapter, entity);
+ new CreateFirewallController().prePopulateFWPolicyData(policyAdapter, entity);
}
}
}
@@ -130,7 +114,5 @@ public class PolicyAdapter {
}
return null;
}
-
-
}
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java
index e62c87839..54a14cb8d 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java
@@ -68,7 +68,6 @@ import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.components.HumanPolicyComponent;
import org.onap.policy.controller.PolicyController;
import org.onap.policy.controller.PolicyExportAndImportController;
-import org.onap.policy.model.Roles;
import org.onap.policy.rest.XACMLRest;
import org.onap.policy.rest.XACMLRestProperties;
import org.onap.policy.rest.adapter.PolicyRestAdapter;
@@ -79,6 +78,7 @@ import org.onap.policy.rest.jpa.PolicyEntity;
import org.onap.policy.rest.jpa.PolicyVersion;
import org.onap.policy.rest.jpa.UserInfo;
import org.onap.policy.utils.PolicyUtils;
+import org.onap.policy.utils.UserUtils.Pair;
import org.onap.policy.xacml.api.XACMLErrorConstants;
import org.onap.policy.xacml.util.XACMLPolicyScanner;
import org.onap.portalsdk.core.web.support.UserUtils;
@@ -314,8 +314,8 @@ public class PolicyManagerServlet extends HttpServlet {
}
private JSONObject searchPolicyList(JSONObject params, HttpServletRequest request) {
- Set<String> scopes = null;
- List<String> roles = null;
+ Set<String> scopes;
+ List<String> roles;
List<Object> policyData = new ArrayList<>();
JSONArray policyList = null;
if(params.has("policyList")){
@@ -326,24 +326,10 @@ public class PolicyManagerServlet extends HttpServlet {
try {
//Get the Login Id of the User from Request
String userId = UserUtils.getUserSession(request).getOrgUserId();
- //Check if the Role and Scope Size are Null get the values from db.
List<Object> userRoles = controller.getRoles(userId);
- roles = new ArrayList<>();
- scopes = new HashSet<>();
- for(Object role: userRoles){
- Roles userRole = (Roles) role;
- roles.add(userRole.getRole());
- if(userRole.getScope() != null){
- if(userRole.getScope().contains(",")){
- String[] multipleScopes = userRole.getScope().split(",");
- for(int i =0; i < multipleScopes.length; i++){
- scopes.add(multipleScopes[i]);
- }
- }else{
- scopes.add(userRole.getScope());
- }
- }
- }
+ Pair<Set<String>, List<String>> pair = org.onap.policy.utils.UserUtils.checkRoleAndScope(userRoles);
+ roles = pair.u;
+ scopes = pair.t;
if (roles.contains(ADMIN) || roles.contains(EDITOR) || roles.contains(GUEST) ) {
if(scopes.isEmpty()){
return error("No Scopes has been Assigned to the User. Please, Contact Super-Admin");
@@ -442,7 +428,7 @@ public class PolicyManagerServlet extends HttpServlet {
policyName = removeExtension.substring(0, removeExtension.lastIndexOf('.'));
}
- String activePolicy = null;
+ String activePolicy;
PolicyController controller = getPolicyControllerInstance();
if(params.toString().contains("activeVersion")){
String activeVersion = params.getString("activeVersion");
@@ -572,24 +558,10 @@ public class PolicyManagerServlet extends HttpServlet {
//Get the Login Id of the User from Request
String testUserID = getTestUserId();
String userId = testUserID != null ? testUserID : UserUtils.getUserSession(request).getOrgUserId();
- //Check if the Role and Scope Size are Null get the values from db.
List<Object> userRoles = controller.getRoles(userId);
- roles = new ArrayList<>();
- scopes = new HashSet<>();
- for(Object role: userRoles){
- Roles userRole = (Roles) role;
- roles.add(userRole.getRole());
- if(userRole.getScope() != null){
- if(userRole.getScope().contains(",")){
- String[] multipleScopes = userRole.getScope().split(",");
- for(int i =0; i < multipleScopes.length; i++){
- scopes.add(multipleScopes[i]);
- }
- }else{
- scopes.add(userRole.getScope());
- }
- }
- }
+ Pair<Set<String>, List<String>> pair = org.onap.policy.utils.UserUtils.checkRoleAndScope(userRoles);
+ roles = pair.u;
+ scopes = pair.t;
List<JSONObject> resultList = new ArrayList<>();
boolean onlyFolders = params.getBoolean("onlyFolders");
@@ -659,7 +631,7 @@ public class PolicyManagerServlet extends HttpServlet {
}
private List<Object> queryPolicyEditorScopes(String scopeName){
- String scopeNamequery = "";
+ String scopeNamequery;
SimpleBindings params = new SimpleBindings();
if(scopeName == null){
scopeNamequery = "from PolicyEditorScopes";
@@ -668,7 +640,7 @@ public class PolicyManagerServlet extends HttpServlet {
params.put("scopeName", scopeName + "%");
}
PolicyController controller = getPolicyControllerInstance();
- List<Object> scopesList = null;
+ List<Object> scopesList;
if(PolicyController.isjUnit()){
scopesList = controller.getDataByQuery(scopeNamequery, null);
}else{
@@ -692,8 +664,8 @@ public class PolicyManagerServlet extends HttpServlet {
SimpleBindings params = new SimpleBindings();
params.put("scopeName", scopeName + "%");
- List<Object> activePolicies = null;
- List<Object> scopesList = null;
+ List<Object> activePolicies;
+ List<Object> scopesList;
if(PolicyController.isjUnit()){
activePolicies = controller.getDataByQuery(query, null);
scopesList = controller.getDataByQuery(scopeNamequery, null);
@@ -727,7 +699,7 @@ public class PolicyManagerServlet extends HttpServlet {
}
}
}
- String scopeNameCheck = null;
+ String scopeNameCheck;
for (Object list : activePolicies) {
PolicyVersion policy = (PolicyVersion) list;
String scopeNameValue = policy.getPolicyName().substring(0, policy.getPolicyName().lastIndexOf(File.separator));
@@ -862,7 +834,7 @@ public class PolicyManagerServlet extends HttpServlet {
private JSONObject policyRename(String oldPath, String newPath, String userId) throws ServletException {
try {
- PolicyEntity entity = null;
+ PolicyEntity entity;
PolicyController controller = getPolicyControllerInstance();
String policyVersionName = newPath.replace(".xml", "");
@@ -1004,7 +976,7 @@ public class PolicyManagerServlet extends HttpServlet {
private JSONObject cloneRecord(String newpolicyName, String oldScope, String removeoldPolicyExtension, String newScope, String removenewPolicyExtension, PolicyEntity entity, String userId) throws ServletException{
FileWriter fw = null;
- String queryEntityName = null;
+ String queryEntityName;
PolicyController controller = getPolicyControllerInstance();
PolicyEntity cloneEntity = new PolicyEntity();
cloneEntity.setPolicyName(newpolicyName);
@@ -1174,7 +1146,7 @@ public class PolicyManagerServlet extends HttpServlet {
path = path.substring(path.indexOf('/')+1);
String policyNamewithExtension = path.replace("/", File.separator);
String policyVersionName = policyNamewithExtension.replace(".xml", "");
- String query = "";
+ String query;
SimpleBindings policyParams = new SimpleBindings();
if(path.endsWith(".xml")){
policyNamewithoutExtension = policyVersionName.substring(0, policyVersionName.lastIndexOf('.'));
@@ -1413,7 +1385,7 @@ public class PolicyManagerServlet extends HttpServlet {
SimpleBindings peParams = new SimpleBindings();
peParams.put("split_1", split[1]);
peParams.put("split_0", split[0]);
- List<Object> queryData = null;
+ List<Object> queryData;
if(PolicyController.isjUnit()){
queryData = controller.getDataByQuery(query, null);
}else{
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyNotificationMail.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyNotificationMail.java
index 36e94c2ca..895adbe41 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyNotificationMail.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyNotificationMail.java
@@ -143,11 +143,9 @@ public class PolicyNotificationMail{
}
}
if(sendFlag){
- AnnotationConfigApplicationContext ctx = null;
- try {
+ try (AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext()) {
to = list.getLoginIds()+"@"+PolicyController.getSmtpEmailExtension();
to = to.trim();
- ctx = new AnnotationConfigApplicationContext();
ctx.register(PolicyNotificationMail.class);
ctx.refresh();
JavaMailSenderImpl mailSender = ctx.getBean(JavaMailSenderImpl.class);
@@ -158,15 +156,11 @@ public class PolicyNotificationMail{
mailMsg.setSubject(subject);
mailMsg.setText(message);
mailSender.send(mimeMessage);
- if(mode.equalsIgnoreCase("Rename") || mode.contains("Delete") || mode.contains("Move")){
+ if("Rename".equalsIgnoreCase(mode) || mode.contains("Delete") || mode.contains("Move")){
policyNotificationDao.delete(watch);
}
} catch (Exception e) {
policyLogger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW+"Exception Occured in Policy Notification" +e);
- }finally{
- if(ctx != null){
- ctx.close();
- }
}
}
}
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java
index d930a6d7a..63d0cb298 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java
@@ -141,14 +141,11 @@ public class PolicyRestController extends RestrictedBaseController{
if(policyData.getConfigPolicyType() != null){
if("ClosedLoop_Fault".equalsIgnoreCase(policyData.getConfigPolicyType())){
- CreateClosedLoopFaultController faultController = new CreateClosedLoopFaultController();
- policyData = faultController.setDataToPolicyRestAdapter(policyData, root);
+ policyData = new CreateClosedLoopFaultController().setDataToPolicyRestAdapter(policyData, root);
}else if("Firewall Config".equalsIgnoreCase(policyData.getConfigPolicyType())){
- CreateFirewallController fwController = new CreateFirewallController();
- policyData = fwController.setDataToPolicyRestAdapter(policyData);
+ policyData = new CreateFirewallController().setDataToPolicyRestAdapter(policyData);
}else if("Micro Service".equalsIgnoreCase(policyData.getConfigPolicyType())){
- CreateDcaeMicroServiceController msController = new CreateDcaeMicroServiceController();
- policyData = msController.setDataToPolicyRestAdapter(policyData, root);
+ policyData = new CreateDcaeMicroServiceController().setDataToPolicyRestAdapter(policyData, root);
}
}
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/components/HumanPolicyComponent.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/components/HumanPolicyComponent.java
index 512901d4f..de1c551fc 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/components/HumanPolicyComponent.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/components/HumanPolicyComponent.java
@@ -24,7 +24,6 @@ package org.onap.policy.components;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
-import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.nio.file.Path;
@@ -132,12 +131,10 @@ public class HumanPolicyComponent{
}
private static String processPolicy() {
- if (LOGGER.isTraceEnabled())
+ if (LOGGER.isTraceEnabled()) {
LOGGER.trace("ENTER");
-
- FileInputStream pIS = null;
- try {
- pIS = new FileInputStream(policyFile);
+ }
+ try (FileInputStream pIS = new FileInputStream(policyFile)){
Object policy = XACMLPolicyScanner.readPolicy(pIS);
if (policy == null)
throw new IllegalArgumentException("Policy File " + policyFile.getName() +
@@ -160,14 +157,6 @@ public class HumanPolicyComponent{
": " + e.getMessage();
LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + msg, e);
throw new IllegalArgumentException(msg);
- } finally {
- if (pIS != null) {
- try {
- pIS.close();
- } catch (IOException e) {
- LOGGER.warn(e.getMessage(), e);
- }
- }
}
}
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/ActionPolicyController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/ActionPolicyController.java
index 88cb2e265..a556beeaa 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/ActionPolicyController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/ActionPolicyController.java
@@ -26,6 +26,7 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import javax.xml.bind.JAXBElement;
@@ -166,8 +167,9 @@ public class ActionPolicyController extends RestrictedBaseController {
AttributeValueType attributeValue = (AttributeValueType) attributeAssignmentExpression
.getExpression().getValue();
if (attributeID.equals(PERFORMER_ATTRIBUTEID)) {
- for (String key : performer.keySet()) {
- String keyValue = performer.get(key);
+ for ( Entry<String, String> entry: performer.entrySet()) {
+ String key = entry.getKey();
+ String keyValue = entry.getValue();
if (keyValue.equals(attributeValue.getContent().get(0))) {
policyAdapter.setActionPerformer(key);
}
@@ -235,10 +237,9 @@ public class ActionPolicyController extends RestrictedBaseController {
ruleMap.put("id", "A" + (index + 1));
// Populate combo box
Map<String, String> dropDownMap = PolicyController.getDropDownMap();
- for (String key : dropDownMap.keySet()) {
- String keyValue = dropDownMap.get(key);
- if (keyValue.equals(actionApply.getFunctionId())) {
- ruleMap.put("dynamicRuleAlgorithmCombo", key);
+ for ( Entry<String, String> entry : dropDownMap.entrySet()) {
+ if (entry.getValue().equals(actionApply.getFunctionId())) {
+ ruleMap.put("dynamicRuleAlgorithmCombo", entry.getKey());
}
}
// Populate the key and value fields
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateBRMSParamController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateBRMSParamController.java
index e578d9108..df1ca6a9f 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateBRMSParamController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateBRMSParamController.java
@@ -85,7 +85,9 @@ public class CreateBRMSParamController extends RestrictedBaseController {
CreateBRMSParamController.commonClassDao = commonClassDao;
}
- public CreateBRMSParamController(){}
+ public CreateBRMSParamController(){
+ // Empty constructor
+ }
protected PolicyRestAdapter policyAdapter = null;
private HashMap<String, String> dynamicLayoutMap;
@@ -185,7 +187,7 @@ public class CreateBRMSParamController extends RestrictedBaseController {
String[] components = params.toString().split(":");
String caption = "";
for (int i = 0; i < components.length; i++) {
- String type = "";
+ String type;
if (i == 0) {
caption = components[i];
}
@@ -415,7 +417,7 @@ public class CreateBRMSParamController extends RestrictedBaseController {
String[] components = params.toString().split("\\);");
if(components!= null && components.length > 0){
for (int i = 0; i < components.length; i++) {
- String value = null;
+ String value;
components[i] = components[i]+")";
String caption = components[i].substring(0,
components[i].indexOf('('));
@@ -456,7 +458,7 @@ public class CreateBRMSParamController extends RestrictedBaseController {
policyData.setEditPolicy(true);
}
- String body = "";
+ String body;
body = "/* Autogenerated Code Please Don't change/remove this comment section. This is for the UI purpose. \n\t " +
brmsTemplateVlaue + policyData.getRuleName() + "%$> \n */ \n";
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateBRMSRawController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateBRMSRawController.java
index e93fbf4e5..3ab4f4f16 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateBRMSRawController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateBRMSRawController.java
@@ -131,16 +131,16 @@ public class CreateBRMSRawController{
AttributeDesignatorType designator = match.getAttributeDesignator();
String attributeId = designator.getAttributeId();
- if (attributeId.equals("RiskType")){
+ if ("RiskType".equals(attributeId)){
policyAdapter.setRiskType(value);
}
- if (attributeId.equals("RiskLevel")){
+ if ("RiskLevel".equals(attributeId)){
policyAdapter.setRiskLevel(value);
}
- if (attributeId.equals("guard")){
+ if ("guard".equals(attributeId)){
policyAdapter.setGuard(value);
}
- if (attributeId.equals("TTLDate") && !value.contains("NA")){
+ if ("TTLDate".equals(attributeId) && !value.contains("NA")){
PolicyController controller = new PolicyController();
String newDate = controller.convertDate(value);
policyAdapter.setTtlDate(newDate);
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateClosedLoopFaultController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateClosedLoopFaultController.java
index 8ce32670f..158ea6248 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateClosedLoopFaultController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateClosedLoopFaultController.java
@@ -73,7 +73,9 @@ public class CreateClosedLoopFaultController extends RestrictedBaseController{
CreateClosedLoopFaultController.commonclassdao = commonclassdao;
}
- public CreateClosedLoopFaultController(){}
+ public CreateClosedLoopFaultController(){
+ // Empty constructor
+ }
public PolicyRestAdapter setDataToPolicyRestAdapter(PolicyRestAdapter policyData, JsonNode root){
try{
@@ -245,35 +247,35 @@ public class CreateClosedLoopFaultController extends RestrictedBaseController{
TrapDatas trapDatas = (TrapDatas) object;
ArrayList<Object> attributeList = new ArrayList<>();
// Read the Trap
- if(!trap.equals("nill")){
+ if(! "nill".equals(trap)){
try{
if(trap.startsWith("Trap")){
- if(trap.equals("Trap1")){
+ if("Trap1".equals(trap)){
attributeList = trapDatas.getTrap1();
- }else if(trap.equals("Trap2")){
+ }else if("Trap2".equals(trap)){
attributeList = trapDatas.getTrap2();
- }else if(trap.equals("Trap3")){
+ }else if("Trap3".equals(trap)){
attributeList = trapDatas.getTrap3();
- }else if(trap.equals("Trap4")){
+ }else if("Trap4".equals(trap)){
attributeList = trapDatas.getTrap4();
- }else if(trap.equals("Trap5")){
+ }else if("Trap5".equals(trap)){
attributeList = trapDatas.getTrap5();
- }else if(trap.equals("Trap6")){
+ }else if("Trap6".equals(trap)){
attributeList = trapDatas.getTrap6();
}
}else{
if(trap.startsWith("Fault")){
- if(trap.equals("Fault1")){
+ if("Fault1".equals(trap)){
attributeList = trapDatas.getTrap1();
- }else if(trap.equals("Fault2")){
+ }else if("Fault2".equals(trap)){
attributeList = trapDatas.getTrap2();
- }else if(trap.equals("Fault3")){
+ }else if("Fault3".equals(trap)){
attributeList = trapDatas.getTrap3();
- }else if(trap.equals("Fault4")){
+ }else if("Fault4".equals(trap)){
attributeList = trapDatas.getTrap4();
- }else if(trap.equals("Fault5")){
+ }else if("Fault5".equals(trap)){
attributeList = trapDatas.getTrap5();
- }else if(trap.equals("Fault6")){
+ }else if("Fault6".equals(trap)){
attributeList = trapDatas.getTrap6();
}
}
@@ -548,22 +550,22 @@ public class CreateClosedLoopFaultController extends RestrictedBaseController{
String attributeId = designator.getAttributeId();
// First match in the target is OnapName, so set that value.
- if (attributeId.equals("ONAPName")) {
+ if ("ONAPName".equals(attributeId)) {
policyAdapter.setOnapName(value);
OnapName onapName = new OnapName();
onapName.setOnapName(value);
policyAdapter.setOnapNameField(onapName);
}
- if (attributeId.equals("RiskType")){
+ if ("RiskType".equals(attributeId)){
policyAdapter.setRiskType(value);
}
- if (attributeId.equals("RiskLevel")){
+ if ("RiskLevel".equals(attributeId)){
policyAdapter.setRiskLevel(value);
}
- if (attributeId.equals("guard")){
+ if ("guard".equals(attributeId)){
policyAdapter.setGuard(value);
}
- if (attributeId.equals("TTLDate") && !value.contains("NA")){
+ if ("TTLDate".equals(attributeId) && !value.contains("NA")){
PolicyController controller = new PolicyController();
String newDate = controller.convertDate(value);
policyAdapter.setTtlDate(newDate);
@@ -584,7 +586,7 @@ public class CreateClosedLoopFaultController extends RestrictedBaseController{
ObjectMapper mapper = new ObjectMapper();
try {
ClosedLoopFaultBody closedLoopBody = mapper.readValue(entity.getConfigurationData().getConfigBody(), ClosedLoopFaultBody.class);
- if(closedLoopBody.getClosedLoopPolicyStatus().equalsIgnoreCase("ACTIVE")){
+ if("ACTIVE".equalsIgnoreCase(closedLoopBody.getClosedLoopPolicyStatus())){
closedLoopBody.setClosedLoopPolicyStatus("Active");
}else{
closedLoopBody.setClosedLoopPolicyStatus("InActive");
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java
index d8ccd9a02..431482d40 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java
@@ -158,7 +158,9 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
CreateDcaeMicroServiceController.commonClassDao = commonClassDao;
}
- public CreateDcaeMicroServiceController(){}
+ public CreateDcaeMicroServiceController(){
+ // Empty Constructor
+ }
protected PolicyRestAdapter policyAdapter = null;
private int priorityCount;
@@ -431,7 +433,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
return settings;
}
- public Map<String, String> load(byte[] source) throws IOException {
+ public Map<String, String> load(byte[] source) {
Yaml yaml = new Yaml();
@SuppressWarnings("unchecked")
Map<Object, Object> yamlMap = (Map<Object, Object>) yaml.load(Arrays.toString(source));
@@ -701,7 +703,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
Iterator<String> itr=keys.iterator();
while(itr.hasNext()){
String key= itr.next();
- if((!("type").equals(key) ||("required").equals(key)))
+ if(!("type").equals(key) ||("required").equals(key))
{
String value= keyValues.get(key);
//The "." in the value determines if its a string or a user defined type.
@@ -721,10 +723,9 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
}
- if(keyValues.get("type").equalsIgnoreCase(LIST)){
- if(constraints == null || constraints.isEmpty()){
+ if(keyValues.get("type").equalsIgnoreCase(LIST) &&
+ (constraints == null || constraints.isEmpty()) ) {
referenceStringBuilder.append(keySetString+"=MANY-true"+",");
- }
}
}else{
//User defined Datatype.
@@ -829,8 +830,10 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
JsonNodeFactory nodeFactory = JsonNodeFactory.instance;
ObjectNode node = nodeFactory.objectNode();
String prevKey = null;
- String presKey = null;
- for(String key: element.keySet()){
+ String presKey;
+ for(Entry<String, String> entry: element.entrySet()){
+ String key = entry.getKey();
+ String value = entry.getValue();
if(key.contains(".")){
presKey = key.substring(0,key.indexOf('.'));
}else if(key.contains("@")){
@@ -858,7 +861,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
nodeKey = key.substring(0,key.indexOf('.'));
}
if(nodeKey.equals(key.substring(0,key.indexOf('.')))){
- node.put(key.substring(key.indexOf('.')+1), element.get(key));
+ node.put(key.substring(key.indexOf('.')+1), value);
}else{
if(node.size()!=0){
if(nodeKey.contains("@")){
@@ -887,54 +890,30 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
if(nodeKey.contains("@")){
arryKey = nodeKey.substring(0,nodeKey.indexOf('@'));
}
- node.put(key.substring(key.indexOf('.')+1), element.get(key));
+ node.put(key.substring(key.indexOf('.')+1), value);
}
- }else if(node.size()!=0){
- if(nodeKey.contains("@")){
- if(arryKey==null){
- arryKey = nodeKey.substring(0,nodeKey.indexOf('@'));
- }
- if(nodeKey.endsWith("@0")){
- isArray = true;
- jsonArray = new JSONArray();
- }
- if(jsonArray != null && arryKey.equals(nodeKey.substring(0,nodeKey.indexOf('@')))){
- jsonArray.put(decodeContent(node));
- }
- jsonResult.put(arryKey, jsonArray);
- jsonArray = new JSONArray();
- arryKey = nodeKey.substring(0,nodeKey.indexOf('@'));
- }else{
- isArray = false;
- jsonResult.put(nodeKey, decodeContent(node));
- }
- node = nodeFactory.objectNode();
- if(key.contains("@")){
- isArray = true;
- if(key.endsWith("@0")|| jsonArray==null){
+ }else {
+ if(node.size()!=0){
+ if(nodeKey.contains("@")){
+ if(arryKey==null){
+ arryKey = nodeKey.substring(0,nodeKey.indexOf('@'));
+ }
+ if(nodeKey.endsWith("@0")){
+ isArray = true;
+ jsonArray = new JSONArray();
+ }
+ if(jsonArray != null && arryKey.equals(nodeKey.substring(0,nodeKey.indexOf('@')))){
+ jsonArray.put(decodeContent(node));
+ }
+ jsonResult.put(arryKey, jsonArray);
jsonArray = new JSONArray();
- }
- }else if(!key.contains("@")){
- isArray = false;
- }
- if(isArray){
- if(oldValue==null){
- oldValue = key.substring(0,key.indexOf('@'));
- }
- if(oldValue!=prevKey){
- oldValue = key.substring(0,key.indexOf('@'));
- }
- if(oldValue.equals(key.substring(0,key.indexOf('@')))){
- jsonArray.put(element.get(key));
+ arryKey = nodeKey.substring(0,nodeKey.indexOf('@'));
}else{
- jsonResult.put(oldValue, jsonArray);
- jsonArray = new JSONArray();
+ isArray = false;
+ jsonResult.put(nodeKey, decodeContent(node));
}
- oldValue = key.substring(0,key.indexOf('@'));
- }else{
- jsonResult.put(key, element.get(key));
+ node = nodeFactory.objectNode();
}
- }else{
if(key.contains("@")){
isArray = true;
if(key.endsWith("@0")|| jsonArray==null){
@@ -951,14 +930,14 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
oldValue = key.substring(0,key.indexOf('@'));
}
if(oldValue.equals(key.substring(0,key.indexOf('@')))){
- jsonArray.put(element.get(key));
+ jsonArray.put(value);
}else{
jsonResult.put(oldValue, jsonArray);
jsonArray = new JSONArray();
}
oldValue = key.substring(0,key.indexOf('@'));
}else{
- jsonResult.put(key, element.get(key));
+ jsonResult.put(key, value);
}
}
}
@@ -1053,7 +1032,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
List<Object> list = new ArrayList<>();
PrintWriter out = response.getWriter();
String responseString = mapper.writeValueAsString(returnModel);
- JSONObject j = null;
+ JSONObject j;
if("".equals(allManyTrueKeys)){
j = new JSONObject("{dcaeModelData: " + responseString + ",jsonValue: " + jsonModel + "}");
}else{
@@ -1103,7 +1082,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
for (Entry<String, String> keySet : attributeMap.entrySet()){
array = new JSONArray();
String value = keySet.getValue();
- if (keySet.getValue().split("MANY-")[1].equalsIgnoreCase("true")){
+ if ("true".equalsIgnoreCase(keySet.getValue().split("MANY-")[1])){
array.put(value);
object.put(keySet.getKey().trim(), array);
}else {
@@ -1115,14 +1094,14 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
array = new JSONArray();
String value = keySet.getValue().split(":")[0];
if (gsonObject.containsKey(value)){
- if (keySet.getValue().split("MANY-")[1].equalsIgnoreCase("true")){
+ if ("true".equalsIgnoreCase(keySet.getValue().split("MANY-")[1])){
array.put(recursiveReference(value, gsonObject, enumAttribute));
object.put(keySet.getKey().trim(), array);
}else {
object.put(keySet.getKey().trim(), recursiveReference(value, gsonObject, enumAttribute));
}
}else {
- if (keySet.getValue().split("MANY-")[1].equalsIgnoreCase("true")){
+ if ("true".equalsIgnoreCase(keySet.getValue().split("MANY-")[1])){
array.put(value.trim());
object.put(keySet.getKey().trim(), array);
}else {
@@ -1148,14 +1127,14 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
String[] splitValue = m.getValue().split(":");
array = new JSONArray();
if (subAttributeMap.containsKey(splitValue[0])){
- if (m.getValue().split("MANY-")[1].equalsIgnoreCase("true")){
+ if ("true".equalsIgnoreCase(m.getValue().split("MANY-")[1])){
array.put(recursiveReference(splitValue[0], subAttributeMap, enumAttribute));
object.put(m.getKey().trim(), array);
}else {
object.put(m.getKey().trim(), recursiveReference(splitValue[0], subAttributeMap, enumAttribute));
}
} else{
- if (m.getValue().split("MANY-")[1].equalsIgnoreCase("true")){
+ if ("true".equalsIgnoreCase(m.getValue().split("MANY-")[1])){
array.put(splitValue[0].trim());
object.put(m.getKey().trim(), array);
}else {
@@ -1203,7 +1182,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
if(referAttributes != null){
String[] referAarray = referAttributes.split(",");
- String []element= null;
+ String []element;
for(int i=0; i<referAarray.length; i++){
element = referAarray[i].split("=");
if(element.length > 1 && element[1].contains("MANY-true")){
@@ -1373,28 +1352,28 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
AttributeDesignatorType designator = match.getAttributeDesignator();
String attributeId = designator.getAttributeId();
// First match in the target is OnapName, so set that value.
- if (attributeId.equals("ONAPName")) {
+ if ("ONAPName".equals(attributeId)) {
policyAdapter.setOnapName(value);
}
- if (attributeId.equals("ConfigName")){
+ if ("ConfigName".equals(attributeId)){
policyAdapter.setConfigName(value);
}
- if (attributeId.equals("uuid")){
+ if ("uuid".equals(attributeId)){
policyAdapter.setUuid(value);
}
- if (attributeId.equals("location")){
+ if ("location".equals(attributeId)){
policyAdapter.setLocation(value);
}
- if (attributeId.equals("RiskType")){
+ if ("RiskType".equals(attributeId)){
policyAdapter.setRiskType(value);
}
- if (attributeId.equals("RiskLevel")){
+ if ("RiskLevel".equals(attributeId)){
policyAdapter.setRiskLevel(value);
}
- if (attributeId.equals("guard")){
+ if ("guard".equals(attributeId)){
policyAdapter.setGuard(value);
}
- if (attributeId.equals("TTLDate") && !value.contains("NA")){
+ if ("TTLDate".equals(attributeId) && !value.contains("NA")){
PolicyController controller = new PolicyController();
String newDate = controller.convertDate(value);
policyAdapter.setTtlDate(newDate);
@@ -1458,8 +1437,8 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
if(value instanceof LinkedHashMap<?, ?>){
LinkedHashMap<String, Object> secondObjec = new LinkedHashMap<>();
readRecursivlyJSONContent((LinkedHashMap<String, ?>) value, secondObjec);
- for(String objKey: secondObjec.keySet()){
- data.put(key+"." +objKey, secondObjec.get(objKey));
+ for( Entry<String, Object> entry : secondObjec.entrySet()){
+ data.put(key+"." + entry.getKey(), entry.getValue());
}
}else if(value instanceof ArrayList){
ArrayList<?> jsonArrayVal = (ArrayList<?>)value;
@@ -1468,8 +1447,8 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
if(arrayvalue instanceof LinkedHashMap<?, ?>){
LinkedHashMap<String, Object> newData = new LinkedHashMap<>();
readRecursivlyJSONContent((LinkedHashMap<String, ?>) arrayvalue, newData);
- for(String objKey: newData.keySet()){
- data.put(key+"@"+i+"." +objKey, newData.get(objKey));
+ for(Entry<String, Object> entry: newData.entrySet()){
+ data.put(key+"@"+i+"." +entry.getKey(), entry.getValue());
}
}else if(arrayvalue instanceof ArrayList){
ArrayList<?> jsonArrayVal1 = (ArrayList<?>)value;
@@ -1499,7 +1478,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
//Convert the map values and set into JSON body
public Map<String, String> convertMap(Map<String, String> attributesMap, Map<String, String> attributesRefMap) {
Map<String, String> attribute = new HashMap<>();
- StringBuilder temp = null;
+ StringBuilder temp;
String key;
String value;
for (Entry<String, String> entry : attributesMap.entrySet()) {
@@ -1604,7 +1583,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
File file = new File(this.newFile);
fileList.add(file);
}
- String modelType= "";
+ String modelType;
if(! yml){
modelType="xmi";
//Process Main Model file first
@@ -1675,9 +1654,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
int BUFFER = 2048;
File file = new File(zipFile);
- ZipFile zip = null;
- try {
- zip = new ZipFile(file);
+ try (ZipFile zip = new ZipFile(file)) {
String newPath = "model" + File.separator + zipFile.substring(0, zipFile.length() - 4);
this.directory = "model" + File.separator + zipFile.substring(0, zipFile.length() - 4);
checkZipDirectory(this.directory);
@@ -1697,15 +1674,20 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
if (!entry.isDirectory()){
BufferedInputStream is = new BufferedInputStream(zip.getInputStream(entry));
int currentByte;
- byte data[] = new byte[BUFFER];
- FileOutputStream fos = new FileOutputStream(destFile);
- BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER);
- while ((currentByte = is.read(data, 0, BUFFER)) != -1) {
- dest.write(data, 0, currentByte);
+ byte[] data = new byte[BUFFER];
+ try (FileOutputStream fos = new FileOutputStream(destFile);
+ BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER)) {
+ while ((currentByte = is.read(data, 0, BUFFER)) != -1) {
+ dest.write(data, 0, currentByte);
+ }
+ dest.flush();
+ } catch (IOException e) {
+ LOGGER.error("Failed to write zip contents to {}" + destFile + e);
+ //
+ // PLD should I throw e?
+ //
+ throw e;
}
- dest.flush();
- dest.close();
- is.close();
}
if (currentEntry.endsWith(".zip")){
@@ -1714,20 +1696,13 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
}
} catch (IOException e) {
LOGGER.error("Failed to unzip model file " + zipFile, e);
- }finally{
- try {
- if(zip != null)
- zip.close();
- } catch (IOException e) {
- LOGGER.error("Exception Occured While closing zipfile " + e);
- }
}
}
private void retreiveDependency(String workingFile, Boolean modelClass) {
MSModelUtils utils = new MSModelUtils(PolicyController.getMsOnapName(), PolicyController.getMsPolicyName());
- HashMap<String, MSAttributeObject> tempMap;
+ Map<String, MSAttributeObject> tempMap;
tempMap = utils.processEpackage(workingFile, MODEL_TYPE.XMI);
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateFirewallController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateFirewallController.java
index f0681a388..2750ff505 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateFirewallController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateFirewallController.java
@@ -119,7 +119,7 @@ public class CreateFirewallController extends RestrictedBaseController {
public PolicyRestAdapter setDataToPolicyRestAdapter(PolicyRestAdapter policyData){
- String jsonBody="";
+ String jsonBody;
termCollectorList = new ArrayList <>();
tagCollectorList = new ArrayList <>();
if(! policyData.getAttributes().isEmpty()){
@@ -134,7 +134,7 @@ public class CreateFirewallController extends RestrictedBaseController {
}
}
jsonBody = constructJson(policyData);
- if (jsonBody != null && !jsonBody.equalsIgnoreCase("")) {
+ if (jsonBody != null && ! "".equalsIgnoreCase(jsonBody)) {
policyData.setJsonBody(jsonBody);
} else {
policyData.setJsonBody("{}");
@@ -145,8 +145,8 @@ public class CreateFirewallController extends RestrictedBaseController {
}
private List<String> mapping(String expandableList) {
- String value = null;
- String desc = null;
+ String value;
+ String desc;
List <String> valueDesc= new ArrayList<>();
List<Object> prefixListData = commonClassDao.getData(PrefixList.class);
for (int i = 0; i< prefixListData.size(); i++) {
@@ -227,7 +227,7 @@ public class CreateFirewallController extends RestrictedBaseController {
TermCollector tc1=null;
try {
//Json conversion.
- String data=null;
+ String data;
SecurityZone jpaSecurityZone;
data = entity.getConfigurationData().getConfigBody();
tc1 = mapper.readValue(data, TermCollector.class);
@@ -244,7 +244,7 @@ public class CreateFirewallController extends RestrictedBaseController {
policyLogger.error("Exception Caused while Retriving the JSON body data" +e);
}
- Map<String, String> termTagMap=null;
+ Map<String, String> termTagMap;
if(tc1 != null){
for(int i=0;i<tc1.getFirewallRuleList().size();i++){
termTagMap = new HashMap <>();
@@ -298,7 +298,7 @@ public class CreateFirewallController extends RestrictedBaseController {
if (("guard").equals(attributeId)){
policyAdapter.setGuard(value);
}
- if (attributeId.equals("TTLDate") && !value.contains("NA")){
+ if ("TTLDate".equals(attributeId) && !value.contains("NA")){
PolicyController controller = new PolicyController();
String newDate = controller.convertDate(value);
policyAdapter.setTtlDate(newDate);
@@ -330,13 +330,13 @@ public class CreateFirewallController extends RestrictedBaseController {
}
}
TermList jpaTermList;
- String ruleSrcList=null;
- String ruleDestList=null;
- String ruleSrcPort=null;
- String ruleDestPort=null;
- String ruleAction=null;
- List <String> valueDesc= new ArrayList<>();
- StringBuffer displayString = new StringBuffer();
+ String ruleSrcList;
+ String ruleDestList;
+ String ruleSrcPort;
+ String ruleDestPort;
+ String ruleAction;
+ List <String> valueDesc;
+ StringBuilder displayString = new StringBuilder();
for (String id : termCollectorList) {
List<Object> tmList = commonClassDao.getDataById(TermList.class, "termName", id);
jpaTermList = (TermList) tmList.get(0);
@@ -349,15 +349,17 @@ public class CreateFirewallController extends RestrictedBaseController {
if(srcList.startsWith(GROUP)){
AddressGroup ag;
ag= mappingAddressGroup(srcList);
- displayString.append("\n\t"+"Group has :"+ag.getPrefixList()+"\n");
- for(String groupItems:ag.getPrefixList().split(",")){
- valueDesc=mapping(groupItems);
- displayString.append("\n\t"+"Name: "+groupItems);
- if(!valueDesc.isEmpty()){
- displayString.append("\n\t"+"Description: "+valueDesc.get(1));
- displayString.append("\n\t"+"Value: "+valueDesc.get(0));
+ displayString.append("\n\t"+"Group has :"+(ag != null ? ag.getPrefixList() : "") +"\n");
+ if (ag != null) {
+ for(String groupItems:ag.getPrefixList().split(",")){
+ valueDesc=mapping(groupItems);
+ displayString.append("\n\t"+"Name: "+groupItems);
+ if(!valueDesc.isEmpty()){
+ displayString.append("\n\t"+"Description: "+valueDesc.get(1));
+ displayString.append("\n\t"+"Value: "+valueDesc.get(0));
+ }
+ displayString.append("\n");
}
- displayString.append("\n");
}
}else{
if(!srcList.equals(ANY)){
@@ -372,20 +374,22 @@ public class CreateFirewallController extends RestrictedBaseController {
displayString.append("\n");
}
ruleDestList= jpaTermList.getDestIPList();
- if ( ruleDestList!= null && (!ruleDestList.isEmpty())&& !ruleDestList.equals("null")){
+ if ( ruleDestList!= null && (!ruleDestList.isEmpty())&& ! "null".equals(ruleDestList)){
displayString.append("Destination IP List: " + jpaTermList.getDestIPList());
displayString.append(" ; \t\n");
for(String destList:ruleDestList.split(",")){
if(destList.startsWith(GROUP)){
AddressGroup ag;
ag= mappingAddressGroup(destList);
- displayString.append("\n\t"+"Group has :"+ag.getPrefixList()+"\n");
- for(String groupItems:ag.getPrefixList().split(",")){
- valueDesc=mapping(groupItems);
- displayString.append("\n\t"+"Name: "+groupItems);
- displayString.append("\n\t"+"Description: "+valueDesc.get(1));
- displayString.append("\n\t"+"Value: "+valueDesc.get(0));
- displayString.append("\n\t");
+ displayString.append("\n\t"+"Group has :"+ (ag != null ? ag.getPrefixList() : "") +"\n");
+ if (ag != null) {
+ for(String groupItems:ag.getPrefixList().split(",")){
+ valueDesc=mapping(groupItems);
+ displayString.append("\n\t"+"Name: "+groupItems);
+ displayString.append("\n\t"+"Description: "+valueDesc.get(1));
+ displayString.append("\n\t"+"Value: "+valueDesc.get(0));
+ displayString.append("\n\t");
+ }
}
}else{
if(!destList.equals(ANY)){
@@ -401,14 +405,14 @@ public class CreateFirewallController extends RestrictedBaseController {
}
ruleSrcPort=jpaTermList.getSrcPortList();
- if ( ruleSrcPort!= null && (!ruleSrcPort.isEmpty())&& !ruleSrcPort.equals("null")) {
+ if ( ruleSrcPort!= null && (!ruleSrcPort.isEmpty())&& !"null".equals(ruleSrcPort)) {
displayString.append("\n"+"Source Port List:"
+ ruleSrcPort);
displayString.append(" ; \t\n");
}
ruleDestPort= jpaTermList.getDestPortList();
- if (ruleDestPort != null && (!ruleDestPort.isEmpty())&& !ruleDestPort.equals("null")) {
+ if (ruleDestPort != null && (!ruleDestPort.isEmpty())&& !"null".equals(ruleDestPort)) {
displayString.append("\n"+"Destination Port List:"
+ ruleDestPort);
displayString.append(" ; \t\n");
@@ -416,19 +420,21 @@ public class CreateFirewallController extends RestrictedBaseController {
if(destServices.startsWith(GROUP)){
GroupServiceList sg;
sg= mappingServiceGroup(destServices);
- displayString.append("\n\t"+"Service Group has :"+sg.getServiceList()+"\n");
- for(String groupItems:sg.getServiceList().split(",")){
- ServiceList sl;
- sl= mappingServiceList(groupItems);
- displayString.append("\n\t"+"Name: "+
- sl.getServiceName());
- displayString.append("\n\t"+"Description: "+
- sl.getServiceDescription());
- displayString.append("\n\t"+"Transport-Protocol: "+
- sl.getServiceTransProtocol());
- displayString.append("\n\t"+"Ports: "+
- sl.getServicePorts());
- displayString.append("\n");
+ displayString.append("\n\t"+"Service Group has :"+ (sg != null ? sg.getServiceList() : "") +"\n");
+ if (sg != null) {
+ for(String groupItems:sg.getServiceList().split(",")){
+ ServiceList sl;
+ sl= mappingServiceList(groupItems);
+ displayString.append("\n\t"+"Name: "+
+ sl.getServiceName());
+ displayString.append("\n\t"+"Description: "+
+ sl.getServiceDescription());
+ displayString.append("\n\t"+"Transport-Protocol: "+
+ sl.getServiceTransProtocol());
+ displayString.append("\n\t"+"Ports: "+
+ sl.getServicePorts());
+ displayString.append("\n");
+ }
}
}
else{
@@ -654,7 +660,7 @@ public class CreateFirewallController extends RestrictedBaseController {
}
//ExpandableServicesList
if((srcPort_map!=null) && (destPort_map!=null)){
- String servicesCollateString = (srcPort_map.get(tl) + "," + destPort_map.get(tl));
+ String servicesCollateString = srcPort_map.get(tl) + "," + destPort_map.get(tl);
expandableServicesList.add(servicesCollateString);
}else if (srcPort_map!=null){
expandableServicesList.add(srcPort_map.get(tl));
@@ -707,8 +713,8 @@ public class CreateFirewallController extends RestrictedBaseController {
//ExpandablePrefixIPList
if ((srcIP_map!=null) && (destIP_map!=null))
{
- String collateString = (srcIP_map.get(tl) + "," + destIP_map
- .get(tl));
+ String collateString = srcIP_map.get(tl) + "," + destIP_map
+ .get(tl);
expandablePrefixIPList.add(collateString);
}
else if(srcIP_map!=null){
@@ -754,15 +760,15 @@ public class CreateFirewallController extends RestrictedBaseController {
Set<AddressGroupJson> addrGroupArray= new HashSet<>();
Set<AddressMembers> addrArray= new HashSet<> ();
- ServiceGroupJson targetSg= null;
- AddressGroupJson addressSg=null;
- ServiceListJson targetAny= null;
- ServiceListJson targetAnyTcp=null;
- ServiceListJson targetAnyUdp=null;
+ ServiceGroupJson targetSg;
+ AddressGroupJson addressSg;
+ ServiceListJson targetAny;
+ ServiceListJson targetAnyTcp;
+ ServiceListJson targetAnyUdp;
for(String serviceList:expandableServicesList){
for(String t: serviceList.split(",")){
- if((!t.startsWith(GROUP))){
+ if(!t.startsWith(GROUP)){
if(!t.equals(ANY)){
ServiceList sl;
targetSl= new ServiceListJson();
@@ -838,7 +844,7 @@ public class CreateFirewallController extends RestrictedBaseController {
Set<PrefixIPList> prefixIPList = new HashSet<>();
for(String prefixList:expandablePrefixIPList){
for(String prefixIP: prefixList.split(",")){
- if((!prefixIP.startsWith(GROUP))){
+ if(!prefixIP.startsWith(GROUP)){
if(!prefixIP.equals(ANY)){
List<AddressMembers> addMembersList= new ArrayList<>();
List<String> valueDesc;
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreatePolicyController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreatePolicyController.java
index af4f9ffaf..6cd121ee6 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreatePolicyController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreatePolicyController.java
@@ -101,24 +101,24 @@ public class CreatePolicyController extends RestrictedBaseController{
AttributeDesignatorType designator = match.getAttributeDesignator();
String attributeId = designator.getAttributeId();
// First match in the target is OnapName, so set that value.
- if (attributeId.equals("ONAPName")) {
+ if ("ONAPName".equals(attributeId)) {
policyAdapter.setOnapName(value);
}
- if (attributeId.equals("RiskType")){
+ if ("RiskType".equals(attributeId)){
policyAdapter.setRiskType(value);
}
- if (attributeId.equals("RiskLevel")){
+ if ("RiskLevel".equals(attributeId)){
policyAdapter.setRiskLevel(value);
}
- if (attributeId.equals("guard")){
+ if ("guard".equals(attributeId)){
policyAdapter.setGuard(value);
}
- if (attributeId.equals("TTLDate") && !value.contains("NA")){
+ if ("TTLDate".equals(attributeId) && !value.contains("NA")){
PolicyController controller = new PolicyController();
String newDate = controller.convertDate(value);
policyAdapter.setTtlDate(newDate);
}
- if (attributeId.equals("ConfigName")){
+ if ("ConfigName".equals(attributeId)){
policyAdapter.setConfigName(value);
}
// After Onap and Config it is optional to have attributes, so
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/DashboardController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/DashboardController.java
index 6679b8954..adb91ec27 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/DashboardController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/DashboardController.java
@@ -281,12 +281,9 @@ public class DashboardController extends RestrictedBaseController{
policyLogger.debug("Create an RMI connector client and connect it to the JMX connector server");
HashMap map = null;
- JMXConnector jmxConnection;
- try {
- jmxConnection = JMXConnectorFactory.newJMXConnector(createConnectionURL(host, port), map);
+ try (JMXConnector jmxConnection = JMXConnectorFactory.newJMXConnector(createConnectionURL(host, port), map)){
jmxConnection.connect();
Object o = jmxConnection.getMBeanServerConnection().getAttribute(new ObjectName("PdpRest:type=PdpRestMonitor"), jmxAttribute);
- jmxConnection.close();
policyLogger.debug("pdpEvaluationNA value retreived: " + o);
return (long) o;
} catch (MalformedURLException e) {
@@ -319,10 +316,10 @@ public class DashboardController extends RestrictedBaseController{
*/
private void addPolicyToTable() {
policyActivityData = new ArrayList<>();
- String policyID = null;
- int policyFireCount = 0;
+ String policyID;
+ int policyFireCount;
Map<String, String> policyMap = new HashMap<>();
- Object policyList = null;
+ Object policyList;
//get list of policy
for (PDPGroup group : this.pdpConatiner.getGroups()){
@@ -346,14 +343,12 @@ public class DashboardController extends RestrictedBaseController{
for (String policyKeyValue : splitPolicy){
policyID = urnPolicyID(policyKeyValue);
policyFireCount = countPolicyID(policyKeyValue);
- if (policyID != null ){
- if (policyMap.containsKey(policyID)){
- JSONObject object = new JSONObject();
- object.put("policyId", policyMap.get(policyID));
- object.put("fireCount", policyFireCount);
- object.put("system", pdp.getId());
- policyActivityData.add(object);
- }
+ if (policyID != null && policyMap.containsKey(policyID)){
+ JSONObject object = new JSONObject();
+ object.put("policyId", policyMap.get(policyID));
+ object.put("fireCount", policyFireCount);
+ object.put("system", pdp.getId());
+ policyActivityData.add(object);
}
}
}else {
@@ -382,12 +377,9 @@ public class DashboardController extends RestrictedBaseController{
private Object getPolicy(String host, int port, String jmxAttribute){
policyLogger.debug("Create an RMI connector client and connect it to the JMX connector server for Policy: " + host);
HashMap map = null;
- JMXConnector jmxConnection;
- try {
- jmxConnection = JMXConnectorFactory.newJMXConnector(createConnectionURL(host, port), map);
+ try (JMXConnector jmxConnection = JMXConnectorFactory.newJMXConnector(createConnectionURL(host, port), map)) {
jmxConnection.connect();
Object o = jmxConnection.getMBeanServerConnection().getAttribute(new ObjectName("PdpRest:type=PdpRestMonitor"), "policyMap");
- jmxConnection.close();
policyLogger.debug("policyMap value retreived: " + o);
return o;
} catch (MalformedURLException e) {
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/DecisionPolicyController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/DecisionPolicyController.java
index 46d24b207..6f8eea8e7 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/DecisionPolicyController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/DecisionPolicyController.java
@@ -27,6 +27,7 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import javax.xml.bind.JAXBElement;
@@ -128,7 +129,7 @@ public class DecisionPolicyController extends RestrictedBaseController {
AttributeDesignatorType designator = match.getAttributeDesignator();
String attributeId = designator.getAttributeId();
// First match in the target is OnapName, so set that value.
- if (attributeId.equals("ONAPName")) {
+ if ("ONAPName".equals(attributeId)) {
policyAdapter.setOnapName(value);
}
// Component attributes are saved under Target here we are fetching them back.
@@ -151,16 +152,16 @@ public class DecisionPolicyController extends RestrictedBaseController {
if(!attributeList.isEmpty()) {
for(int i=0; i<attributeList.size() ; i++){
Map<String, String> map = (Map<String,String>)attributeList.get(i);
- if(map.get("key").equals("WorkStep")){
+ if("WorkStep".equals(map.get("key"))){
rainydayParams.setWorkstep(map.get("value"));
rainy=true;
- }else if(map.get("key").equals("BB_ID")){
+ }else if("BB_ID".equals(map.get("key"))){
rainydayParams.setBbid(map.get("value"));
rainy=true;
- }else if(map.get("key").equals("ServiceType")){
+ }else if("ServiceType".equals(map.get("key"))){
rainydayParams.setServiceType(map.get("value"));
rainy=true;
- }else if(map.get("key").equals("VNFType")){
+ }else if("VNFType".equals(map.get("key"))){
rainydayParams.setVnfType(map.get("value"));
rainy=true;
}
@@ -188,12 +189,12 @@ public class DecisionPolicyController extends RestrictedBaseController {
// get the condition data under the rule for rule Algorithms.
if(((RuleType) object).getEffect().equals(EffectType.DENY)) {
if(((RuleType) object).getAdviceExpressions()!=null){
- if(((RuleType) object).getAdviceExpressions().getAdviceExpression().get(0).getAdviceId().equalsIgnoreCase("AAF")){
+ if("AAF".equalsIgnoreCase(((RuleType) object).getAdviceExpressions().getAdviceExpression().get(0).getAdviceId())){
policyAdapter.setRuleProvider("AAF");
break;
- }else if(((RuleType) object).getAdviceExpressions().getAdviceExpression().get(0).getAdviceId().equalsIgnoreCase("GUARD_YAML")){
+ }else if("GUARD_YAML".equalsIgnoreCase(((RuleType) object).getAdviceExpressions().getAdviceExpression().get(0).getAdviceId())){
policyAdapter.setRuleProvider("GUARD_YAML");
- }else if(((RuleType) object).getAdviceExpressions().getAdviceExpression().get(0).getAdviceId().equalsIgnoreCase("GUARD_BL_YAML")){
+ }else if("GUARD_BL_YAML".equalsIgnoreCase(((RuleType) object).getAdviceExpressions().getAdviceExpression().get(0).getAdviceId())){
policyAdapter.setRuleProvider("GUARD_BL_YAML");
}
}else{
@@ -204,7 +205,7 @@ public class DecisionPolicyController extends RestrictedBaseController {
ApplyType decisionApply = (ApplyType) condition.getExpression().getValue();
decisionApply = (ApplyType) decisionApply.getExpression().get(0).getValue();
ruleAlgoirthmTracker = new LinkedList<>();
- if(policyAdapter.getRuleProvider()!=null && (policyAdapter.getRuleProvider().equals("GUARD_YAML")||(policyAdapter.getRuleProvider().equals("GUARD_BL_YAML")))){
+ if(policyAdapter.getRuleProvider()!=null && ("GUARD_YAML".equals(policyAdapter.getRuleProvider())||(policyAdapter.getRuleProvider().equals("GUARD_BL_YAML")))){
YAMLParams yamlParams = new YAMLParams();
for(int i=0; i<attributeList.size() ; i++){
Map<String, String> map = (Map<String,String>)attributeList.get(i);
@@ -218,10 +219,10 @@ public class DecisionPolicyController extends RestrictedBaseController {
yamlParams.setClname(map.get("value"));
}
}
- ApplyType apply = ((ApplyType)((ApplyType)decisionApply.getExpression().get(0).getValue()).getExpression().get(0).getValue());
+ ApplyType apply = (ApplyType)((ApplyType)decisionApply.getExpression().get(0).getValue()).getExpression().get(0).getValue();
yamlParams.setGuardActiveStart(((AttributeValueType)apply.getExpression().get(1).getValue()).getContent().get(0).toString());
yamlParams.setGuardActiveEnd(((AttributeValueType)apply.getExpression().get(2).getValue()).getContent().get(0).toString());
- if(policyAdapter.getRuleProvider().equals("GUARD_BL_YAML")){
+ if("GUARD_BL_YAML".equals(policyAdapter.getRuleProvider())){
apply = (ApplyType)((ApplyType)((ApplyType)decisionApply.getExpression().get(0).getValue()).getExpression().get(1).getValue()).getExpression().get(2).getValue();
Iterator<JAXBElement<?>> attributes = apply.getExpression().iterator();
List<String> blackList = new ArrayList<>();
@@ -245,7 +246,7 @@ public class DecisionPolicyController extends RestrictedBaseController {
prePopulateDecisionCompoundRuleAlgorithm(index, decisionApply);
policyAdapter.setRuleAlgorithmschoices(ruleAlgorithmList);
}
- } else if(policyAdapter.getRuleProvider()!=null && policyAdapter.getRuleProvider().equals("Rainy_Day")&& ((RuleType) object).getEffect().equals(EffectType.PERMIT)) {
+ } else if(policyAdapter.getRuleProvider()!=null && "Rainy_Day".equals(policyAdapter.getRuleProvider())&& ((RuleType) object).getEffect().equals(EffectType.PERMIT)) {
TargetType ruleTarget = ((RuleType) object).getTarget();
AdviceExpressionsType adviceExpression = ((RuleType) object).getAdviceExpressions();
@@ -283,14 +284,13 @@ public class DecisionPolicyController extends RestrictedBaseController {
Map<String, String> ruleMap = new HashMap<>();
ruleMap.put("id", "A" + (index +1));
Map<String, String> dropDownMap = PolicyController.getDropDownMap();
- for (String key : dropDownMap.keySet()) {
- String keyValue = dropDownMap.get(key);
- if (keyValue.equals(decisionApply.getFunctionId())) {
- ruleMap.put("dynamicRuleAlgorithmCombo", key);
+ for (Entry<String, String> entry : dropDownMap.entrySet()) {
+ if (entry.getValue().equals(decisionApply.getFunctionId())) {
+ ruleMap.put("dynamicRuleAlgorithmCombo", entry.getKey());
}
}
// Populate the key and value fields
- if (((jaxbDecisionTypes.get(0).getValue()) instanceof AttributeValueType)) {
+ if ((jaxbDecisionTypes.get(0).getValue() instanceof AttributeValueType)) {
ApplyType innerDecisionApply = (ApplyType) jaxbDecisionTypes.get(1).getValue();
List<JAXBElement<?>> jaxbInnerDecisionTypes = innerDecisionApply.getExpression();
if (jaxbInnerDecisionTypes.get(0).getValue() instanceof AttributeDesignatorType) {
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PDPController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PDPController.java
index e5ed3122e..7966af15b 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PDPController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PDPController.java
@@ -38,7 +38,7 @@ import org.onap.policy.admin.RESTfulPAPEngine;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.model.PDPGroupContainer;
-import org.onap.policy.model.Roles;
+import org.onap.policy.utils.UserUtils.Pair;
import org.onap.policy.xacml.api.XACMLErrorConstants;
import org.onap.policy.xacml.api.pap.OnapPDPGroup;
import org.onap.policy.xacml.api.pap.PAPPolicyEngine;
@@ -88,26 +88,14 @@ public class PDPController extends RestrictedBaseController {
try {
PolicyController controller = getPolicyControllerInstance();
Set<PDPPolicy> filteredPolicies = new HashSet<>();
- Set<String> scopes = null;
- List<String> roles = null;
+ Set<String> scopes;
+ List<String> roles;
String userId = isJunit() ? "Test" : UserUtils.getUserSession(request).getOrgUserId();
List<Object> userRoles = controller.getRoles(userId);
- roles = new ArrayList<>();
- scopes = new HashSet<>();
- for(Object role: userRoles){
- Roles userRole = (Roles) role;
- roles.add(userRole.getRole());
- if(userRole.getScope() != null){
- if(userRole.getScope().contains(",")){
- String[] multipleScopes = userRole.getScope().split(",");
- for(int i =0; i < multipleScopes.length; i++){
- scopes.add(multipleScopes[i]);
- }
- }else{
- scopes.add(userRole.getScope());
- }
- }
- }
+ Pair<Set<String>, List<String>> pair = org.onap.policy.utils.UserUtils.checkRoleAndScope(userRoles);
+ roles = pair.u;
+ scopes = pair.t;
+
if(!junit&& controller.getPapEngine()==null){
setPAPEngine(request);
}
@@ -118,39 +106,37 @@ public class PDPController extends RestrictedBaseController {
this.groups.addAll(this.getGroupsData());
}
}else{
- if(!userRoles.isEmpty()){
- if(!scopes.isEmpty()){
- this.groups.addAll(controller.getPapEngine().getOnapPDPGroups());
- List<OnapPDPGroup> tempGroups = new ArrayList<>();
- if(!groups.isEmpty()){
- Iterator<OnapPDPGroup> pdpGroup = groups.iterator();
- while(pdpGroup.hasNext()){
- OnapPDPGroup group = pdpGroup.next();
- Set<PDPPolicy> policies = group.getPolicies();
- for(PDPPolicy policy : policies){
- for(String scope : scopes){
- scope = scope.replace(File.separator, ".");
- String policyName = policy.getId();
- if(policyName.contains(".Config_")){
- policyName = policyName.substring(0, policyName.lastIndexOf(".Config_"));
- }else if(policyName.contains(".Action_")){
- policyName = policyName.substring(0, policyName.lastIndexOf(".Action_"));
- }else if(policyName.contains(".Decision_")){
- policyName = policyName.substring(0, policyName.lastIndexOf(".Decision_"));
- }
- if(policyName.startsWith(scope)){
- filteredPolicies.add(policy);
- }
+ if(!userRoles.isEmpty() && !scopes.isEmpty()){
+ this.groups.addAll(controller.getPapEngine().getOnapPDPGroups());
+ List<OnapPDPGroup> tempGroups = new ArrayList<>();
+ if(!groups.isEmpty()){
+ Iterator<OnapPDPGroup> pdpGroup = groups.iterator();
+ while(pdpGroup.hasNext()){
+ OnapPDPGroup group = pdpGroup.next();
+ Set<PDPPolicy> policies = group.getPolicies();
+ for(PDPPolicy policy : policies){
+ for(String scope : scopes){
+ scope = scope.replace(File.separator, ".");
+ String policyName = policy.getId();
+ if(policyName.contains(".Config_")){
+ policyName = policyName.substring(0, policyName.lastIndexOf(".Config_"));
+ }else if(policyName.contains(".Action_")){
+ policyName = policyName.substring(0, policyName.lastIndexOf(".Action_"));
+ }else if(policyName.contains(".Decision_")){
+ policyName = policyName.substring(0, policyName.lastIndexOf(".Decision_"));
+ }
+ if(policyName.startsWith(scope)){
+ filteredPolicies.add(policy);
}
}
- pdpGroup.remove();
- StdPDPGroup newGroup = (StdPDPGroup) group;
- newGroup.setPolicies(filteredPolicies);
- tempGroups.add(newGroup);
- }
- groups.clear();
- groups = tempGroups;
- }
+ }
+ pdpGroup.remove();
+ StdPDPGroup newGroup = (StdPDPGroup) group;
+ newGroup.setPolicies(filteredPolicies);
+ tempGroups.add(newGroup);
+ }
+ groups.clear();
+ groups = tempGroups;
}
}
}
@@ -254,7 +240,7 @@ public class PDPController extends RestrictedBaseController {
policyLogger.info("*****************************************************************************************************************************");
StdPDPGroup pdpGroupData = mapper.readValue(root.get("pdpGroupData").toString(), StdPDPGroup.class);
- if(pdpGroupData.getName().equals("Default")) {
+ if("Default".equals(pdpGroupData.getName())) {
throw new UnsupportedOperationException("You can't remove the Default Group.");
}else{
this.container.removeGroup(pdpGroupData, null);
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java
index 46510ba4f..2df70c726 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java
@@ -29,6 +29,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Properties;
import javax.annotation.PostConstruct;
@@ -164,6 +165,7 @@ public class PolicyController extends RestrictedBaseController {
}
public PolicyController() {
+ // Empty constructor
}
@PostConstruct
@@ -241,8 +243,8 @@ public class PolicyController extends RestrictedBaseController {
//Initialize the FunctionDefinition table at Server Start up
Map<Datatype, List<FunctionDefinition>> functionMap = getFunctionDatatypeMap();
- for (Datatype id : functionMap.keySet()) {
- List<FunctionDefinition> functionDefinations = functionMap.get(id);
+ for ( Entry<Datatype, List<FunctionDefinition>> entry : functionMap.entrySet()) {
+ List<FunctionDefinition> functionDefinations = entry.getValue();
for (FunctionDefinition functionDef : functionDefinations) {
dropDownMap.put(functionDef.getShortname(),functionDef.getXacmlid());
}
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyExportAndImportController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyExportAndImportController.java
index 5978f145e..5365af18c 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyExportAndImportController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyExportAndImportController.java
@@ -29,7 +29,6 @@ import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
@@ -49,7 +48,6 @@ import org.apache.poi.ss.usermodel.Workbook;
import org.json.JSONObject;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
-import org.onap.policy.model.Roles;
import org.onap.policy.rest.adapter.PolicyExportAdapter;
import org.onap.policy.rest.dao.CommonClassDao;
import org.onap.policy.rest.jpa.ActionBodyEntity;
@@ -58,6 +56,7 @@ import org.onap.policy.rest.jpa.PolicyEditorScopes;
import org.onap.policy.rest.jpa.PolicyEntity;
import org.onap.policy.rest.jpa.PolicyVersion;
import org.onap.policy.rest.jpa.UserInfo;
+import org.onap.policy.utils.UserUtils.Pair;
import org.onap.policy.xacml.api.XACMLErrorConstants;
import org.onap.portalsdk.core.controller.RestrictedBaseController;
import org.onap.portalsdk.core.web.support.UserUtils;
@@ -116,12 +115,14 @@ public class PolicyExportAndImportController extends RestrictedBaseController {
PolicyExportAndImportController.commonClassDao = commonClassDao;
}
- public PolicyExportAndImportController(){}
+ public PolicyExportAndImportController(){
+ // Empty constructor
+ }
@RequestMapping(value={"/policy_download/exportPolicy.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
public void exportPolicy(HttpServletRequest request, HttpServletResponse response) throws IOException{
try{
- String file = null;
+ String file;
selectedPolicy = new ArrayList<>();
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
@@ -209,30 +210,17 @@ public class PolicyExportAndImportController extends RestrictedBaseController {
boolean configExists = false;
boolean actionExists = false;
String configName = null;
- String scope = null;
- boolean finalColumn = false;
+ String scope;
+ boolean finalColumn;
PolicyController controller = policyController != null ? getPolicyController() : new PolicyController();
String userId = UserUtils.getUserSession(request).getOrgUserId();
UserInfo userInfo = (UserInfo) commonClassDao.getEntityItem(UserInfo.class, "userLoginId", userId);
- //Check if the Role and Scope Size are Null get the values from db.
List<Object> userRoles = controller.getRoles(userId);
- roles = new ArrayList<>();
- scopes = new HashSet<>();
- for(Object role: userRoles){
- Roles userRole = (Roles) role;
- roles.add(userRole.getRole());
- if(userRole.getScope() != null){
- if(userRole.getScope().contains(",")){
- String[] multipleScopes = userRole.getScope().split(",");
- for(int i =0; i < multipleScopes.length; i++){
- scopes.add(multipleScopes[i]);
- }
- }else{
- scopes.add(userRole.getScope());
- }
- }
- }
+ Pair<Set<String>, List<String>> pair = org.onap.policy.utils.UserUtils.checkRoleAndScope(userRoles);
+ roles = pair.u;
+ scopes = pair.t;
+
FileInputStream excelFile = new FileInputStream(new File(file));
workbook = new HSSFWorkbook(excelFile);
Sheet datatypeSheet = workbook.getSheetAt(0);
@@ -251,19 +239,19 @@ public class PolicyExportAndImportController extends RestrictedBaseController {
Iterator<Cell> cellIterator = currentRow.cellIterator();
while (cellIterator.hasNext()) {
Cell cell = cellIterator.next();
- if (getCellHeaderName(cell).equalsIgnoreCase("policyName")) {
+ if ("policyName".equalsIgnoreCase(getCellHeaderName(cell))) {
policyEntity.setPolicyName(cell.getStringCellValue());
}
- if (getCellHeaderName(cell).equalsIgnoreCase("scope")) {
+ if ("scope".equalsIgnoreCase(getCellHeaderName(cell))) {
policyEntity.setScope(cell.getStringCellValue());
}
- if (getCellHeaderName(cell).equalsIgnoreCase("policyData")) {
+ if ("policyData".equalsIgnoreCase(getCellHeaderName(cell))) {
policyEntity.setPolicyData(cell.getStringCellValue());
}
- if (getCellHeaderName(cell).equalsIgnoreCase("description")) {
+ if ("description".equalsIgnoreCase(getCellHeaderName(cell))) {
policyEntity.setDescription(cell.getStringCellValue());
}
- if (getCellHeaderName(cell).equalsIgnoreCase("configurationbody")) {
+ if ("configurationbody".equalsIgnoreCase(getCellHeaderName(cell))) {
if(policyEntity.getPolicyName().contains("Config_")){
configExists = true;
configurationDataEntity.setConfigBody(cell.getStringCellValue());
@@ -272,7 +260,7 @@ public class PolicyExportAndImportController extends RestrictedBaseController {
actionBodyEntity.setActionBody(cell.getStringCellValue());
}
}
- if (getCellHeaderName(cell).equalsIgnoreCase("configurationName")) {
+ if ("configurationName".equalsIgnoreCase(getCellHeaderName(cell))) {
finalColumn = true;
configName = cell.getStringCellValue();
if(policyEntity.getPolicyName().contains("Config_")){
@@ -312,7 +300,7 @@ public class PolicyExportAndImportController extends RestrictedBaseController {
}
if (roles.contains(ADMIN) || roles.contains(EDITOR)) {
if(scopes.isEmpty()){
- //return error("No Scopes has been Assigned to the User. Please, Contact Super-Admin");
+ logger.error("No Scopes has been Assigned to the User. Please, Contact Super-Admin");
}else{
//1. if Role contains admin, then check if parent scope has role admin, if not don't create a scope and add to list.
if(roles.contains(ADMIN)){
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/CommonClassDaoImpl.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/CommonClassDaoImpl.java
index b9eb5ed15..170c30838 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/CommonClassDaoImpl.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/CommonClassDaoImpl.java
@@ -21,6 +21,7 @@
package org.onap.policy.daoImp;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -253,7 +254,7 @@ public class CommonClassDaoImpl implements CommonClassDao{
@Override
public List<Object> checkExistingGroupListforUpdate(String arg0, String arg1) {
- return null;
+ return Collections.emptyList();
}
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPGroupContainer.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPGroupContainer.java
index 5952761eb..d5767b46a 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPGroupContainer.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPGroupContainer.java
@@ -113,7 +113,7 @@ public class PDPGroupContainer extends PolicyItemSetChangeNotifier implements Po
}
public boolean isSupported(Object itemId) {
- return (itemId instanceof OnapPDPGroup);
+ return itemId instanceof OnapPDPGroup;
}
public synchronized void refreshGroups() {
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPPolicyContainer.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPPolicyContainer.java
index 27fe71959..e73adf84b 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPPolicyContainer.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/model/PDPPolicyContainer.java
@@ -151,7 +151,7 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
if (this.policies.isEmpty()) {
return false;
}
- return (itemId.equals(this.policies.get(0)));
+ return itemId.equals(this.policies.get(0));
}
@Override
@@ -162,7 +162,7 @@ public class PDPPolicyContainer extends PolicyItemSetChangeNotifier implements P
if (this.policies.isEmpty()) {
return false;
}
- return (itemId.equals(this.policies.get(this.policies.size() - 1)));
+ return itemId.equals(this.policies.get(this.policies.size() - 1));
}
@Override
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/utils/ConfigurableRESTUtils.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/utils/ConfigurableRESTUtils.java
index 3e935dd74..74576100a 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/utils/ConfigurableRESTUtils.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/utils/ConfigurableRESTUtils.java
@@ -27,6 +27,7 @@ import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Map;
+import java.util.Map.Entry;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
@@ -88,11 +89,9 @@ public class ConfigurableRESTUtils {
connection.setUseCaches(false);
// add hard-coded headers
- for (String headerName : hardCodedHeaderMap.keySet()) {
- connection.addRequestProperty(headerName, hardCodedHeaderMap.get(headerName));
+ for (Entry<String, String> entry : hardCodedHeaderMap.entrySet()) {
+ connection.addRequestProperty(entry.getKey(), entry.getValue());
}
-
-
if (jsonBody != null){
connection.setDoInput(true);
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/utils/UserUtils.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/utils/UserUtils.java
new file mode 100644
index 000000000..a34983a5f
--- /dev/null
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/utils/UserUtils.java
@@ -0,0 +1,70 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.policy.utils;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.onap.policy.controller.PolicyController;
+import org.onap.policy.model.Roles;
+
+public final class UserUtils {
+
+ private UserUtils () {
+ // Empty Constructor
+ }
+
+ public static class Pair<T, U> {
+ public final T t;
+ public final U u;
+
+ public Pair (T t, U u) {
+ this.t = t;
+ this.u = u;
+ }
+ }
+
+ public static Pair<Set<String>, List<String>> checkRoleAndScope(List<Object> userRoles) {
+ Set<String> scopes;
+ List<String> roles;
+ //Check if the Role and Scope Size are Null get the values from db.
+// List<Object> userRoles = ;
+ roles = new ArrayList<>();
+ scopes = new HashSet<>();
+ for(Object role: userRoles){
+ Roles userRole = (Roles) role;
+ roles.add(userRole.getRole());
+ if(userRole.getScope() != null){
+ if(userRole.getScope().contains(",")){
+ String[] multipleScopes = userRole.getScope().split(",");
+ for(int i =0; i < multipleScopes.length; i++){
+ scopes.add(multipleScopes[i]);
+ }
+ }else{
+ scopes.add(userRole.getScope());
+ }
+ }
+ }
+ return new Pair<>(scopes, roles);
+ }
+
+}
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/utils/XACMLPolicyWriterWithPapNotify.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/utils/XACMLPolicyWriterWithPapNotify.java
index 0fc293e5a..cbcf06249 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/utils/XACMLPolicyWriterWithPapNotify.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/utils/XACMLPolicyWriterWithPapNotify.java
@@ -210,7 +210,7 @@ public class XACMLPolicyWriterWithPapNotify{
}
Base64.Encoder encoder = Base64.getEncoder();
String encoding = encoder.encodeToString((XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_USERID)+":"+XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_PASS)).getBytes(StandardCharsets.UTF_8));
- HttpURLConnection connection = null;
+ HttpURLConnection connection;
UUID requestID = UUID.randomUUID();
URL url;
try {
@@ -297,7 +297,7 @@ public class XACMLPolicyWriterWithPapNotify{
public static boolean notifyPapOfDelete(String policyToDelete){
Base64.Encoder encoder = Base64.getEncoder();
String encoding = encoder.encodeToString((XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_USERID)+":"+XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_PASS)).getBytes(StandardCharsets.UTF_8));
- HttpURLConnection connection = null;
+ HttpURLConnection connection;
UUID requestID = UUID.randomUUID();
String papUrl = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_URL);
if(papUrl == null){
@@ -397,7 +397,7 @@ public class XACMLPolicyWriterWithPapNotify{
}
Base64.Encoder encoder = Base64.getEncoder();
String encoding = encoder.encodeToString((XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_USERID)+":"+XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_PASS)).getBytes(StandardCharsets.UTF_8));
- HttpURLConnection connection = null;
+ HttpURLConnection connection;
UUID requestID = UUID.randomUUID();
URL url;
try {
diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/CheckPDPTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/CheckPDPTest.java
index 47358a8f2..e97e89eae 100644
--- a/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/CheckPDPTest.java
+++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/CheckPDPTest.java
@@ -19,19 +19,54 @@
*/
package org.onap.policy.admin;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.File;
+import org.junit.FixMethodOrder;
import org.junit.Test;
+import org.junit.runners.MethodSorters;
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class CheckPDPTest {
@Test
- public final void testCheckPDP() {
+ public final void test1NoPropertySet() {
+ try {
+ System.clearProperty("xacml.rest.pdp.idfile");
+ assertFalse(CheckPDP.validateID("http://localhost:8082/pdp/"));
+
+ System.setProperty("xacml.rest.pdp.idfile", new File(".").getCanonicalPath() + File.separator + "src"+ File.separator + "test" + File.separator + "resources" + File.separator + "idonotexist.properties");
+ assertFalse(CheckPDP.validateID("http://localhost:8082/pdp/"));
+
+ System.setProperty("xacml.rest.pdp.idfile", new File(".").getCanonicalPath() + File.separator + "src"+ File.separator + "test" + File.separator + "resources" + File.separator + "doesnothaveproperties.atall");
+ assertFalse(CheckPDP.validateID("http://localhost:8082/pdp/"));
+
+ System.setProperty("xacml.rest.pdp.idfile", new File(".").getCanonicalPath() + File.separator + "src"+ File.separator + "test" + File.separator + "resources" + File.separator + "testbad.properties");
+ assertFalse(CheckPDP.validateID("http://localhost:8082/pdp/"));
+
+ System.setProperty("xacml.rest.pdp.idfile", new File(".").getCanonicalPath() + File.separator + "src"+ File.separator + "test" + File.separator + "resources" + File.separator + "empty.properties");
+ assertFalse(CheckPDP.validateID("http://localhost:8082/pdp/"));
+
+ System.setProperty("xacml.rest.pdp.idfile", new File(".").getCanonicalPath() + File.separator + "src"+ File.separator + "test" + File.separator + "resources" + File.separator + "testnotenoughvalues.properties");
+ assertFalse(CheckPDP.validateID("http://localhost:8082/pdp/"));
+
+ assertNull(CheckPDP.getPdpMap());
+ assertNull(CheckPDP.getEncoding("http://localhost:8082/pdp/"));
+
+ } catch (Exception e) {
+ fail("Error occured in CheckPDP test");
+ }
+ }
+
+ @Test
+ public final void test2CheckPDP() {
try {
System.setProperty("xacml.rest.pdp.idfile", new File(".").getCanonicalPath() + File.separator + "src"+ File.separator + "test" + File.separator + "resources" + File.separator + "test.properties");
- CheckPDP.validateID("http://localhost:8082/pdp/");
+ assertTrue(CheckPDP.validateID("http://localhost:8082/pdp/"));
assertTrue(CheckPDP.getPdpMap().containsKey("http://localhost:8082/pdp/"));
assertTrue(CheckPDP.getEncoding("http://localhost:8082/pdp/").equals("dGVzdHBkcDphbHBoYTQ1Ng=="));
} catch (Exception e) {
diff --git a/POLICY-SDK-APP/src/test/resources/empty.properties b/POLICY-SDK-APP/src/test/resources/empty.properties
new file mode 100644
index 000000000..f6a6a6062
--- /dev/null
+++ b/POLICY-SDK-APP/src/test/resources/empty.properties
@@ -0,0 +1,21 @@
+###
+# ============LICENSE_START=======================================================
+# ONAP Policy Engine
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+
+# Purposefully empty \ No newline at end of file
diff --git a/POLICY-SDK-APP/src/test/resources/test.properties b/POLICY-SDK-APP/src/test/resources/test.properties
index e882dfd20..c3c6e9ec8 100644
--- a/POLICY-SDK-APP/src/test/resources/test.properties
+++ b/POLICY-SDK-APP/src/test/resources/test.properties
@@ -19,3 +19,4 @@
###
PDP_URL=http://localhost:8082/pdp/, testpdp, alpha456;http://localhost:8081/pdp/, testpdp, alpha456
+WHAT=
diff --git a/POLICY-SDK-APP/src/test/resources/testbad.properties b/POLICY-SDK-APP/src/test/resources/testbad.properties
new file mode 100644
index 000000000..384af8ab4
--- /dev/null
+++ b/POLICY-SDK-APP/src/test/resources/testbad.properties
@@ -0,0 +1,21 @@
+###
+# ============LICENSE_START=======================================================
+# ONAP Policy Engine
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+
+BADPDP_URL=http://localhost:8082/pdp/, testpdp, alpha456;http://localhost:8081/pdp/, testpdp, alpha456
diff --git a/POLICY-SDK-APP/src/test/resources/testnotenoughvalues.properties b/POLICY-SDK-APP/src/test/resources/testnotenoughvalues.properties
new file mode 100644
index 000000000..5823a5d68
--- /dev/null
+++ b/POLICY-SDK-APP/src/test/resources/testnotenoughvalues.properties
@@ -0,0 +1,21 @@
+###
+# ============LICENSE_START=======================================================
+# ONAP Policy Engine
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+
+PDP_URL=http://localhost:8082/pdp/, testpdp;http://localhost:8081/pdp/, alpha456