NotifyOriginalAttributes();
}
-void ConfigObject::RestoreAttribute(const String& attr)
+void ConfigObject::RestoreAttribute(const String& attr, bool updateVersion)
{
Type::Ptr type = GetReflectionType();
original_attributes->Remove(attr);
SetField(fid, newValue);
- SetVersion(Utility::GetTime());
+ if (updateVersion)
+ SetVersion(Utility::GetTime());
}
bool ConfigObject::IsAttributeModified(const String& attr) const
void ClearExtension(const String& key);
void ModifyAttribute(const String& attr, const Value& value, bool updateVersion = true);
- void RestoreAttribute(const String& attr);
+ void RestoreAttribute(const String& attr, bool updateVersion = true);
bool IsAttributeModified(const String& attr) const;
void Register(void);
}
}
+ /* check whether original attributes changed and restore them locally */
+ Array::Ptr newOriginalAttributes = params->Get("original_attributes");
+ Dictionary::Ptr objOriginalAttributes = object->GetOriginalAttributes();
+
+ if (newOriginalAttributes && objOriginalAttributes) {
+ std::vector<String> restoreAttrs;
+
+ {
+ ObjectLock xlock(objOriginalAttributes);
+ BOOST_FOREACH(const Dictionary::Pair& kv, objOriginalAttributes) {
+ /* original attribute was removed, restore it */
+ if (!newOriginalAttributes->Contains(kv.first))
+ restoreAttrs.push_back(kv.first);
+ }
+ }
+
+ BOOST_FOREACH(const String& key, restoreAttrs) {
+ /* do not update the object version yet. */
+ object->RestoreAttribute(key, false);
+ }
+ }
+
/* keep the object version in sync with the sender */
object->SetVersion(objVersion, false, origin);
Dictionary::Ptr original_attributes = object->GetOriginalAttributes();
Dictionary::Ptr modified_attributes = new Dictionary();
+ Array::Ptr newOriginalAttributes = new Array();
if (original_attributes) {
ObjectLock olock(original_attributes);
}
modified_attributes->Set(kv.first, value);
+
+ newOriginalAttributes->Add(kv.first);
}
}
params->Set("modified_attributes", modified_attributes);
+ /* only send the original attribute keys */
+ params->Set("original_attributes", newOriginalAttributes);
+
message->Set("params", params);
#ifdef I2_DEBUG