@Test public void testGetPropertiesValue_1() { logger.debug("testGetPropertiesValue: enter"); config = new Properties(); config.put("RESOURCE_NAME", "logparser_pap01"); config.put("JDBC_DRIVER", "org.mariadb.jdbc.Driver"); config.put("JDBC_URL", "jdbc:mariadb: config.put("JDBC_USER", "root"); config.put("JDBC_PASSWORD", "password"); config.put("JMX_URL", "service:jmx:rmi: config.put("SERVER", "password"); config.put("JDBC_PASSWORD", "https: config.put("LOGTYPE", "PAP"); config.put("LOGPATH", "C:\\Workspaces\\HealthCheck\\debug\\pap-rest.log"); config.put("PARSERLOGPATH", "IntegrityMonitor.log"); final Properties returnConfig = ParseLog.getPropertiesValue(configFileDebug); logger.debug("testGetPropertiesValue: returnConfig: " + returnConfig); assertEquals(config.get("RESOURCE_NAME"), returnConfig.get("RESOURCE_NAME")); logger.debug("testGetPropertiesValue_1: exit"); }
public static Properties getPropertiesValue(final String fileName) { final Properties config = new Properties(); final Path file = Paths.get(fileName); if (!(file.toFile().exists() && file.toString().endsWith(".properties"))) { logger.debug("File doesn't exist in the specified Path Or it is not a properties file" + file.toString()); return null; } try (InputStream in = new FileInputStream(file.toFile())) { config.load(in); resourceName = config.getProperty("RESOURCE_NAME"); system = config.getProperty("SERVER"); type = config.getProperty("LOGTYPE"); systemLogFile = config.getProperty("PARSERLOGPATH"); final String logFiles = config.getProperty("LOGPATH"); final String cleanupInterval = config.getProperty("CHECK_INTERVAL"); final String timeFrame = config.getProperty("TIME_FRAME"); setCleanUpProperties(cleanupInterval, timeFrame); if (logFiles == null || logFiles.isEmpty()) { isMissingLogFile = true; return null; } final String[] splitString = getPaths(logFiles); setLogFileProperties(splitString); jdbcUrl = config.getProperty("JDBC_URL").replace("'", ""); jdbcUser = getValue(config.getProperty("JDBC_USER")); jdbcDriver = config.getProperty("JDBC_DRIVER"); PeCryptoUtils.initAesKey(config.getProperty(PROP_AES_KEY)); jdbcPassword = PeCryptoUtils.decrypt(getValue(config.getProperty("JDBC_PASSWORD"))); config.setProperty("javax.persistence.jdbc.password", jdbcPassword); return config; } catch (final IOException e) { logger.error("Error porcessing Config file will be unable to create Health Check" + e); } catch (final Exception e) { logger.error("Error getPropertiesValue on TIME_FRAME", e); logger.debug("Error getPropertiesValue on TIME_FRAME, so use its default value:" + defaultTimeFrame + " days"); } return null; }
ParseLog { public static Properties getPropertiesValue(final String fileName) { final Properties config = new Properties(); final Path file = Paths.get(fileName); if (!(file.toFile().exists() && file.toString().endsWith(".properties"))) { logger.debug("File doesn't exist in the specified Path Or it is not a properties file" + file.toString()); return null; } try (InputStream in = new FileInputStream(file.toFile())) { config.load(in); resourceName = config.getProperty("RESOURCE_NAME"); system = config.getProperty("SERVER"); type = config.getProperty("LOGTYPE"); systemLogFile = config.getProperty("PARSERLOGPATH"); final String logFiles = config.getProperty("LOGPATH"); final String cleanupInterval = config.getProperty("CHECK_INTERVAL"); final String timeFrame = config.getProperty("TIME_FRAME"); setCleanUpProperties(cleanupInterval, timeFrame); if (logFiles == null || logFiles.isEmpty()) { isMissingLogFile = true; return null; } final String[] splitString = getPaths(logFiles); setLogFileProperties(splitString); jdbcUrl = config.getProperty("JDBC_URL").replace("'", ""); jdbcUser = getValue(config.getProperty("JDBC_USER")); jdbcDriver = config.getProperty("JDBC_DRIVER"); PeCryptoUtils.initAesKey(config.getProperty(PROP_AES_KEY)); jdbcPassword = PeCryptoUtils.decrypt(getValue(config.getProperty("JDBC_PASSWORD"))); config.setProperty("javax.persistence.jdbc.password", jdbcPassword); return config; } catch (final IOException e) { logger.error("Error porcessing Config file will be unable to create Health Check" + e); } catch (final Exception e) { logger.error("Error getPropertiesValue on TIME_FRAME", e); logger.debug("Error getPropertiesValue on TIME_FRAME, so use its default value:" + defaultTimeFrame + " days"); } return null; } }
ParseLog { public static Properties getPropertiesValue(final String fileName) { final Properties config = new Properties(); final Path file = Paths.get(fileName); if (!(file.toFile().exists() && file.toString().endsWith(".properties"))) { logger.debug("File doesn't exist in the specified Path Or it is not a properties file" + file.toString()); return null; } try (InputStream in = new FileInputStream(file.toFile())) { config.load(in); resourceName = config.getProperty("RESOURCE_NAME"); system = config.getProperty("SERVER"); type = config.getProperty("LOGTYPE"); systemLogFile = config.getProperty("PARSERLOGPATH"); final String logFiles = config.getProperty("LOGPATH"); final String cleanupInterval = config.getProperty("CHECK_INTERVAL"); final String timeFrame = config.getProperty("TIME_FRAME"); setCleanUpProperties(cleanupInterval, timeFrame); if (logFiles == null || logFiles.isEmpty()) { isMissingLogFile = true; return null; } final String[] splitString = getPaths(logFiles); setLogFileProperties(splitString); jdbcUrl = config.getProperty("JDBC_URL").replace("'", ""); jdbcUser = getValue(config.getProperty("JDBC_USER")); jdbcDriver = config.getProperty("JDBC_DRIVER"); PeCryptoUtils.initAesKey(config.getProperty(PROP_AES_KEY)); jdbcPassword = PeCryptoUtils.decrypt(getValue(config.getProperty("JDBC_PASSWORD"))); config.setProperty("javax.persistence.jdbc.password", jdbcPassword); return config; } catch (final IOException e) { logger.error("Error porcessing Config file will be unable to create Health Check" + e); } catch (final Exception e) { logger.error("Error getPropertiesValue on TIME_FRAME", e); logger.debug("Error getPropertiesValue on TIME_FRAME, so use its default value:" + defaultTimeFrame + " days"); } return null; }  }
ParseLog { public static Properties getPropertiesValue(final String fileName) { final Properties config = new Properties(); final Path file = Paths.get(fileName); if (!(file.toFile().exists() && file.toString().endsWith(".properties"))) { logger.debug("File doesn't exist in the specified Path Or it is not a properties file" + file.toString()); return null; } try (InputStream in = new FileInputStream(file.toFile())) { config.load(in); resourceName = config.getProperty("RESOURCE_NAME"); system = config.getProperty("SERVER"); type = config.getProperty("LOGTYPE"); systemLogFile = config.getProperty("PARSERLOGPATH"); final String logFiles = config.getProperty("LOGPATH"); final String cleanupInterval = config.getProperty("CHECK_INTERVAL"); final String timeFrame = config.getProperty("TIME_FRAME"); setCleanUpProperties(cleanupInterval, timeFrame); if (logFiles == null || logFiles.isEmpty()) { isMissingLogFile = true; return null; } final String[] splitString = getPaths(logFiles); setLogFileProperties(splitString); jdbcUrl = config.getProperty("JDBC_URL").replace("'", ""); jdbcUser = getValue(config.getProperty("JDBC_USER")); jdbcDriver = config.getProperty("JDBC_DRIVER"); PeCryptoUtils.initAesKey(config.getProperty(PROP_AES_KEY)); jdbcPassword = PeCryptoUtils.decrypt(getValue(config.getProperty("JDBC_PASSWORD"))); config.setProperty("javax.persistence.jdbc.password", jdbcPassword); return config; } catch (final IOException e) { logger.error("Error porcessing Config file will be unable to create Health Check" + e); } catch (final Exception e) { logger.error("Error getPropertiesValue on TIME_FRAME", e); logger.debug("Error getPropertiesValue on TIME_FRAME, so use its default value:" + defaultTimeFrame + " days"); } return null; }  static void main(final String[] args); static int countLines(final String filename); static String pullLastLineRead(final File file, final String dataFileName); static LogEntryObject pullOutLogValues(final String line, final String type); static void process(final String line, final String type, final LogType logFile); static Date parseDate(final String dateline, final String pattern, final boolean singleSplit); static String parseRemoteSystem(final String line); static String[] getPaths(final String logPath); static Properties getPropertiesValue(final String fileName); static Connection getDbConnection(); }
ParseLog { public static Properties getPropertiesValue(final String fileName) { final Properties config = new Properties(); final Path file = Paths.get(fileName); if (!(file.toFile().exists() && file.toString().endsWith(".properties"))) { logger.debug("File doesn't exist in the specified Path Or it is not a properties file" + file.toString()); return null; } try (InputStream in = new FileInputStream(file.toFile())) { config.load(in); resourceName = config.getProperty("RESOURCE_NAME"); system = config.getProperty("SERVER"); type = config.getProperty("LOGTYPE"); systemLogFile = config.getProperty("PARSERLOGPATH"); final String logFiles = config.getProperty("LOGPATH"); final String cleanupInterval = config.getProperty("CHECK_INTERVAL"); final String timeFrame = config.getProperty("TIME_FRAME"); setCleanUpProperties(cleanupInterval, timeFrame); if (logFiles == null || logFiles.isEmpty()) { isMissingLogFile = true; return null; } final String[] splitString = getPaths(logFiles); setLogFileProperties(splitString); jdbcUrl = config.getProperty("JDBC_URL").replace("'", ""); jdbcUser = getValue(config.getProperty("JDBC_USER")); jdbcDriver = config.getProperty("JDBC_DRIVER"); PeCryptoUtils.initAesKey(config.getProperty(PROP_AES_KEY)); jdbcPassword = PeCryptoUtils.decrypt(getValue(config.getProperty("JDBC_PASSWORD"))); config.setProperty("javax.persistence.jdbc.password", jdbcPassword); return config; } catch (final IOException e) { logger.error("Error porcessing Config file will be unable to create Health Check" + e); } catch (final Exception e) { logger.error("Error getPropertiesValue on TIME_FRAME", e); logger.debug("Error getPropertiesValue on TIME_FRAME, so use its default value:" + defaultTimeFrame + " days"); } return null; }  static void main(final String[] args); static int countLines(final String filename); static String pullLastLineRead(final File file, final String dataFileName); static LogEntryObject pullOutLogValues(final String line, final String type); static void process(final String line, final String type, final LogType logFile); static Date parseDate(final String dateline, final String pattern, final boolean singleSplit); static String parseRemoteSystem(final String line); static String[] getPaths(final String logPath); static Properties getPropertiesValue(final String fileName); static Connection getDbConnection();  }