Omaha #5264 - replace status handler with slf4j logging.
Former-commit-id: 36962f444f55b414bd8aaa0f114b00104129d303
This commit is contained in:
parent
3d2ee72702
commit
16b57022bc
2 changed files with 33 additions and 36 deletions
|
@ -7,7 +7,7 @@ Bundle-Vendor: RAYTHEON
|
||||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||||
Require-Bundle: com.raytheon.uf.common.localization,
|
Require-Bundle: com.raytheon.uf.common.localization,
|
||||||
javax.persistence,
|
javax.persistence,
|
||||||
com.raytheon.uf.common.status;bundle-version="1.15.0"
|
org.slf4j;bundle-version="1.7.12"
|
||||||
Export-Package: com.raytheon.uf.common.ohd
|
Export-Package: com.raytheon.uf.common.ohd
|
||||||
Import-Package: com.raytheon.uf.common.localization,
|
Import-Package: com.raytheon.uf.common.localization,
|
||||||
com.raytheon.uf.common.util
|
com.raytheon.uf.common.util
|
||||||
|
|
|
@ -30,15 +30,15 @@ import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.raytheon.uf.common.localization.ILocalizationPathObserver;
|
import com.raytheon.uf.common.localization.ILocalizationPathObserver;
|
||||||
import com.raytheon.uf.common.localization.IPathManager;
|
import com.raytheon.uf.common.localization.IPathManager;
|
||||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||||
import com.raytheon.uf.common.localization.ILocalizationFile;
|
import com.raytheon.uf.common.localization.ILocalizationFile;
|
||||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
|
||||||
import com.raytheon.uf.common.status.UFStatus;
|
|
||||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
|
||||||
import com.raytheon.uf.common.util.FileUtil;
|
import com.raytheon.uf.common.util.FileUtil;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -69,6 +69,7 @@ import com.raytheon.uf.common.util.FileUtil;
|
||||||
* Sep 22, 2014 3356 njensen Fix constructor usage in viz finding VizApp class
|
* Sep 22, 2014 3356 njensen Fix constructor usage in viz finding VizApp class
|
||||||
* Jan 26, 2016 5264 bkowal Added validation of certain directories. Fixed
|
* Jan 26, 2016 5264 bkowal Added validation of certain directories. Fixed
|
||||||
* warnings.
|
* warnings.
|
||||||
|
* Feb 01, 2016 5264 bkowal Replace status handler with slf4j logging.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -76,8 +77,7 @@ import com.raytheon.uf.common.util.FileUtil;
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
public class AppsDefaults {
|
public class AppsDefaults {
|
||||||
private final IUFStatusHandler statusHandler = UFStatus
|
private final Logger logger = LoggerFactory.getLogger(getClass());
|
||||||
.getHandler(getClass());
|
|
||||||
|
|
||||||
private static final String Apps_defaults_FILENAME = Paths.get("hydro",
|
private static final String Apps_defaults_FILENAME = Paths.get("hydro",
|
||||||
"Apps_defaults").toString();
|
"Apps_defaults").toString();
|
||||||
|
@ -154,8 +154,8 @@ public class AppsDefaults {
|
||||||
_envProperties.put("apps_dir",
|
_envProperties.put("apps_dir",
|
||||||
FileUtil.join(shareDir, "hydroapps"));
|
FileUtil.join(shareDir, "hydroapps"));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
statusHandler
|
logger.error(
|
||||||
.error("Failed to determine the location of the hydroapps share directory.",
|
"Failed to determine the location of the hydroapps share directory.",
|
||||||
e);
|
e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,21 +171,21 @@ public class AppsDefaults {
|
||||||
Set<String> tokenSet = new HashSet<String>();
|
Set<String> tokenSet = new HashSet<String>();
|
||||||
userMap = new HashMap<>();
|
userMap = new HashMap<>();
|
||||||
if (_appsDefaultsUserFile.exists()) {
|
if (_appsDefaultsUserFile.exists()) {
|
||||||
statusHandler.info("USER file exists, updating map...");
|
logger.info("USER file exists, updating map...");
|
||||||
update(userMap, _appsDefaultsUserFile);
|
update(userMap, _appsDefaultsUserFile);
|
||||||
tokenSet.addAll(userMap.keySet());
|
tokenSet.addAll(userMap.keySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
siteMap = new HashMap<>();
|
siteMap = new HashMap<>();
|
||||||
if (_appsDefaultsSiteFile.exists()) {
|
if (_appsDefaultsSiteFile.exists()) {
|
||||||
statusHandler.info("SITE file exists, updating map...");
|
logger.info("SITE file exists, updating map...");
|
||||||
update(siteMap, _appsDefaultsSiteFile);
|
update(siteMap, _appsDefaultsSiteFile);
|
||||||
tokenSet.addAll(siteMap.keySet());
|
tokenSet.addAll(siteMap.keySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
baseMap = new HashMap<>();
|
baseMap = new HashMap<>();
|
||||||
if (_appsDefaultsNationalFile.exists()) {
|
if (_appsDefaultsNationalFile.exists()) {
|
||||||
statusHandler.info("BASE file exists, updating map...");
|
logger.info("BASE file exists, updating map...");
|
||||||
update(baseMap, _appsDefaultsNationalFile);
|
update(baseMap, _appsDefaultsNationalFile);
|
||||||
tokenSet.addAll(baseMap.keySet());
|
tokenSet.addAll(baseMap.keySet());
|
||||||
}
|
}
|
||||||
|
@ -206,8 +206,8 @@ public class AppsDefaults {
|
||||||
|
|
||||||
private void checkAppsDefaults(Map<String, String> propertiesMap,
|
private void checkAppsDefaults(Map<String, String> propertiesMap,
|
||||||
String containingFile) {
|
String containingFile) {
|
||||||
statusHandler.info("Validating Apps Defaults properties in: "
|
logger.info("Validating Apps Defaults properties in: " + containingFile
|
||||||
+ containingFile + " ...");
|
+ " ...");
|
||||||
for (String key : AppsDefaultsDirKeys.DIR_KEYS_TO_VALIDATE) {
|
for (String key : AppsDefaultsDirKeys.DIR_KEYS_TO_VALIDATE) {
|
||||||
String valueToValidate = propertiesMap.get(key);
|
String valueToValidate = propertiesMap.get(key);
|
||||||
if (valueToValidate == null) {
|
if (valueToValidate == null) {
|
||||||
|
@ -231,10 +231,9 @@ public class AppsDefaults {
|
||||||
.append(". Property has been ignored. Valid values must map to a location within one of the specified directories: ")
|
.append(". Property has been ignored. Valid values must map to a location within one of the specified directories: ")
|
||||||
.append(AppsDefaultsDirKeys.getValidRootsAsString())
|
.append(AppsDefaultsDirKeys.getValidRootsAsString())
|
||||||
.append(".");
|
.append(".");
|
||||||
statusHandler.error(sb.toString());
|
logger.error(sb.toString());
|
||||||
}
|
}
|
||||||
statusHandler
|
logger.info("Finished validation of Apps Defaults properties in: "
|
||||||
.info("Finished validation of Apps Defaults properties in: "
|
|
||||||
+ containingFile + ".");
|
+ containingFile + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,38 +247,37 @@ public class AppsDefaults {
|
||||||
LocalizationType.COMMON_STATIC, LocalizationLevel.USER),
|
LocalizationType.COMMON_STATIC, LocalizationLevel.USER),
|
||||||
Apps_defaults_FILENAME);
|
Apps_defaults_FILENAME);
|
||||||
if (_appsDefaultsUserFile.exists()) {
|
if (_appsDefaultsUserFile.exists()) {
|
||||||
statusHandler.info("Setting user Apps_defaults file: "
|
logger.info("Setting user Apps_defaults file: "
|
||||||
+ _appsDefaultsUserFile);
|
+ _appsDefaultsUserFile);
|
||||||
} else {
|
} else {
|
||||||
statusHandler.info("No user Apps_defaults file found.");
|
logger.info("No user Apps_defaults file found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
_appsDefaultsSiteFile = pm.getLocalizationFile(pm.getContext(
|
_appsDefaultsSiteFile = pm.getLocalizationFile(pm.getContext(
|
||||||
LocalizationType.COMMON_STATIC, LocalizationLevel.SITE),
|
LocalizationType.COMMON_STATIC, LocalizationLevel.SITE),
|
||||||
Apps_defaults_FILENAME);
|
Apps_defaults_FILENAME);
|
||||||
if (_appsDefaultsSiteFile.exists()) {
|
if (_appsDefaultsSiteFile.exists()) {
|
||||||
statusHandler.info("Setting site Apps_defaults file: "
|
logger.info("Setting site Apps_defaults file: "
|
||||||
+ _appsDefaultsSiteFile);
|
+ _appsDefaultsSiteFile);
|
||||||
} else {
|
} else {
|
||||||
statusHandler.warn("No site Apps_defaults file found.");
|
logger.warn("No site Apps_defaults file found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
_appsDefaultsNationalFile = pm.getLocalizationFile(pm.getContext(
|
_appsDefaultsNationalFile = pm.getLocalizationFile(pm.getContext(
|
||||||
LocalizationType.COMMON_STATIC, LocalizationLevel.BASE),
|
LocalizationType.COMMON_STATIC, LocalizationLevel.BASE),
|
||||||
Apps_defaults_FILENAME);
|
Apps_defaults_FILENAME);
|
||||||
if (_appsDefaultsNationalFile.exists()) {
|
if (_appsDefaultsNationalFile.exists()) {
|
||||||
statusHandler.info("Setting base Apps_defaults file: "
|
logger.info("Setting base Apps_defaults file: "
|
||||||
+ _appsDefaultsNationalFile);
|
+ _appsDefaultsNationalFile);
|
||||||
} else {
|
} else {
|
||||||
statusHandler.error("No base Apps_defaults file found.");
|
logger.error("No base Apps_defaults file found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.appsDefaultsObserver == null) {
|
if (this.appsDefaultsObserver == null) {
|
||||||
appsDefaultsObserver = new ILocalizationPathObserver() {
|
appsDefaultsObserver = new ILocalizationPathObserver() {
|
||||||
@Override
|
@Override
|
||||||
public void fileChanged(ILocalizationFile file) {
|
public void fileChanged(ILocalizationFile file) {
|
||||||
statusHandler
|
logger.info("Detected change in Apps_defaults file: "
|
||||||
.info("Detected change in Apps_defaults file: "
|
|
||||||
+ file.toString() + " ...");
|
+ file.toString() + " ...");
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
@ -309,7 +307,7 @@ public class AppsDefaults {
|
||||||
if (file != null && file.exists()) {
|
if (file != null && file.exists()) {
|
||||||
BufferedReader reader = null;
|
BufferedReader reader = null;
|
||||||
try {
|
try {
|
||||||
statusHandler.info("Reading " + file + " into AppsDefaults");
|
logger.info("Reading " + file + " into AppsDefaults");
|
||||||
reader = new BufferedReader(new InputStreamReader(
|
reader = new BufferedReader(new InputStreamReader(
|
||||||
file.openInputStream()));
|
file.openInputStream()));
|
||||||
String line = null;
|
String line = null;
|
||||||
|
@ -324,14 +322,14 @@ public class AppsDefaults {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
statusHandler.error("Error reading file " + file, e);
|
logger.error("Error reading file " + file, e);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
if (reader != null) {
|
if (reader != null) {
|
||||||
reader.close();
|
reader.close();
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
statusHandler.error("Error closing file " + file, e);
|
logger.error("Error closing file " + file, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -581,8 +579,7 @@ public class AppsDefaults {
|
||||||
recursionCount--;
|
recursionCount--;
|
||||||
} else {
|
} else {
|
||||||
middle = "ERROR_ERROR_ERROR";
|
middle = "ERROR_ERROR_ERROR";
|
||||||
statusHandler
|
logger.error("You probably have a cycle in your Apps Defaults File's refer backs, please check it");
|
||||||
.error("You probably have a cycle in your Apps Defaults File's refer backs, please check it");
|
|
||||||
}
|
}
|
||||||
if ((referBackEndIndex + RFR_CLOSE.length()) < tokenValue.length()) {
|
if ((referBackEndIndex + RFR_CLOSE.length()) < tokenValue.length()) {
|
||||||
end = tokenValue.substring(
|
end = tokenValue.substring(
|
||||||
|
@ -893,13 +890,13 @@ public class AppsDefaults {
|
||||||
String contextVar = setAppContextVar(callingContext, false);
|
String contextVar = setAppContextVar(callingContext, false);
|
||||||
boolean isOn = getBoolean(contextVar, true);
|
boolean isOn = getBoolean(contextVar, true);
|
||||||
|
|
||||||
if (statusHandler.isPriorityEnabled(Priority.WARN)) {
|
if (logger.isWarnEnabled()) {
|
||||||
StringBuilder sb = new StringBuilder(
|
StringBuilder sb = new StringBuilder(
|
||||||
"App Execution Token for App Context ");
|
"App Execution Token for App Context ");
|
||||||
sb.append(contextVar);
|
sb.append(contextVar);
|
||||||
sb.append(" is ");
|
sb.append(" is ");
|
||||||
sb.append(isOn);
|
sb.append(isOn);
|
||||||
statusHandler.warn(sb.toString());
|
logger.warn(sb.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return isOn;
|
return isOn;
|
||||||
|
@ -925,13 +922,13 @@ public class AppsDefaults {
|
||||||
String contextVar = setAppContextVar(callingContext, true);
|
String contextVar = setAppContextVar(callingContext, true);
|
||||||
boolean isOn = getBoolean(contextVar, true);
|
boolean isOn = getBoolean(contextVar, true);
|
||||||
|
|
||||||
if (statusHandler.isPriorityEnabled(Priority.WARN)) {
|
if (logger.isWarnEnabled()) {
|
||||||
StringBuilder sb = new StringBuilder(
|
StringBuilder sb = new StringBuilder(
|
||||||
"App Execution Token for App Context ");
|
"App Execution Token for App Context ");
|
||||||
sb.append(contextVar);
|
sb.append(contextVar);
|
||||||
sb.append(" is ");
|
sb.append(" is ");
|
||||||
sb.append(isOn);
|
sb.append(isOn);
|
||||||
statusHandler.warn(sb.toString());
|
logger.warn(sb.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return isOn;
|
return isOn;
|
||||||
|
|
Loading…
Add table
Reference in a new issue