Issue #2491 Fix collaboration Xml.

Former-commit-id: 64517ab3139be3cc21d5df7ff9d36709435bd7cd
This commit is contained in:
Ben Steffensmeier 2013-10-31 14:06:05 -05:00
parent de50a9214b
commit fdeff81da2
14 changed files with 329 additions and 77 deletions

View file

@ -1,25 +1,26 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Collaboratioin
Bundle-SymbolicName: com.raytheon.uf.viz.collaboration.comm
Bundle-Version: 1.0.0.qualifier
Bundle-SymbolicName: com.raytheon.uf.viz.collaboration.comm;singleton:=true
Bundle-Version: 1.13.0.qualifier
Bundle-Activator: com.raytheon.uf.viz.collaboration.comm.Activator
Bundle-Vendor: RAYTHEON
Eclipse-RegisterBuddy: com.raytheon.uf.viz.core
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ecf;bundle-version="3.1.300";visibility:=reexport,
org.eclipse.ecf.presence;bundle-version="2.0.0",
org.eclipse.ecf.provider.xmpp;bundle-version="3.2.0",
org.apache.commons.lang;bundle-version="2.3.0",
com.google.guava;bundle-version="1.0.0";visibility:=reexport,
com.raytheon.uf.common.serialization;bundle-version="1.12.1174",
com.raytheon.uf.common.status;bundle-version="1.12.1174",
org.jivesoftware.smack;bundle-version="3.1.100",
org.eclipse.swt;bundle-version="3.6.1",
com.raytheon.uf.common.comm,
com.raytheon.uf.common.localization
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ecf,
org.eclipse.ecf.presence,
org.eclipse.ecf.provider.xmpp,
org.apache.commons.lang,
com.google.guava;visibility:=reexport,
com.raytheon.uf.common.serialization,
com.raytheon.uf.common.status,
org.jivesoftware.smack,
org.eclipse.swt,
com.raytheon.uf.common.comm,
com.raytheon.uf.common.localization,
com.raytheon.uf.viz.core
Export-Package: com.raytheon.uf.viz.collaboration.comm,
com.raytheon.uf.viz.collaboration.comm.compression,
com.raytheon.uf.viz.collaboration.comm.identity,

View file

@ -1,4 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
.,\
plugin.xml

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension-point id="com.raytheon.uf.viz.collaboration.xml" name="Collaboration Xml Objects" schema="schema/com.raytheon.uf.viz.collaboration.xml.exsd"/>
</plugin>

View file

@ -0,0 +1,78 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="com.raytheon.uf.viz.collaboration.comm" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appinfo>
<meta.schema plugin="com.raytheon.uf.viz.collaboration.comm" id="com.raytheon.uf.viz.collaboration.xml" name="Collaboration Xml Objects"/>
</appinfo>
<documentation>
Extension point for specifying what types of objects can be the xml root of a collaboraton xml object.
</documentation>
</annotation>
<element name="extension">
<annotation>
<appinfo>
<meta.element />
</appinfo>
</annotation>
<complexType>
<sequence minOccurs="1" maxOccurs="unbounded">
<element ref="xmlRoot"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute translatable="true"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>
<element name="xmlRoot">
<complexType>
<attribute name="class" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute kind="java"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
<appinfo>
<meta.section type="since"/>
</appinfo>
<documentation>
1.13.0
</documentation>
</annotation>
</schema>

View file

