aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-05-06 14:57:24 -0400
committerJim Hahn <jrh3@att.com>2021-05-06 15:00:49 -0400
commit5301a4b0b49eb568d05d59fd20d7b5724b47b8ac (patch)
tree5ac180d2228cb65d8f74a0b3a79547fde53184b4
parent2f74523b7c5657b4bed38315c5ebfc0ed1bd02c6 (diff)
Fix sonars in xacml-pdp
Fixed: - use "var" instead of actual type Issue-ID: POLICY-3285 Change-Id: Id17142d1f2e3e5f9dfbffcb96aff7fe76321a56b Signed-off-by: Jim Hahn <jrh3@att.com>
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/OnapObligation.java8
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/OnapPolicyFinderFactory.java10
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/ToscaPolicyTranslatorUtils.java28
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlPolicyUtils.java46
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePolicyType.java4
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeMap.java4
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/CountRecentOperationsPip.java6
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePip.java4
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdBaseTranslator.java29
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyRequest.java4
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyResultsTranslator.java23
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchablePolicyRequest.java12
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java24
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdOnapPip.java6
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java14
-rw-r--r--applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/CoordinationGuardTranslator.java12
-rw-r--r--applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardPolicyRequest.java2
-rw-r--r--applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardTranslator.java80
-rw-r--r--applications/monitoring/src/main/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplication.java4
-rw-r--r--applications/native/src/main/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplicationTranslator.java6
-rw-r--r--applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplication.java2
-rw-r--r--applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplicationTranslator.java17
-rw-r--r--applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationSubscriberRequest.java13
-rw-r--r--main/src/main/java/org/onap/policy/pdpx/main/XacmlState.java4
-rw-r--r--main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisher.java6
-rw-r--r--main/src/main/java/org/onap/policy/pdpx/main/parameters/XacmlPdpParameterGroup.java2
-rw-r--r--main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManager.java4
-rw-r--r--main/src/main/java/org/onap/policy/pdpx/main/rest/provider/HealthCheckProvider.java4
-rw-r--r--main/src/main/java/org/onap/policy/pdpx/main/rest/provider/StatisticsProvider.java6
-rw-r--r--main/src/main/java/org/onap/policy/pdpx/main/rest/serialization/XacmlJsonMessageBodyHandler.java6
-rw-r--r--main/src/main/java/org/onap/policy/pdpx/main/rest/serialization/XacmlXmlMessageBodyHandler.java6
-rw-r--r--main/src/main/java/org/onap/policy/pdpx/main/startstop/Main.java8
-rw-r--r--main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpActivator.java4
-rw-r--r--main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpCommandLineArguments.java13
-rw-r--r--main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpRestServer.java4
-rw-r--r--tutorials/tutorial-enforcement/src/main/java/org/onap/policy/tutorial/policyenforcement/App.java17
-rw-r--r--tutorials/tutorial-xacml-application/src/main/java/org/onap/policy/tutorial/tutorial/TutorialRequest.java4
-rw-r--r--tutorials/tutorial-xacml-application/src/main/java/org/onap/policy/tutorial/tutorial/TutorialTranslator.java25
-rw-r--r--xacml-test/src/main/java/org/onap/policy/pdp/xacml/xacmltest/TestUtils.java8
39 files changed, 235 insertions, 244 deletions
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/OnapObligation.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/OnapObligation.java
index c1a949f3..4febd212 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/OnapObligation.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/OnapObligation.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 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.
@@ -129,7 +129,7 @@ public class OnapObligation {
//
// Create an ObligationExpression
//
- ObligationExpressionType obligation = new ObligationExpressionType();
+ var obligation = new ObligationExpressionType();
obligation.setFulfillOn(effectType);
obligation.setObligationId(obligationId.stringValue());
//
@@ -238,14 +238,14 @@ public class OnapObligation {
//
// Create an AttributeValue for it
//
- AttributeValueType value = new AttributeValueType();
+ var value = new AttributeValueType();
value.setDataType(datatype.stringValue());
value.getContent().add(theValue.toString());
//
// Create our AttributeAssignmentExpression where we will
// store the contents of the policy id.
//
- AttributeAssignmentExpressionType expressionType = new AttributeAssignmentExpressionType();
+ var expressionType = new AttributeAssignmentExpressionType();
expressionType.setAttributeId(id.stringValue());
expressionType.setCategory(category.stringValue());
expressionType.setExpression(factory.createAttributeValue(value));
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/OnapPolicyFinderFactory.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/OnapPolicyFinderFactory.java
index b000db92..a4fc03fd 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/OnapPolicyFinderFactory.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/OnapPolicyFinderFactory.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 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.
@@ -121,7 +121,7 @@ public class OnapPolicyFinderFactory extends PolicyFinderFactory {
}
protected PolicyDef loadPolicyFileDef(String propLocation) {
- File fileLocation = new File(propLocation);
+ var fileLocation = new File(propLocation);
if (!fileLocation.exists()) {
logger.error("Policy file {} does not exist.", fileLocation.getAbsolutePath());
return null;
@@ -132,7 +132,7 @@ public class OnapPolicyFinderFactory extends PolicyFinderFactory {
}
try {
logger.info("Loading policy file {}", fileLocation);
- PolicyDef policyDef = DOMPolicyDef.load(fileLocation);
+ var policyDef = DOMPolicyDef.load(fileLocation);
if (policyDef != null) {
return policyDef;
}
@@ -163,7 +163,7 @@ public class OnapPolicyFinderFactory extends PolicyFinderFactory {
List<PolicyDef> listPolicyDefs = new ArrayList<>();
for (String policyId : policyIdArray) {
- PolicyDef policyDef = this.loadPolicyDef(policyId);
+ var policyDef = this.loadPolicyDef(policyId);
if (policyDef != null) {
listPolicyDefs.add(policyDef);
}
@@ -194,7 +194,7 @@ public class OnapPolicyFinderFactory extends PolicyFinderFactory {
//
// Create our root policy
//
- PolicySet root = new PolicySet();
+ var root = new PolicySet();
root.setIdentifier(new IdentifierImpl(UUID.randomUUID().toString()));
root.setVersion(StdVersion.newInstance("1.0"));
root.setTarget(new Target());
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/ToscaPolicyTranslatorUtils.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/ToscaPolicyTranslatorUtils.java
index a5e804e0..e19130d3 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/ToscaPolicyTranslatorUtils.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/ToscaPolicyTranslatorUtils.java
@@ -70,12 +70,12 @@ public final class ToscaPolicyTranslatorUtils {
//
// Create the MatchType object and set its function
//
- MatchType match = new MatchType();
+ var match = new MatchType();
match.setMatchId(function.stringValue());
//
// Add in the AttributeValue object
//
- AttributeValueType valueType = new AttributeValueType();
+ var valueType = new AttributeValueType();
valueType.setDataType(datatype.stringValue());
valueType.getContent().add(value);
@@ -83,7 +83,7 @@ public final class ToscaPolicyTranslatorUtils {
//
// Add in the AttributeDesignator object
//
- AttributeDesignatorType designator = new AttributeDesignatorType();
+ var designator = new AttributeDesignatorType();
designator.setAttributeId(designatorId.stringValue());
designator.setCategory(designatorCategory.stringValue());
designator.setDataType(datatype.stringValue());
@@ -102,7 +102,7 @@ public final class ToscaPolicyTranslatorUtils {
* @return The AllOf object
*/
public static AllOfType buildAllOf(MatchType... matches) {
- AllOfType allOf = new AllOfType();
+ var allOf = new AllOfType();
for (MatchType match : matches) {
allOf.getMatch().add(match);
}
@@ -121,26 +121,26 @@ public final class ToscaPolicyTranslatorUtils {
return null;
}
- AttributeDesignatorType designator = new AttributeDesignatorType();
+ var designator = new AttributeDesignatorType();
designator.setAttributeId(XACML3.ID_ENVIRONMENT_CURRENT_TIME.stringValue());
designator.setCategory(XACML3.ID_ATTRIBUTE_CATEGORY_ENVIRONMENT.stringValue());
designator.setDataType(XACML3.ID_DATATYPE_TIME.stringValue());
- AttributeValueType valueStart = new AttributeValueType();
+ var valueStart = new AttributeValueType();
valueStart.setDataType(XACML3.ID_DATATYPE_TIME.stringValue());
valueStart.getContent().add(start);
- AttributeValueType valueEnd = new AttributeValueType();
+ var valueEnd = new AttributeValueType();
valueEnd.setDataType(XACML3.ID_DATATYPE_TIME.stringValue());
valueEnd.getContent().add(end);
- ApplyType applyOneAndOnly = new ApplyType();
+ var applyOneAndOnly = new ApplyType();
applyOneAndOnly.setDescription("Unbag the current time");
applyOneAndOnly.setFunctionId(XACML3.ID_FUNCTION_TIME_ONE_AND_ONLY.stringValue());
applyOneAndOnly.getExpression().add(factory.createAttributeDesignator(designator));
- ApplyType applyTimeInRange = new ApplyType();
+ var applyTimeInRange = new ApplyType();
applyTimeInRange.setDescription("return true if current time is in range.");
if (useRecurringFunction) {
applyTimeInRange.setFunctionId(XACML3.ID_FUNCTION_TIME_IN_RECURRING_RANGE.stringValue());
@@ -185,7 +185,7 @@ public final class ToscaPolicyTranslatorUtils {
*/
public static AnyOfType buildAndAppendAllof(AnyOfType anyOf, Object type) {
if (type instanceof MatchType) {
- AllOfType allOf = new AllOfType();
+ var allOf = new AllOfType();
allOf.getMatch().add((MatchType) type);
if (anyOf == null) {
anyOf = new AnyOfType();
@@ -212,9 +212,9 @@ public final class ToscaPolicyTranslatorUtils {
if (object instanceof AnyOfType) {
target.getAnyOf().add((AnyOfType) object);
} else if (object instanceof MatchType) {
- AllOfType allOf = new AllOfType();
+ var allOf = new AllOfType();
allOf.getMatch().add((MatchType) object);
- AnyOfType anyOf = new AnyOfType();
+ var anyOf = new AnyOfType();
anyOf.getAllOf().add(allOf);
target.getAnyOf().add(anyOf);
}
@@ -232,11 +232,11 @@ public final class ToscaPolicyTranslatorUtils {
*/
public static ConditionType addVariableToCondition(ConditionType condition, VariableReferenceType variable,
Identifier functionId) {
- ApplyType applyFunction = new ApplyType();
+ var applyFunction = new ApplyType();
applyFunction.setFunctionId(functionId.stringValue());
applyFunction.getExpression().add(condition.getExpression());
applyFunction.getExpression().add(factory.createVariableReference(variable));
- ConditionType newCondition = new ConditionType();
+ var newCondition = new ConditionType();
newCondition.setExpression(factory.createApply(applyFunction));
return newCondition;
}
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlPolicyUtils.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlPolicyUtils.java
index a2ecf8c0..860189f9 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlPolicyUtils.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlPolicyUtils.java
@@ -29,7 +29,6 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -80,7 +79,7 @@ public class XacmlPolicyUtils {
* @return PolicySetType object
*/
public static PolicySetType createEmptyPolicySet(String policyId, Identifier policyCombiningAlgorithm) {
- PolicySetType policy = new PolicySetType();
+ var policy = new PolicySetType();
policy.setPolicySetId(policyId);
policy.setPolicyCombiningAlgId(policyCombiningAlgorithm.stringValue());
policy.setTarget(new TargetType());
@@ -96,7 +95,7 @@ public class XacmlPolicyUtils {
* @return PolicyType object
*/
public static PolicyType createEmptyPolicy(String policyId, Identifier ruleCombiningAlgorithm) {
- PolicyType policy = new PolicyType();
+ var policy = new PolicyType();
policy.setPolicyId(policyId);
policy.setRuleCombiningAlgId(ruleCombiningAlgorithm.stringValue());
policy.setTarget(new TargetType());
@@ -113,12 +112,12 @@ public class XacmlPolicyUtils {
*/
public static PolicySetType addPoliciesToXacmlRootPolicy(PolicySetType rootPolicy,
PolicyType... referencedPolicies) {
- ObjectFactory factory = new ObjectFactory();
+ var factory = new ObjectFactory();
//
// Iterate each policy
//
for (PolicyType referencedPolicy : referencedPolicies) {
- IdReferenceType reference = new IdReferenceType();
+ var reference = new IdReferenceType();
reference.setValue(referencedPolicy.getPolicyId());
//
// Add it in
@@ -140,12 +139,12 @@ public class XacmlPolicyUtils {
*/
public static PolicySetType addPolicySetsToXacmlRootPolicy(PolicySetType rootPolicy,
PolicySetType... referencedPolicySets) {
- ObjectFactory factory = new ObjectFactory();
+ var factory = new ObjectFactory();
//
// Iterate each policy
//
for (PolicySetType referencedPolicySet : referencedPolicySets) {
- IdReferenceType reference = new IdReferenceType();
+ var reference = new IdReferenceType();
reference.setValue(referencedPolicySet.getPolicySetId());
//
// Add it in
@@ -173,7 +172,7 @@ public class XacmlPolicyUtils {
//
// Construct a unique id
//
- int id = 1;
+ var id = 1;
while (true) {
String refId = "root" + id;
if (rootPolicies.contains(refId)) {
@@ -207,7 +206,7 @@ public class XacmlPolicyUtils {
//
// Construct a unique id
//
- int id = 1;
+ var id = 1;
while (true) {
String refId = "ref" + id;
if (referencedPolicies.contains(refId)) {
@@ -238,8 +237,8 @@ public class XacmlPolicyUtils {
//
// Get the current set of referenced policy ids
//
- StringJoiner join = new StringJoiner(",");
- boolean found = false;
+ var join = new StringJoiner(",");
+ var found = false;
Set<String> rootPolicies = XACMLProperties.getRootPolicyIDs(properties);
for (String refPolicy : rootPolicies) {
String refPolicyFile = refPolicy + DOT_FILE_SUFFIX;
@@ -282,8 +281,8 @@ public class XacmlPolicyUtils {
//
// Get the current set of referenced policy ids
//
- StringJoiner join = new StringJoiner(",");
- boolean found = false;
+ var join = new StringJoiner(",");
+ var found = false;
Set<String> referencedPolicies = XACMLProperties.getReferencedPolicyIDs(properties);
for (String refPolicy : referencedPolicies) {
String refPolicyFile = refPolicy + DOT_FILE_SUFFIX;
@@ -391,8 +390,8 @@ public class XacmlPolicyUtils {
*/
public static Properties loadXacmlProperties(Path propertyPath) throws IOException {
LOGGER.info("Loading xacml properties {}", propertyPath);
- try (InputStream is = Files.newInputStream(propertyPath)) {
- Properties properties = new Properties();
+ try (var is = Files.newInputStream(propertyPath)) {
+ var properties = new Properties();
properties.load(is);
if (LOGGER.isInfoEnabled()) {
LOGGER.info("Loaded xacml properties {} {}", XacmlPolicyUtils.LINE_SEPARATOR, properties);
@@ -411,9 +410,8 @@ public class XacmlPolicyUtils {
*/
public static void storeXacmlProperties(Properties properties, Path propertyPath) throws IOException {
LOGGER.info("Storing xacml properties {} {} {}", properties, XacmlPolicyUtils.LINE_SEPARATOR, propertyPath);
- try (OutputStream os = Files.newOutputStream(propertyPath)) {
- String strComments = "#";
- properties.store(os, strComments);
+ try (var os = Files.newOutputStream(propertyPath)) {
+ properties.store(os, "#");
}
}
@@ -447,7 +445,7 @@ public class XacmlPolicyUtils {
//
// Open the properties file
//
- try (InputStream is = new FileInputStream(propertiesPath)) {
+ try (var is = new FileInputStream(propertiesPath)) {
//
// Load in the properties
//
@@ -455,7 +453,7 @@ public class XacmlPolicyUtils {
//
// Now we create a new xacml.properties in the temporary folder location
//
- File propertiesFile = creator.createAFile(XACML_PROPERTY_FILE);
+ var propertiesFile = creator.createAFile(XACML_PROPERTY_FILE);
//
// Iterate through any root policies defined
//
@@ -463,12 +461,12 @@ public class XacmlPolicyUtils {
//
// Get a file
//
- Path rootPath = Paths.get(properties.getProperty(root + DOT_FILE_SUFFIX));
+ var rootPath = Paths.get(properties.getProperty(root + DOT_FILE_SUFFIX));
LOGGER.info("Root file {} {}", rootPath, rootPath.getFileName());
//
// Construct new path for the root policy
//
- File newRootPath = creator.createAFile(rootPath.getFileName().toString());
+ var newRootPath = creator.createAFile(rootPath.getFileName().toString());
//
// Copy the policy file to the temporary folder
//
@@ -486,12 +484,12 @@ public class XacmlPolicyUtils {
//
// Get a file
//
- Path refPath = Paths.get(properties.getProperty(referenced + DOT_FILE_SUFFIX));
+ var refPath = Paths.get(properties.getProperty(referenced + DOT_FILE_SUFFIX));
LOGGER.info("Referenced file {} {}", refPath, refPath.getFileName());
//
// Construct new path for the root policy
//
- File newReferencedPath = creator.createAFile(refPath.getFileName().toString());
+ var newReferencedPath = creator.createAFile(refPath.getFileName().toString());
//
// Copy the policy file to the temporary folder
//
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePolicyType.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePolicyType.java
index c0cbb77f..fe79e861 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePolicyType.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePolicyType.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2020-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -117,7 +117,7 @@ public class MatchablePolicyType {
MatchableCallback callback) {
for (Entry<String, ToscaProperty> entrySet : properties.entrySet()) {
final String property = entrySet.getKey();
- final ToscaProperty toscaProperty = entrySet.getValue();
+ final var toscaProperty = entrySet.getValue();
//
// Most likely case is its a primitive
//
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeMap.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeMap.java
index 5687e251..f6d8414a 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeMap.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeMap.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -61,7 +61,7 @@ public class MatchablePropertyTypeMap extends MatchablePropertyTypeBase<Map<Stri
@Override
public Object generate(Object value, Identifier attributeId) throws ToscaPolicyConversionException {
- AnyOfType anyOf = new AnyOfType();
+ var anyOf = new AnyOfType();
for (Entry<String, MatchablePropertyType<?>> entrySet : this.validate(value).entrySet()) {
final String id = entrySet.getKey();
final Object val = entrySet.getValue();
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/CountRecentOperationsPip.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/CountRecentOperationsPip.java
index 3d7270e1..0d2b1ddd 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/CountRecentOperationsPip.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/CountRecentOperationsPip.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 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.
@@ -90,7 +90,7 @@ public class CountRecentOperationsPip extends StdOnapPip {
//
String[] s1 = pipRequest.getIssuer().split("tw:");
String[] s2 = s1[1].split(":");
- int timeWindowVal = Integer.parseInt(s2[0]);
+ var timeWindowVal = Integer.parseInt(s2[0]);
String timeWindowScale = s2[1];
//
// Grab other attribute values
@@ -118,7 +118,7 @@ public class CountRecentOperationsPip extends StdOnapPip {
//
// Create and return PipResponse
//
- StdMutablePIPResponse pipResponse = new StdMutablePIPResponse();
+ var pipResponse = new StdMutablePIPResponse();
this.addLongAttribute(pipResponse,
XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE,
ToscaDictionary.ID_RESOURCE_GUARD_OPERATIONCOUNT,
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePip.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePip.java
index 95595986..a2440d5b 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePip.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePip.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 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.
@@ -93,7 +93,7 @@ public class GetOperationOutcomePip extends StdOnapPip {
String outcome = doDatabaseQuery(clname);
logger.info("Query result is: {}", outcome);
- StdMutablePIPResponse pipResponse = new StdMutablePIPResponse();
+ var pipResponse = new StdMutablePIPResponse();
this.addStringAttribute(pipResponse, XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE,
ToscaDictionary.ID_RESOURCE_GUARD_OPERATIONOUTCOME, outcome, pipRequest);
return new StdPIPResponse(pipResponse);
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdBaseTranslator.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdBaseTranslator.java
index a6c9977e..61d28f58 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdBaseTranslator.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdBaseTranslator.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 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.
@@ -37,7 +37,6 @@ import oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.ConditionType;
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.MatchType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.ObjectFactory;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.ObligationExpressionType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.ObligationExpressionsType;
@@ -76,7 +75,7 @@ public abstract class StdBaseTranslator implements ToscaPolicyTranslator {
@Override
public DecisionResponse convertResponse(Response xacmlResponse) {
LOGGER.info("Converting Response {}", xacmlResponse);
- DecisionResponse decisionResponse = new DecisionResponse();
+ var decisionResponse = new DecisionResponse();
//
// Setup policies
//
@@ -182,7 +181,7 @@ public abstract class StdBaseTranslator implements ToscaPolicyTranslator {
//
// Create our OnapObligation
//
- OnapObligation onapObligation = new OnapObligation(policyId, jsonPolicy, policyType, weight);
+ var onapObligation = new OnapObligation(policyId, jsonPolicy, policyType, weight);
//
// Generate the obligation
//
@@ -190,7 +189,7 @@ public abstract class StdBaseTranslator implements ToscaPolicyTranslator {
//
// Now we can add it into the rule/policy/policyset
//
- ObligationExpressionsType obligations = new ObligationExpressionsType();
+ var obligations = new ObligationExpressionsType();
obligations.getObligationExpression().add(obligation);
if (ruleOrPolicy instanceof RuleType) {
((RuleType) ruleOrPolicy).setObligationExpressions(obligations);
@@ -218,7 +217,7 @@ public abstract class StdBaseTranslator implements ToscaPolicyTranslator {
//
// Create the match for the policy type
//
- MatchType match = ToscaPolicyTranslatorUtils.buildMatchTypeDesignator(
+ var match = ToscaPolicyTranslatorUtils.buildMatchTypeDesignator(
XACML3.ID_FUNCTION_STRING_EQUAL,
type,
XACML3.ID_DATATYPE_STRING,
@@ -227,7 +226,7 @@ public abstract class StdBaseTranslator implements ToscaPolicyTranslator {
//
// Add it to an AnyOfType object
//
- AnyOfType anyOf = new AnyOfType();
+ var anyOf = new AnyOfType();
anyOf.getAllOf().add(ToscaPolicyTranslatorUtils.buildAllOf(match));
//
// Return new AnyOfType
@@ -250,22 +249,22 @@ public abstract class StdBaseTranslator implements ToscaPolicyTranslator {
// Create an ApplyType that checks if the request contains the
// policy-type attribute
//
- AttributeDesignatorType designator = new AttributeDesignatorType();
+ var designator = new AttributeDesignatorType();
designator.setAttributeId(ToscaDictionary.ID_RESOURCE_POLICY_TYPE.stringValue());
designator.setCategory(XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE.stringValue());
designator.setDataType(XACML3.ID_DATATYPE_STRING.stringValue());
- ApplyType applyBagSize = new ApplyType();
+ var applyBagSize = new ApplyType();
applyBagSize.setDescription("Get the size of policy-type attributes");
applyBagSize.setFunctionId(XACML3.ID_FUNCTION_STRING_BAG_SIZE.stringValue());
- AttributeValueType valueZero = new AttributeValueType();
+ var valueZero = new AttributeValueType();
valueZero.setDataType(XACML3.ID_DATATYPE_INTEGER.stringValue());
valueZero.getContent().add("0"); // Yes really - represent as a string
applyBagSize.getExpression().add(factory.createAttributeDesignator(designator));
- ApplyType applyGreaterThan = new ApplyType();
+ var applyGreaterThan = new ApplyType();
applyGreaterThan.setDescription("Does the policy-type attribute exist?");
applyGreaterThan.setFunctionId(XACML3.ID_FUNCTION_INTEGER_EQUAL.stringValue());
@@ -275,7 +274,7 @@ public abstract class StdBaseTranslator implements ToscaPolicyTranslator {
//
// Create an apply type that checks the actual value
//
- AttributeValueType value = new AttributeValueType();
+ var value = new AttributeValueType();
value.setDataType(XACML3.ID_DATATYPE_STRING.stringValue());
value.getContent().add(type);
@@ -283,7 +282,7 @@ public abstract class StdBaseTranslator implements ToscaPolicyTranslator {
// Create string-is-in apply - which determines if the policy-type
// is in the request bag of resources for policy-type
//
- ApplyType applyIsIn = new ApplyType();
+ var applyIsIn = new ApplyType();
applyIsIn.setDescription("Is this policy-type in the list?");
applyIsIn.setFunctionId(XACML3.ID_FUNCTION_STRING_IS_IN.stringValue());
applyIsIn.getExpression().add(factory.createAttributeValue(value));
@@ -292,7 +291,7 @@ public abstract class StdBaseTranslator implements ToscaPolicyTranslator {
//
// Create our outer apply
//
- ApplyType applyOr = new ApplyType();
+ var applyOr = new ApplyType();
applyOr.setDescription("IF exists and is equal");
applyOr.setFunctionId(XACML3.ID_FUNCTION_OR.stringValue());
@@ -302,7 +301,7 @@ public abstract class StdBaseTranslator implements ToscaPolicyTranslator {
//
// Finally create the condition
//
- ConditionType condition = new ConditionType();
+ var condition = new ConditionType();
condition.setExpression(factory.createApply(applyOr));
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyRequest.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyRequest.java
index 4b50e724..75b89d24 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyRequest.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyRequest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 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.
@@ -77,7 +77,7 @@ public class StdCombinedPolicyRequest {
//
// Create our request object
//
- StdCombinedPolicyRequest request = new StdCombinedPolicyRequest();
+ var request = new StdCombinedPolicyRequest();
//
// Add the subject attributes
//
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyResultsTranslator.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyResultsTranslator.java
index 8db9948d..c22545cd 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyResultsTranslator.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyResultsTranslator.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 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.
@@ -34,7 +34,6 @@ import java.util.Collection;
import java.util.Map;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.EffectType;
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.MatchType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.RuleType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType;
@@ -76,7 +75,7 @@ public class StdCombinedPolicyResultsTranslator extends StdBaseTranslator {
//
// Set it as the policy ID
//
- PolicyType newPolicyType = new PolicyType();
+ var newPolicyType = new PolicyType();
newPolicyType.setPolicyId(policyId);
//
// Optional description
@@ -93,14 +92,14 @@ public class StdCombinedPolicyResultsTranslator extends StdBaseTranslator {
//
// Generate the TargetType
//
- TargetType target = this.generateTargetType(policyId, toscaPolicy.getType(), toscaPolicy.getVersion());
+ var target = this.generateTargetType(policyId, toscaPolicy.getType(), toscaPolicy.getVersion());
newPolicyType.setTarget(target);
//
// Now create the Permit Rule
// No target since the policy has a target
// With obligations.
//
- RuleType rule = new RuleType();
+ var rule = new RuleType();
rule.setDescription("Default is to PERMIT if the policy matches.");
rule.setRuleId(policyId + ":rule");
rule.setEffect(EffectType.PERMIT);
@@ -108,7 +107,7 @@ public class StdCombinedPolicyResultsTranslator extends StdBaseTranslator {
//
// Now represent the policy as Json
//
- StandardCoder coder = new StandardCoder();
+ var coder = new StandardCoder();
String jsonPolicy;
try {
jsonPolicy = coder.encode(toscaPolicy);
@@ -179,7 +178,7 @@ public class StdCombinedPolicyResultsTranslator extends StdBaseTranslator {
//
// Create our OnapObligation which will scan for attributes
//
- OnapObligation onapObligation = new OnapObligation(obligation);
+ var onapObligation = new OnapObligation(obligation);
//
// Get the attributes we care about
//
@@ -211,7 +210,7 @@ public class StdCombinedPolicyResultsTranslator extends StdBaseTranslator {
//
// This is for the Policy Id
//
- MatchType matchPolicyId = ToscaPolicyTranslatorUtils.buildMatchTypeDesignator(
+ var matchPolicyId = ToscaPolicyTranslatorUtils.buildMatchTypeDesignator(
XACML3.ID_FUNCTION_STRING_EQUAL,
policyId,
XACML3.ID_DATATYPE_STRING,
@@ -220,7 +219,7 @@ public class StdCombinedPolicyResultsTranslator extends StdBaseTranslator {
//
// This is for the Policy Type
//
- MatchType matchPolicyType = ToscaPolicyTranslatorUtils.buildMatchTypeDesignator(
+ var matchPolicyType = ToscaPolicyTranslatorUtils.buildMatchTypeDesignator(
XACML3.ID_FUNCTION_STRING_EQUAL,
policyType,
XACML3.ID_DATATYPE_STRING,
@@ -229,7 +228,7 @@ public class StdCombinedPolicyResultsTranslator extends StdBaseTranslator {
//
// This is for the Policy Type version
//
- MatchType matchPolicyTypeVersion = ToscaPolicyTranslatorUtils.buildMatchTypeDesignator(
+ var matchPolicyTypeVersion = ToscaPolicyTranslatorUtils.buildMatchTypeDesignator(
XACML3.ID_FUNCTION_STRING_EQUAL,
policyTypeVersion,
XACML3.ID_DATATYPE_STRING,
@@ -238,7 +237,7 @@ public class StdCombinedPolicyResultsTranslator extends StdBaseTranslator {
//
// This is our outer AnyOf - which is an OR
//
- AnyOfType anyOf = new AnyOfType();
+ var anyOf = new AnyOfType();
//
// Create AllOf (AND) of just Policy Id
//
@@ -255,7 +254,7 @@ public class StdCombinedPolicyResultsTranslator extends StdBaseTranslator {
// Now we can create the TargetType, add the top-level anyOf (OR),
// and return the value.
//
- TargetType target = new TargetType();
+ var target = new TargetType();
target.getAnyOf().add(anyOf);
return target;
}
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchablePolicyRequest.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchablePolicyRequest.java
index d0ae524c..c038f383 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchablePolicyRequest.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchablePolicyRequest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 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.
@@ -103,7 +103,7 @@ public class StdMatchablePolicyRequest {
//
// Create our request object
//
- StdMatchablePolicyRequest request = new StdMatchablePolicyRequest();
+ var request = new StdMatchablePolicyRequest();
//
// Add the subject attributes
//
@@ -127,8 +127,8 @@ public class StdMatchablePolicyRequest {
//
// Create an object we can add to
//
- StdMutableRequest mutableRequest = new StdMutableRequest(xacmlRequest);
- StdMutableRequestAttributes resourceAttributes = new StdMutableRequestAttributes();
+ var mutableRequest = new StdMutableRequest(xacmlRequest);
+ var resourceAttributes = new StdMutableRequestAttributes();
resourceAttributes.setCategory(XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE);
//
// Add the resource attributes
@@ -166,12 +166,12 @@ public class StdMatchablePolicyRequest {
protected static StdMutableRequestAttributes addResources(StdMutableRequestAttributes attributes,
Collection<Object> values, String id) throws DataTypeException {
- DataTypeFactory factory = getDataTypeFactory();
+ var factory = getDataTypeFactory();
if (factory == null) {
return null;
}
for (Object value : values) {
- StdMutableAttribute mutableAttribute = new StdMutableAttribute();
+ var mutableAttribute = new StdMutableAttribute();
mutableAttribute.setCategory(XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE);
mutableAttribute.setAttributeId(new IdentifierImpl(id));
mutableAttribute.setIncludeInResults(true);
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java
index 3222f4ad..1d76d0e3 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java
@@ -174,7 +174,7 @@ public class StdMatchableTranslator extends StdBaseTranslator implements Matcha
//
// Create our OnapObligation object
//
- OnapObligation onapObligation = new OnapObligation(obligation);
+ var onapObligation = new OnapObligation(obligation);
//
// All 4 *should* be there
//
@@ -257,7 +257,7 @@ public class StdMatchableTranslator extends StdBaseTranslator implements Matcha
//
// Set it as the policy ID
//
- PolicyType newPolicyType = new PolicyType();
+ var newPolicyType = new PolicyType();
newPolicyType.setPolicyId(policyName);
//
// Optional description
@@ -280,7 +280,7 @@ public class StdMatchableTranslator extends StdBaseTranslator implements Matcha
//
// Now represent the policy as Json
//
- StandardCoder coder = new StandardCoder();
+ var coder = new StandardCoder();
String jsonPolicy;
try {
jsonPolicy = coder.encode(toscaPolicy);
@@ -294,7 +294,7 @@ public class StdMatchableTranslator extends StdBaseTranslator implements Matcha
//
// Now create the Permit Rule.
//
- RuleType rule = new RuleType();
+ var rule = new RuleType();
rule.setDescription("Default is to PERMIT if the policy matches.");
rule.setRuleId(policyName + ":rule");
rule.setEffect(EffectType.PERMIT);
@@ -311,7 +311,7 @@ public class StdMatchableTranslator extends StdBaseTranslator implements Matcha
//
// Log output of the policy
//
- try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
+ try (var os = new ByteArrayOutputStream()) {
XACMLPolicyWriter.writePolicyFile(os, newPolicyType);
LOGGER.info("{}", os);
} catch (IOException e) {
@@ -379,11 +379,11 @@ public class StdMatchableTranslator extends StdBaseTranslator implements Matcha
//
// Our return object
//
- TargetType target = new TargetType();
+ var target = new TargetType();
//
// See if we have a matchable in the cache already
//
- MatchablePolicyType matchablePolicyType = matchableCache.get(policy.getTypeIdentifier());
+ var matchablePolicyType = matchableCache.get(policy.getTypeIdentifier());
//
// If not found, create one
//
@@ -391,7 +391,7 @@ public class StdMatchableTranslator extends StdBaseTranslator implements Matcha
//
// Our callback
//
- MyMatchableCallback myCallback = new MyMatchableCallback(this, template);
+ var myCallback = new MyMatchableCallback(this, template);
//
// Create the matchable
//
@@ -459,7 +459,7 @@ public class StdMatchableTranslator extends StdBaseTranslator implements Matcha
}
protected int calculateWeight(TargetType target) {
- int weight = 0;
+ var weight = 0;
for (AnyOfType anyOf : target.getAnyOf()) {
for (AllOfType allOf : anyOf.getAllOf()) {
weight += allOf.getMatch().size();
@@ -512,7 +512,7 @@ public class StdMatchableTranslator extends StdBaseTranslator implements Matcha
//
// Construct what the file name should be
//
- Path policyTypePath = this.constructLocalFilePath(policyTypeId);
+ var policyTypePath = this.constructLocalFilePath(policyTypeId);
//
// See if it exists
//
@@ -546,7 +546,7 @@ public class StdMatchableTranslator extends StdBaseTranslator implements Matcha
//
// Ensure all the fields are setup correctly
//
- JpaToscaServiceTemplate jtst = new JpaToscaServiceTemplate();
+ var jtst = new JpaToscaServiceTemplate();
jtst.fromAuthorative(template);
return jtst.toAuthorative();
} catch (CoderException e) {
@@ -574,7 +574,7 @@ public class StdMatchableTranslator extends StdBaseTranslator implements Matcha
//
ToscaServiceTemplate policyTemplate = null;
try {
- PolicyApiCaller api = new PolicyApiCaller(this.apiRestParameters);
+ var api = new PolicyApiCaller(this.apiRestParameters);
policyTemplate = api.getPolicyType(policyTypeId);
} catch (PolicyApiException e) {
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdOnapPip.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdOnapPip.java
index 4cf23652..e8839ecb 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdOnapPip.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdOnapPip.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -99,7 +99,7 @@ public abstract class StdOnapPip extends StdConfigurableEngine {
//
// In case there are any overloaded properties for the JPA
//
- Properties emProperties = new Properties();
+ var emProperties = new Properties();
emProperties.putAll(properties);
//
@@ -126,7 +126,7 @@ public abstract class StdOnapPip extends StdConfigurableEngine {
//
// Get the actor value
//
- PIPResponse pipResponse = this.getAttribute(pipRequest, pipFinder);
+ var pipResponse = this.getAttribute(pipRequest, pipFinder);
if (pipResponse == null) {
logger.error("Need actor attribute which is not found");
return null;
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java
index 5e00499e..f29c4e76 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java
@@ -133,11 +133,11 @@ public abstract class StdXacmlApplicationServiceProvider implements XacmlApplica
//
// Create a copy of the properties object
//
- Properties newProperties = this.getProperties();
+ var newProperties = this.getProperties();
//
// Construct the filename
//
- Path refPath = XacmlPolicyUtils.constructUniquePolicyFilename(xacmlPolicy, this.getDataPath());
+ var refPath = XacmlPolicyUtils.constructUniquePolicyFilename(xacmlPolicy, this.getDataPath());
//
// Write the policy to disk
// Maybe check for an error
@@ -189,7 +189,7 @@ public abstract class StdXacmlApplicationServiceProvider implements XacmlApplica
//
// Create a copy of the properties object
//
- Properties newProperties = this.getProperties();
+ var newProperties = this.getProperties();
//
// Remove it from the properties
//
@@ -244,7 +244,7 @@ public abstract class StdXacmlApplicationServiceProvider implements XacmlApplica
xacmlRequest = this.getTranslator().convertRequest(request);
} catch (ToscaPolicyConversionException e) {
LOGGER.error("Failed to convert request", e);
- DecisionResponse response = new DecisionResponse();
+ var response = new DecisionResponse();
response.setStatus("error");
response.setMessage(e.getLocalizedMessage());
return Pair.of(response, null);
@@ -252,7 +252,7 @@ public abstract class StdXacmlApplicationServiceProvider implements XacmlApplica
//
// Now get a decision
//
- Response xacmlResponse = this.xacmlDecision(xacmlRequest);
+ var xacmlResponse = this.xacmlDecision(xacmlRequest);
//
// Convert to a DecisionResponse
//
@@ -270,7 +270,7 @@ public abstract class StdXacmlApplicationServiceProvider implements XacmlApplica
}
protected synchronized Properties getProperties() {
- Properties newProperties = new Properties();
+ var newProperties = new Properties();
newProperties.putAll(pdpProperties);
return newProperties;
}
@@ -287,7 +287,7 @@ public abstract class StdXacmlApplicationServiceProvider implements XacmlApplica
// Now initialize the XACML PDP Engine
//
try {
- PDPEngineFactory factory = getPdpEngineFactory();
+ var factory = getPdpEngineFactory();
PDPEngine engine = factory.newEngine(properties);
if (engine != null) {
//
diff --git a/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/CoordinationGuardTranslator.java b/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/CoordinationGuardTranslator.java
index 126955e7..90f56a90 100644
--- a/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/CoordinationGuardTranslator.java
+++ b/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/CoordinationGuardTranslator.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 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.
@@ -61,13 +61,13 @@ public class CoordinationGuardTranslator implements ToscaPolicyTranslator {
// Policy name should be at the root
//
String type = toscaPolicy.getType();
- String coordinationFunctionPath = "coordination/function";
+ var coordinationFunctionPath = "coordination/function";
Map<String, Object> policyProps = toscaPolicy.getProperties();
LOGGER.debug("path = {}", coordinationFunctionPath);
LOGGER.debug("props = {}", policyProps);
@SuppressWarnings("unchecked")
List<String> controlLoop = (List<String>) policyProps.get("controlLoop");
- CoordinationDirective cd = new CoordinationDirective();
+ var cd = new CoordinationDirective();
cd.setCoordinationFunction(type);
cd.setControlLoop(controlLoop);
LOGGER.debug("CoordinationDirective = {}", cd);
@@ -117,7 +117,7 @@ public class CoordinationGuardTranslator implements ToscaPolicyTranslator {
return null;
}
try (InputStream is = new FileInputStream(new File(directiveFilename))) {
- String contents = IOUtils.toString(is, StandardCharsets.UTF_8);
+ var contents = IOUtils.toString(is, StandardCharsets.UTF_8);
//
// Read the yaml into our Java Object
//
@@ -149,13 +149,13 @@ public class CoordinationGuardTranslator implements ToscaPolicyTranslator {
/*
* Values to be substituted for placeholder's
*/
- final String uniqueId = UUID.randomUUID().toString();
+ final var uniqueId = UUID.randomUUID().toString();
final String cLOne = cd.getControlLoop(0);
final String cLTwo = cd.getControlLoop(1);
/*
* Replace function placeholder's with appropriate values
*/
- String policyXml = ResourceUtils.getResourceAsString(xacmlProtoFilename);
+ var policyXml = ResourceUtils.getResourceAsString(xacmlProtoFilename);
if (policyXml == null) {
throw new ToscaPolicyConversionException("Unable to find prototype " + xacmlProtoFilename);
}
diff --git a/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardPolicyRequest.java b/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardPolicyRequest.java
index 7394ab30..96b2878a 100644
--- a/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardPolicyRequest.java
+++ b/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardPolicyRequest.java
@@ -126,7 +126,7 @@ public class GuardPolicyRequest {
//
// Create our return object
//
- GuardPolicyRequest request = new GuardPolicyRequest();
+ var request = new GuardPolicyRequest();
//
// Add the subject attributes
//
diff --git a/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardTranslator.java b/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardTranslator.java
index fd9bb004..0eea9729 100644
--- a/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardTranslator.java
+++ b/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardTranslator.java
@@ -129,7 +129,7 @@ public class GuardTranslator implements ToscaPolicyTranslator {
//
// Set it as the policy ID
//
- PolicyType newPolicyType = new PolicyType();
+ var newPolicyType = new PolicyType();
newPolicyType.setPolicyId(policyName);
//
// Optional description
@@ -202,7 +202,7 @@ public class GuardTranslator implements ToscaPolicyTranslator {
//
// No condition already, just create and add a new one
//
- ConditionType condition = new ConditionType();
+ var condition = new ConditionType();
condition.setExpression(new ObjectFactory().createVariableReference(variable));
rule.setCondition(condition);
} else {
@@ -236,7 +236,7 @@ public class GuardTranslator implements ToscaPolicyTranslator {
@Override
public DecisionResponse convertResponse(Response xacmlResponse) {
LOGGER.info("Converting Response {}", xacmlResponse);
- DecisionResponse decisionResponse = new DecisionResponse();
+ var decisionResponse = new DecisionResponse();
//
// Iterate through all the results
//
@@ -297,7 +297,7 @@ public class GuardTranslator implements ToscaPolicyTranslator {
//
// Go through potential properties
//
- AllOfType allOf = new AllOfType();
+ var allOf = new AllOfType();
if (properties.containsKey(FIELD_ACTOR)) {
addMatch(allOf, properties.get(FIELD_ACTOR), ToscaDictionary.ID_RESOURCE_GUARD_ACTOR);
}
@@ -313,8 +313,8 @@ public class GuardTranslator implements ToscaPolicyTranslator {
//
// Create target
//
- TargetType target = new TargetType();
- AnyOfType anyOf = new AnyOfType();
+ var target = new TargetType();
+ var anyOf = new AnyOfType();
anyOf.getAllOf().add(allOf);
target.getAnyOf().add(anyOf);
return target;
@@ -332,7 +332,7 @@ public class GuardTranslator implements ToscaPolicyTranslator {
//
// Exact match
//
- MatchType match = ToscaPolicyTranslatorUtils.buildMatchTypeDesignator(
+ var match = ToscaPolicyTranslatorUtils.buildMatchTypeDesignator(
XACML3.ID_FUNCTION_STRING_EQUAL,
value,
XACML3.ID_DATATYPE_STRING,
@@ -345,7 +345,7 @@ public class GuardTranslator implements ToscaPolicyTranslator {
}
if (value instanceof Collection) {
((Collection<String>) value).forEach(val -> {
- MatchType match = ToscaPolicyTranslatorUtils.buildMatchTypeDesignator(
+ var match = ToscaPolicyTranslatorUtils.buildMatchTypeDesignator(
XACML3.ID_FUNCTION_STRING_EQUAL,
val,
XACML3.ID_DATATYPE_STRING,
@@ -365,7 +365,7 @@ public class GuardTranslator implements ToscaPolicyTranslator {
throw new ToscaPolicyConversionException("timeRange is not a map object " + timeRange.getClass());
}
- MatchType matchStart = ToscaPolicyTranslatorUtils.buildMatchTypeDesignator(
+ var matchStart = ToscaPolicyTranslatorUtils.buildMatchTypeDesignator(
XACML3.ID_FUNCTION_TIME_GREATER_THAN_OR_EQUAL,
((Map) timeRange).get("start_time").toString(),
XACML3.ID_DATATYPE_TIME,
@@ -374,7 +374,7 @@ public class GuardTranslator implements ToscaPolicyTranslator {
allOf.getMatch().add(matchStart);
- MatchType matchEnd = ToscaPolicyTranslatorUtils.buildMatchTypeDesignator(
+ var matchEnd = ToscaPolicyTranslatorUtils.buildMatchTypeDesignator(
XACML3.ID_FUNCTION_TIME_LESS_THAN_OR_EQUAL,
((Map) timeRange).get("end_time").toString(),
XACML3.ID_DATATYPE_TIME,
@@ -412,8 +412,8 @@ public class GuardTranslator implements ToscaPolicyTranslator {
//
// Should also be parseable as an ISO8601 timestamp
//
- Object startTimeObject = parseTimestamp(startTimestamp);
- Object endTimeObject = parseTimestamp(endTimestamp);
+ var startTimeObject = parseTimestamp(startTimestamp);
+ var endTimeObject = parseTimestamp(endTimestamp);
//
// They should be the same object types. We cannot establish a range
// between an OffsetDateTime and an OffsetTime
@@ -425,7 +425,7 @@ public class GuardTranslator implements ToscaPolicyTranslator {
// Create the inner timeInRange ApplyType
//
ApplyType timeInRange = ToscaPolicyTranslatorUtils.generateTimeInRange(startTimestamp, endTimestamp, true);
- VariableDefinitionType variable = new VariableDefinitionType();
+ var variable = new VariableDefinitionType();
variable.setVariableId(VARIABLE_TIMEINRANGE);
variable.setExpression(new ObjectFactory().createApply(timeInRange));
//
@@ -435,7 +435,7 @@ public class GuardTranslator implements ToscaPolicyTranslator {
//
// Create and return the reference to the variable
//
- VariableReferenceType reference = new VariableReferenceType();
+ var reference = new VariableReferenceType();
reference.setVariableId(variable.getVariableId());
return reference;
}
@@ -470,14 +470,14 @@ public class GuardTranslator implements ToscaPolicyTranslator {
//
// See if its possible to generate a count
//
- Integer limit = ToscaPolicyTranslatorUtils.parseInteger(
+ var limit = ToscaPolicyTranslatorUtils.parseInteger(
toscaPolicy.getProperties().get(FIELD_LIMIT).toString());
if (limit == null) {
throw new ToscaPolicyConversionException("Missing limit value");
}
String timeWindow = null;
if (toscaPolicy.getProperties().containsKey(FIELD_TIMEWINDOW)) {
- Integer intTimeWindow = ToscaPolicyTranslatorUtils.parseInteger(
+ var intTimeWindow = ToscaPolicyTranslatorUtils.parseInteger(
toscaPolicy.getProperties().get(FIELD_TIMEWINDOW).toString());
if (intTimeWindow == null) {
throw new ToscaPolicyConversionException("timeWindow is not an integer");
@@ -495,13 +495,13 @@ public class GuardTranslator implements ToscaPolicyTranslator {
//
// Create our condition
//
- final ConditionType condition = new ConditionType();
+ final var condition = new ConditionType();
condition.setExpression(new ObjectFactory().createApply(countCheck));
//
// Now we can create our rule
//
- RuleType frequencyRule = new RuleType();
+ var frequencyRule = new RuleType();
frequencyRule.setDescription("Frequency limit permit rule");
frequencyRule.setRuleId(policyName + ":frequency");
frequencyRule.setEffect(EffectType.PERMIT);
@@ -517,7 +517,7 @@ public class GuardTranslator implements ToscaPolicyTranslator {
}
protected ApplyType generateCountCheck(Integer limit, String timeWindow, String timeUnits) {
- AttributeDesignatorType designator = new AttributeDesignatorType();
+ var designator = new AttributeDesignatorType();
designator.setAttributeId(ToscaDictionary.ID_RESOURCE_GUARD_OPERATIONCOUNT.stringValue());
designator.setCategory(XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE.stringValue());
designator.setDataType(XACML3.ID_DATATYPE_INTEGER.stringValue());
@@ -530,7 +530,7 @@ public class GuardTranslator implements ToscaPolicyTranslator {
+ ":tw:" + timeWindow + ":" + timeUnits;
designator.setIssuer(issuer);
- AttributeValueType valueLimit = new AttributeValueType();
+ var valueLimit = new AttributeValueType();
valueLimit.setDataType(XACML3.ID_DATATYPE_INTEGER.stringValue());
//
// Yes really use toString(), the marshaller will
@@ -539,14 +539,14 @@ public class GuardTranslator implements ToscaPolicyTranslator {
//
valueLimit.getContent().add(limit.toString());
- ObjectFactory factory = new ObjectFactory();
+ var factory = new ObjectFactory();
- ApplyType applyOneAndOnly = new ApplyType();
+ var applyOneAndOnly = new ApplyType();
applyOneAndOnly.setDescription("Unbag the limit");
applyOneAndOnly.setFunctionId(XACML3.ID_FUNCTION_INTEGER_ONE_AND_ONLY.stringValue());
applyOneAndOnly.getExpression().add(factory.createAttributeDesignator(designator));
- ApplyType applyLessThan = new ApplyType();
+ var applyLessThan = new ApplyType();
applyLessThan.setDescription("return true if current count is less than.");
applyLessThan.setFunctionId(XACML3.ID_FUNCTION_INTEGER_LESS_THAN.stringValue());
applyLessThan.getExpression().add(factory.createApply(applyOneAndOnly));
@@ -563,7 +563,7 @@ public class GuardTranslator implements ToscaPolicyTranslator {
if (! toscaPolicy.getProperties().containsKey(FIELD_TARGET)) {
throw new ToscaPolicyConversionException("Missing target field in minmax policy");
}
- MatchType matchTarget = ToscaPolicyTranslatorUtils.buildMatchTypeDesignator(
+ var matchTarget = ToscaPolicyTranslatorUtils.buildMatchTypeDesignator(
XACML3.ID_FUNCTION_STRING_EQUAL,
toscaPolicy.getProperties().get(FIELD_TARGET).toString(),
XACML3.ID_DATATYPE_STRING,
@@ -576,7 +576,7 @@ public class GuardTranslator implements ToscaPolicyTranslator {
Integer min = null;
if (toscaPolicy.getProperties().containsKey(FIELD_MIN)) {
min = ToscaPolicyTranslatorUtils.parseInteger(toscaPolicy.getProperties().get(FIELD_MIN).toString());
- MatchType matchMin = ToscaPolicyTranslatorUtils.buildMatchTypeDesignator(
+ var matchMin = ToscaPolicyTranslatorUtils.buildMatchTypeDesignator(
XACML3.ID_FUNCTION_INTEGER_GREATER_THAN,
min.toString(),
XACML3.ID_DATATYPE_INTEGER,
@@ -589,7 +589,7 @@ public class GuardTranslator implements ToscaPolicyTranslator {
Integer max = null;
if (toscaPolicy.getProperties().containsKey(FIELD_MAX)) {
max = ToscaPolicyTranslatorUtils.parseInteger(toscaPolicy.getProperties().get(FIELD_MAX).toString());
- MatchType matchMax = ToscaPolicyTranslatorUtils.buildMatchTypeDesignator(
+ var matchMax = ToscaPolicyTranslatorUtils.buildMatchTypeDesignator(
XACML3.ID_FUNCTION_INTEGER_GREATER_THAN,
max.toString(),
XACML3.ID_DATATYPE_INTEGER,
@@ -608,14 +608,14 @@ public class GuardTranslator implements ToscaPolicyTranslator {
}
protected RuleType generateMinMaxRule(MatchType matchTarget, MatchType matchMinOrMax, String ruleId, String desc) {
- AllOfType allOf = new AllOfType();
+ var allOf = new AllOfType();
allOf.getMatch().add(matchTarget);
allOf.getMatch().add(matchMinOrMax);
- AnyOfType anyOf = new AnyOfType();
+ var anyOf = new AnyOfType();
anyOf.getAllOf().add(allOf);
- TargetType target = new TargetType();
+ var target = new TargetType();
target.getAnyOf().add(anyOf);
- RuleType minMaxRule = new RuleType();
+ var minMaxRule = new RuleType();
minMaxRule.setEffect(EffectType.PERMIT);
minMaxRule.setDescription(desc);
minMaxRule.setRuleId(ruleId);
@@ -642,10 +642,10 @@ public class GuardTranslator implements ToscaPolicyTranslator {
// Iterate the entries and create individual AnyOf so each entry is
// treated as an OR.
//
- TargetType target = new TargetType();
- AnyOfType anyOf = new AnyOfType();
+ var target = new TargetType();
+ var anyOf = new AnyOfType();
for (Object blacklisted : ((Collection<?>) arrayBlacklisted)) {
- AllOfType allOf = new AllOfType();
+ var allOf = new AllOfType();
this.addMatch(allOf, blacklisted, ToscaDictionary.ID_RESOURCE_GUARD_TARGETID);
anyOf.getAllOf().add(allOf);
}
@@ -653,7 +653,7 @@ public class GuardTranslator implements ToscaPolicyTranslator {
//
// Create our rule and add the target
//
- RuleType blacklistRule = new RuleType();
+ var blacklistRule = new RuleType();
blacklistRule.setEffect(EffectType.DENY);
blacklistRule.setDescription("blacklist the entities");
blacklistRule.setRuleId(policyName + ":blacklist");
@@ -698,7 +698,7 @@ public class GuardTranslator implements ToscaPolicyTranslator {
//
// Iterate the filters
//
- int ruleId = 1;
+ var ruleId = 1;
for (Object filterAttributes : ((Collection<?>) arrayFilters)) {
if (!(filterAttributes instanceof Map)) {
throw new ToscaPolicyConversionException("Filter should be a map");
@@ -799,24 +799,24 @@ public class GuardTranslator implements ToscaPolicyTranslator {
private RuleType createFilterRule(String ruleId, String field, String filter, Identifier function,
boolean isBlacklisted) {
- RuleType rule = new RuleType();
+ var rule = new RuleType();
rule.setRuleId(ruleId);
//
// Create the Match
//
- MatchType matchFilter = ToscaPolicyTranslatorUtils.buildMatchTypeDesignator(
+ var matchFilter = ToscaPolicyTranslatorUtils.buildMatchTypeDesignator(
function,
filter,
XACML3.ID_DATATYPE_STRING,
new IdentifierImpl(GuardPolicyRequest.PREFIX_RESOURCE_ATTRIBUTE_ID + field),
XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE
);
- AllOfType allOf = new AllOfType();
+ var allOf = new AllOfType();
allOf.getMatch().add(matchFilter);
- AnyOfType anyOf = new AnyOfType();
+ var anyOf = new AnyOfType();
anyOf.getAllOf().add(allOf);
- TargetType target = new TargetType();
+ var target = new TargetType();
target.getAnyOf().add(anyOf);
rule.setTarget(target);
diff --git a/applications/monitoring/src/main/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplication.java b/applications/monitoring/src/main/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplication.java
index 17a9e743..fc03f1c4 100644
--- a/applications/monitoring/src/main/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplication.java
+++ b/applications/monitoring/src/main/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplication.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -87,7 +87,7 @@ public class MonitoringPdpApplication extends StdXacmlApplicationServiceProvider
// Make the decision
//
Pair<DecisionResponse, Response> decisionPair = super.makeDecision(request, requestQueryParams);
- DecisionResponse decisionResponse = decisionPair.getKey();
+ var decisionResponse = decisionPair.getKey();
//
// Abbreviate results if needed
//
diff --git a/applications/native/src/main/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplicationTranslator.java b/applications/native/src/main/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplicationTranslator.java
index 34ef1462..7302b676 100644
--- a/applications/native/src/main/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplicationTranslator.java
+++ b/applications/native/src/main/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplicationTranslator.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -71,7 +71,7 @@ public class NativePdpApplicationTranslator implements ToscaPolicyTranslator {
//
// Scan the string and convert to xacml PolicyType
//
- try (ByteArrayInputStream is = new ByteArrayInputStream(decodedXacmlPolicy.getBytes(StandardCharsets.UTF_8))) {
+ try (var is = new ByteArrayInputStream(decodedXacmlPolicy.getBytes(StandardCharsets.UTF_8))) {
//
// Read the Policy In
//
@@ -92,7 +92,7 @@ public class NativePdpApplicationTranslator implements ToscaPolicyTranslator {
throw new ToscaPolicyConversionException("no xacml native policy found in the tosca policy");
}
- String nativePolicyString = propertyMap.get(POLICY).toString();
+ var nativePolicyString = propertyMap.get(POLICY).toString();
LOGGER.debug("Base64 encoded native xacml policy {}", nativePolicyString);
return nativePolicyString;
}
diff --git a/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplication.java b/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplication.java
index 50bc0bd8..92a8e688 100644
--- a/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplication.java
+++ b/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplication.java
@@ -137,7 +137,7 @@ public class OptimizationPdpApplication extends StdXacmlApplicationServiceProvid
//
// Convert the request
//
- DecisionRequest subscriberRequest = new DecisionRequest(request);
+ var subscriberRequest = new DecisionRequest(request);
//
// Override the PolicyType to ensure we are only looking at Subscriber Policies
//
diff --git a/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplicationTranslator.java b/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplicationTranslator.java
index 52f1ec0a..068245ff 100644
--- a/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplicationTranslator.java
+++ b/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplicationTranslator.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 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.
@@ -41,7 +41,6 @@ import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeAssignmentExpressionType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.EffectType;
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.MatchType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.ObjectFactory;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
import org.apache.commons.lang3.StringUtils;
@@ -95,7 +94,7 @@ public class OptimizationPdpApplicationTranslator extends StdMatchableTranslator
//
// Dump our revised policy out
//
- try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
+ try (var os = new ByteArrayOutputStream()) {
XACMLPolicyWriter.writePolicyFile(os, policy);
LOGGER.info("{}", os);
} catch (IOException e) {
@@ -161,11 +160,11 @@ public class OptimizationPdpApplicationTranslator extends StdMatchableTranslator
//
// Iterate through all the subscriber names
//
- AnyOfType anyOf = new AnyOfType();
+ var anyOf = new AnyOfType();
for (Object subscriberName : subscriberNames instanceof Collection ? (List<Object>) subscriberNames :
Arrays.asList(subscriberNames)) {
- MatchType match = ToscaPolicyTranslatorUtils.buildMatchTypeDesignator(
+ var match = ToscaPolicyTranslatorUtils.buildMatchTypeDesignator(
XACML3.ID_FUNCTION_STRING_EQUAL,
subscriberName,
XACML3.ID_DATATYPE_STRING,
@@ -197,7 +196,7 @@ public class OptimizationPdpApplicationTranslator extends StdMatchableTranslator
//
// Create our subscriber advice expression
//
- AdviceExpressionType adviceExpression = new AdviceExpressionType();
+ var adviceExpression = new AdviceExpressionType();
adviceExpression.setAppliesTo(EffectType.PERMIT);
adviceExpression.setAdviceId(ToscaDictionary.ID_ADVICE_OPTIMIZATION_SUBSCRIBER.stringValue());
//
@@ -221,7 +220,7 @@ public class OptimizationPdpApplicationTranslator extends StdMatchableTranslator
//
// Add it to the overall expressions
//
- AdviceExpressionsType adviceExpressions = new AdviceExpressionsType();
+ var adviceExpressions = new AdviceExpressionsType();
adviceExpressions.getAdviceExpression().add(adviceExpression);
//
// Done return our advice expressions
@@ -232,11 +231,11 @@ public class OptimizationPdpApplicationTranslator extends StdMatchableTranslator
private static AdviceExpressionType generateSubscriberAdviceAttributes(AdviceExpressionType adviceExpression,
Identifier attributeId, Collection<Object> adviceAttribute) {
for (Object attribute : adviceAttribute) {
- AttributeValueType value = new AttributeValueType();
+ var value = new AttributeValueType();
value.setDataType(XACML3.ID_DATATYPE_STRING.stringValue());
value.getContent().add(attribute.toString());
- AttributeAssignmentExpressionType assignment = new AttributeAssignmentExpressionType();
+ var assignment = new AttributeAssignmentExpressionType();
assignment.setAttributeId(attributeId.stringValue());
assignment.setCategory(XACML3.ID_SUBJECT_CATEGORY_ACCESS_SUBJECT.stringValue());
assignment.setExpression(new ObjectFactory().createAttributeValue(value));
diff --git a/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationSubscriberRequest.java b/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationSubscriberRequest.java
index 263c6540..5eda7678 100644
--- a/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationSubscriberRequest.java
+++ b/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationSubscriberRequest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 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.
@@ -25,7 +25,6 @@ package org.onap.policy.xacml.pdp.application.optimization;
import com.att.research.xacml.api.AttributeValue;
import com.att.research.xacml.api.DataType;
import com.att.research.xacml.api.DataTypeException;
-import com.att.research.xacml.api.DataTypeFactory;
import com.att.research.xacml.api.Identifier;
import com.att.research.xacml.api.Request;
import com.att.research.xacml.api.XACML3;
@@ -58,13 +57,13 @@ public class OptimizationSubscriberRequest extends StdMatchablePolicyRequest {
*/
@SuppressWarnings({"rawtypes", "unchecked"})
public static Request createInstance(DecisionRequest decisionRequest) throws XacmlApplicationException {
- Request request = StdMatchablePolicyRequest.createInstance(decisionRequest);
+ var request = StdMatchablePolicyRequest.createInstance(decisionRequest);
//
// Add in the context attributes
//
- StdMutableRequest mutableRequest = new StdMutableRequest(request);
- StdMutableRequestAttributes contextAttributes = new StdMutableRequestAttributes();
+ var mutableRequest = new StdMutableRequest(request);
+ var contextAttributes = new StdMutableRequestAttributes();
contextAttributes.setCategory(XACML3.ID_SUBJECT_CATEGORY_ACCESS_SUBJECT);
//
// Add the context attributes
@@ -94,12 +93,12 @@ public class OptimizationSubscriberRequest extends StdMatchablePolicyRequest {
protected static StdMutableRequestAttributes addSubject(StdMutableRequestAttributes attributes,
Collection<Object> values, Identifier id) throws DataTypeException {
- DataTypeFactory factory = getDataTypeFactory();
+ var factory = getDataTypeFactory();
if (factory == null) {
return null;
}
for (Object value : values) {
- StdMutableAttribute mutableAttribute = new StdMutableAttribute();
+ var mutableAttribute = new StdMutableAttribute();
mutableAttribute.setCategory(XACML3.ID_SUBJECT_CATEGORY_ACCESS_SUBJECT);
mutableAttribute.setAttributeId(id);
mutableAttribute.setIncludeInResults(true);
diff --git a/main/src/main/java/org/onap/policy/pdpx/main/XacmlState.java b/main/src/main/java/org/onap/policy/pdpx/main/XacmlState.java
index 5ca75a62..8ec5ed2b 100644
--- a/main/src/main/java/org/onap/policy/pdpx/main/XacmlState.java
+++ b/main/src/main/java/org/onap/policy/pdpx/main/XacmlState.java
@@ -148,7 +148,7 @@ public class XacmlState {
* @return a new response
*/
private PdpStatus makeResponse(PdpMessage message, String errMessage) {
- PdpResponseDetails resp = new PdpResponseDetails();
+ var resp = new PdpResponseDetails();
if (StringUtils.isBlank(errMessage)) {
resp.setResponseStatus(PdpResponseStatus.SUCCESS);
@@ -158,7 +158,7 @@ public class XacmlState {
}
resp.setResponseTo(message.getRequestId());
- PdpStatus status2 = new PdpStatus(status);
+ var status2 = new PdpStatus(status);
status2.setResponse(resp);
return status2;
}
diff --git a/main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisher.java b/main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisher.java
index 4882760e..7806fead 100644
--- a/main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisher.java
+++ b/main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisher.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 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.
@@ -76,7 +76,7 @@ public class XacmlPdpUpdatePublisher {
}
}
- StringBuilder errorMessage = new StringBuilder();
+ var errorMessage = new StringBuilder();
// Deploy a policy
// if deployed policies do not contain the incoming policy load it
for (ToscaPolicy policy : incomingPolicies) {
@@ -96,7 +96,7 @@ public class XacmlPdpUpdatePublisher {
LOGGER.debug("Returning current deployed policies: {} ", message.getPolicies());
// update the policy count statistic
- XacmlPdpStatisticsManager stats = XacmlPdpStatisticsManager.getCurrent();
+ var stats = XacmlPdpStatisticsManager.getCurrent();
if (stats != null) {
stats.setTotalPolicyCount(appManager.getPolicyCount());
}
diff --git a/main/src/main/java/org/onap/policy/pdpx/main/parameters/XacmlPdpParameterGroup.java b/main/src/main/java/org/onap/policy/pdpx/main/parameters/XacmlPdpParameterGroup.java
index 12fec484..7afa480a 100644
--- a/main/src/main/java/org/onap/policy/pdpx/main/parameters/XacmlPdpParameterGroup.java
+++ b/main/src/main/java/org/onap/policy/pdpx/main/parameters/XacmlPdpParameterGroup.java
@@ -82,7 +82,7 @@ public class XacmlPdpParameterGroup extends ParameterGroupImpl {
final BeanValidationResult validationResult = super.validate();
if (policyApiParameters != null && StringUtils.isBlank(policyApiParameters.getHostname())) {
- BeanValidationResult sub = new BeanValidationResult(PARAM_POLICY_API, policyApiParameters);
+ var sub = new BeanValidationResult(PARAM_POLICY_API, policyApiParameters);
sub.addResult("hostname", policyApiParameters.getHostname(), ValidationStatus.INVALID, Validated.IS_NULL);
validationResult.addResult(sub);
}
diff --git a/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManager.java b/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManager.java
index 3553b4c4..e144ba3e 100644
--- a/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManager.java
+++ b/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManager.java
@@ -78,7 +78,7 @@ public class XacmlPdpApplicationManager {
// We are not going to make this available unless the application can
// install correctly.
//
- boolean applicationInitialized = false;
+ var applicationInitialized = false;
//
// Have it initialize at a path
//
@@ -237,7 +237,7 @@ public class XacmlPdpApplicationManager {
// Making an assumption that all application names are unique, and
// they can result in a valid directory being created.
//
- Path path = Paths.get(basePath.toAbsolutePath().toString(), application.applicationName());
+ var path = Paths.get(basePath.toAbsolutePath().toString(), application.applicationName());
if (LOGGER.isInfoEnabled()) {
LOGGER.info("initializeApplicationPath {} at this path {}", application.applicationName(), path);
}
diff --git a/main/src/main/java/org/onap/policy/pdpx/main/rest/provider/HealthCheckProvider.java b/main/src/main/java/org/onap/policy/pdpx/main/rest/provider/HealthCheckProvider.java
index 71a4e4e6..bc791872 100644
--- a/main/src/main/java/org/onap/policy/pdpx/main/rest/provider/HealthCheckProvider.java
+++ b/main/src/main/java/org/onap/policy/pdpx/main/rest/provider/HealthCheckProvider.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 2021 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.
@@ -40,7 +40,7 @@ public class HealthCheckProvider {
* @return Report containing health check status
*/
public HealthCheckReport performHealthCheck() {
- final HealthCheckReport report = new HealthCheckReport();
+ final var report = new HealthCheckReport();
report.setName(NAME);
report.setUrl(URL);
diff --git a/main/src/main/java/org/onap/policy/pdpx/main/rest/provider/StatisticsProvider.java b/main/src/main/java/org/onap/policy/pdpx/main/rest/provider/StatisticsProvider.java
index cf2fd608..6c7a7cd9 100644
--- a/main/src/main/java/org/onap/policy/pdpx/main/rest/provider/StatisticsProvider.java
+++ b/main/src/main/java/org/onap/policy/pdpx/main/rest/provider/StatisticsProvider.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 2021 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.
@@ -36,10 +36,10 @@ public class StatisticsProvider {
* @return Report containing statistics of xacmlPdp service
*/
public StatisticsReport fetchCurrentStatistics() {
- final StatisticsReport report = new StatisticsReport();
+ final var report = new StatisticsReport();
report.setCode(XacmlPdpActivator.getCurrent().isAlive() ? 200 : 500);
- XacmlPdpStatisticsManager stats = XacmlPdpStatisticsManager.getCurrent();
+ var stats = XacmlPdpStatisticsManager.getCurrent();
report.setTotalPolicyTypesCount(stats.getTotalPolicyTypesCount());
report.setTotalPoliciesCount(stats.getTotalPoliciesCount());
report.setTotalErrorCount(stats.getErrorCount());
diff --git a/main/src/main/java/org/onap/policy/pdpx/main/rest/serialization/XacmlJsonMessageBodyHandler.java b/main/src/main/java/org/onap/policy/pdpx/main/rest/serialization/XacmlJsonMessageBodyHandler.java
index 9b59a003..a6d9952e 100644
--- a/main/src/main/java/org/onap/policy/pdpx/main/rest/serialization/XacmlJsonMessageBodyHandler.java
+++ b/main/src/main/java/org/onap/policy/pdpx/main/rest/serialization/XacmlJsonMessageBodyHandler.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 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.
@@ -61,7 +61,7 @@ public class XacmlJsonMessageBodyHandler implements MessageBodyReader<Request>,
MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
throws IOException {
- try (OutputStreamWriter writer = new OutputStreamWriter(entityStream, StandardCharsets.UTF_8)) {
+ try (var writer = new OutputStreamWriter(entityStream, StandardCharsets.UTF_8)) {
writer.write(JsonResponseTranslator.toString(response, true));
} catch (Exception exc) {
throw new IOException("failed to convert a json response to a string");
@@ -100,4 +100,4 @@ public class XacmlJsonMessageBodyHandler implements MessageBodyReader<Request>,
return ("xacml+json".equals(mediaType.getSubtype()))
&& (type == Request.class || type == Response.class);
}
-} \ No newline at end of file
+}
diff --git a/main/src/main/java/org/onap/policy/pdpx/main/rest/serialization/XacmlXmlMessageBodyHandler.java b/main/src/main/java/org/onap/policy/pdpx/main/rest/serialization/XacmlXmlMessageBodyHandler.java
index ddd77528..4ddfbe26 100644
--- a/main/src/main/java/org/onap/policy/pdpx/main/rest/serialization/XacmlXmlMessageBodyHandler.java
+++ b/main/src/main/java/org/onap/policy/pdpx/main/rest/serialization/XacmlXmlMessageBodyHandler.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 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.
@@ -62,7 +62,7 @@ public class XacmlXmlMessageBodyHandler implements MessageBodyReader<Request>, M
MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
throws IOException {
- try (OutputStreamWriter writer = new OutputStreamWriter(entityStream, StandardCharsets.UTF_8)) {
+ try (var writer = new OutputStreamWriter(entityStream, StandardCharsets.UTF_8)) {
writer.write(DOMResponse.toString(response, true));
} catch (Exception exc) {
throw new IOException("failed to convert a dom response to a string");
@@ -100,4 +100,4 @@ public class XacmlXmlMessageBodyHandler implements MessageBodyReader<Request>, M
return ("xacml+xml".equals(mediaType.getSubtype()))
&& (type == Request.class || type == Response.class);
}
-} \ No newline at end of file
+}
diff --git a/main/src/main/java/org/onap/policy/pdpx/main/startstop/Main.java b/main/src/main/java/org/onap/policy/pdpx/main/startstop/Main.java
index 64c41330..b19f31b8 100644
--- a/main/src/main/java/org/onap/policy/pdpx/main/startstop/Main.java
+++ b/main/src/main/java/org/onap/policy/pdpx/main/startstop/Main.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* ================================================================================
@@ -53,11 +53,11 @@ public class Main {
* @throws PolicyXacmlPdpException if an error occurs
*/
public Main(final String[] args) throws PolicyXacmlPdpException {
- final String argumentString = Arrays.toString(args);
+ final var argumentString = Arrays.toString(args);
LOGGER.info("Starting policy xacml pdp service with arguments - {}", argumentString);
// Check the arguments
- final XacmlPdpCommandLineArguments arguments = new XacmlPdpCommandLineArguments();
+ final var arguments = new XacmlPdpCommandLineArguments();
// The arguments return a string if there is a message to print and we should exit
argumentMessage = arguments.parse(args);
@@ -81,7 +81,7 @@ public class Main {
// Add a shutdown hook to shut everything down in an orderly manner
Runtime.getRuntime().addShutdownHook(new Thread(this::shutdown));
- String successMsg = String.format(MessageConstants.START_SUCCESS_MSG, MessageConstants.POLICY_XACML_PDP);
+ var successMsg = String.format(MessageConstants.START_SUCCESS_MSG, MessageConstants.POLICY_XACML_PDP);
LOGGER.info(successMsg);
}
diff --git a/main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpActivator.java b/main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpActivator.java
index 0a32d234..e17cecf7 100644
--- a/main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpActivator.java
+++ b/main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpActivator.java
@@ -87,12 +87,12 @@ public class XacmlPdpActivator extends ServiceManagerContainer {
final XacmlState state;
try {
- XacmlPdpApplicationManager appmgr =
+ var appmgr =
new XacmlPdpApplicationManager(Paths.get(xacmlPdpParameterGroup.getApplicationPath()),
xacmlPdpParameterGroup.getPolicyApiParameters());
XacmlPdpApplicationManager.setCurrent(appmgr);
- XacmlPdpStatisticsManager stats = new XacmlPdpStatisticsManager();
+ var stats = new XacmlPdpStatisticsManager();
XacmlPdpStatisticsManager.setCurrent(stats);
stats.setTotalPolicyTypesCount(appmgr.getPolicyTypeCount());
stats.setTotalPolicyCount(appmgr.getPolicyCount());
diff --git a/main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpCommandLineArguments.java b/main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpCommandLineArguments.java
index f393fc91..1267d858 100644
--- a/main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpCommandLineArguments.java
+++ b/main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpCommandLineArguments.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 2021 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.
@@ -23,7 +23,6 @@ package org.onap.policy.pdpx.main.startstop;
import java.io.File;
import java.io.PrintWriter;
import java.io.StringWriter;
-import java.net.URL;
import java.util.Arrays;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.DefaultParser;
@@ -180,9 +179,9 @@ public class XacmlPdpCommandLineArguments {
* @return the help string
*/
public String help(final String mainClassName) {
- final HelpFormatter helpFormatter = new HelpFormatter();
- final StringWriter stringWriter = new StringWriter();
- final PrintWriter printWriter = new PrintWriter(stringWriter);
+ final var helpFormatter = new HelpFormatter();
+ final var stringWriter = new StringWriter();
+ final var printWriter = new PrintWriter(stringWriter);
helpFormatter.printHelp(printWriter, HELP_LINE_LENGTH, mainClassName + " [options...]", "options", options, 0,
0, "");
@@ -268,12 +267,12 @@ public class XacmlPdpCommandLineArguments {
}
// The file name refers to a resource on the local file system
- final URL fileUrl = ResourceUtils.getUrl4Resource(fileName);
+ final var fileUrl = ResourceUtils.getUrl4Resource(fileName);
if (fileUrl == null) {
throw new PolicyXacmlPdpException(fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" does not exist");
}
- final File theFile = new File(fileUrl.getPath());
+ final var theFile = new File(fileUrl.getPath());
if (!theFile.exists()) {
throw new PolicyXacmlPdpException(fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" does not exist");
}
diff --git a/main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpRestServer.java b/main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpRestServer.java
index b0f3b8c0..487253b2 100644
--- a/main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpRestServer.java
+++ b/main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpRestServer.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 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.
@@ -57,7 +57,7 @@ public class XacmlPdpRestServer extends RestServer {
@Override
protected Properties getServerProperties(RestServerParameters restServerParameters, String names) {
- final Properties props = super.getServerProperties(restServerParameters, names);
+ final var props = super.getServerProperties(restServerParameters, names);
final String svcpfx =
PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "." + restServerParameters.getName();
diff --git a/tutorials/tutorial-enforcement/src/main/java/org/onap/policy/tutorial/policyenforcement/App.java b/tutorials/tutorial-enforcement/src/main/java/org/onap/policy/tutorial/policyenforcement/App.java
index 764b3bdf..6b291c6a 100644
--- a/tutorials/tutorial-enforcement/src/main/java/org/onap/policy/tutorial/policyenforcement/App.java
+++ b/tutorials/tutorial-enforcement/src/main/java/org/onap/policy/tutorial/policyenforcement/App.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 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.
@@ -26,7 +26,6 @@ import java.util.Map.Entry;
import java.util.Scanner;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.TopicListener;
@@ -63,13 +62,13 @@ public class App extends Thread implements TopicListener {
xacmlPdpHost = args[0];
xacmlPdpPort = args[1];
- TopicParameters params = new TopicParameters();
+ var params = new TopicParameters();
params.setTopicCommInfrastructure("dmaap");
params.setFetchLimit(1);
params.setFetchTimeout(5000);
params.setTopic("POLICY-NOTIFICATION");
params.setServers(Arrays.asList(args[2] + ":" + args[3]));
- TopicParameterGroup topicParams = new TopicParameterGroup();
+ var topicParams = new TopicParameterGroup();
topicParams.setTopicSources(Arrays.asList(params));
TopicEndpointManager.getManager().addTopics(topicParams);
@@ -117,7 +116,7 @@ public class App extends Thread implements TopicListener {
TopicEndpointManager.getManager().start();
@SuppressWarnings("resource") // never close System.in
- Scanner input = new Scanner(System.in);
+ var input = new Scanner(System.in);
while (!Thread.currentThread().isInterrupted()) {
String quit = input.nextLine();
if ("q".equalsIgnoreCase(quit)) {
@@ -155,7 +154,7 @@ public class App extends Thread implements TopicListener {
* @return true if MY_POLICYTYPEID is in the message
*/
private boolean scanForPolicyType(String msg) {
- StandardCoder gson = new StandardCoder();
+ var gson = new StandardCoder();
try {
PolicyNotification notification = gson.decode(msg, PolicyNotification.class);
for (PolicyStatus added : notification.getAdded()) {
@@ -189,7 +188,7 @@ public class App extends Thread implements TopicListener {
Entity<DecisionRequest> entityRequest =
Entity.entity(decisionRequest, MediaType.APPLICATION_JSON);
- Response response = client.post("/decision", entityRequest, Collections.emptyMap());
+ var response = client.post("/decision", entityRequest, Collections.emptyMap());
if (response.getStatus() != 200) {
logger.error(
@@ -197,7 +196,7 @@ public class App extends Thread implements TopicListener {
return Collections.emptyMap();
}
- DecisionResponse decisionResponse = HttpClient.getBody(response, DecisionResponse.class);
+ var decisionResponse = HttpClient.getBody(response, DecisionResponse.class);
return decisionResponse.getPolicies();
}
@@ -210,7 +209,7 @@ public class App extends Thread implements TopicListener {
public static void main(String[] args) {
logger.info("Hello Welcome to ONAP Enforcement Tutorial!");
- App app = new App(args);
+ var app = new App(args);
app.start();
diff --git a/tutorials/tutorial-xacml-application/src/main/java/org/onap/policy/tutorial/tutorial/TutorialRequest.java b/tutorials/tutorial-xacml-application/src/main/java/org/onap/policy/tutorial/tutorial/TutorialRequest.java
index 4bb94cd7..00d4fe70 100644
--- a/tutorials/tutorial-xacml-application/src/main/java/org/onap/policy/tutorial/tutorial/TutorialRequest.java
+++ b/tutorials/tutorial-xacml-application/src/main/java/org/onap/policy/tutorial/tutorial/TutorialRequest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 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.
@@ -65,7 +65,7 @@ public class TutorialRequest {
//
// Create our object
//
- TutorialRequest request = new TutorialRequest();
+ var request = new TutorialRequest();
//
// Add the subject attributes
//
diff --git a/tutorials/tutorial-xacml-application/src/main/java/org/onap/policy/tutorial/tutorial/TutorialTranslator.java b/tutorials/tutorial-xacml-application/src/main/java/org/onap/policy/tutorial/tutorial/TutorialTranslator.java
index 7a6b5d8a..3d9effe5 100644
--- a/tutorials/tutorial-xacml-application/src/main/java/org/onap/policy/tutorial/tutorial/TutorialTranslator.java
+++ b/tutorials/tutorial-xacml-application/src/main/java/org/onap/policy/tutorial/tutorial/TutorialTranslator.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 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.
@@ -31,7 +31,6 @@ import java.util.List;
import java.util.Map;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.EffectType;
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.MatchType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.RuleType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType;
@@ -59,7 +58,7 @@ public class TutorialTranslator implements ToscaPolicyTranslator {
//
// Here is our policy with a version and default combining algo
//
- PolicyType newPolicyType = new PolicyType();
+ var newPolicyType = new PolicyType();
newPolicyType.setPolicyId(toscaPolicy.getMetadata().get("policy-id"));
newPolicyType.setVersion(toscaPolicy.getMetadata().get("policy-version"));
//
@@ -77,33 +76,33 @@ public class TutorialTranslator implements ToscaPolicyTranslator {
//
// For simplicity, let's just match on the action "authorize" and the user
//
- MatchType matchAction = ToscaPolicyTranslatorUtils.buildMatchTypeDesignator(
+ var matchAction = ToscaPolicyTranslatorUtils.buildMatchTypeDesignator(
XACML3.ID_FUNCTION_STRING_EQUAL, "authorize", XACML3.ID_DATATYPE_STRING,
XACML3.ID_ACTION_ACTION_ID, XACML3.ID_ATTRIBUTE_CATEGORY_ACTION);
Map<String, Object> props = toscaPolicy.getProperties();
- String user = props.get("user").toString();
- MatchType matchUser = ToscaPolicyTranslatorUtils.buildMatchTypeDesignator(XACML3.ID_FUNCTION_STRING_EQUAL, user,
+ var user = props.get("user").toString();
+ var matchUser = ToscaPolicyTranslatorUtils.buildMatchTypeDesignator(XACML3.ID_FUNCTION_STRING_EQUAL, user,
XACML3.ID_DATATYPE_STRING, ID_TUTORIAL_USER, XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE);
- AnyOfType anyOf = new AnyOfType();
+ var anyOf = new AnyOfType();
//
// Create AllOf (AND) of just Policy Id
//
anyOf.getAllOf().add(ToscaPolicyTranslatorUtils.buildAllOf(matchAction, matchUser));
- TargetType target = new TargetType();
+ var target = new TargetType();
target.getAnyOf().add(anyOf);
newPolicyType.setTarget(target);
//
// Now add the rule for each permission
//
- int ruleNumber = 0;
+ var ruleNumber = 0;
List<Object> permissions = (List<Object>) props.get("permissions");
for (Object permission : permissions) {
- MatchType matchEntity = ToscaPolicyTranslatorUtils.buildMatchTypeDesignator(XACML3.ID_FUNCTION_STRING_EQUAL,
+ var matchEntity = ToscaPolicyTranslatorUtils.buildMatchTypeDesignator(XACML3.ID_FUNCTION_STRING_EQUAL,
((Map<String, String>) permission).get("entity"), XACML3.ID_DATATYPE_STRING, ID_TUTORIAL_ENTITY,
XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE);
- MatchType matchPermission = ToscaPolicyTranslatorUtils.buildMatchTypeDesignator(
+ var matchPermission = ToscaPolicyTranslatorUtils.buildMatchTypeDesignator(
XACML3.ID_FUNCTION_STRING_EQUAL, ((Map<String, String>) permission).get("permission"),
XACML3.ID_DATATYPE_STRING, ID_TUTORIAL_PERM, XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE);
anyOf = new AnyOfType();
@@ -111,7 +110,7 @@ public class TutorialTranslator implements ToscaPolicyTranslator {
target = new TargetType();
target.getAnyOf().add(anyOf);
- RuleType rule = new RuleType();
+ var rule = new RuleType();
rule.setDescription("Default is to PERMIT if the policy matches.");
rule.setRuleId(newPolicyType.getPolicyId() + ":rule" + ruleNumber);
@@ -141,7 +140,7 @@ public class TutorialTranslator implements ToscaPolicyTranslator {
* Convert XACML Response to ONAP DecisionResponse.
*/
public DecisionResponse convertResponse(Response xacmlResponse) {
- DecisionResponse decisionResponse = new DecisionResponse();
+ var decisionResponse = new DecisionResponse();
//
// Iterate through all the results
//
diff --git a/xacml-test/src/main/java/org/onap/policy/pdp/xacml/xacmltest/TestUtils.java b/xacml-test/src/main/java/org/onap/policy/pdp/xacml/xacmltest/TestUtils.java
index cb12e0f6..e2bdd96a 100644
--- a/xacml-test/src/main/java/org/onap/policy/pdp/xacml/xacmltest/TestUtils.java
+++ b/xacml-test/src/main/java/org/onap/policy/pdp/xacml/xacmltest/TestUtils.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 2021 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.
@@ -60,7 +60,7 @@ public class TestUtils {
//
// Decode it
//
- String policyYaml = ResourceUtils.getResourceAsString(resourceFile);
+ var policyYaml = ResourceUtils.getResourceAsString(resourceFile);
//
// Serialize it into a class
//
@@ -73,7 +73,7 @@ public class TestUtils {
//
// Make sure all the fields are setup properly
//
- JpaToscaServiceTemplate jtst = new JpaToscaServiceTemplate();
+ var jtst = new JpaToscaServiceTemplate();
jtst.fromAuthorative(serviceTemplate);
ToscaServiceTemplate completedJtst = jtst.toAuthorative();
//
@@ -92,4 +92,4 @@ public class TestUtils {
return loadedPolicies;
}
-} \ No newline at end of file
+}