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;
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 {
private static final EELFLogger log =
- EELFManager.getInstance().getLogger(ConfigGeneratorActivator.class);
+ EELFManager.getInstance().getLogger(ConfigGeneratorActivator.class);
@Override
public void start(BundleContext ctx) throws Exception {
package org.onap.sdnc.config.generator.convert;
-public class InvalidParameterException extends Exception{
+public class InvalidParameterException extends Exception {
public InvalidParameterException(String message) {
super(message);
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;
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 {
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 {
}
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());
}
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;
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 {
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 {
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());
}
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";
import org.slf4j.LoggerFactory;
public class DbServiceUtil {
+
private static final Logger log = LoggerFactory.getLogger(DbServiceUtil.class);
private static Properties props;
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;
}
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;
}
-
}
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;
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);
}
}
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;
}
}
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;
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;
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 {
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");
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();
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
}
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;
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 {
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)) {
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();
}