Issue #2361 remove SerializationUtil from SoundingPrefs
Change-Id: Ia394f825954c0d96e17431589d64af13d8c7f991 Former-commit-id: eab1cf126b79ec5708facf2b2c9a303fca8a24fe
This commit is contained in:
parent
43bbf31347
commit
e9ca44ee64
2 changed files with 19 additions and 18 deletions
|
@ -1 +0,0 @@
|
|||
com.raytheon.uf.common.sounding.util.SoundingPrefs
|
|
@ -21,6 +21,7 @@ package com.raytheon.uf.common.sounding.util;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
import javax.xml.bind.JAXB;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
@ -31,8 +32,6 @@ import com.raytheon.uf.common.localization.LocalizationContext;
|
|||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.serialization.SerializationUtil;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
@ -50,6 +49,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 15, 2011 bsteffen Initial creation
|
||||
* Aug 21, 2013 2259 bsteffen Add javadoc
|
||||
* Nov 08, 2013 2361 njensen Use JAXB instead of SerializationUtil
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
|
@ -60,11 +60,12 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
@XmlRootElement
|
||||
public class SoundingPrefs {
|
||||
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(SoundingPrefs.class);
|
||||
|
||||
.getHandler(SoundingPrefs.class);
|
||||
|
||||
private static final String SOUNDING_PREFS_FILE = "sounding/soundingPrefs.xml";
|
||||
|
||||
|
||||
@XmlElement
|
||||
private double temperatureOffset = 0.0;
|
||||
|
||||
|
@ -75,29 +76,30 @@ public class SoundingPrefs {
|
|||
public void setTemperatureOffset(double temperatureOffset) {
|
||||
this.temperatureOffset = temperatureOffset;
|
||||
}
|
||||
|
||||
|
||||
private static SoundingPrefs soundingPrefs;
|
||||
|
||||
|
||||
public static SoundingPrefs getSoundingPrefs() {
|
||||
if(soundingPrefs == null) {
|
||||
if (soundingPrefs == null) {
|
||||
IPathManager pathMgr = PathManagerFactory.getPathManager();
|
||||
LocalizationContext lc = pathMgr.getContext(
|
||||
LocalizationType.COMMON_STATIC, LocalizationLevel.SITE);
|
||||
File file = pathMgr.getFile(lc, SOUNDING_PREFS_FILE);
|
||||
if(file == null || !file.exists()) {
|
||||
lc = pathMgr.getContext(
|
||||
LocalizationType.COMMON_STATIC, LocalizationLevel.BASE);
|
||||
file = pathMgr.getFile(lc, SOUNDING_PREFS_FILE);
|
||||
if (file == null || !file.exists()) {
|
||||
lc = pathMgr.getContext(LocalizationType.COMMON_STATIC,
|
||||
LocalizationLevel.BASE);
|
||||
file = pathMgr.getFile(lc, SOUNDING_PREFS_FILE);
|
||||
}
|
||||
try {
|
||||
soundingPrefs = (SoundingPrefs) SerializationUtil.jaxbUnmarshalFromXmlFile(file);
|
||||
} catch (SerializationException e) {
|
||||
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
|
||||
soundingPrefs = JAXB.unmarshal(file, SoundingPrefs.class);
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
|
||||
e);
|
||||
soundingPrefs = new SoundingPrefs();
|
||||
}
|
||||
}
|
||||
return soundingPrefs;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue