diff options
author | 2018-02-26 12:38:53 +0100 | |
---|---|---|
committer | 2018-02-26 19:11:11 +0000 | |
commit | 312e9f071ef0a8b3482278e8909f66f4c986ba89 (patch) | |
tree | 8aecf342768b9d86fb1f68bf107ef5c313b2c7f8 /appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/transform | |
parent | 534f94b92547efab097040209e61fa06e07f6e43 (diff) |
appc-config-generator-provider sonar fixes part 2
Sonar fixes in whole module
Change-Id: I55856a6ce73a73098dadb2c5b9428437349ed8a8
Issue-ID: APPC-671
Signed-off-by: Jakub Dudycz <jakub.dudycz@nokia.com>
Diffstat (limited to 'appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/transform')
-rw-r--r-- | appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/transform/XSLTTransformerNode.java | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/transform/XSLTTransformerNode.java b/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/transform/XSLTTransformerNode.java index 5ce7a69b0..300e30428 100644 --- a/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/transform/XSLTTransformerNode.java +++ b/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/transform/XSLTTransformerNode.java @@ -32,7 +32,6 @@ import java.io.StringWriter; import java.nio.charset.Charset; import java.util.Map; import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.stream.StreamResult; @@ -43,7 +42,7 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; import org.onap.sdnc.config.generator.ConfigGeneratorConstant; - +import org.onap.sdnc.config.generator.merge.ParameterMissingException; public class XSLTTransformerNode implements SvcLogicJavaPlugin { @@ -68,12 +67,12 @@ public class XSLTTransformerNode implements SvcLogicJavaPlugin { } } if (StringUtils.isBlank(templateData)) { - throw new Exception("In-param templateFile/templateData value is missing"); + throw new ParameterMissingException("In-param templateFile/templateData value is missing"); } String requestData = inParams.get(ConfigGeneratorConstant.INPUT_PARAM_REQUEST_DATA); if (StringUtils.isBlank(requestData)) { - throw new Exception("In-param requestData value is missing"); + throw new ParameterMissingException("In-param requestData value is missing"); } String transformedData = transform(requestData, templateData); @@ -83,24 +82,25 @@ public class XSLTTransformerNode implements SvcLogicJavaPlugin { ctx.setAttribute(responsePrefix + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS, ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS); } catch (Exception e) { - e.printStackTrace(); ctx.setAttribute(responsePrefix + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS, ConfigGeneratorConstant.OUTPUT_STATUS_FAILURE); ctx.setAttribute(responsePrefix + ConfigGeneratorConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage()); - log.error("Failed in XSLTTransformerNode : " + e.getMessage()); + log.error("Failed in XSLTTransformerNode", e); throw new SvcLogicException(e.getMessage()); } } - public String transform(String requestData, String templateData) - throws TransformerConfigurationException, TransformerException { + private String transform(String requestData, String templateData) throws TransformerException { StringWriter xmlResultResource = new StringWriter(); - Transformer xmlTransformer = TransformerFactory.newInstance() + + Transformer xmlTransformer = TransformerFactory + .newInstance() .newTransformer(new StreamSource(new StringReader(templateData))); - xmlTransformer.transform(new StreamSource(new StringReader(requestData)), - new StreamResult(xmlResultResource)); + + xmlTransformer + .transform(new StreamSource(new StringReader(requestData)), new StreamResult(xmlResultResource)); + return xmlResultResource.getBuffer().toString(); } - } |