FIX SONAR ISSUE NESTED TRY BLOCKS
[policy/engine.git] / ONAP-XACML / src / main / java / org / onap / policy / xacml / util / XACMLPolicyWriter.java
index 5e60e37..ecbd3fa 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP-XACML
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -144,13 +144,10 @@ public class XACMLPolicyWriter {
                        Marshaller m = context.createMarshaller();
                        m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
                        m.marshal(policyElement, byteArrayOutputStream);
-                       ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
-
-                       return byteArrayInputStream;
-
+                       return new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
                } catch (JAXBException e) {
                        PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "XACMLPolicyWriter", "writePolicyFile failed");
-                       return null;
+                       throw new IllegalArgumentException("XACMLPolicyWriter writePolicyFile failed", e);
                }               
        }
        /**
@@ -230,7 +227,7 @@ public class XACMLPolicyWriter {
                                                                                AdviceExpressionType adviceExpressionType = (AdviceExpressionType) iterator
                                                                                                .next();
                                                                                if (adviceExpressionType.getAdviceId() != null && !"".equals(adviceExpressionType.getAdviceId()) && ("configID".equals(adviceExpressionType.getAdviceId())
-                                                                                               || "faultID".equals(adviceExpressionType.getAdviceId()) || "PMID".equals(adviceExpressionType.getAdviceId())||"firewallConfigID".equals(adviceExpressionType.getAdviceId()) 
+                                                                                               || "faultID".equals(adviceExpressionType.getAdviceId()) || "PMID".equals(adviceExpressionType.getAdviceId())||"firewallConfigID".equals(adviceExpressionType.getAdviceId()) || "OptimizationID".equals(adviceExpressionType.getAdviceId())
                                                                                                || "MSID".equals(adviceExpressionType.getAdviceId())) || "GocID".equals(adviceExpressionType.getAdviceId())||"GocHPID".equals(adviceExpressionType.getAdviceId())||"BRMSRAWID".equals(adviceExpressionType.getAdviceId())
                                                                                                || "BRMSPARAMID".equals(adviceExpressionType.getAdviceId())|| "HPSuppID".equals(adviceExpressionType.getAdviceId()) || "HPFlapID".equals(adviceExpressionType.getAdviceId()) || "HPOverID".equals(adviceExpressionType.getAdviceId()))
                                                                                {
@@ -252,7 +249,7 @@ public class XACMLPolicyWriter {
                                                                                                                txtFileName = txtFileName.substring(0, txtFileName.lastIndexOf(".")+1) + origExtension;
                                                                                                                txtFileName = configUrl+ File.separator + "Config" + File.separator + domain + txtFileName;
                                                                                                                attributeValueType1.getContent().add(txtFileName);      
-                                                                                                       } else if (attributeAssignmentExpressionType.getAttributeId().equals("PolicyName")) {
+                                                                                                       } else if ("PolicyName".equals(attributeAssignmentExpressionType.getAttributeId())) {
                                                                                                                JAXBElement<AttributeValueType> attributeValueType = (JAXBElement<AttributeValueType>) attributeAssignmentExpressionType.getExpression();
                                                                                                                AttributeValueType attributeValueType1 = attributeValueType.getValue();
                                                                                                                List<Object> contents = attributeValueType1.getContent();