diff options
Diffstat (limited to 'appc-config/appc-config-generator/provider/src/main')
9 files changed, 69 insertions, 66 deletions
diff --git a/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/ConfigGeneratorActivator.java b/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/ConfigGeneratorActivator.java index 48858c013..957f324d3 100644 --- a/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/ConfigGeneratorActivator.java +++ b/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/ConfigGeneratorActivator.java @@ -24,6 +24,8 @@ package org.onap.sdnc.config.generator; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import java.util.LinkedList; import java.util.List; import org.onap.sdnc.config.generator.convert.ConvertNode; @@ -34,8 +36,6 @@ import org.onap.sdnc.config.generator.writer.FileWriterNode; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; public class ConfigGeneratorActivator implements BundleActivator { @@ -43,7 +43,7 @@ public class ConfigGeneratorActivator implements BundleActivator { private static final EELFLogger log = - EELFManager.getInstance().getLogger(ConfigGeneratorActivator.class); + EELFManager.getInstance().getLogger(ConfigGeneratorActivator.class); @Override public void start(BundleContext ctx) throws Exception { diff --git a/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/convert/InvalidParameterException.java b/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/convert/InvalidParameterException.java index 7ac67b041..985b7101c 100644 --- a/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/convert/InvalidParameterException.java +++ b/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/convert/InvalidParameterException.java @@ -1,6 +1,6 @@ package org.onap.sdnc.config.generator.convert; -public class InvalidParameterException extends Exception{ +public class InvalidParameterException extends Exception { public InvalidParameterException(String message) { super(message); diff --git a/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/pattern/PatternNode.java b/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/pattern/PatternNode.java index 4333cfd90..4d4ba6bd6 100644 --- a/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/pattern/PatternNode.java +++ b/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/pattern/PatternNode.java @@ -24,6 +24,8 @@ package org.onap.sdnc.config.generator.pattern; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import java.util.Map; import org.apache.commons.lang3.StringUtils; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; @@ -32,15 +34,13 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; import org.onap.sdnc.config.generator.ConfigGeneratorConstant; import org.onap.sdnc.config.generator.tool.CheckDataTool; import org.onap.sdnc.config.generator.tool.LogParserTool; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; public class PatternNode implements SvcLogicJavaPlugin { private static final EELFLogger log = EELFManager.getInstance().getLogger(PatternNode.class); public void parseErrorLog(Map<String, String> inParams, SvcLogicContext ctx) - throws SvcLogicException { + throws SvcLogicException { log.info("Received parseErroLog call with params : " + inParams); String responsePrefix = inParams.get(ConfigGeneratorConstant.INPUT_PARAM_RESPONSE_PRIFIX); try { @@ -52,21 +52,21 @@ public class PatternNode implements SvcLogicJavaPlugin { LogParserTool logParserTool = new LogParserTool(); String parsedError = logParserTool.parseErrorLog(logData); ctx.setAttribute(responsePrefix + ConfigGeneratorConstant.OUTPUT_PARAM_PARSED_ERROR, - parsedError); + parsedError); ctx.setAttribute(responsePrefix + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS, - ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS); + ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS); } catch (Exception e) { ctx.setAttribute(responsePrefix + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS, - ConfigGeneratorConstant.OUTPUT_STATUS_FAILURE); + ConfigGeneratorConstant.OUTPUT_STATUS_FAILURE); ctx.setAttribute(responsePrefix + ConfigGeneratorConstant.OUTPUT_PARAM_ERROR_MESSAGE, - e.getMessage()); + e.getMessage()); log.error("Failed in parsing error log " + e.getMessage()); throw new SvcLogicException(e.getMessage()); } } public void checkDataType(Map<String, String> inParams, SvcLogicContext ctx) - throws SvcLogicException { + throws SvcLogicException { log.info("Received checkDataType call with params : " + inParams); String responsePrefix = inParams.get(ConfigGeneratorConstant.INPUT_PARAM_RESPONSE_PRIFIX); try { @@ -77,14 +77,14 @@ public class PatternNode implements SvcLogicJavaPlugin { } String dataType = CheckDataTool.checkData(checkData); ctx.setAttribute(responsePrefix + ConfigGeneratorConstant.OUTPUT_PARAM_DATA_TYPE, - dataType); + dataType); ctx.setAttribute(responsePrefix + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS, - ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS); + ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS); } catch (Exception e) { ctx.setAttribute(responsePrefix + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS, - ConfigGeneratorConstant.OUTPUT_STATUS_FAILURE); + ConfigGeneratorConstant.OUTPUT_STATUS_FAILURE); ctx.setAttribute(responsePrefix + ConfigGeneratorConstant.OUTPUT_PARAM_ERROR_MESSAGE, - e.getMessage()); + e.getMessage()); log.error("Failed in checkDataType " + e.getMessage()); throw new SvcLogicException(e.getMessage()); } diff --git a/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/reader/ReaderNode.java b/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/reader/ReaderNode.java index 501df635e..c657ee531 100644 --- a/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/reader/ReaderNode.java +++ b/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/reader/ReaderNode.java @@ -24,6 +24,8 @@ package org.onap.sdnc.config.generator.reader; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import java.io.File; import java.util.Map; import org.apache.commons.io.FileUtils; @@ -33,8 +35,6 @@ 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.MergeNode; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; public class ReaderNode implements SvcLogicJavaPlugin { @@ -42,7 +42,7 @@ public class ReaderNode implements SvcLogicJavaPlugin { public void getFileData(Map<String, String> inParams, SvcLogicContext ctx) - throws SvcLogicException { + throws SvcLogicException { log.info("Received getFileData call with params : " + inParams); String responsePrefix = inParams.get(ConfigGeneratorConstant.INPUT_PARAM_RESPONSE_PRIFIX); try { @@ -50,17 +50,17 @@ public class ReaderNode implements SvcLogicJavaPlugin { String fileName = inParams.get(ConfigGeneratorConstant.INPUT_PARAM_FILE_NAME); String fileData = FileUtils.readFileToString(new File(fileName), - ConfigGeneratorConstant.STRING_ENCODING); + ConfigGeneratorConstant.STRING_ENCODING); ctx.setAttribute(responsePrefix + ConfigGeneratorConstant.OUTPUT_PARAM_FILE_DATA, - fileData); + fileData); ctx.setAttribute(responsePrefix + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS, - ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS); + ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS); } catch (Exception e) { ctx.setAttribute(responsePrefix + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS, - ConfigGeneratorConstant.OUTPUT_STATUS_FAILURE); + ConfigGeneratorConstant.OUTPUT_STATUS_FAILURE); ctx.setAttribute(responsePrefix + ConfigGeneratorConstant.OUTPUT_PARAM_ERROR_MESSAGE, - e.getMessage()); + e.getMessage()); log.error("Failed in merging data to template " + e.getMessage()); throw new SvcLogicException(e.getMessage()); } diff --git a/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/tool/Constants.java b/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/tool/Constants.java index 322e1a6c5..00fda9fb7 100644 --- a/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/tool/Constants.java +++ b/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/tool/Constants.java @@ -27,7 +27,7 @@ package org.onap.sdnc.config.generator.tool; public class Constants { public static final String DBLIB_SERVICE = - "org.onap.ccsdk.sli.core.dblib.DBResourceManager"; + "org.onap.ccsdk.sli.core.dblib.DBResourceManager"; public static final String DEVICE_AUTHENTICATION = "DEVICE_AUTHENTICATION"; public static final String SCHEMA_SDNCTL = "SDNCTL"; diff --git a/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/tool/DbServiceUtil.java b/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/tool/DbServiceUtil.java index a39f0d2e4..c98429c02 100644 --- a/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/tool/DbServiceUtil.java +++ b/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/tool/DbServiceUtil.java @@ -35,6 +35,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class DbServiceUtil { + private static final Logger log = LoggerFactory.getLogger(DbServiceUtil.class); private static Properties props; @@ -42,19 +43,19 @@ public class DbServiceUtil { public static boolean updateDB(String tableName, ArrayList inputArgs, String scema, - String whereClause, String setCluase) throws SQLException { + String whereClause, String setCluase) throws SQLException { String updatePasswordString = - "update " + tableName + " set " + setCluase + " where " + whereClause; + "update " + tableName + " set " + setCluase + " where " + whereClause; boolean result = - jdbcDataSource.writeData(updatePasswordString, inputArgs, Constants.SCHEMA_SDNCTL); + jdbcDataSource.writeData(updatePasswordString, inputArgs, Constants.SCHEMA_SDNCTL); return result; } public static CachedRowSet getData(String tableName, ArrayList argList, String schema, - String getselectData, String getDataClasue) throws SQLException { + String getselectData, String getDataClasue) throws SQLException { String selectQuery = - "select " + getselectData + "from " + tableName + " where " + getDataClasue; + "select " + getselectData + "from " + tableName + " where " + getDataClasue; CachedRowSet data = jdbcDataSource.getData(selectQuery, argList, schema); return data; } @@ -66,7 +67,7 @@ public class DbServiceUtil { URL propURL = file.toURI().toURL(); props.load(propURL.openStream()); - // this is an expected difference in CCSDK + // this is an expected difference in CCSDK jdbcDataSource = new DBResourceManager(props); return jdbcDataSource; @@ -74,5 +75,4 @@ public class DbServiceUtil { } - } diff --git a/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/tool/LogParserTool.java b/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/tool/LogParserTool.java index 0c228b8eb..ebd58b01c 100644 --- a/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/tool/LogParserTool.java +++ b/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/tool/LogParserTool.java @@ -24,19 +24,21 @@ package org.onap.sdnc.config.generator.tool; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; public class LogParserTool { + private static final EELFLogger log = EELFManager.getInstance().getLogger(JSONTool.class); private String[] singleLines; - private List<String> recentErrors = new ArrayList<String>();; + private List<String> recentErrors = new ArrayList<String>(); + ; private Date todaysDate = new Date(); private SimpleDateFormat dFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); private final int minMilli = 60000; @@ -62,7 +64,7 @@ public class LogParserTool { String error = recentErrors.get(0); recentErrors.clear(); return "Error: " - + error.substring(error.indexOf("Error parsing orchestration file:") + 34); + + error.substring(error.indexOf("Error parsing orchestration file:") + 34); } } @@ -70,11 +72,11 @@ public class LogParserTool { int result; for (int i = singleLines.length - 1; i >= 0; i--) { if (singleLines[i].contains("Starting orchestration of file backed up to") - || singleLines[i].contains("Error parsing orchestration file:")) { + || singleLines[i].contains("Error parsing orchestration file:")) { result = checkDateTime(singleLines[i]); - if (result == IN_TIME) + if (result == IN_TIME) { recentErrors.add(singleLines[i]); - else if (result == NOT_IN_TIME) { + } else if (result == NOT_IN_TIME) { return; } } @@ -87,8 +89,9 @@ public class LogParserTool { newDate = dFormat.parse(line.substring(0, 19)); if ((todaysDate.getTime() - newDate.getTime()) <= 5 * minMilli) { return IN_TIME; - } else + } else { return NOT_IN_TIME; + } } catch (ParseException e) { e.printStackTrace(); return NO_DATE; diff --git a/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/tool/MergeTool.java b/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/tool/MergeTool.java index a7f0b9d32..1126c2adb 100644 --- a/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/tool/MergeTool.java +++ b/appc-config/appc-config-generator/provider/src/main/java/org/onap/sdnc/config/generator/tool/MergeTool.java @@ -24,6 +24,12 @@ package org.onap.sdnc.config.generator.tool; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; import java.io.IOException; import java.io.StringWriter; import java.util.Iterator; @@ -37,12 +43,6 @@ import org.apache.velocity.runtime.RuntimeConstants; import org.apache.velocity.runtime.resource.loader.StringResourceLoader; import org.apache.velocity.runtime.resource.util.StringResourceRepository; import org.onap.sdnc.config.generator.ConfigGeneratorConstant; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; public class MergeTool { @@ -59,7 +59,7 @@ public class MergeTool { ve.init(); StringResourceRepository repo = (StringResourceRepository) ve - .getApplicationAttribute(StringResourceLoader.REPOSITORY_NAME_DEFAULT); + .getApplicationAttribute(StringResourceLoader.REPOSITORY_NAME_DEFAULT); repo.putStringResource("TemplateResource", template); Template t = ve.getTemplate("TemplateResource"); @@ -75,8 +75,8 @@ public class MergeTool { public static String mergeJson2TemplateData(String template, String jsonData, - String templateType, String doPrettyOutput) - throws JsonParseException, JsonMappingException, IOException { + String templateType, String doPrettyOutput) + throws JsonParseException, JsonMappingException, IOException { String mergedData = template; if (StringUtils.isNotBlank(template) && StringUtils.isNotBlank(jsonData)) { Velocity.init(); @@ -100,10 +100,10 @@ public class MergeTool { mergedData = writer.toString(); if (StringUtils.isNotBlank(templateType) && StringUtils.isNotBlank(doPrettyOutput) - && ConfigGeneratorConstant.Y.equalsIgnoreCase(doPrettyOutput) - && (ConfigGeneratorConstant.DATA_TYPE_JSON.equalsIgnoreCase(templateType) - || ConfigGeneratorConstant.DATA_TYPE_XML - .equalsIgnoreCase(templateType))) { + && ConfigGeneratorConstant.Y.equalsIgnoreCase(doPrettyOutput) + && (ConfigGeneratorConstant.DATA_TYPE_JSON.equalsIgnoreCase(templateType) + || ConfigGeneratorConstant.DATA_TYPE_XML + .equalsIgnoreCase(templateType))) { // Perform Prettying } 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 2aacc587e..5ce7a69b0 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 @@ -24,6 +24,8 @@ package org.onap.sdnc.config.generator.transform; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import java.io.File; import java.io.StringReader; import java.io.StringWriter; @@ -41,17 +43,15 @@ 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 com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; public class XSLTTransformerNode implements SvcLogicJavaPlugin { private static final EELFLogger log = - EELFManager.getInstance().getLogger(XSLTTransformerNode.class); + EELFManager.getInstance().getLogger(XSLTTransformerNode.class); public void transformData(Map<String, String> inParams, SvcLogicContext ctx) - throws SvcLogicException { + throws SvcLogicException { log.trace("Received convertJson2DGContext call with params : " + inParams); String responsePrefix = inParams.get(ConfigGeneratorConstant.INPUT_PARAM_RESPONSE_PRIFIX); try { @@ -61,10 +61,10 @@ public class XSLTTransformerNode implements SvcLogicJavaPlugin { if (StringUtils.isNotBlank(templateData)) { String templateFile = - inParams.get(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_FILE); + inParams.get(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_FILE); if (StringUtils.isNotBlank(templateFile)) { templateData = FileUtils.readFileToString(new File(templateFile), - Charset.defaultCharset()); + Charset.defaultCharset()); } } if (StringUtils.isBlank(templateData)) { @@ -79,27 +79,27 @@ public class XSLTTransformerNode implements SvcLogicJavaPlugin { String transformedData = transform(requestData, templateData); log.trace("Transformed Data : " + transformedData); ctx.setAttribute(responsePrefix + ConfigGeneratorConstant.OUTPUT_PARAM_TRANSFORMED_DATA, - transformedData); + transformedData); ctx.setAttribute(responsePrefix + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS, - ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS); + ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS); } catch (Exception e) { e.printStackTrace(); ctx.setAttribute(responsePrefix + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS, - ConfigGeneratorConstant.OUTPUT_STATUS_FAILURE); + ConfigGeneratorConstant.OUTPUT_STATUS_FAILURE); ctx.setAttribute(responsePrefix + ConfigGeneratorConstant.OUTPUT_PARAM_ERROR_MESSAGE, - e.getMessage()); + e.getMessage()); log.error("Failed in XSLTTransformerNode : " + e.getMessage()); throw new SvcLogicException(e.getMessage()); } } public String transform(String requestData, String templateData) - throws TransformerConfigurationException, TransformerException { + throws TransformerConfigurationException, TransformerException { StringWriter xmlResultResource = new StringWriter(); Transformer xmlTransformer = TransformerFactory.newInstance() - .newTransformer(new StreamSource(new StringReader(templateData))); + .newTransformer(new StreamSource(new StringReader(templateData))); xmlTransformer.transform(new StreamSource(new StringReader(requestData)), - new StreamResult(xmlResultResource)); + new StreamResult(xmlResultResource)); return xmlResultResource.getBuffer().toString(); } |