Commit cf56d5b7 authored by Nicolas Delaby's avatar Nicolas Delaby

Transport only xml with GID in SyncML Frames instead of local ids.

Only GID means something for both part.
ie. <object id="foo"/> become <object gid="2340234098"/>


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35810 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0f29ba17
...@@ -800,8 +800,16 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -800,8 +800,16 @@ class XMLSyncUtilsMixin(SyncCode):
# If there is no xml, we re-send all the objects # If there is no xml, we re-send all the objects
xml_string = xml_object xml_string = xml_object
else: else:
# This object has changed on this side, we have to generate some xmldiff # This object has changed on this side, we have to generate some xmldiff
xml_string = self.getXupdateObject(xml_object, signature.getXML()) gid = signature.getGid()
xml_object_with_gid = conduit.replaceIdFromXML(xml_object, 'gid',
gid)
previous_xml_with_gid = conduit.replaceIdFromXML(
signature.getXML(), 'gid', gid)
xml_string = self.getXupdateObject(xml_object_with_gid,
previous_xml_with_gid)
#LOG('XMLSyncUtils diff:%s' % object.getPath(), INFO,
#xupdate_string)
if xml_string.count('\n') > self.MAX_LINES: if xml_string.count('\n') > self.MAX_LINES:
# This make comment fails, so we need to replace # This make comment fails, so we need to replace
more_data = True more_data = True
...@@ -826,15 +834,14 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -826,15 +834,14 @@ class XMLSyncUtilsMixin(SyncCode):
if subscriber_xupdate is not None: if subscriber_xupdate is not None:
# The modification in the xml from signature is compare and update # The modification in the xml from signature is compare and update
# with xml_xupdate from subscriber # with xml_xupdate from subscriber
old_xml = signature.getXML() previous_xml_with_gid = conduit.replaceIdFromXML(
conduit.updateNode( signature.getXML(), 'gid', gid, as_string=False)
xml=subscriber_xupdate, conduit.updateNode(xml=subscriber_xupdate, object=object,
object=object, previous_xml=previous_xml_with_gid,
previous_xml=old_xml, force=(domain.getDomainType() == self.SUB),
force=(domain.getDomainType() == self.SUB), simulate=False)
simulate=0) xml_object = conduit.getXMLFromObjectWithId(object,
xml_object = conduit.getXMLFromObjectWithId(object,\ xml_mapping=domain.getXMLMapping())
xml_mapping=domain.getXMLMapping())
signature.setTempXML(xml_object) signature.setTempXML(xml_object)
if set_synchronized: # We have to do that after this previous update if set_synchronized: # We have to do that after this previous update
# We should not have this case when we are in CONFLICT_MERGE # We should not have this case when we are in CONFLICT_MERGE
...@@ -845,11 +852,12 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -845,11 +852,12 @@ class XMLSyncUtilsMixin(SyncCode):
# some modification was already made and the update # some modification was already made and the update
# may not apply correctly # may not apply correctly
xml_update = signature.getPartialXML() xml_update = signature.getPartialXML()
conduit.updateNode( previous_xml_with_gid = conduit.replaceIdFromXML(signature.getXML(),
xml=xml_update, 'gid', gid,
object=object, as_string=False)
previous_xml=signature.getXML(), conduit.updateNode(xml=xml_update, object=object,
force=1) previous_xml=previous_xml_with_gid, force=True,
gid=gid)
xml_confirmation_list.append(self.SyncMLConfirmation( xml_confirmation_list.append(self.SyncMLConfirmation(
cmd_id=cmd_id, cmd_id=cmd_id,
target_ref=object_gid, target_ref=object_gid,
...@@ -1001,22 +1009,21 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -1001,22 +1009,21 @@ class XMLSyncUtilsMixin(SyncCode):
# Object was retrieve but need to be updated without recreated # Object was retrieve but need to be updated without recreated
# usefull when an object is only deleted by workflow. # usefull when an object is only deleted by workflow.
if data_subnode is not None: if data_subnode is not None:
actual_xml = conduit.getXMLFromObjectWithId(object, actual_xml = conduit.getXMLFromObjectWithGid(object, gid,
xml_mapping=domain.getXMLMapping(force=1)) xml_mapping=domain.getXMLMapping(force=True))
actual_xml = etree.XML(actual_xml, parser=parser) # use gid to compare because their ids can be different
xml_string_gid = conduit.replaceIdFromXML(data_subnode, gid) data_subnode = conduit.replaceIdFromXML(data_subnode, 'gid', gid)
actual_xml_gid = conduit.replaceIdFromXML(actual_xml, gid) # produce xupdate
# use gid as compare key because their ids can be different data_subnode = self.getXupdateObject(data_subnode, actual_xml)
data_subnode = self.getXupdateObject(xml_string_gid, actual_xml_gid)
conflict_list.extend(conduit.updateNode( conflict_list.extend(conduit.updateNode(
xml=data_subnode, xml=data_subnode,
object=object, object=object,
previous_xml=signature.getXML(), previous_xml=actual_xml,
force=force, force=force,
simulate=simulate, simulate=simulate,
reset=reset)) reset=reset))
xml_object = conduit.getXMLFromObjectWithId(object,\ xml_object = conduit.getXMLFromObjectWithId(object,
xml_mapping=domain.getXMLMapping()) xml_mapping=domain.getXMLMapping())
signature.setTempXML(xml_object) signature.setTempXML(xml_object)
if object is not None: if object is not None:
#LOG('applyActionList', DEBUG, 'addNode, found the object') #LOG('applyActionList', DEBUG, 'addNode, found the object')
...@@ -1046,6 +1053,9 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -1046,6 +1053,9 @@ class XMLSyncUtilsMixin(SyncCode):
signature = subscriber.getSignatureFromGid(gid) signature = subscriber.getSignatureFromGid(gid)
#LOG('applyActionList', DEBUG, 'previous signature: %s' % str(signature)) #LOG('applyActionList', DEBUG, 'previous signature: %s' % str(signature))
previous_xml = signature.getXML() previous_xml = signature.getXML()
if previous_xml:
# can be None
previous_xml = conduit.replaceIdFromXML(previous_xml, 'gid', gid)
conflict_list += conduit.updateNode( conflict_list += conduit.updateNode(
xml=data_subnode, xml=data_subnode,
object=object, object=object,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment