const AwaResourceDefinition * ServerSession_GetResourceDefinitionFromPath(const AwaServerSession * session, const char * path) { const AwaResourceDefinition * result = NULL; if (session != NULL) { result = SessionCommon_GetResourceDefinitionFromPath(session->SessionCommon, path); } else { LogErrorWithEnum(AwaError_SessionInvalid); } return result; }
AwaResourceType AwaChangeSet_GetResourceType(const AwaChangeSet * changeSet, const char * path) { if (changeSet != NULL) { const AwaResourceDefinition * resourceDefinition = SessionCommon_GetResourceDefinitionFromPath(OperationCommon_GetSessionCommon(changeSet->OperationCommon), path); if (resourceDefinition) { return AwaResourceDefinition_GetType(resourceDefinition); } } else { LogError("ChangeSet is null"); } return AwaResourceType_Invalid; }
AwaError ResponseCommon_BuildValues(ResponseCommon * response) { AwaError result = AwaError_Success; // success if no values are found if (response != NULL) { FreeValues(&response->Values); response->Values = Map_New(); if (response->Values != NULL) { // get the resource type for the path const OperationCommon * operation = ResponseCommon_GetOperation(response); if (operation != NULL) { const SessionCommon * sessionCommon = OperationCommon_GetSessionCommon(operation); if (sessionCommon != NULL) { TreeNode currentNode = response->ObjectsNode; while ((currentNode = ObjectsTree_GetNextLeafNode(currentNode)) != NULL) { char path[MAX_PATH_LENGTH] = { 0 }; ObjectsTree_GetPath(currentNode, path, sizeof(path)); if (Path_IsValidForResource(path)) { LogDebug("Build values path: %s", path); const AwaResourceDefinition * resourceDefinition = SessionCommon_GetResourceDefinitionFromPath(sessionCommon, path); if (resourceDefinition != NULL) { AwaResourceType resourceType = AwaResourceDefinition_GetType(resourceDefinition); if (resourceType != AwaResourceType_Invalid) { Value * value = Value_New(currentNode, resourceType); if (value != NULL) { if (!Map_Contains(response->Values, path)) { LogDebug("MAP item path: %s", path); Map_Put(response->Values, path, value); result = AwaError_Success; } else { result = LogErrorWithEnum(AwaError_Internal, "A value already exists for %s", path); } } else { // No value is fine - occurs in operations where we only expect path results in the response. } } else { result = LogErrorWithEnum(AwaError_DefinitionInvalid, "resourceDefinition for %s has invalid type", path); } } else { result = LogErrorWithEnum(AwaError_DefinitionInvalid, "resourceDefinition for %s is NULL", path); } } } } else { result = LogErrorWithEnum(AwaError_SessionInvalid, "session is NULL"); } } else { result = LogErrorWithEnum(AwaError_OperationInvalid, "operation is NULL"); } } else { result = LogErrorWithEnum(AwaError_OutOfMemory); } } else { result = LogErrorWithEnum(AwaError_ResponseInvalid, "response is NULL"); } return result; }