Browse Source

Allow abstract node types in case of events

According to the specification, events are supposed to be allowed to
have abstract types. Changing the behavior of the node management
allows for checking whether the node being added is an event and thus
skipping the check for whether the type is abstract.
Ari 5 years ago
parent
commit
c1a5a163d3
1 changed files with 5 additions and 2 deletions
  1. 5 2
      src/server/ua_services_nodemanagement.c

+ 5 - 2
src/server/ua_services_nodemanagement.c

@@ -729,13 +729,16 @@ AddNode_addRefs(UA_Server *server, UA_Session *session, const UA_NodeId *nodeId,
                 if(retval != UA_STATUSCODE_GOOD)
                     goto cleanup;
                 /* Object node created of an abstract ObjectType. Only allowed
-                 * if within BaseObjectType folder */
+                 * if within BaseObjectType folder or if it's an event (subType of BaseEventType) */
                 const UA_NodeId objectTypes = UA_NODEID_NUMERIC(0, UA_NS0ID_BASEOBJECTTYPE);
                 UA_Boolean isInBaseObjectType = isNodeInTree(server->nsCtx, parentNodeId, &objectTypes,
                                                              parentTypeHierachy, parentTypeHierachySize);
 
+                const UA_NodeId eventTypes = UA_NODEID_NUMERIC(0, UA_NS0ID_BASEEVENTTYPE);
+                UA_Boolean isInBaseEventType = isNodeInTree(server->nsCtx, &type->nodeId, &eventTypes, &hasSubtype, 1);
+
                 UA_Array_delete(parentTypeHierachy, parentTypeHierachySize, &UA_TYPES[UA_TYPES_NODEID]);
-                if(!isInBaseObjectType) {
+                if(!isInBaseObjectType && !(isInBaseEventType && UA_NodeId_isNull(parentNodeId))) {
                     UA_LOG_NODEID_WRAP(nodeId, UA_LOG_INFO_SESSION(&server->config.logger, session,
                                         "AddNodes: Type of object node %.*s must "
                                         "be ObjectType and not be abstract",