VLab Issue #3221 - Fix XML serialization problems
A few problems reading/writing XML files were noticed after upgrading to 14.2.1. This commit fixes the saving of SPFs, reading of image style rules, and the location of lockedColorMap file. Change-Id: I8aad4197029c70f72612299a25329687892884af Former-commit-id: 4f58998c899e28521658bf17dee852592c534713
This commit is contained in:
parent
1fe5504d4c
commit
6dd6ae8d36
3 changed files with 49 additions and 7 deletions
|
@ -236,7 +236,7 @@ public class ColorMapUtil {
|
|||
|
||||
Map<LocalizationLevel, LocalizationFile> files = PathManagerFactory
|
||||
.getPathManager().getTieredLocalizationFile(
|
||||
LocalizationType.COMMON_STATIC,
|
||||
LocalizationType.CAVE_STATIC,
|
||||
NcPathConstants.LOCKED_CMAP_TBL);
|
||||
|
||||
File locCmapFile = null;
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.io.File;
|
||||
import javax.xml.bind.JAXBException;
|
||||
|
||||
import com.raytheon.uf.common.localization.FileUpdatedMessage;
|
||||
import com.raytheon.uf.common.localization.ILocalizationAdapter;
|
||||
|
@ -56,6 +57,7 @@ import gov.noaa.nws.ncep.viz.resources.AbstractNatlCntrsRequestableResourceData;
|
|||
* 07/22/12 #568 Greg Hull return Rbds and rbdNames sorted by seq num.
|
||||
* 02/10/13 #972 Greg Hull changed to work with AbstractRbds
|
||||
* 05/19/13 #1001 Greg Hull getRbdsFromSpf(), trap RBD errors
|
||||
* 03/06/14 ? B. Yin Replaced SerializationUtil with JAXBManager.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -451,7 +453,7 @@ public class SpfsManager implements ILocalizationFileObserver {
|
|||
// group and spf
|
||||
//
|
||||
try {
|
||||
SerializationUtil.jaxbMarshalToXmlFile( rbd, rbdFile.getAbsolutePath() );
|
||||
AbstractRBD.getJaxbManager().marshalToXmlFile( rbd, rbdFile.getAbsolutePath() );
|
||||
|
||||
rbd.setLocalizationFile( lFile );
|
||||
|
||||
|
@ -463,6 +465,8 @@ public class SpfsManager implements ILocalizationFileObserver {
|
|||
|
||||
} catch (LocalizationOpFailedException e) {
|
||||
throw new VizException(e);
|
||||
} catch (JAXBException e) {
|
||||
throw new VizException(e);
|
||||
} catch (SerializationException e) {
|
||||
throw new VizException(e);
|
||||
} finally {
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.text.ParseException;
|
|||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
@ -28,6 +29,8 @@ import java.util.Map;
|
|||
import java.util.TimeZone;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.opengis.referencing.FactoryException;
|
||||
import org.opengis.referencing.operation.TransformException;
|
||||
|
@ -38,8 +41,10 @@ import com.raytheon.uf.common.colormap.prefs.DataMappingPreferences;
|
|||
import com.raytheon.uf.common.colormap.prefs.DataMappingPreferences.DataMappingEntry;
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.geospatial.ReferencedCoordinate;
|
||||
import com.raytheon.uf.common.serialization.JAXBManager;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.serialization.SerializationUtil;
|
||||
import com.raytheon.uf.common.serialization.jaxb.JAXBClassLocator;
|
||||
import com.raytheon.uf.common.serialization.jaxb.JaxbDummyObject;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
@ -53,12 +58,14 @@ import com.raytheon.uf.common.style.image.DataScale;
|
|||
import com.raytheon.uf.common.style.image.DataScale.Type;
|
||||
import com.raytheon.uf.common.style.image.ImagePreferences;
|
||||
import com.raytheon.uf.common.style.image.SamplePreferences;
|
||||
import com.raytheon.uf.common.style.level.Level;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
import com.raytheon.uf.viz.core.drawables.ResourcePair;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.reflect.SubClassLocator;
|
||||
import com.raytheon.uf.viz.core.rsc.IInputHandler;
|
||||
import com.raytheon.uf.viz.core.rsc.IInputHandler.InputPriority;
|
||||
import com.raytheon.uf.viz.core.rsc.IResourceDataChanged;
|
||||
|
@ -90,6 +97,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* 12/16/2013 #958 sgurung Set virtual cursor to point to lat/lon instead of pixel coordinates (in multipnaes)
|
||||
* 12/27/2013 #1046 qzhou Added getFunctioningRecords method
|
||||
* Sep 5,2013 2051 mnash Fixed a deprecated method.
|
||||
* 02/27/2014 qzhou Changed SerializaitionUtil to JAXBManager. Added getJaxbManager function
|
||||
* </pre>
|
||||
*
|
||||
* @author qzhou, sgurung
|
||||
|
@ -136,6 +144,8 @@ public class SolarImageResource extends
|
|||
|
||||
private RGB rgbB;
|
||||
|
||||
private static JAXBManager jaxb;
|
||||
|
||||
protected static class SampleResult {
|
||||
|
||||
public SampleResult() {
|
||||
|
@ -260,7 +270,6 @@ public class SolarImageResource extends
|
|||
return legendStr;
|
||||
}
|
||||
|
||||
// TODO : probably not correct : fix this as it needs to be.
|
||||
public void setLegendForFrame(SolarImageRecord rec) {
|
||||
|
||||
String timeStr = dateFmt.format(rec.getDataTime().getRefTime());
|
||||
|
@ -393,7 +402,6 @@ public class SolarImageResource extends
|
|||
sampleCoord);
|
||||
}
|
||||
|
||||
// TODO : draw the lat lon lines even if there is no image?
|
||||
if (isLatLonOverlayOn()) {
|
||||
try {
|
||||
if (isCarrington) {
|
||||
|
@ -838,6 +846,31 @@ public class SolarImageResource extends
|
|||
return NcPathConstants.SOLAR_IMG_STYLE_RULES;
|
||||
}
|
||||
|
||||
public static synchronized JAXBManager getJaxbManager()
|
||||
throws JAXBException {
|
||||
if (jaxb == null) {
|
||||
SubClassLocator locator = new SubClassLocator();
|
||||
Collection<Class<?>> classes = JAXBClassLocator.getJAXBClasses(
|
||||
locator, StyleRuleset.class, StyleRule.class, Level.class,
|
||||
AbstractStylePreferences.class, MatchCriteria.class);
|
||||
|
||||
locator.save();
|
||||
|
||||
Class<?>[] jaxbClasses = new Class<?>[classes.size() + 1];
|
||||
classes.toArray(jaxbClasses);
|
||||
|
||||
/*
|
||||
* Add JaxbDummyObject at the beginning so properties are loaded
|
||||
* correctly
|
||||
*/
|
||||
jaxbClasses[jaxbClasses.length - 1] = jaxbClasses[0];
|
||||
jaxbClasses[0] = JaxbDummyObject.class;
|
||||
|
||||
jaxb = new JAXBManager(jaxbClasses);
|
||||
}
|
||||
return jaxb;
|
||||
}
|
||||
|
||||
private void setColorMapParametersAndColorBar() throws VizException {
|
||||
double minPixVal = Double.NaN;
|
||||
double maxPixVal = Double.NaN;
|
||||
|
@ -881,8 +914,10 @@ public class SolarImageResource extends
|
|||
File file = NcPathManager.getInstance().getStaticFile(locFileName);
|
||||
StyleRule sRule = null;
|
||||
try {
|
||||
StyleRuleset styleSet = (StyleRuleset) SerializationUtil
|
||||
.jaxbUnmarshalFromXmlFile(StyleRuleset.class, file);
|
||||
StyleRuleset styleSet = (StyleRuleset) getJaxbManager()
|
||||
.unmarshalFromXmlFile(file);
|
||||
|
||||
// .jaxbUnmarshalFromXmlFile(StyleRuleset.class, file);
|
||||
|
||||
if (styleSet != null) {
|
||||
List<StyleRule> styleRuleList = styleSet.getStyleRules();
|
||||
|
@ -932,6 +967,9 @@ public class SolarImageResource extends
|
|||
}
|
||||
|
||||
}
|
||||
} catch (JAXBException e) {
|
||||
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
|
||||
|
||||
} catch (SerializationException e1) {
|
||||
|
||||
e1.printStackTrace();
|
||||
|
|
Loading…
Add table
Reference in a new issue