def test_xml_serialization(self): """ test new serialization in contrast with legacy serializer to ensure compatibility """ from FreeTAKServer.model.FTSModel.Event import Event xmlstring = '<event version="2.0" uid="GeoChat.ANDROID-359975090666199.FEATHER.27d8ef23-8578-4cb4-8f53-02f5dc150cd2" type="b-t-f" how="h-g-i-g-o" start="2021-01-03T19:01:35.472Z" time="2021-01-03T19:01:35.472Z" stale="2021-01-04T19:01:35.472Z"><detail><__chat id="S-1-5-21-2720623347-3037847324-4167270909-1002" parent="RootContactGroup" chatroom="FEATHER" groupOwner="false"><chatgrp uid0="ANDROID-359975090666199" uid1="S-1-5-21-2720623347-3037847324-4167270909-1002" id="S-1-5-21-2720623347-3037847324-4167270909-1002"/></__chat><link uid="ANDROID-359975090666199" relation="p-p" type="a-f-G-E-V-A"/><remarks time="2021-01-03T19:01:35.472Z" source="BAO.F.ATAK.ANDROID-359975090666199" to="S-1-5-21-2720623347-3037847324-4167270909-1002">at VDO</remarks><__serverdestination destinations="192.168.2.66:4242:tcp:ANDROID-359975090666199"/><marti><dest callsign = "WOLF"/><dest callsign="GALLOP"/><dest callsign="FEATHER"/></marti></detail><point le="9999999.0" ce="3.2" hae="22.958679722315807" lon="-66.10803" lat="43.855711"/></event>' fts_obj = XmlSerializer().from_format_to_fts_object( xmlstring, Event.GeoChat()) obj = XmlSerializer().from_fts_object_to_format(fts_obj) print(etree.tostring(obj).decode()) legacyftsobj = XMLCoTController().serialize_CoT_to_model( Event.GeoChat(), etree.fromstring(xmlstring)) legacy_string = XMLCoTController().serialize_model_to_CoT(legacyftsobj) self.assertEqual(legacy_string.decode(), etree.tostring(obj).decode())
def __init__(self, json): tempObject = event.GeoChat() object = SendGeoChat() object.setModelObject(tempObject) object.modelObject = self._serializeJsonToModel(object.modelObject, json) object.setXmlString(XMLCoTController().serialize_model_to_CoT(object.modelObject)) self.setCoTObject(object)
def SendGeoChat(): try: json = request.json modelObject = Event.GeoChat() out = ApplyFullJsonController().serializeJsonToModel(modelObject, json) xml = XMLCoTController().serialize_model_to_CoT(out, 'event') from FreeTAKServer.controllers.SpecificCoTControllers.SendGeoChatController import SendGeoChatController rawcot = RawCoT() rawcot.xmlString = xml rawcot.clientInformation = None object = SendGeoChatController(rawcot) APIPipe.send(object.getObject()) return '200', 200 except Exception as e: print(e)
def from_api_to_fts_object(self, api_json: dict) -> Types.specific_cot: from FreeTAKServer.model.SpecificCoT.SendGeoChat import SendGeoChat serialized_json = self.serialize_initial_json(api_json) CoTObject = self._create_cot_object(serialized_json, Event.GeoChat(), SendGeoChat()) return CoTObject