From: <rm...@hy...> - 2008-01-06 20:26:40
|
Author: rmorgan Date: 2008-01-06 09:40:34 -0800 (Sun, 06 Jan 2008) New Revision: 7428 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=7428 Modified: trunk/src/org/hyperic/hq/livedata/Resources.properties trunk/src/org/hyperic/hq/livedata/agent/client/LiveDataClient.java Log: Attempt to deserialize the live data xml result on the server side to catch errors in serialization caused by differing class versions between the agent and server. [HHQ-1402] Modified: trunk/src/org/hyperic/hq/livedata/Resources.properties =================================================================== --- trunk/src/org/hyperic/hq/livedata/Resources.properties 2008-01-06 16:39:48 UTC (rev 7427) +++ trunk/src/org/hyperic/hq/livedata/Resources.properties 2008-01-06 17:40:34 UTC (rev 7428) @@ -82,3 +82,5 @@ format.type.text=Text format.type.html=HTML + +error.serialization=Unable to deserialize agent data. You may need to update your agent. Modified: trunk/src/org/hyperic/hq/livedata/agent/client/LiveDataClient.java =================================================================== --- trunk/src/org/hyperic/hq/livedata/agent/client/LiveDataClient.java 2008-01-06 16:39:48 UTC (rev 7427) +++ trunk/src/org/hyperic/hq/livedata/agent/client/LiveDataClient.java 2008-01-06 17:40:34 UTC (rev 7428) @@ -33,17 +33,34 @@ import org.hyperic.hq.agent.AgentRemoteValue; import org.hyperic.hq.appdef.shared.AppdefEntityID; import org.hyperic.util.config.ConfigResponse; +import org.hyperic.util.i18n.MessageBundle; +import com.thoughtworks.xstream.XStream; public class LiveDataClient { private LiveDataCommandsAPI _api; private AgentConnection _conn; + private static final MessageBundle BUNDLE = + MessageBundle.getBundle("org.hyperic.hq.livedata.Resources"); + public LiveDataClient(AgentConnection agentConnection) { _conn = agentConnection; _api = new LiveDataCommandsAPI(); } + /** + * Helper method to validate the XStream serialization on the server. In + * some cases (i.e. outdated Agents) we may get objects that cannot be + * serialized back to their original form. + * + * @param xml The xml representation of the object. + */ + private void serializeData(String xml) { + XStream xstream = new XStream(); + xstream.fromXML(xml); + } + public LiveDataResult getData(AppdefEntityID id, String type, String command, ConfigResponse config) @@ -58,7 +75,14 @@ _api.getVersion(), args); LiveData_result val = new LiveData_result(res); String xml = val.getResult(); - return new LiveDataResult(id, xml); + + try { + serializeData(xml); + return new LiveDataResult(id, xml); + } catch (Throwable t) { + return new LiveDataResult(id, t, + BUNDLE.format("error.serialization")); + } } catch (Exception e) { return new LiveDataResult(id, e, e.getMessage()); } |