in src/utils/workflow_utils/src/workflow_utils.c [718:815]
ADUC_Result workflow_parse_peek_unprotected_workflow_properties(
JSON_Object* updateActionJsonObj,
ADUCITF_UpdateAction* outWorkflowUpdateAction,
char** outRootKeyPkgUrl_optional,
char** outWorkflowId_optional)
{
ADUC_Result result = {
.ResultCode = ADUC_GeneralResult_Failure,
.ExtendedResultCode = 0,
};
ADUCITF_UpdateAction updateAction = ADUCITF_UpdateAction_Undefined;
const char* workflowId = NULL;
const char* rootkeyPkgUrl = NULL;
char* tmpWorkflowId = NULL;
char* tmpRootKeyPkgUrl = NULL;
bool is_nodeployment_delay_period = false;
if (json_object_dothas_value(updateActionJsonObj, ADUCITF_FIELDNAME_WORKFLOW_DOT_ACTION))
{
updateAction = json_object_dotget_number(updateActionJsonObj, ADUCITF_FIELDNAME_WORKFLOW_DOT_ACTION);
if (updateAction == 0)
{
result.ExtendedResultCode = ADUC_ERC_UTILITIES_UPDATE_DATA_PARSER_BAD_WORKFLOW_ACTION;
goto done;
}
}
// workflowId can be NULL in some cases.
if (outWorkflowId_optional != NULL)
{
workflowId = json_object_dotget_string(updateActionJsonObj, WORKFLOW_PROPERTY_FIELD_WORKFLOW_DOT_ID);
if (IsNullOrEmpty(workflowId))
{
result.ExtendedResultCode = ADUC_ERC_UTILITIES_UPDATE_DATA_PARSER_BAD_UPDATE_MANIFEST;
goto done;
}
if (0 == strcmp(workflowId, "nodeployment"))
{
is_nodeployment_delay_period = true;
}
tmpWorkflowId = workflow_copy_string(workflowId);
if (tmpWorkflowId == NULL)
{
result.ExtendedResultCode = ADUC_ERC_NOMEM;
goto done;
}
}
if (outRootKeyPkgUrl_optional != NULL && !is_nodeployment_delay_period)
{
rootkeyPkgUrl = json_object_dotget_string(updateActionJsonObj, ADUCITF_FIELDNAME_ROOTKEY_PACKAGE_URL);
if (IsNullOrEmpty(rootkeyPkgUrl))
{
result.ExtendedResultCode = ADUC_ERC_UTILITIES_UPDATE_DATA_PARSER_EMPTY_OR_MISSING_ROOTKEY_PKG_URL;
goto done;
}
tmpRootKeyPkgUrl = workflow_copy_string(rootkeyPkgUrl);
if (tmpRootKeyPkgUrl == NULL)
{
result.ExtendedResultCode = ADUC_ERC_NOMEM;
goto done;
}
}
// Commit the optional out parameters now that nothing can goto done.
if (outWorkflowUpdateAction != NULL)
{
*outWorkflowUpdateAction = updateAction;
}
if (outWorkflowId_optional != NULL && tmpWorkflowId != NULL)
{
*outWorkflowId_optional = tmpWorkflowId;
tmpWorkflowId = NULL;
}
if (outRootKeyPkgUrl_optional != NULL)
{
*outRootKeyPkgUrl_optional = tmpRootKeyPkgUrl;
tmpRootKeyPkgUrl = NULL;
}
result.ResultCode = ADUC_GeneralResult_Success;
result.ExtendedResultCode = 0;
done:
workflow_free_string(tmpWorkflowId);
workflow_free_string(tmpRootKeyPkgUrl);
return result;
}