|
@@ -18,8 +18,8 @@ checkParentReference(UA_Server *server, UA_Session *session, UA_NodeClass nodeCl
|
|
/* See if the parent exists */
|
|
/* See if the parent exists */
|
|
const UA_Node *parent = UA_NodeStore_get(server->nodestore, parentNodeId);
|
|
const UA_Node *parent = UA_NodeStore_get(server->nodestore, parentNodeId);
|
|
if(!parent) {
|
|
if(!parent) {
|
|
- UA_LOG_DEBUG_SESSION(server->config.logger, session,
|
|
|
|
- "AddNodes: Parent node not found");
|
|
|
|
|
|
+ UA_LOG_INFO_SESSION(server->config.logger, session,
|
|
|
|
+ "AddNodes: Parent node not found");
|
|
return UA_STATUSCODE_BADPARENTNODEIDINVALID;
|
|
return UA_STATUSCODE_BADPARENTNODEIDINVALID;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -27,22 +27,22 @@ checkParentReference(UA_Server *server, UA_Session *session, UA_NodeClass nodeCl
|
|
const UA_ReferenceTypeNode *referenceType =
|
|
const UA_ReferenceTypeNode *referenceType =
|
|
(const UA_ReferenceTypeNode*)UA_NodeStore_get(server->nodestore, referenceTypeId);
|
|
(const UA_ReferenceTypeNode*)UA_NodeStore_get(server->nodestore, referenceTypeId);
|
|
if(!referenceType) {
|
|
if(!referenceType) {
|
|
- UA_LOG_DEBUG_SESSION(server->config.logger, session,
|
|
|
|
- "AddNodes: Reference type to the parent not found");
|
|
|
|
|
|
+ UA_LOG_INFO_SESSION(server->config.logger, session,
|
|
|
|
+ "AddNodes: Reference type to the parent not found");
|
|
return UA_STATUSCODE_BADREFERENCETYPEIDINVALID;
|
|
return UA_STATUSCODE_BADREFERENCETYPEIDINVALID;
|
|
}
|
|
}
|
|
|
|
|
|
/* Check if the referencetype is a reference type node */
|
|
/* Check if the referencetype is a reference type node */
|
|
if(referenceType->nodeClass != UA_NODECLASS_REFERENCETYPE) {
|
|
if(referenceType->nodeClass != UA_NODECLASS_REFERENCETYPE) {
|
|
- UA_LOG_DEBUG_SESSION(server->config.logger, session,
|
|
|
|
- "AddNodes: Reference type to the parent invalid");
|
|
|
|
|
|
+ UA_LOG_INFO_SESSION(server->config.logger, session,
|
|
|
|
+ "AddNodes: Reference type to the parent invalid");
|
|
return UA_STATUSCODE_BADREFERENCETYPEIDINVALID;
|
|
return UA_STATUSCODE_BADREFERENCETYPEIDINVALID;
|
|
}
|
|
}
|
|
|
|
|
|
/* Check that the reference type is not abstract */
|
|
/* Check that the reference type is not abstract */
|
|
if(referenceType->isAbstract == true) {
|
|
if(referenceType->isAbstract == true) {
|
|
- UA_LOG_DEBUG_SESSION(server->config.logger, session,
|
|
|
|
- "AddNodes: Abstract reference type to the parent invalid");
|
|
|
|
|
|
+ UA_LOG_INFO_SESSION(server->config.logger, session,
|
|
|
|
+ "AddNodes: Abstract reference type to the parent not allowed");
|
|
return UA_STATUSCODE_BADREFERENCENOTALLOWED;
|
|
return UA_STATUSCODE_BADREFERENCENOTALLOWED;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -54,16 +54,16 @@ checkParentReference(UA_Server *server, UA_Session *session, UA_NodeClass nodeCl
|
|
nodeClass == UA_NODECLASS_REFERENCETYPE) {
|
|
nodeClass == UA_NODECLASS_REFERENCETYPE) {
|
|
/* type needs hassubtype reference to the supertype */
|
|
/* type needs hassubtype reference to the supertype */
|
|
if(!UA_NodeId_equal(referenceTypeId, &subtypeId)) {
|
|
if(!UA_NodeId_equal(referenceTypeId, &subtypeId)) {
|
|
- UA_LOG_DEBUG_SESSION(server->config.logger, session,
|
|
|
|
- "AddNodes: New type node need to have a "
|
|
|
|
- "hassubtype reference");
|
|
|
|
|
|
+ UA_LOG_INFO_SESSION(server->config.logger, session,
|
|
|
|
+ "AddNodes: New type node need to have a "
|
|
|
|
+ "HasSubType reference");
|
|
return UA_STATUSCODE_BADREFERENCENOTALLOWED;
|
|
return UA_STATUSCODE_BADREFERENCENOTALLOWED;
|
|
}
|
|
}
|
|
/* supertype needs to be of the same node type */
|
|
/* supertype needs to be of the same node type */
|
|
if(parent->nodeClass != nodeClass) {
|
|
if(parent->nodeClass != nodeClass) {
|
|
- UA_LOG_DEBUG_SESSION(server->config.logger, session,
|
|
|
|
- "AddNodes: New type node needs to be of the same "
|
|
|
|
- "node type as the parent");
|
|
|
|
|
|
+ UA_LOG_INFO_SESSION(server->config.logger, session,
|
|
|
|
+ "AddNodes: New type node needs to be of the same "
|
|
|
|
+ "node type as the parent");
|
|
return UA_STATUSCODE_BADPARENTNODEIDINVALID;
|
|
return UA_STATUSCODE_BADPARENTNODEIDINVALID;
|
|
}
|
|
}
|
|
return UA_STATUSCODE_GOOD;
|
|
return UA_STATUSCODE_GOOD;
|
|
@@ -74,8 +74,8 @@ checkParentReference(UA_Server *server, UA_Session *session, UA_NodeClass nodeCl
|
|
UA_NODEID_NUMERIC(0, UA_NS0ID_HIERARCHICALREFERENCES);
|
|
UA_NODEID_NUMERIC(0, UA_NS0ID_HIERARCHICALREFERENCES);
|
|
if(!isNodeInTree(server->nodestore, referenceTypeId,
|
|
if(!isNodeInTree(server->nodestore, referenceTypeId,
|
|
&hierarchicalReference, &subtypeId, 1)) {
|
|
&hierarchicalReference, &subtypeId, 1)) {
|
|
- UA_LOG_DEBUG_SESSION(server->config.logger, session,
|
|
|
|
- "AddNodes: Reference type is not hierarchical");
|
|
|
|
|
|
+ UA_LOG_INFO_SESSION(server->config.logger, session,
|
|
|
|
+ "AddNodes: Reference type is not hierarchical");
|
|
return UA_STATUSCODE_BADREFERENCETYPEIDINVALID;
|
|
return UA_STATUSCODE_BADREFERENCETYPEIDINVALID;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -417,7 +417,7 @@ Service_AddNodes_existing(UA_Server *server, UA_Session *session, UA_Node *node,
|
|
|
|
|
|
/* Check the namespaceindex */
|
|
/* Check the namespaceindex */
|
|
if(node->nodeId.namespaceIndex >= server->namespacesSize) {
|
|
if(node->nodeId.namespaceIndex >= server->namespacesSize) {
|
|
- UA_LOG_DEBUG_SESSION(server->config.logger, session, "AddNodes: Namespace invalid");
|
|
|
|
|
|
+ UA_LOG_INFO_SESSION(server->config.logger, session, "AddNodes: Namespace invalid");
|
|
UA_NodeStore_deleteNode(node);
|
|
UA_NodeStore_deleteNode(node);
|
|
return UA_STATUSCODE_BADNODEIDINVALID;
|
|
return UA_STATUSCODE_BADNODEIDINVALID;
|
|
}
|
|
}
|
|
@@ -426,9 +426,9 @@ Service_AddNodes_existing(UA_Server *server, UA_Session *session, UA_Node *node,
|
|
UA_StatusCode retval = checkParentReference(server, session, node->nodeClass,
|
|
UA_StatusCode retval = checkParentReference(server, session, node->nodeClass,
|
|
parentNodeId, referenceTypeId);
|
|
parentNodeId, referenceTypeId);
|
|
if(retval != UA_STATUSCODE_GOOD) {
|
|
if(retval != UA_STATUSCODE_GOOD) {
|
|
- UA_LOG_DEBUG_SESSION(server->config.logger, session,
|
|
|
|
- "AddNodes: Checking the reference to the parent returned"
|
|
|
|
- "error code %s", UA_StatusCode_name(retval));
|
|
|
|
|
|
+ UA_LOG_INFO_SESSION(server->config.logger, session,
|
|
|
|
+ "AddNodes: Checking the reference to the parent returned"
|
|
|
|
+ "error code %s", UA_StatusCode_name(retval));
|
|
UA_NodeStore_deleteNode(node);
|
|
UA_NodeStore_deleteNode(node);
|
|
return retval;
|
|
return retval;
|
|
}
|
|
}
|
|
@@ -436,9 +436,9 @@ Service_AddNodes_existing(UA_Server *server, UA_Session *session, UA_Node *node,
|
|
/* Add the node to the nodestore */
|
|
/* Add the node to the nodestore */
|
|
retval = UA_NodeStore_insert(server->nodestore, node);
|
|
retval = UA_NodeStore_insert(server->nodestore, node);
|
|
if(retval != UA_STATUSCODE_GOOD) {
|
|
if(retval != UA_STATUSCODE_GOOD) {
|
|
- UA_LOG_DEBUG_SESSION(server->config.logger, session,
|
|
|
|
- "AddNodes: Node could not be added to the nodestore "
|
|
|
|
- "with error code %s", UA_StatusCode_name(retval));
|
|
|
|
|
|
+ UA_LOG_INFO_SESSION(server->config.logger, session,
|
|
|
|
+ "AddNodes: Node could not be added to the nodestore "
|
|
|
|
+ "with error code %s", UA_StatusCode_name(retval));
|
|
return retval;
|
|
return retval;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -446,8 +446,8 @@ Service_AddNodes_existing(UA_Server *server, UA_Session *session, UA_Node *node,
|
|
if(addedNodeId) {
|
|
if(addedNodeId) {
|
|
retval = UA_NodeId_copy(&node->nodeId, addedNodeId);
|
|
retval = UA_NodeId_copy(&node->nodeId, addedNodeId);
|
|
if(retval != UA_STATUSCODE_GOOD) {
|
|
if(retval != UA_STATUSCODE_GOOD) {
|
|
- UA_LOG_DEBUG_SESSION(server->config.logger, session,
|
|
|
|
- "AddNodes: Could not copy the nodeid");
|
|
|
|
|
|
+ UA_LOG_INFO_SESSION(server->config.logger, session,
|
|
|
|
+ "AddNodes: Could not copy the nodeid");
|
|
goto remove_node;
|
|
goto remove_node;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -461,9 +461,9 @@ Service_AddNodes_existing(UA_Server *server, UA_Session *session, UA_Node *node,
|
|
item.targetNodeId.nodeId = *parentNodeId;
|
|
item.targetNodeId.nodeId = *parentNodeId;
|
|
retval = Service_AddReferences_single(server, session, &item);
|
|
retval = Service_AddReferences_single(server, session, &item);
|
|
if(retval != UA_STATUSCODE_GOOD) {
|
|
if(retval != UA_STATUSCODE_GOOD) {
|
|
- UA_LOG_DEBUG_SESSION(server->config.logger, session,
|
|
|
|
- "AddNodes: Could not add the reference to the parent"
|
|
|
|
- "with error code %s", UA_StatusCode_name(retval));
|
|
|
|
|
|
+ UA_LOG_INFO_SESSION(server->config.logger, session,
|
|
|
|
+ "AddNodes: Could not add the reference to the parent"
|
|
|
|
+ "with error code %s", UA_StatusCode_name(retval));
|
|
goto remove_node;
|
|
goto remove_node;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -483,9 +483,9 @@ Service_AddNodes_existing(UA_Server *server, UA_Session *session, UA_Node *node,
|
|
retval = instantiateNode(server, session, &node->nodeId, node->nodeClass,
|
|
retval = instantiateNode(server, session, &node->nodeId, node->nodeClass,
|
|
typeDefinition, instantiationCallback);
|
|
typeDefinition, instantiationCallback);
|
|
if(retval != UA_STATUSCODE_GOOD) {
|
|
if(retval != UA_STATUSCODE_GOOD) {
|
|
- UA_LOG_DEBUG_SESSION(server->config.logger, session,
|
|
|
|
- "AddNodes: Could not instantiate the node with"
|
|
|
|
- "error code 0x%08x", retval);
|
|
|
|
|
|
+ UA_LOG_INFO_SESSION(server->config.logger, session,
|
|
|
|
+ "AddNodes: Could not instantiate the node with"
|
|
|
|
+ "error code %s", UA_StatusCode_name(retval));
|
|
goto remove_node;
|
|
goto remove_node;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -531,9 +531,9 @@ copyCommonVariableAttributes(UA_Server *server, UA_VariableNode *node,
|
|
UA_StatusCode retval = UA_STATUSCODE_GOOD;
|
|
UA_StatusCode retval = UA_STATUSCODE_GOOD;
|
|
if(UA_NodeId_equal(&node->nodeId, &basevartype) ||
|
|
if(UA_NodeId_equal(&node->nodeId, &basevartype) ||
|
|
UA_NodeId_equal(&node->nodeId, &basedatavartype)) {
|
|
UA_NodeId_equal(&node->nodeId, &basedatavartype)) {
|
|
- node->dataType = UA_NODEID_NUMERIC(0, UA_NS0ID_BASEDATATYPE);
|
|
|
|
- node->valueRank = -2;
|
|
|
|
- return retval;
|
|
|
|
|
|
+ node->dataType = UA_NODEID_NUMERIC(0, UA_NS0ID_BASEDATATYPE);
|
|
|
|
+ node->valueRank = -2;
|
|
|
|
+ return retval;
|
|
}
|
|
}
|
|
|
|
|
|
const UA_VariableTypeNode *vt =
|
|
const UA_VariableTypeNode *vt =
|
|
@@ -552,14 +552,18 @@ copyCommonVariableAttributes(UA_Server *server, UA_VariableNode *node,
|
|
return retval;
|
|
return retval;
|
|
|
|
|
|
/* Set the array dimensions. Check only against the vt. */
|
|
/* Set the array dimensions. Check only against the vt. */
|
|
- retval = compatibleArrayDimensions(attr->arrayDimensionsSize, attr->arrayDimensions,
|
|
|
|
- vt->arrayDimensionsSize, vt->arrayDimensions);
|
|
|
|
- if(retval != UA_STATUSCODE_GOOD)
|
|
|
|
- return retval;
|
|
|
|
- retval = UA_Array_copy(attr->arrayDimensions, attr->arrayDimensionsSize,
|
|
|
|
- (void**)&node->arrayDimensions, &UA_TYPES[UA_TYPES_UINT32]);
|
|
|
|
- if(retval != UA_STATUSCODE_GOOD)
|
|
|
|
|
|
+ retval = compatibleArrayDimensions(vt->arrayDimensionsSize, vt->arrayDimensions,
|
|
|
|
+ attr->arrayDimensionsSize, attr->arrayDimensions);
|
|
|
|
+ if(retval == UA_STATUSCODE_GOOD) {
|
|
|
|
+ retval = UA_Array_copy(attr->arrayDimensions, attr->arrayDimensionsSize,
|
|
|
|
+ (void**)&node->arrayDimensions, &UA_TYPES[UA_TYPES_UINT32]);
|
|
|
|
+ }
|
|
|
|
+ if(retval != UA_STATUSCODE_GOOD) {
|
|
|
|
+ UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_SERVER,
|
|
|
|
+ "Array dimensions incompatible with the VariableType "
|
|
|
|
+ "with error code %s", UA_StatusCode_name(retval));
|
|
return retval;
|
|
return retval;
|
|
|
|
+ }
|
|
node->arrayDimensionsSize = attr->arrayDimensionsSize;
|
|
node->arrayDimensionsSize = attr->arrayDimensionsSize;
|
|
|
|
|
|
/* Set the valuerank */
|
|
/* Set the valuerank */
|
|
@@ -567,15 +571,32 @@ copyCommonVariableAttributes(UA_Server *server, UA_VariableNode *node,
|
|
retval = writeValueRankAttribute(server, node, attr->valueRank, vt->valueRank);
|
|
retval = writeValueRankAttribute(server, node, attr->valueRank, vt->valueRank);
|
|
else /* workaround common error where the valuerank is left as 0 */
|
|
else /* workaround common error where the valuerank is left as 0 */
|
|
node->valueRank = vt->valueRank;
|
|
node->valueRank = vt->valueRank;
|
|
- if(retval != UA_STATUSCODE_GOOD)
|
|
|
|
|
|
+ if(retval != UA_STATUSCODE_GOOD) {
|
|
|
|
+ UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_SERVER,
|
|
|
|
+ "Value Rank incompatible with the VariableType "
|
|
|
|
+ "with error code %s", UA_StatusCode_name(retval));
|
|
return retval;
|
|
return retval;
|
|
-
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
/* Set the value */
|
|
/* Set the value */
|
|
UA_DataValue value;
|
|
UA_DataValue value;
|
|
UA_DataValue_init(&value);
|
|
UA_DataValue_init(&value);
|
|
- value.value = attr->value;
|
|
|
|
value.hasValue = true;
|
|
value.hasValue = true;
|
|
- retval |= writeValueAttribute(server, node, &value, NULL);
|
|
|
|
|
|
+ value.value = attr->value;
|
|
|
|
+ value.value.storageType = UA_VARIANT_DATA_NODELETE;
|
|
|
|
+
|
|
|
|
+ /* Use the default value from the vt if none is defined */
|
|
|
|
+ if(!value.value.type)
|
|
|
|
+ readValueAttribute(server, (const UA_VariableNode *)vt, &value);
|
|
|
|
+
|
|
|
|
+ /* Write the value to the node */
|
|
|
|
+ retval = writeValueAttribute(server, node, &value, NULL);
|
|
|
|
+ if(retval != UA_STATUSCODE_GOOD) {
|
|
|
|
+ UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_SERVER,
|
|
|
|
+ "Could not set the value of the new node "
|
|
|
|
+ "with error code %s", UA_StatusCode_name(retval));
|
|
|
|
+ }
|
|
|
|
+ UA_DataValue_deleteMembers(&value);
|
|
return retval;
|
|
return retval;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -704,14 +725,23 @@ Service_AddNodes_single(UA_Server *server, UA_Session *session,
|
|
/* Create the node from the attributes*/
|
|
/* Create the node from the attributes*/
|
|
UA_Node *node = NULL;
|
|
UA_Node *node = NULL;
|
|
result->statusCode = createNodeFromAttributes(server, item, &node);
|
|
result->statusCode = createNodeFromAttributes(server, item, &node);
|
|
- if(result->statusCode != UA_STATUSCODE_GOOD)
|
|
|
|
|
|
+ if(result->statusCode != UA_STATUSCODE_GOOD) {
|
|
|
|
+ UA_LOG_INFO_SESSION(server->config.logger, session,
|
|
|
|
+ "Could not add node with error code %s",
|
|
|
|
+ UA_StatusCode_name(result->statusCode));
|
|
return;
|
|
return;
|
|
|
|
+ }
|
|
|
|
|
|
/* Run consistency checks and add the node */
|
|
/* Run consistency checks and add the node */
|
|
UA_assert(node != NULL);
|
|
UA_assert(node != NULL);
|
|
result->statusCode = Service_AddNodes_existing(server, session, node, &item->parentNodeId.nodeId,
|
|
result->statusCode = Service_AddNodes_existing(server, session, node, &item->parentNodeId.nodeId,
|
|
&item->referenceTypeId, &item->typeDefinition.nodeId,
|
|
&item->referenceTypeId, &item->typeDefinition.nodeId,
|
|
instantiationCallback, &result->addedNodeId);
|
|
instantiationCallback, &result->addedNodeId);
|
|
|
|
+ if(result->statusCode != UA_STATUSCODE_GOOD) {
|
|
|
|
+ UA_LOG_INFO_SESSION(server->config.logger, session,
|
|
|
|
+ "Could not add node with error code %s",
|
|
|
|
+ UA_StatusCode_name(result->statusCode));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
void Service_AddNodes(UA_Server *server, UA_Session *session,
|
|
void Service_AddNodes(UA_Server *server, UA_Session *session,
|