diff --git a/base/dynamicobject.cpp b/base/dynamicobject.cpp index 0f3a72d33..de63cff7d 100644 --- a/base/dynamicobject.cpp +++ b/base/dynamicobject.cpp @@ -40,6 +40,9 @@ DynamicObject::DynamicObject(const Dictionary::Ptr& serializedObject) RegisterAttribute("__source", Attribute_Local); RegisterAttribute("methods", Attribute_Config); + if (!serializedObject->Contains("configTx")) + throw invalid_argument("Serialized object must contain a config snapshot."); + /* apply state from the config item/remote update */ ApplyUpdate(serializedObject, true); @@ -392,12 +395,8 @@ void DynamicObject::DumpObjects(const String& filename) /* only persist properties for replicated objects or for objects * that are marked as persistent */ - if (!object->GetSource().IsEmpty() /*|| object->IsPersistent()*/) { + if (!object->GetSource().IsEmpty() /*|| object->IsPersistent()*/) types |= Attribute_Config; - persistentObject->Set("create", true); - } else { - persistentObject->Set("create", false); - } Dictionary::Ptr update = object->BuildUpdate(0, types); @@ -453,10 +452,10 @@ void DynamicObject::RestoreObjects(const String& filename) String type = persistentObject->Get("type"); String name = persistentObject->Get("name"); - int create = persistentObject->Get("create"); + bool hasConfig = persistentObject->Contains("configTx"); Dictionary::Ptr update = persistentObject->Get("update"); - if (create != 0) { + if (hasConfig) { DynamicObject::Ptr object = Create(type, update); object->Register(); } else { diff --git a/components/cibsync/cibsynccomponent.cpp b/components/cibsync/cibsynccomponent.cpp index 41547ad92..dd44c2913 100644 --- a/components/cibsync/cibsynccomponent.cpp +++ b/components/cibsync/cibsynccomponent.cpp @@ -131,7 +131,7 @@ bool CIBSyncComponent::ShouldReplicateObject(const DynamicObject::Ptr& object) void CIBSyncComponent::FetchObjectsHandler(const Endpoint::Ptr& sender) { - pair trange; + pair trange = DynamicObject::GetTypes(); DynamicObject::TypeMap::iterator tt; for (tt = trange.first; tt != trange.second; tt++) { DynamicObject::Ptr object; @@ -156,7 +156,7 @@ void CIBSyncComponent::LocalObjectRegisteredHandler(const DynamicObject::Ptr& ob return; EndpointManager::GetInstance()->SendMulticastMessage(m_Endpoint, - MakeObjectMessage(object, "config::ObjectCommitted", 0, true)); + MakeObjectMessage(object, "config::ObjectUpdate", 0, true)); } void CIBSyncComponent::LocalObjectUnregisteredHandler(const DynamicObject::Ptr& object) diff --git a/components/discovery/discoverycomponent.cpp b/components/discovery/discoverycomponent.cpp index 8da64c451..ab82a7906 100644 --- a/components/discovery/discoverycomponent.cpp +++ b/components/discovery/discoverycomponent.cpp @@ -356,7 +356,7 @@ void DiscoveryComponent::ProcessDiscoveryMessage(const String& identity, const D if (message.GetService(&service) && !service.IsEmpty()) info->Service = service; - DynamicObject::Ptr endpointConfig = DynamicObject::GetObject("endpoint", identity); + DynamicObject::Ptr endpointConfig = DynamicObject::GetObject("Endpoint", identity); Dictionary::Ptr roles; if (endpointConfig) endpointConfig->GetAttribute("roles", &roles);