Esempio n. 1
0
AwaError AwaClientSetOperation_CreateObjectInstance(AwaClientSetOperation * operation, const char * path)
{
    AwaError result = AwaError_Unspecified;

    if (path != NULL)
    {
        AwaObjectID objectID;
        AwaResourceID resourceID;

        if (Path_IsValid(path))
        {
            objectID = Path_GetObjectID(path);
            resourceID = Path_GetResourceID(path);

            if ((objectID != AWA_INVALID_ID) && (resourceID == AWA_INVALID_ID))
            {
                if (operation != NULL)
                {
                    TreeNode resultNode;
                    if ((result = OperationCommon_AddPathV2(operation->Common, path, &resultNode)) == AwaError_Success && resultNode != NULL)
                    {
                        //NB: if object instance ID isn't specified in the path we have to check the response for the generated ID
                        if (ClientSetOperation_AddCreate(resultNode) == InternalError_Success)
                        {
                            result = AwaError_Success;
                        }
                        else
                        {
                            result = LogErrorWithEnum(AwaError_Internal, "Failed to add value to path");
                        }
                    }
                }
                else
                {
                    result = LogErrorWithEnum(AwaError_OperationInvalid, "Operation is NULL");
                }
            }
            else
            {
                result = LogErrorWithEnum(AwaError_PathInvalid,  "%s is not a valid object or object instance path", path);
            }
        }
        else
        {
            result = LogErrorWithEnum(AwaError_PathInvalid,  "%s is not a valid path", path);
        }
    }
    else
    {
        result = LogErrorWithEnum(AwaError_PathInvalid, "Path is NULL");
    }
    return result;
}
Esempio n. 2
0
static void ClientSubscribe_PerformAddPathCallback(const char * path, void * value, void * context)
{
    PerformAddPathCallbackContext * addPathContext = (PerformAddPathCallbackContext *)context;
    if (addPathContext->Result == AwaError_Success)
    {
        OperationCommon * operationCommon = addPathContext->OperationCommon;
        AwaClientSubscription * subscription = (AwaClientSubscription *)value;

        TreeNode resultNode;
        if ((addPathContext->Result = OperationCommon_AddPathV2(operationCommon, subscription->Path, &resultNode)) == AwaError_Success)
        {
            if (ClientSubscribe_AddAwaSubscribeType(resultNode, subscription) == InternalError_Success)
            {
                addPathContext->Result = AwaError_Success;
            }
            else
            {
                addPathContext->Result = LogErrorWithEnum(AwaError_Internal, "Failed to add value to path");
            }
        }
    }
}