diff --git a/src/main/java/tv/mangrana/config/CommonConfigFileLoader.java b/src/main/java/tv/mangrana/config/CommonConfigFileLoader.java index 0913515..3816df9 100644 --- a/src/main/java/tv/mangrana/config/CommonConfigFileLoader.java +++ b/src/main/java/tv/mangrana/config/CommonConfigFileLoader.java @@ -27,7 +27,6 @@ public abstract class CommonConfigFileLoader
> { private final Class
projectConfigEnumType; private EnumMap
configurationsMap; - public CommonConfigFileLoader(Class
projectConfigEnumType) throws IncorrectWorkingReferencesException { this.projectConfigEnumType = projectConfigEnumType; loadAllConfigFromFile(false); @@ -37,12 +36,8 @@ public abstract class CommonConfigFileLoader
> { } private CommonConfigFileLoader
loadAllConfigFromFile(boolean silently) throws IncorrectWorkingReferencesException { - commonConfigurationsMap = new EnumMap<>(CommonProjectConfiguration.class); - commonConfigurationsMap.putAll( loadFromFile(CommonProjectConfiguration.class, silently) ); - - configurationsMap = new EnumMap<>(projectConfigEnumType); - configurationsMap.putAll( loadFromFile(projectConfigEnumType, silently) ); - + commonConfigurationsMap = loadFromFile(CommonProjectConfiguration.class, silently); + configurationsMap = loadFromFile(projectConfigEnumType, silently); return this; } @@ -56,7 +51,7 @@ public abstract class CommonConfigFileLoader
> { public String getConfig(P key) { return configurationsMap.get(key); } - public String getCommonConfig(CommonProjectConfiguration key) { + public String getConfig(CommonProjectConfiguration key) { return commonConfigurationsMap.get(key); } diff --git a/src/main/java/tv/mangrana/plex/url/PlexCommandLauncher.java b/src/main/java/tv/mangrana/plex/url/PlexCommandLauncher.java index e6b455a..e04cd1b 100644 --- a/src/main/java/tv/mangrana/plex/url/PlexCommandLauncher.java +++ b/src/main/java/tv/mangrana/plex/url/PlexCommandLauncher.java @@ -50,11 +50,11 @@ public class PlexCommandLauncher { HttpUriRequest httpGET = RequestBuilder.get() .setUri(new URI(plexRefreshURL)) .addParameter("path", plexPathToRefresh) - .addParameter("X-Plex-Token", config.getCommonConfig(PLEX_TOKEN)) + .addParameter("X-Plex-Token", config.getConfig(PLEX_TOKEN)) .build(); httpclient.execute(httpGET); @SuppressWarnings("unused") - String urlWithTokenHidden = httpGET.getURI().toString().replaceFirst(config.getCommonConfig(PLEX_TOKEN), "__plex_token__"); + String urlWithTokenHidden = httpGET.getURI().toString().replaceFirst(config.getConfig(PLEX_TOKEN), "__plex_token__"); logger.nLog("Launched URL command: {0}", httpGET.getURI().toString()); } catch (Exception e) { logger.nHLog("Some error has happened using the URL <{0}>", plexRefreshURL); @@ -63,10 +63,10 @@ public class PlexCommandLauncher { } public String getPlexUrlPath2Refresh(String fullDestinationPath) { - Pattern p = Pattern.compile(config.getCommonConfig(SONARR_PATHS_STARTER).concat("(.+/.+ \\(\\d{4}\\))")); + Pattern p = Pattern.compile(config.getConfig(SONARR_PATHS_STARTER).concat("(.+/.+ \\(\\d{4}\\))")); Matcher m = p.matcher(fullDestinationPath); if (m.find()) { - String pathInPlexDockerStart = config.getCommonConfig(PLEX_SERIES_PATHS_STARTER); + String pathInPlexDockerStart = config.getConfig(PLEX_SERIES_PATHS_STARTER); return pathInPlexDockerStart.concat(m.group(1)); } return null; @@ -76,7 +76,7 @@ public class PlexCommandLauncher { try (CloseableHttpClient httpclient = HttpClients.createDefault()) { HttpUriRequest httpGET = RequestBuilder.get() .setUri(new URI(getPlexSectionsURL())) - .addParameter("X-Plex-Token", config.getCommonConfig(PLEX_TOKEN)) + .addParameter("X-Plex-Token", config.getConfig(PLEX_TOKEN)) .build(); try (CloseableHttpResponse httpResponse = httpclient.execute(httpGET)) { final HttpEntity entity = httpResponse.getEntity(); @@ -90,7 +90,7 @@ public class PlexCommandLauncher { } } } - log("launched url command: "+httpGET.getURI().toString().replaceFirst(config.getCommonConfig(PLEX_TOKEN), "__plex_token__")); + log("launched url command: "+httpGET.getURI().toString().replaceFirst(config.getConfig(PLEX_TOKEN), "__plex_token__")); } catch (URISyntaxException | IOException e) { log("could not refresh plex artist because of "+e.getMessage()); e.printStackTrace(); @@ -101,15 +101,15 @@ public class PlexCommandLauncher { private String getPlexRefreshURL(String fullDestinationPath) { String sectionId = sectionResolver.resolveSectionByPath(fullDestinationPath); if (sectionId==null) return null; - String host = config.getCommonConfig(PLEX_HOST); - String uriFormat = config.getCommonConfig(PLEX_SECTION_REFRESH_URI); + String host = config.getConfig(PLEX_HOST); + String uriFormat = config.getConfig(PLEX_SECTION_REFRESH_URI); String uri = uriFormat.replaceFirst("\\{section_id}", sectionId); return HTTPS.getMark() + host + uri; } private String getPlexSectionsURL() { - String host = HTTPS.getMark() + config.getCommonConfig(PLEX_HOST); - String uri = config.getCommonConfig(PLEX_SECTIONS_LIST_URI); + String host = HTTPS.getMark() + config.getConfig(PLEX_HOST); + String uri = config.getConfig(PLEX_SECTIONS_LIST_URI); return host + uri; } diff --git a/src/main/java/tv/mangrana/plex/url/PlexLibrarySectionsResolver.java b/src/main/java/tv/mangrana/plex/url/PlexLibrarySectionsResolver.java index eec59cd..4c68fcb 100644 --- a/src/main/java/tv/mangrana/plex/url/PlexLibrarySectionsResolver.java +++ b/src/main/java/tv/mangrana/plex/url/PlexLibrarySectionsResolver.java @@ -26,7 +26,7 @@ public class PlexLibrarySectionsResolver { } public String resolveSectionByPath(String fullDestinationPath) { - final String plexPathStarter = config.getCommonConfig(PLEX_SERIES_PATHS_STARTER); + final String plexPathStarter = config.getConfig(PLEX_SERIES_PATHS_STARTER); String keyFolder = fullDestinationPath.replaceFirst(plexPathStarter,"").split("/")[1]; Document xmlDocument = commandLauncher.retrieveSectionsInfo(); XPath xPath = XPathFactory.newInstance().newXPath(); diff --git a/src/main/java/tv/mangrana/radarr/api/client/gateway/RadarrApiGateway.java b/src/main/java/tv/mangrana/radarr/api/client/gateway/RadarrApiGateway.java index 483016e..6758e49 100644 --- a/src/main/java/tv/mangrana/radarr/api/client/gateway/RadarrApiGateway.java +++ b/src/main/java/tv/mangrana/radarr/api/client/gateway/RadarrApiGateway.java @@ -16,8 +16,8 @@ public class RadarrApiGateway { private final RadarrAPIInterface proxy; public RadarrApiGateway(CommonConfigFileLoader> config) { - apiKey = config.getCommonConfig(RADARR_API_KEY); - proxy = APIProxyBuilderSingleton.getRadarrInterface(config.getCommonConfig(RADARR_API_HOST)); + apiKey = config.getConfig(RADARR_API_KEY); + proxy = APIProxyBuilderSingleton.getRadarrInterface(config.getConfig(RADARR_API_HOST)); } public QueueResourcePagingResource getQueue() { diff --git a/src/main/java/tv/mangrana/sonarr/api/client/gateway/SonarrApiGateway.java b/src/main/java/tv/mangrana/sonarr/api/client/gateway/SonarrApiGateway.java index b6c693e..807d8b0 100644 --- a/src/main/java/tv/mangrana/sonarr/api/client/gateway/SonarrApiGateway.java +++ b/src/main/java/tv/mangrana/sonarr/api/client/gateway/SonarrApiGateway.java @@ -19,8 +19,8 @@ public class SonarrApiGateway { private final EasyLogger logger; public SonarrApiGateway(CommonConfigFileLoader> config) { - apiKey = config.getCommonConfig(SONARR_API_KEY); - proxy = APIProxyBuilderSingleton.getSonarrInterface(config.getCommonConfig(SONARR_API_HOST)); + apiKey = config.getConfig(SONARR_API_KEY); + proxy = APIProxyBuilderSingleton.getSonarrInterface(config.getConfig(SONARR_API_HOST)); logger = new EasyLogger(); }