Set all cross references of policy/xacml-pdp
[policy/xacml-pdp.git] / applications / common / src / main / java / org / onap / policy / pdp / xacml / application / common / std / StdCombinedPolicyResultsTranslator.java
index 5756071..64a7db9 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2022 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.
@@ -32,6 +32,7 @@ import com.att.research.xacml.std.annotations.RequestParser;
 import com.google.common.base.Strings;
 import java.util.Collection;
 import java.util.Map;
+import lombok.NoArgsConstructor;
 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.PolicyType;
@@ -49,14 +50,11 @@ import org.onap.policy.pdp.xacml.application.common.ToscaPolicyTranslatorUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@NoArgsConstructor
 public class StdCombinedPolicyResultsTranslator extends StdBaseTranslator {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(StdCombinedPolicyResultsTranslator.class);
 
-    public StdCombinedPolicyResultsTranslator() {
-        super();
-    }
-
     @Override
     public Object convertPolicy(ToscaPolicy toscaPolicy) throws ToscaPolicyConversionException {
         //
@@ -71,7 +69,7 @@ public class StdCombinedPolicyResultsTranslator extends StdBaseTranslator {
         //
         // Get the policy Id
         //
-        String policyId = toscaPolicy.getMetadata().get(POLICY_ID);
+        String policyId = String.valueOf(toscaPolicy.getMetadata().get(POLICY_ID));
         //
         // Set it as the policy ID
         //
@@ -188,7 +186,7 @@ public class StdCombinedPolicyResultsTranslator extends StdBaseTranslator {
         // Sanity check that we got the attributes we care about. NOTE: This translator
         // ensures that these are set when convertPolicy is called.
         //
-        if (! Strings.isNullOrEmpty(policyId) && policyContent != null) {
+        if (! Strings.isNullOrEmpty(policyId) && !policyContent.isEmpty()) {
             decisionResponse.getPolicies().put(policyId, policyContent);
         } else {
             LOGGER.error("Missing obligation policyId {} or policyContent {}", policyId,