@ -0,0 +1,155 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.collaboration.comm.provider;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.xml.bind.JAXBException;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import com.raytheon.uf.common.serialization.JAXBManager;
import com.raytheon.uf.common.serialization.SerializationException;
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;
import com.raytheon.uf.viz.core.procedures.ProcedureXmlManager;
import com.raytheon.uf.viz.core.reflect.SubClassLocator;
/**
* Loads the XML context for all collaboration objects by using the xmlRoot
* objects defined in an extension point.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Oct 31, 2013 2491 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public class CollaborationXmlManager {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(CollaborationXmlManager.class);
private static final String EXTENSION_ID = "com.raytheon.uf.viz.collaboration.xml";
private static CollaborationXmlManager instance;
private final JAXBManager manager;
private CollaborationXmlManager() {
manager = initManager();
}
private JAXBManager initManager() {
List<Class<?>> baseClasses = new ArrayList<Class<?>>();
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint point = registry.getExtensionPoint(EXTENSION_ID);
if (point != null) {
IExtension[] extensions = point.getExtensions();
for (int i = 0; i < extensions.length; i++) {
IConfigurationElement[] config = extensions[i]
.getConfigurationElements();
for (int j = 0; j < config.length; j++) {
try {
baseClasses.add(config[j].createExecutableExtension(
"class").getClass());
} catch (CoreException e) {
statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
}
}
}
}
SubClassLocator locator = new SubClassLocator();
Collection<Class<?>> classes = JAXBClassLocator.getJAXBClasses(locator,
baseClasses.toArray(new Class<?>[0]));
locator.save();
Class<?>[] jaxbClasses = new Class<?>[classes.size() + 1];
classes.toArray(jaxbClasses);
/*
* Add JaxbDummyObject at the begining so properties are loaded
* correctly
*/
jaxbClasses[jaxbClasses.length - 1] = jaxbClasses[0];
jaxbClasses[0] = JaxbDummyObject.class;
try {
return new JAXBManager(jaxbClasses);
} catch (JAXBException e) {
statusHandler.handle(Priority.PROBLEM,
ProcedureXmlManager.class.getSimpleName()
+ " Failed to initialize.", e);
}
return null;
}
private JAXBManager getManager() throws SerializationException {
if (manager == null) {
throw new SerializationException(
ProcedureXmlManager.class.getSimpleName()
+ " Failed to initialize.");
}
return manager;
}
public Object unmarshal(String xml) throws SerializationException {
try {
return getManager().unmarshalFromXml(xml);
} catch (JAXBException e) {
throw new SerializationException(e);
}
}
public String marshal(Object obj) throws SerializationException {
try {
return getManager().marshalToXml(obj);
} catch (JAXBException e) {
throw new SerializationException(e);
}
}
public static synchronized CollaborationXmlManager getInstance() {
if (instance == null) {
instance = new CollaborationXmlManager();
}
return instance;
}
}

View file

