package org.kurento.demo;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.Paths;

import org.kurento.commons.ConfigFileFinder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.stream.JsonReader;

public class ConfigurationReader {

	private static final Logger log = LoggerFactory.getLogger(ConfigurationReader.class);
	private static final Gson gson = new GsonBuilder().create();

	private JsonObject configFile;

	public ConfigurationReader(String configFileName) throws IOException {

		String configFile = ConfigFileFinder.getPathInClasspath(configFileName).toString();

		Path configFilePath = Paths.get(configFile);

		if (configFilePath == null) {
			log.debug("File not found {}", configFileName);
		}

		try (JsonReader reader = new JsonReader(Files.newBufferedReader(configFilePath, StandardCharsets.UTF_8))) {
			reader.setLenient(true);
			this.configFile = gson.fromJson(reader, JsonObject.class);

		} catch (NoSuchFileException e) {
			log.warn("Configuration file {} not found", configFilePath);
		} catch (IOException e) {
			log.error("Error opening config file {}", configFilePath, e);
		} catch (JsonParseException e) {
			log.error("Error parsing configuration file {}", configFilePath, e);
		}
	}

	public JsonObject getConfig() {
		return this.configFile;
	}
}

@@ -244,31 +244,24 @@
 ommons.C
-onfigFileFinder
+lassPath
 ;%0Aimport
@@ -582,16 +582,20 @@
 rFactory
+%0A%09%09%09
 .getLogg
@@ -820,43 +820,21 @@
 e = 
-ConfigFileFinder.getPathIn
 Class
-p
+P
 ath
+.get
 (con
@@ -995,16 +995,16 @@
 );%0A%09%09%7D%0A%0A
-
 %09%09try (J
@@ -1042,16 +1042,21 @@
 er(Files
+%0A%09%09%09%09
 .newBuff

Refactor to use ClassPath.get()