|
@@ -178,38 +178,29 @@ addNodeInternalWithType(UA_Server *server, UA_Node *node, const UA_NodeId parent
|
|
|
}
|
|
|
|
|
|
// delete any children of an instance without touching the object itself
|
|
|
-static void deleteInstanceChildren(UA_Server *server, UA_NodeId *objectNodeId) {
|
|
|
- UA_RCU_LOCK();
|
|
|
- UA_BrowseDescription bDes;
|
|
|
- UA_BrowseDescription_init(&bDes);
|
|
|
- UA_NodeId_copy(objectNodeId, &bDes.nodeId );
|
|
|
- bDes.browseDirection = UA_BROWSEDIRECTION_FORWARD;
|
|
|
- bDes.nodeClassMask = UA_NODECLASS_OBJECT | UA_NODECLASS_VARIABLE | UA_NODECLASS_METHOD;
|
|
|
- bDes.resultMask = UA_BROWSERESULTMASK_ISFORWARD | UA_BROWSERESULTMASK_NODECLASS | UA_BROWSERESULTMASK_REFERENCETYPEINFO;
|
|
|
- UA_BrowseResult bRes;
|
|
|
- UA_BrowseResult_init(&bRes);
|
|
|
- Service_Browse_single(server, &adminSession, NULL, &bDes, 0, &bRes);
|
|
|
- for(size_t i=0; i<bRes.referencesSize; ++i) {
|
|
|
- UA_ReferenceDescription *rd = &bRes.references[i];
|
|
|
- if((rd->nodeClass == UA_NODECLASS_OBJECT || rd->nodeClass == UA_NODECLASS_VARIABLE))
|
|
|
- {
|
|
|
- Service_DeleteNodes_single(server, &adminSession, &rd->nodeId.nodeId, UA_TRUE) ;
|
|
|
- }
|
|
|
- else if (rd->nodeClass == UA_NODECLASS_METHOD)
|
|
|
- {
|
|
|
- UA_DeleteReferencesItem dR;
|
|
|
- UA_DeleteReferencesItem_init(&dR);
|
|
|
- dR.sourceNodeId = *objectNodeId;
|
|
|
- dR.isForward = UA_TRUE;
|
|
|
- UA_NodeId_copy(&rd->referenceTypeId, &dR.referenceTypeId);
|
|
|
- UA_NodeId_copy(&rd->nodeId.nodeId, &dR.targetNodeId.nodeId);
|
|
|
- dR.deleteBidirectional = UA_TRUE;
|
|
|
- Service_DeleteReferences_single(server, &adminSession, &dR);
|
|
|
- UA_DeleteReferencesItem_deleteMembers(&dR);
|
|
|
+static void
|
|
|
+deleteInstanceChildren(UA_Server *server, UA_NodeId *objectNodeId) {
|
|
|
+ /* Browse for children */
|
|
|
+ UA_BrowseDescription bDes;
|
|
|
+ UA_BrowseDescription_init(&bDes);
|
|
|
+ bDes.nodeId = *objectNodeId;
|
|
|
+ bDes.browseDirection = UA_BROWSEDIRECTION_FORWARD;
|
|
|
+ bDes.nodeClassMask = UA_NODECLASS_OBJECT | UA_NODECLASS_VARIABLE | UA_NODECLASS_METHOD;
|
|
|
+ bDes.resultMask = UA_BROWSERESULTMASK_ISFORWARD | UA_BROWSERESULTMASK_NODECLASS | UA_BROWSERESULTMASK_REFERENCETYPEINFO;
|
|
|
+ UA_BrowseResult bRes = UA_Server_browse(server, 0, &bDes);
|
|
|
+
|
|
|
+ /* Delete Children */
|
|
|
+ for(size_t i=0; i<bRes.referencesSize; ++i) {
|
|
|
+ UA_ReferenceDescription *rd = &bRes.references[i];
|
|
|
+ if((rd->nodeClass == UA_NODECLASS_OBJECT || rd->nodeClass == UA_NODECLASS_VARIABLE)) {
|
|
|
+ UA_Server_deleteNode(server, rd->nodeId.nodeId, true);
|
|
|
+ } else if (rd->nodeClass == UA_NODECLASS_METHOD) {
|
|
|
+ UA_Server_deleteReference(server, *objectNodeId, rd->referenceTypeId,
|
|
|
+ true, rd->nodeId, true);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- UA_BrowseResult_deleteMembers(&bRes);
|
|
|
- UA_RCU_UNLOCK();
|
|
|
+
|
|
|
+ UA_BrowseResult_deleteMembers(&bRes);
|
|
|
}
|
|
|
|
|
|
/**********/
|