First cut at signing support.
[shibboleth/cpp-xmltooling.git] / xmltooling / AbstractDOMCachingXMLObject.cpp
index 655f22d..7ffc58c 100644 (file)
@@ -123,6 +123,8 @@ XMLObject* AbstractDOMCachingXMLObject::clone() const
             Category::getInstance(XMLTOOLING_LOGCAT".DOM").error(\r
                 "DOM clone failed, unable to locate unmarshaller for element (%s)", q->toString().c_str()\r
                 );\r
+            domCopy->getOwnerDocument()->release();\r
+            throw UnmarshallingException("Unable to locate unmarshaller for cloned element.");\r
         }\r
         try {\r
             return u->unmarshall(domCopy, true);    // bind document\r
@@ -133,3 +135,28 @@ XMLObject* AbstractDOMCachingXMLObject::clone() const
     }\r
     return NULL;\r
 }\r
+\r
+XMLObject* AbstractDOMCachingXMLObject::prepareForAssignment(XMLObject* oldValue, XMLObject* newValue) {\r
+\r
+    if (newValue && newValue->hasParent())\r
+        throw XMLObjectException("child XMLObject cannot be added - it is already the child of another XMLObject");\r
+\r
+    if (!oldValue) {\r
+        if (newValue) {\r
+            releaseThisandParentDOM();\r
+            newValue->setParent(this);\r
+            return newValue;\r
+        }\r
+        else {\r
+            return NULL;\r
+        }\r
+    }\r
+\r
+    if (oldValue != newValue) {\r
+        delete oldValue;\r
+        releaseThisandParentDOM();\r
+        newValue->setParent(this);\r
+    }\r
+\r
+    return newValue;\r
+}\r