//
// Create our OnapObligation object
//
- OnapObligation onapObligation = new OnapObligation(obligation);
+ var onapObligation = new OnapObligation(obligation);
//
// All 4 *should* be there
//
//
// Set it as the policy ID
//
- PolicyType newPolicyType = new PolicyType();
+ var newPolicyType = new PolicyType();
newPolicyType.setPolicyId(policyName);
//
// Optional description
//
// Now represent the policy as Json
//
- StandardCoder coder = new StandardCoder();
+ var coder = new StandardCoder();
String jsonPolicy;
try {
jsonPolicy = coder.encode(toscaPolicy);
//
// 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);
//
// 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) {
//
// 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
//
//
// Our callback
//
- MyMatchableCallback myCallback = new MyMatchableCallback(this, template);
+ var myCallback = new MyMatchableCallback(this, template);
//
// Create the matchable
//
}
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();
//
// Construct what the file name should be
//
- Path policyTypePath = this.constructLocalFilePath(policyTypeId);
+ var policyTypePath = this.constructLocalFilePath(policyTypeId);
//
// See if it exists
//
//
// Ensure all the fields are setup correctly
//
- JpaToscaServiceTemplate jtst = new JpaToscaServiceTemplate();
+ var jtst = new JpaToscaServiceTemplate();
jtst.fromAuthorative(template);
return jtst.toAuthorative();
} catch (CoderException e) {
//
ToscaServiceTemplate policyTemplate = null;
try {
- PolicyApiCaller api = new PolicyApiCaller(this.apiRestParameters);
+ var api = new PolicyApiCaller(this.apiRestParameters);
policyTemplate = api.getPolicyType(policyTypeId);
} catch (PolicyApiException e) {