diff --git a/cave/com.raytheon.viz.hydro/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/cave/com.raytheon.viz.hydro/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index 9144a771dd..0000000000 --- a/cave/com.raytheon.viz.hydro/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1,2 +0,0 @@ -com.raytheon.viz.hydro.timeseries.ShefIssueXML -com.raytheon.viz.hydro.appsdefaults.SHEFAppsDefaultsXML diff --git a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/appsdefaults/SHEFAppsDefaultsDlg.java b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/appsdefaults/SHEFAppsDefaultsDlg.java index 754ffbcdb4..a59e9ed484 100644 --- a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/appsdefaults/SHEFAppsDefaultsDlg.java +++ b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/appsdefaults/SHEFAppsDefaultsDlg.java @@ -23,6 +23,8 @@ import java.io.File; import java.util.ArrayList; import java.util.List; +import javax.xml.bind.JAXB; + import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.events.SelectionAdapter; @@ -39,8 +41,6 @@ import org.eclipse.swt.widgets.Shell; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.PathManagerFactory; import com.raytheon.uf.common.ohd.AppsDefaults; -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; @@ -57,7 +57,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * ------------ ---------- ----------- -------------------------- * Jan 26, 2011 mpduff Initial creation * Dec 07, 2012 1353 rferrel Make non-blocking dialog. - * Aug 09, 2013 2033 mschenke Switched File.separator to IPathManager.SEPARATOR + * Aug 09, 2013 2033 mschenke Switched File.separator to IPathManager.SEPARATOR + * Nov 04, 2013 2361 njensen Use JAXB instead of SerializationUtil * * * @@ -170,17 +171,14 @@ public class SHEFAppsDefaultsDlg extends CaveSWTDialog { IPathManager pm = PathManagerFactory.getPathManager(); System.out.println("Searching for " + CONFIG_FILE_NAME); File file = pm.getStaticFile(this.CONFIG_FILE_NAME); - String configPath = null; if (file != null) { - configPath = file.getAbsolutePath(); try { - SHEFAppsDefaultsXML xml = SerializationUtil - .jaxbUnmarshalFromXmlFile(SHEFAppsDefaultsXML.class, - configPath); + SHEFAppsDefaultsXML xml = JAXB.unmarshal(file, + SHEFAppsDefaultsXML.class); for (String token : xml.getTokenList()) { tokenList.add(token); } - } catch (SerializationException e) { + } catch (Exception e) { statusHandler.handle(Priority.PROBLEM, e.getMessage(), e); } } else { diff --git a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/ShefIssueMgr.java b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/ShefIssueMgr.java index 5e24c4da37..2bf58b2342 100644 --- a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/ShefIssueMgr.java +++ b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/ShefIssueMgr.java @@ -28,7 +28,9 @@ import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; -import com.raytheon.uf.common.serialization.SerializationUtil; +import com.raytheon.uf.common.serialization.SingleTypeJAXBManager; +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; /** * Shef Issue Configuration Manager. @@ -39,7 +41,8 @@ import com.raytheon.uf.common.serialization.SerializationUtil; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Mar 28, 2011 mpduff Initial creation + * Mar 28, 2011 mpduff Initial creation + * Nov 04, 2013 2361 njensen Use JAXBManager for XML * * * @@ -48,6 +51,13 @@ import com.raytheon.uf.common.serialization.SerializationUtil; */ public class ShefIssueMgr { + + private static final SingleTypeJAXBManager jaxb = SingleTypeJAXBManager + .createWithoutException(ShefIssueXML.class); + + private final IUFStatusHandler statusHandler = UFStatus + .getHandler(ShefIssueMgr.class); + private static ShefIssueMgr instance = null; private ShefIssueXML xml = null; @@ -69,10 +79,11 @@ public class ShefIssueMgr { } private void readXML() { + LocalizationFile file = null; try { IPathManager pm = PathManagerFactory.getPathManager(); Map shefIssueMap = pm.getTieredLocalizationFile(LocalizationType.COMMON_STATIC, "hydro" + File.separatorChar + "shefIssue.xml"); - LocalizationFile file = null; + if (shefIssueMap.containsKey(LocalizationLevel.SITE)) { file = shefIssueMap.get(LocalizationLevel.SITE); @@ -81,13 +92,13 @@ public class ShefIssueMgr { } if (file != null) { - xml = (ShefIssueXML) SerializationUtil - .jaxbUnmarshalFromXmlFile(file.getFile().getAbsolutePath()); + xml = jaxb + .unmarshalFromXmlFile(file.getFile()); } else { xml = new ShefIssueXML(); } } catch (Exception e) { - e.printStackTrace(); + statusHandler.error("Error reading " + file.getName(), e); } } @@ -119,11 +130,11 @@ public class ShefIssueMgr { if (xml == null) { xml = new ShefIssueXML(); } - SerializationUtil.jaxbMarshalToXmlFile(xml, newXmlFile + jaxb.marshalToXmlFile(xml, newXmlFile .getFile().getAbsolutePath()); newXmlFile.save(); } catch (Exception e) { - e.printStackTrace(); + statusHandler.error("Error writing " + newXmlFile.getName(), e); } } } diff --git a/cave/com.raytheon.viz.redbook/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/cave/com.raytheon.viz.redbook/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index 8d76b088d8..0000000000 --- a/cave/com.raytheon.viz.redbook/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1,2 +0,0 @@ -com.raytheon.viz.redbook.RedbookWMOMap -com.raytheon.viz.redbook.rsc.RedbookProductBrowserDataDefinition diff --git a/cave/com.raytheon.viz.redbook/src/com/raytheon/viz/redbook/RedbookWMOMap.java b/cave/com.raytheon.viz.redbook/src/com/raytheon/viz/redbook/RedbookWMOMap.java index 6c998100be..825d1f5926 100644 --- a/cave/com.raytheon.viz.redbook/src/com/raytheon/viz/redbook/RedbookWMOMap.java +++ b/cave/com.raytheon.viz.redbook/src/com/raytheon/viz/redbook/RedbookWMOMap.java @@ -22,14 +22,13 @@ package com.raytheon.viz.redbook; import java.io.File; import java.util.HashMap; +import javax.xml.bind.JAXB; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import com.raytheon.uf.common.localization.PathManagerFactory; -import com.raytheon.uf.common.serialization.ISerializableObject; -import com.raytheon.uf.common.serialization.SerializationUtil; /** * Returns the redbook WMO prefix to human readable name @@ -39,6 +38,7 @@ import com.raytheon.uf.common.serialization.SerializationUtil; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * May 30, 2008 chammack Initial creation + * Nov 04, 2013 2361 njensen Use JAXB instead of SerializationUtil * * * @@ -47,10 +47,10 @@ import com.raytheon.uf.common.serialization.SerializationUtil; */ @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) -public class RedbookWMOMap implements ISerializableObject { +public class RedbookWMOMap { @XmlAccessorType(XmlAccessType.FIELD) - public static class Info implements ISerializableObject { + public static class Info { public String name; @XmlElement(required = false) @@ -63,8 +63,8 @@ public class RedbookWMOMap implements ISerializableObject { File file = PathManagerFactory.getPathManager().getStaticFile( "redbook/redbookMapping.xml"); try { - RedbookWMOMap map = (RedbookWMOMap) SerializationUtil - .jaxbUnmarshalFromXmlFile(file.getAbsolutePath()); + RedbookWMOMap map = JAXB.unmarshal(file, RedbookWMOMap.class); + // add ability for comma separated values in xml file RedbookWMOMap secondMap = new RedbookWMOMap(); secondMap.mapping = new HashMap(); diff --git a/edexOsgi/com.raytheon.edex.plugin.redbook/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/edexOsgi/com.raytheon.edex.plugin.redbook/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index cb7615ab77..0000000000 --- a/edexOsgi/com.raytheon.edex.plugin.redbook/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1,2 +0,0 @@ -com.raytheon.edex.plugin.redbook.common.RedbookRecord -com.raytheon.edex.plugin.redbook.decoder.RedbookFcstMap \ No newline at end of file diff --git a/edexOsgi/com.raytheon.edex.plugin.redbook/src/com/raytheon/edex/plugin/redbook/common/RedbookRecord.java b/edexOsgi/com.raytheon.edex.plugin.redbook/src/com/raytheon/edex/plugin/redbook/common/RedbookRecord.java index 199634a1d7..e02a4a9b9c 100644 --- a/edexOsgi/com.raytheon.edex.plugin.redbook/src/com/raytheon/edex/plugin/redbook/common/RedbookRecord.java +++ b/edexOsgi/com.raytheon.edex.plugin.redbook/src/com/raytheon/edex/plugin/redbook/common/RedbookRecord.java @@ -31,14 +31,9 @@ import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.persistence.Transient; import javax.persistence.UniqueConstraint; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; import org.hibernate.annotations.Index; -import com.raytheon.uf.common.dataplugin.IDecoderGettable; import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.dataplugin.PluginException; import com.raytheon.uf.common.dataplugin.annotations.DataURI; @@ -72,6 +67,7 @@ import com.raytheon.uf.common.time.DataTime; * May 07, 2013 1869 bsteffen Remove dataURI column from * PluginDataObject. * Aug 30, 2013 2298 rjpeter Make getPluginName abstract + * Nov 04, 2013 2361 njensen Remove XML annotations * * * @@ -87,8 +83,6 @@ import com.raytheon.uf.common.time.DataTime; */ @org.hibernate.annotations.Table(appliesTo = "redbook", indexes = { @Index(name = "redbook_refTimeIndex", columnNames = { "refTime", "forecastTime" }) }) -@XmlRootElement -@XmlAccessorType(XmlAccessType.NONE) @DynamicSerialize public class RedbookRecord extends PersistablePluginDataObject implements IPersistable, Cloneable { @@ -99,57 +93,48 @@ public class RedbookRecord extends PersistablePluginDataObject implements // Time of the observation. @Column - @XmlAttribute @DynamicSerializeElement private Calendar timeObs; @DataURI(position = 1) @Column(length = 8) - @XmlAttribute @DynamicSerializeElement private String wmoTTAAii; // Text of the WMO header @Column(length = 16) - @XmlAttribute @DynamicSerializeElement private String wmoCCCCdt; // Correction indicator from wmo header @DataURI(position = 3) @Column(length = 8) - @XmlAttribute @DynamicSerializeElement private String corIndicator; @Column - @XmlAttribute @DynamicSerializeElement private Integer retentionHours; @DataURI(position = 5) @Column - @XmlAttribute @DynamicSerializeElement private Integer fcstHours; // varchar(15) @DataURI(position = 2) @Column(length = 15) - @XmlAttribute @DynamicSerializeElement private String productId; @DataURI(position = 6) @Column - @XmlAttribute @DynamicSerializeElement private Integer fileId; // varchar(4) @DataURI(position = 4) @Column(length = 4) - @XmlAttribute @DynamicSerializeElement private String originatorId; @@ -335,16 +320,6 @@ public class RedbookRecord extends PersistablePluginDataObject implements this.redBookData = redBookData; } - /** - * Get the IDecoderGettable reference for this record. - * - * @return This class does not implement IDecoderGettable, return null. - */ - @Override - public IDecoderGettable getDecoderGettable() { - return null; - } - /** * @return a mostly shallow copy of the RedbookRecord with the reference * time set back one minute. Clears the id and dataURI fields of the diff --git a/edexOsgi/com.raytheon.edex.plugin.redbook/src/com/raytheon/edex/plugin/redbook/decoder/RedbookFcstMap.java b/edexOsgi/com.raytheon.edex.plugin.redbook/src/com/raytheon/edex/plugin/redbook/decoder/RedbookFcstMap.java index c98d57750a..701489756a 100644 --- a/edexOsgi/com.raytheon.edex.plugin.redbook/src/com/raytheon/edex/plugin/redbook/decoder/RedbookFcstMap.java +++ b/edexOsgi/com.raytheon.edex.plugin.redbook/src/com/raytheon/edex/plugin/redbook/decoder/RedbookFcstMap.java @@ -21,6 +21,7 @@ package com.raytheon.edex.plugin.redbook.decoder; import java.util.HashMap; +import javax.xml.bind.JAXB; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; @@ -33,9 +34,6 @@ import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; -import com.raytheon.uf.common.serialization.ISerializableObject; -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; @@ -48,9 +46,10 @@ import com.raytheon.uf.common.status.UFStatus.Priority; * Date Ticket# Engineer Description * ------------ ----------- ----------- -------------------------- * 20101022 6424 kshrestha Add fcsttime - * Apr 29, 2013 1958 bgonzale Map is loaded once, and then + * Apr 29, 2013 1958 bgonzale Map is loaded once, and then * not loaded again unless the mapping * file changes. + * Nov 04, 2013 2361 njensen Use JAXB for XML instead of SerializationUtil * * * @@ -59,7 +58,8 @@ import com.raytheon.uf.common.status.UFStatus.Priority; */ @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) -public class RedbookFcstMap implements ISerializableObject { +public class RedbookFcstMap { + private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(RedbookFcstMap.class); @@ -90,9 +90,8 @@ public class RedbookFcstMap implements ISerializableObject { private static RedbookFcstMap load(LocalizationFile xmlFile) { RedbookFcstMap loadedMap = null; try { - loadedMap = SerializationUtil.jaxbUnmarshalFromXmlFile( - RedbookFcstMap.class, xmlFile.getFile().getAbsolutePath()); - } catch (SerializationException e) { + loadedMap = JAXB.unmarshal(xmlFile.getFile(), RedbookFcstMap.class); + } catch (Exception e) { statusHandler.handle(Priority.PROBLEM, e.getMessage(), e); } return loadedMap;