You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
2.4 KiB
92 lines
2.4 KiB
#include"kutil.h"
|
|
#define ITK_err 919012
|
|
|
|
int Connor_allow_Workflow(EPM_action_message_t msg) {
|
|
int ifail = ITK_ok, att_cnt = 0, arg_cnt = 0;
|
|
char* arg = NULL, * argflag = NULL, * argvalue = NULL;
|
|
tag_t* attachments = NULLTAG, task_tag = NULLTAG, rootTask_tag;
|
|
string type, grant_value;
|
|
vector<string> types;
|
|
arg_cnt = TC_number_of_arguments(msg.arguments);
|
|
if (arg_cnt > 0) {
|
|
for (int i = 0; i < arg_cnt; i++) {
|
|
arg = TC_next_argument(msg.arguments);
|
|
ITKCALL(ifail = ITK_ask_argument_named_value(arg, &argflag, &argvalue));
|
|
if (strcmp(argflag, "type") == 0) {
|
|
type.assign(argvalue);
|
|
printf("%s\n", argvalue);
|
|
}
|
|
else if (strcmp(argflag, "grant") == 0) {
|
|
grant_value.assign(argvalue);
|
|
printf("%s\n", argvalue);
|
|
}
|
|
MEM_free(argflag);
|
|
MEM_free(argvalue);
|
|
}
|
|
}
|
|
else {
|
|
EMH_store_error_s1(EMH_severity_error, ITK_err, "未配置流程参数");
|
|
ifail = 1;
|
|
goto end;
|
|
}
|
|
{
|
|
if (grant_value.empty()) {
|
|
EMH_store_error_s1(EMH_severity_error, ITK_err, "未配置流程参数:-grant");
|
|
ifail = 1;
|
|
goto end;
|
|
}
|
|
Split(type, ";", types);
|
|
if (types.size() == 0) {
|
|
EMH_store_error_s1(EMH_severity_error, ITK_err, "未配置流程参数:-type");
|
|
ifail = 1;
|
|
goto end;
|
|
}
|
|
}
|
|
task_tag = msg.task;
|
|
if (task_tag == NULLTAG) {
|
|
ifail = 1;
|
|
goto end;
|
|
}
|
|
ITKCALL(ifail = EPM_ask_root_task(task_tag, &rootTask_tag));
|
|
//获取目标下所有对象
|
|
ITKCALL(ifail = EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments));
|
|
if (att_cnt == 0) {
|
|
goto end;
|
|
}
|
|
printf("types的长度为%d\n", types.size());
|
|
for (int i = 0; i < att_cnt; i++)
|
|
{
|
|
tag_t target_tag = attachments[i];
|
|
char* object_type = NULL;
|
|
AOM_ask_value_string(target_tag,"object_type",&object_type);
|
|
printf("当前对象的类型为:%s\n",object_type);
|
|
int sum = 0;
|
|
for each (string type in types)
|
|
{
|
|
if (isTypeOf(target_tag, type.c_str()))
|
|
{
|
|
sum++;
|
|
//EMH_store_error_s1(EMH_severity_error, ITK_err, "对象类型在流程参数-type中不存在");
|
|
//ifail = 1;
|
|
//goto end;
|
|
}
|
|
}
|
|
printf("sum的长度为%d\n", sum);
|
|
if (sum == 0) {
|
|
EMH_store_error_s1(EMH_severity_error, ITK_err, "对象类型在流程参数-type中不存在");
|
|
ifail = 1;
|
|
goto end;
|
|
}
|
|
logical verdict = false;
|
|
ITKCALL(ifail = AM_check_privilege(target_tag, grant_value.c_str(), &verdict));
|
|
if (!verdict) {
|
|
EMH_store_error_s1(EMH_severity_error, ITK_err, "对象权限不符合!");
|
|
ifail = 1;
|
|
goto end;
|
|
}
|
|
}
|
|
|
|
end:
|
|
DOFREE(attachments);
|
|
return ifail;
|
|
} |