diff options
author | 2019-07-16 15:09:21 +0200 | |
---|---|---|
committer | 2019-07-17 09:21:05 +0000 | |
commit | 96e5fc67fd0da6e1a966944d5c6fed1a30931d90 (patch) | |
tree | c09c36ea9c5effe6192739ff4bc373c49319c74a /common-app-api/src/main/java/org/openecomp/sdc/fe | |
parent | 8a894e564dc7577d78273c890396ffb5dbe86bbb (diff) |
fixing warnings from checkstyle in common-app-api
Issue-ID: SDC-2454
Signed-off-by: Bartosz Gardziejewski <bartosz.gardziejewski@nokia.com>
Change-Id: I17c562380e39f3eab6b3bff45a4a12fe8a586cec
Diffstat (limited to 'common-app-api/src/main/java/org/openecomp/sdc/fe')
6 files changed, 204 insertions, 203 deletions
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/fe/config/Configuration.java b/common-app-api/src/main/java/org/openecomp/sdc/fe/config/Configuration.java index 012e96afa2..85417fb611 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/fe/config/Configuration.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/fe/config/Configuration.java @@ -288,9 +288,9 @@ public class Configuration extends BasicConfiguration { public static class FeMonitoringConfig { - Boolean enabled; - Boolean isProxy; - Integer probeIntervalInSeconds; + private Boolean enabled; + private Boolean isProxy; + private Integer probeIntervalInSeconds; public Boolean getEnabled() { return enabled; @@ -322,13 +322,13 @@ public class Configuration extends BasicConfiguration { } public static class OnboardingConfig { - String protocolFe = "http"; - String hostFe; - Integer portFe; - String protocolBe = "http"; - String hostBe; - Integer portBe; - String healthCheckUriFe; + private String protocolFe = "http"; + private String hostFe; + private Integer portFe; + private String protocolBe = "http"; + private String hostBe; + private Integer portBe; + private String healthCheckUriFe; public String getProtocolFe() { return protocolFe; @@ -389,10 +389,10 @@ public class Configuration extends BasicConfiguration { public static class DcaeConfig { - String protocol = "http"; - String host; - Integer port; - String healthCheckUri; + private String protocol = "http"; + private String host; + private Integer port; + private String healthCheckUri; public String getProtocol() { return protocol; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/fe/config/ConfigurationManager.java b/common-app-api/src/main/java/org/openecomp/sdc/fe/config/ConfigurationManager.java index 413c8f825f..9353dd934f 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/fe/config/ConfigurationManager.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/fe/config/ConfigurationManager.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -35,100 +35,100 @@ import java.util.Map; public class ConfigurationManager implements FileChangeCallback, IEcompConfigurationManager { - ConfigurationSource configurationSource = null; - private static ConfigurationManager instance; - private static Logger log = LoggerFactory.getLogger(ConfigurationManager.class.getName()); + private ConfigurationSource configurationSource = null; + private static ConfigurationManager instance; + private static Logger logger = LoggerFactory.getLogger(ConfigurationManager.class.getName()); - public ConfigurationManager(ConfigurationSource configurationSource) { - super(); - this.configurationSource = configurationSource; - loadConfigurationFiles(); - instance = this; - } + public ConfigurationManager(ConfigurationSource configurationSource) { + super(); + this.configurationSource = configurationSource; + loadConfigurationFiles(); + instance = this; + } - Map<String, Object> configurations = new HashMap<>(); + private Map<String, Object> configurations = new HashMap<>(); - private void loadConfigurationFiles() { + private void loadConfigurationFiles() { - loadConfigurationClass(Configuration.class); - loadConfigurationClass(RestConfigurationInfo.class); - loadConfigurationClass(EcompErrorConfiguration.class); - loadConfigurationClass(PluginsConfiguration.class); + loadConfigurationClass(Configuration.class); + loadConfigurationClass(RestConfigurationInfo.class); + loadConfigurationClass(EcompErrorConfiguration.class); + loadConfigurationClass(PluginsConfiguration.class); - } + } - private <T extends BasicConfiguration> void loadConfigurationClass(Class<T> clazz) { - ConfigurationListener configurationListener = new ConfigurationListener(clazz, this); - - log.info("created listener for class {}: {}", clazz.getName(), configurationListener); + private <T extends BasicConfiguration> void loadConfigurationClass(Class<T> clazz) { + ConfigurationListener configurationListener = new ConfigurationListener(clazz, this); - T object = configurationSource.getAndWatchConfiguration(clazz, configurationListener); + logger.info("created listener for class {}: {}", clazz.getName(), configurationListener); - configurations.put(getKey(clazz), object); - } + T object = configurationSource.getAndWatchConfiguration(clazz, configurationListener); - private <T> String getKey(Class<T> class1) { + configurations.put(getKey(clazz), object); + } - return class1.getSimpleName(); + private <T> String getKey(Class<T> class1) { - } + return class1.getSimpleName(); - public Configuration getConfiguration() { + } - return (Configuration) configurations.get(getKey(Configuration.class)); + public Configuration getConfiguration() { - } + return (Configuration) configurations.get(getKey(Configuration.class)); - public RestConfigurationInfo getRestClientConfiguration() { + } - return (RestConfigurationInfo) configurations.get(getKey(RestConfigurationInfo.class)); + public RestConfigurationInfo getRestClientConfiguration() { - } + return (RestConfigurationInfo) configurations.get(getKey(RestConfigurationInfo.class)); - @Override - public EcompErrorConfiguration getEcompErrorConfiguration() { + } - return (EcompErrorConfiguration) configurations.get(getKey(EcompErrorConfiguration.class)); + @Override + public EcompErrorConfiguration getEcompErrorConfiguration() { - } - - public PluginsConfiguration getPluginsConfiguration() { - - log.info("requested plugins configuration and got this:{}", configurations.get(getKey(PluginsConfiguration.class))); - - return (PluginsConfiguration) configurations.get(getKey(PluginsConfiguration.class)); - } + return (EcompErrorConfiguration) configurations.get(getKey(EcompErrorConfiguration.class)); - public Configuration getConfigurationAndWatch(ConfigurationListener configurationListener) { + } - if (configurationListener != null) { + public PluginsConfiguration getPluginsConfiguration() { - configurationSource.addWatchConfiguration(Configuration.class, configurationListener); + logger.info("requested plugins configuration and got this:{}", configurations.get(getKey(PluginsConfiguration.class))); - } - return (Configuration) configurations.get(getKey(Configuration.class)); + return (PluginsConfiguration) configurations.get(getKey(PluginsConfiguration.class)); + } - } + public Configuration getConfigurationAndWatch(ConfigurationListener configurationListener) { - public void reconfigure(BasicConfiguration obj) { - // - // if (obj != null) { - // - // if (obj instanceof Configuration) { - // configurations.put(getKey(Configuration.class), obj); - // } - // - // if (obj instanceof EcompErrorConfiguration) { - // configurations.put(getKey(EcompErrorConfiguration.class), obj); - // } - // } - } + if (configurationListener != null) { - public static ConfigurationManager getConfigurationManager() { - return instance; - } - - public static void setTestInstance(ConfigurationManager configurationManagerInstance) { - instance = configurationManagerInstance; - } + configurationSource.addWatchConfiguration(Configuration.class, configurationListener); + + } + return (Configuration) configurations.get(getKey(Configuration.class)); + + } + + public void reconfigure(BasicConfiguration obj) { + // + // if (obj != null) { + // + // if (obj instanceof Configuration) { + // configurations.put(getKey(Configuration.class), obj); + // } + // + // if (obj instanceof EcompErrorConfiguration) { + // configurations.put(getKey(EcompErrorConfiguration.class), obj); + // } + // } + } + + public static ConfigurationManager getConfigurationManager() { + return instance; + } + + public static void setTestInstance(ConfigurationManager configurationManagerInstance) { + instance = configurationManagerInstance; + } } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/fe/config/Connection.java b/common-app-api/src/main/java/org/openecomp/sdc/fe/config/Connection.java index 7208398525..7d681bdba6 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/fe/config/Connection.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/fe/config/Connection.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,27 +22,27 @@ package org.openecomp.sdc.fe.config; public class Connection { - private String url; - private int poolSize; + private String url; + private int poolSize; - public String getUrl() { - return url; - } + public String getUrl() { + return url; + } - public void setUrl(String url) { - this.url = url; - } + public void setUrl(String url) { + this.url = url; + } - public int getPoolSize() { - return poolSize; - } + public int getPoolSize() { + return poolSize; + } - public void setPoolSize(int poolSize) { - this.poolSize = poolSize; - } + public void setPoolSize(int poolSize) { + this.poolSize = poolSize; + } - @Override - public String toString() { - return String.format("'%s' with pool of %d", getUrl(), getPoolSize()); - } + @Override + public String toString() { + return String.format("'%s' with pool of %d", getUrl(), getPoolSize()); + } } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/fe/config/FeEcompErrorManager.java b/common-app-api/src/main/java/org/openecomp/sdc/fe/config/FeEcompErrorManager.java index a36293b829..13459713ff 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/fe/config/FeEcompErrorManager.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/fe/config/FeEcompErrorManager.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,51 +26,51 @@ import org.openecomp.sdc.common.config.IEcompConfigurationManager; public class FeEcompErrorManager extends AbsEcompErrorManager { - private static volatile FeEcompErrorManager instance; - private static ConfigurationManager configurationManager; + private static volatile FeEcompErrorManager instance; + private static ConfigurationManager configurationManager; - private FeEcompErrorManager() { - }; + private FeEcompErrorManager() { + } - public static FeEcompErrorManager getInstance() { - if (instance == null) { + public static FeEcompErrorManager getInstance() { + if (instance == null) { - instance = init(); - } - return instance; - } + instance = init(); + } + return instance; + } - private static synchronized FeEcompErrorManager init() { - if (instance == null) { - instance = new FeEcompErrorManager(); - configurationManager = ConfigurationManager.getConfigurationManager(); - } - return instance; - } + private static synchronized FeEcompErrorManager init() { + if (instance == null) { + instance = new FeEcompErrorManager(); + configurationManager = ConfigurationManager.getConfigurationManager(); + } + return instance; + } - @Override - public IEcompConfigurationManager getConfigurationManager() { - return configurationManager; - } + @Override + public IEcompConfigurationManager getConfigurationManager() { + return configurationManager; + } - public void logFeHealthCheckRecovery(String context) { - processEcompError(context, EcompErrorEnum.FeHealthCheckRecovery); - } + public void logFeHealthCheckRecovery(String context) { + processEcompError(context, EcompErrorEnum.FeHealthCheckRecovery); + } - public void logFeHealthCheckError(String context) { - processEcompError(context, EcompErrorEnum.FeHealthCheckError); - } + public void logFeHealthCheckError(String context) { + processEcompError(context, EcompErrorEnum.FeHealthCheckError); + } - public void logFeHttpLoggingError(String context) { - processEcompError(context, EcompErrorEnum.FeHttpLoggingError); - } + public void logFeHttpLoggingError(String context) { + processEcompError(context, EcompErrorEnum.FeHttpLoggingError); + } - public void logFePortalServletError(String context) { - processEcompError(context, EcompErrorEnum.FePortalServletError); - } + public void logFePortalServletError(String context) { + processEcompError(context, EcompErrorEnum.FePortalServletError); + } - public void logFeHealthCheckGeneralError(String context) { - processEcompError(context, EcompErrorEnum.FeHealthCheckGeneralError); - } + public void logFeHealthCheckGeneralError(String context) { + processEcompError(context, EcompErrorEnum.FeHealthCheckGeneralError); + } } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/fe/config/PluginsConfiguration.java b/common-app-api/src/main/java/org/openecomp/sdc/fe/config/PluginsConfiguration.java index b891c7f85c..449c9eaccc 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/fe/config/PluginsConfiguration.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/fe/config/PluginsConfiguration.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -134,17 +134,17 @@ public class PluginsConfiguration extends BasicConfiguration { @Override public String toString() { - return "PluginDisplayOptions[" + - "displayName='" + displayName + - ", displayContext=" + displayContext + - ", displayRoles=" + displayRoles + - ']'; + return "PluginDisplayOptions[" + + "displayName='" + displayName + + ", displayContext=" + displayContext + + ", displayRoles=" + displayRoles + + ']'; } } @Override public String toString() { - return "PluginsConfiguration[" + "pluginsList=" + pluginsList + ", connectionTimeout=" + connectionTimeout +']'; + return "PluginsConfiguration[" + "pluginsList=" + pluginsList + ", connectionTimeout=" + connectionTimeout + ']'; } } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/fe/monitoring/FeMonitoringService.java b/common-app-api/src/main/java/org/openecomp/sdc/fe/monitoring/FeMonitoringService.java index 0bb33190f8..1ac10a2611 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/fe/monitoring/FeMonitoringService.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/fe/monitoring/FeMonitoringService.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -46,64 +46,65 @@ import java.util.concurrent.TimeUnit; public class FeMonitoringService { - private static final String URL = "%s://%s:%s/sdc2/rest/monitoring"; - private static Logger monitoringLogger = LoggerFactory.getLogger("asdc.fe.monitoring.service"); - private static Logger log = LoggerFactory.getLogger(FeMonitoringService.class.getName()); - private static Gson gson = new GsonBuilder().setPrettyPrinting().create(); + private static final String URL = "%s://%s:%s/sdc2/rest/monitoring"; + private static final int DEFAULT_TIMEOUT = 3000; + private static Logger monitoringLogger = LoggerFactory.getLogger("asdc.fe.monitoring.service"); + private static Logger log = LoggerFactory.getLogger(FeMonitoringService.class.getName()); + private static Gson gson = new GsonBuilder().setPrettyPrinting().create(); - private class MonitoringScheduledTask implements Runnable { - @Override - public void run() { - monitoringLogger.trace("Executing FE Monitoring Task - Start"); - MonitoringEvent monitoringMetrics = MonitoringMetricsFetcher.getInstance().getMonitoringMetrics(); - processMonitoringEvent(monitoringMetrics); - monitoringLogger.trace("Executing FE Monitoring Task - Status = {}", monitoringMetrics.toString()); - } - } + private class MonitoringScheduledTask implements Runnable { + @Override + public void run() { + monitoringLogger.trace("Executing FE Monitoring Task - Start"); + MonitoringEvent monitoringMetrics = MonitoringMetricsFetcher.getInstance().getMonitoringMetrics(); + processMonitoringEvent(monitoringMetrics); + monitoringLogger.trace("Executing FE Monitoring Task - Status = {}", monitoringMetrics.toString()); + } + } - /** - * This executor will execute the Monitoring task. - */ - ScheduledExecutorService monitoringExecutor = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() { - @Override - public Thread newThread(Runnable r) { - return new Thread(r, "FE-Monitoring-Thread"); - } - }); - private ServletContext context; + /** + * This executor will execute the Monitoring task. + */ + private ScheduledExecutorService monitoringExecutor = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() { + @Override + public Thread newThread(Runnable r) { + return new Thread(r, "FE-Monitoring-Thread"); + } + }); + private ServletContext context; - public FeMonitoringService(ServletContext context) { - this.context = context; - } + public FeMonitoringService(ServletContext context) { + this.context = context; + } - public void start(int interval) { - Configuration config = ((ConfigurationManager) context.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)) - .getConfiguration(); - if (config.getSystemMonitoring().getEnabled()) { - log.info("FE monitoring service enabled, interval is {} seconds", interval); - this.monitoringExecutor.scheduleAtFixedRate(new MonitoringScheduledTask(), 0, interval, TimeUnit.SECONDS); - } else { - log.info("FE monitoring service is disabled"); - } - } + public void start(int interval) { + Configuration config = ((ConfigurationManager) context.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)) + .getConfiguration(); + if (config.getSystemMonitoring().getEnabled()) { + log.info("FE monitoring service enabled, interval is {} seconds", interval); + this.monitoringExecutor.scheduleAtFixedRate(new MonitoringScheduledTask(), 0, interval, TimeUnit.SECONDS); + } else { + log.info("FE monitoring service is disabled"); + } + } - private void processMonitoringEvent(MonitoringEvent monitoringMetrics) { - try { - Configuration config = ((ConfigurationManager) context.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)) - .getConfiguration(); - String redirectedUrl = String.format(URL, config.getBeProtocol(), config.getBeHost(), - Constants.HTTPS.equals(config.getBeProtocol()) ? config.getBeSslPort() : config.getBeHttpPort()); + private void processMonitoringEvent(MonitoringEvent monitoringMetrics) { + try { + Configuration config = ((ConfigurationManager) context.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)) + .getConfiguration(); + String redirectedUrl = String.format(URL, config.getBeProtocol(), config.getBeHost(), + Constants.HTTPS.equals(config.getBeProtocol()) ? config.getBeSslPort() : config.getBeHttpPort()); - int timeout = 3000; - String monitoringMetricsJson = gson.toJson(monitoringMetrics); - HttpEntity myEntity = new StringEntity(monitoringMetricsJson, ContentType.APPLICATION_JSON); - HttpResponse<String> resposne = HttpRequest.post(redirectedUrl, myEntity, new HttpClientConfig(new Timeouts(timeout, timeout))); + int timeout = DEFAULT_TIMEOUT; + String monitoringMetricsJson = gson.toJson(monitoringMetrics); + HttpEntity myEntity = new StringEntity(monitoringMetricsJson, ContentType.APPLICATION_JSON); + HttpResponse<String> resposne = HttpRequest.post(redirectedUrl, myEntity, new HttpClientConfig(new Timeouts(timeout, timeout))); int beResponseStatus = resposne.getStatusCode(); if (beResponseStatus != HttpStatus.SC_OK) { monitoringLogger.error("Unexpected HTTP response from BE : {}", beResponseStatus); } - } catch (Exception e) { - monitoringLogger.error("Monitoring BE failed with exception ", e); - } - } + } catch (Exception e) { + monitoringLogger.error("Monitoring BE failed with exception ", e); + } + } } |