Reading Legacy Event Data
Summary
Whenever an action or trigger instance is initialized, the configuration data, serialized and encoded as a byte array, is deserialized into the JUI page used to store configuration options and presented to the user. When the configuration data is still in the legacy format, this will cause an exception during deserialization and the configuration will be defaulted to a blank JUI page. To modify this process so legacy data can be properly read from the data the ConvertLegacyData method needs to be overridden in your implementation of the AbstractActionType Class or AbstractTriggerType Class.
Override the ConvertLegacyData method
Override this method and include the necessary code to deserialize your custom legacy data. If you used the data serialization methods defined in the legacy API, you can take advantage of the TrigActInfo.DeserializeLegacyData(TOutObject) Method to deserialize your legacy data. For example:
C# Example
protected override byte[] ConvertLegacyData(byte[] inData) {
MyLegacyEventActionDataClass legacyAction;
if (inData != null && inData.Length > 0) {
try {
//attempt to deserialize the byte array to your custom class
legacyAction = TrigActInfo.DeserializeLegacyData<MyLegacyEventActionDataClass>(inData);
}
catch (Exception ex) {
//if there was a problem - set the legacy data object to null
legacyAction = null;
}
}
if (legacyAction == null) {
return new byte[0];
}
//Replace the following line with your own code to upgrade your legacy data to modern config page
ConfigPage = ConvertLegacyDataToConfigPage(legacyAction);
//return the Data property to automatically convert the ConfigPage to a byte array for later storage
return Data;
}
VB.NET Example
Protected Overrides Function ConvertLegacyData(inData As Byte()) As Byte()
Dim legacyAction As MyLegacyEventActionDataClass
If inData IsNot Nothing AndAlso inData.Length > 0 Then
Try
'attempt to deserialize the byte array to your custom class
legacyAction = TrigActInfo.DeserializeLegacyData(Of MyLegacyEventActionDataClass)(inData)
Catch ex As Exception
'if there was a problem - set the legacy data object to null
legacyAction = Nothing
End Try
End If
If legacyAction Is Nothing
Return New Byte() {}
End If
'Replace the following line with your own code to upgrade your legacy data to modern config page
ConfigPage = ConvertLegacyDataToConfigPage(legacyAction)
'return the Data property to automatically convert the ConfigPage to a byte array for later storage
Return Data
End Function