@ -19,8 +19,6 @@
**/
package com.raytheon.uf.viz.collaboration.comm.provider;
import javax.xml.bind.JAXBException;
import org.eclipse.ecf.core.IContainer;
import org.eclipse.ecf.core.util.Base64;
@ -30,15 +28,18 @@ import com.raytheon.uf.viz.collaboration.comm.compression.CompressionUtil;
import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException;
/**
* TODO Add Description
* Provides some utility methods for parsing and serializing/deserializing data.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 7, 2012 jkorman Initial creation
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Mar 07, 2012 jkorman Initial creation
* Oct 31, 2013 2491 bsteffen Use CollaborationXmlManager for xml
* serialization.
*
*
* </pre>
*
@ -55,9 +56,9 @@ public abstract class Tools {
public static final String PROP_SESSION_ID = "sessionId";
public static final String CMD_PREAMBLE = "[[COMMAND#";
public static final String CONFIG_PREAMBLE = "[[CONFIG#";
public static final String DIRECTIVE_SUFFIX = "]]";
private static final String ENV_THRIFT = CMD_PREAMBLE
@ -275,14 +276,16 @@ public abstract class Tools {
}
case JAXB: {
try {
CollaborationXmlManager jaxb = CollaborationXmlManager
.getInstance();
if (COMPRESSION_OFF) {
String s = SerializationUtil.marshalToXml(data);
String s = jaxb.marshal(data);
if (s != null) {
sb.append(ENV_JAXB);
sb.append(s);
}
} else {
String rawString = SerializationUtil.marshalToXml(data);
String rawString = jaxb.marshal(data);
marshalledBinary = CompressionUtil.compress(rawString
.getBytes());
sb.append(ENV_JAXB_COMPRESSED);
@ -334,7 +337,8 @@ public abstract class Tools {
String s = data.substring(ENV_THRIFT.length());
try {
byte[] b = decodeFromBase64(s);
unMarshalledData = SerializationUtil.transformFromThrift(b);
unMarshalledData = SerializationUtil.transformFromThrift(
Object.class, b);
} catch (SerializationException e) {
throw new CollaborationException(
"Could not deserialize object", e);
@ -346,8 +350,8 @@ public abstract class Tools {
byte[] uncompressedBytes = CompressionUtil
.uncompress(rawBytes);
unMarshalledData = SerializationUtil
.transformFromThrift(uncompressedBytes);
unMarshalledData = SerializationUtil.transformFromThrift(
Object.class, uncompressedBytes);
// unMarshalledData = SerializationUtil
// .transformFromThrift(createCompressionInputStream(rawBytes));
} catch (Exception e) {
@ -357,8 +361,9 @@ public abstract class Tools {
} else if (data.startsWith(ENV_JAXB)) {
String s = data.substring(ENV_JAXB.length());
try {
unMarshalledData = SerializationUtil.unmarshalFromXml(s);
} catch (JAXBException je) {
unMarshalledData = CollaborationXmlManager.getInstance()
.unmarshal(s);
} catch (SerializationException je) {
throw new CollaborationException(
"[JAXB] Could not deserialize object", je);
}
@ -366,9 +371,10 @@ public abstract class Tools {
String rawString = data.substring(ENV_JAXB_COMPRESSED.length());
try {
byte[] rawBytes = decodeFromBase64(rawString);
unMarshalledData = SerializationUtil
.unmarshalFromXml(new String(CompressionUtil
.uncompress(rawBytes)));
unMarshalledData = CollaborationXmlManager.getInstance()
.unmarshal(
new String(CompressionUtil
.uncompress(rawBytes)));
// unMarshalledData = SerializationUtil
// .unmarshalFromXml(createCompressionInputStream(rawBytes));
} catch (Exception je) {

View file

@ -1,26 +1,27 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Display
Bundle-Name: Collaboration Display
Bundle-SymbolicName: com.raytheon.uf.viz.collaboration.display;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Version: 1.13.0.qualifier
Bundle-Activator: com.raytheon.uf.viz.collaboration.display.Activator
Bundle-Vendor: RAYTHEON
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Eclipse-RegisterBuddy: com.raytheon.uf.viz.core
Require-Bundle: org.eclipse.core.runtime,
com.raytheon.uf.viz.core,
com.raytheon.viz.ui,
org.eclipse.ui;bundle-version="3.6.1",
org.eclipse.ui,
org.eclipse.ecf,
com.raytheon.uf.viz.collaboration.comm,
com.raytheon.uf.common.colormap;bundle-version="1.12.1174",
com.raytheon.uf.viz.remote.graphics;bundle-version="1.0.0",
com.raytheon.uf.viz.drawing;bundle-version="1.0.0",
com.raytheon.uf.common.comm;bundle-version="1.12.1174",
com.raytheon.uf.common.time;bundle-version="1.12.1174",
com.raytheon.uf.common.geospatial;bundle-version="1.12.1174",
com.raytheon.uf.common.util;bundle-version="1.12.1174",
com.raytheon.viz.core;bundle-version="1.12.1174"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
com.raytheon.uf.common.colormap,
com.raytheon.uf.viz.remote.graphics,
com.raytheon.uf.viz.drawing,
com.raytheon.uf.common.comm,
com.raytheon.uf.common.time,
com.raytheon.uf.common.geospatial,
com.raytheon.uf.common.util,
com.raytheon.viz.core
Export-Package: com.raytheon.uf.viz.collaboration.display,
com.raytheon.uf.viz.collaboration.display.data,
com.raytheon.uf.viz.collaboration.display.editor,

View file

@ -1,4 +0,0 @@
com.raytheon.uf.viz.collaboration.display.editor.CreateRemoteDisplay
com.raytheon.uf.viz.collaboration.display.rsc.event.SharedResource
com.raytheon.uf.viz.collaboration.display.rsc.event.ResourceCapabilityChanged
com.raytheon.uf.viz.collaboration.display.rsc.event.ResourcePropertiesChanged

View file

@ -21,4 +21,10 @@
class="com.raytheon.uf.viz.collaboration.display.rsc.rendering.PrimitiveRenderingHandler">
</renderingExtension>
</extension>
</plugin>
<extension point="com.raytheon.uf.viz.collaboration.xml">
<xmlRoot class="com.raytheon.uf.viz.collaboration.display.editor.CreateRemoteDisplay" />
<xmlRoot class="com.raytheon.uf.viz.collaboration.display.rsc.event.SharedResource" />
<xmlRoot class="com.raytheon.uf.viz.collaboration.display.rsc.event.ResourceCapabilityChanged" />
<xmlRoot class="com.raytheon.uf.viz.collaboration.display.rsc.event.ResourcePropertiesChanged" />
</extension>
</plugin>

View file

@ -25,7 +25,6 @@ import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.raytheon.uf.common.serialization.ISerializableObject;
import com.raytheon.uf.viz.core.drawables.AbstractRenderableDisplay;
/**
@ -37,9 +36,11 @@ import com.raytheon.uf.viz.core.drawables.AbstractRenderableDisplay;
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 16, 2012 njensen Initial creation
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Mar 16, 2012 njensen Initial creation
* Oct 31, 2013 2491 bsteffen Remove ISerializableObject
*
*
* </pre>
*
@ -49,7 +50,7 @@ import com.raytheon.uf.viz.core.drawables.AbstractRenderableDisplay;
@XmlAccessorType(XmlAccessType.NONE)
@XmlRootElement
public class CreateRemoteDisplay implements ISerializableObject {
public class CreateRemoteDisplay {
@XmlAttribute
private int displayId;

View file

@ -24,7 +24,6 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.raytheon.uf.common.serialization.ISerializableObject;
import com.raytheon.uf.viz.core.rsc.capabilities.AbstractCapability;
/**
@ -34,9 +33,10 @@ import com.raytheon.uf.viz.core.rsc.capabilities.AbstractCapability;
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 26, 2012 mschenke Initial creation
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Sep 26, 2012 mschenke Initial creation
* Oct 31, 2013 2491 bsteffen Remove ISerializableObject
*
* </pre>
*
@ -45,8 +45,7 @@ import com.raytheon.uf.viz.core.rsc.capabilities.AbstractCapability;
*/
@XmlAccessorType(XmlAccessType.NONE)
@XmlRootElement
public class ResourceCapabilityChanged extends AbstractResourceChangedEvent
implements ISerializableObject {
public class ResourceCapabilityChanged extends AbstractResourceChangedEvent {
@XmlElement
private AbstractCapability capability;

View file

@ -24,7 +24,6 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.raytheon.uf.common.serialization.ISerializableObject;
import com.raytheon.uf.viz.core.rsc.ResourceProperties;
/**
@ -34,9 +33,10 @@ import com.raytheon.uf.viz.core.rsc.ResourceProperties;
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 28, 2012 mschenke Initial creation
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Sep 28, 2012 mschenke Initial creation
* Oct 31, 2013 2491 bsteffen Remove ISerializableObject
*
* </pre>
*
@ -45,8 +45,7 @@ import com.raytheon.uf.viz.core.rsc.ResourceProperties;
*/
@XmlAccessorType(XmlAccessType.NONE)
@XmlRootElement
public class ResourcePropertiesChanged extends AbstractResourceChangedEvent
implements ISerializableObject {
public class ResourcePropertiesChanged extends AbstractResourceChangedEvent {
@XmlElement
private ResourceProperties properties;

View file

@ -25,7 +25,6 @@ import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.raytheon.uf.common.serialization.ISerializableObject;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
/**
@ -36,9 +35,11 @@ import com.raytheon.uf.viz.core.drawables.ResourcePair;
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 10, 2012 mschenke Initial creation
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Apr 10, 2012 mschenke Initial creation
* Oct 31, 2013 2491 bsteffen Remove ISerializableObject
*
*
* </pre>
*
@ -47,7 +48,7 @@ import com.raytheon.uf.viz.core.drawables.ResourcePair;
*/
@XmlAccessorType(XmlAccessType.NONE)
@XmlRootElement
public class SharedResource implements ISerializableObject {
public class SharedResource {
@XmlAttribute
private int displayId;

View file

@ -69,10 +69,12 @@ public class JAXBClassLocator {
private List<Class<?>> included = new ArrayList<Class<?>>(512);
private JAXBClassLocator(ISubClassLocator locator, Class<?> rootClass) {
private JAXBClassLocator(ISubClassLocator locator, Class<?>... rootClasses) {
this.locator = locator;
processed.addAll(getBuiltinTypes());
processClass(rootClass);
for (Class<?> rootClass : rootClasses) {
processClass(rootClass);
}
}
private void processClass(Class<?> clazz) {
@ -191,7 +193,7 @@ public class JAXBClassLocator {
* @return all classes that are can be in the xml.
*/
public static Collection<Class<?>> getJAXBClasses(ISubClassLocator locator,
Class<?> baseClass) {
return new JAXBClassLocator(locator, baseClass).getResults();
Class<?>... baseClasses) {
return new JAXBClassLocator(locator, baseClasses).getResults();
}
}