|
|
|
@@ -95,7 +95,8 @@
|
|
|
|
|
<cfreturn representationOf(out)/>
|
|
|
|
|
</cffunction>
|
|
|
|
|
|
|
|
|
|
<cffunction name="post" hint="Создание нового CFS параметра операции.">
|
|
|
|
|
|
|
|
|
|
<!--- <cffunction name="post" hint="Создание нового CFS параметра операции.">
|
|
|
|
|
<cfargument name="instanceOperationUid" type="string" required=true hint="type:guid"/>
|
|
|
|
|
<cfargument name="svcOperationCfsParamId" type="string" required=true hint="type:integer"/>
|
|
|
|
|
<cfargument name="paramValue" type="string" required=true hint="type:string ***Валидацию пока не проводим, а надо"/>
|
|
|
|
@@ -137,9 +138,9 @@
|
|
|
|
|
.withHeaders({location: "./#local.instanceOperationCfsParamUid#"})
|
|
|
|
|
.withStatus(201, "Created")
|
|
|
|
|
/>
|
|
|
|
|
</cffunction>
|
|
|
|
|
</cffunction> --->
|
|
|
|
|
|
|
|
|
|
<cffunction name="post" hint="Создание нового CFS параметра операции.">
|
|
|
|
|
<cffunction name="post" hint="Создание нового CFS параметра операции.">
|
|
|
|
|
<cfargument name="instanceOperationUid" type="string" required=true hint="type:guid"/>
|
|
|
|
|
<cfargument name="svcOperationCfsParamId" type="string" required=true hint="type:integer"/>
|
|
|
|
|
<cfargument name="paramValue" type="string" required=true hint="type:string ***Валидацию пока не проводим, а надо"/>
|
|
|
|
@@ -148,6 +149,7 @@
|
|
|
|
|
<cfset this.helper.validateField(arguments, "instanceOperationUid", "guid")/>
|
|
|
|
|
<cfset this.helper.validateField(arguments, "svcOperationCfsParamId", "integer")/>
|
|
|
|
|
<!--- Еще возможна ошибка, что мы подадим параметр не от своей операции или сервиса - он останется невидим для всех --->
|
|
|
|
|
<cfset checkParam(arguments.svcOperationCfsParamId, arguments.paramValue)/>
|
|
|
|
|
|
|
|
|
|
<cfcatch type="invalidParamValue">
|
|
|
|
|
<cfreturn representationOf(this.helper.formatBadRequestError(cfcatch)).withStatus(400)/>
|
|
|
|
@@ -167,27 +169,30 @@
|
|
|
|
|
<cfreturn representationOf(this.helper.formatMessage("Operation already started", "Parameter creation disabled for started operation")).withStatus(422)/>
|
|
|
|
|
</cfif>
|
|
|
|
|
|
|
|
|
|
<!--- Проверить: параметр от нашего ли сервиса --->
|
|
|
|
|
<!--- Проверка: параметр от нашего ли сервиса *** и операции --->
|
|
|
|
|
<cfquery name="local.qInstanceService" result="local.result">
|
|
|
|
|
select e.service_id
|
|
|
|
|
select e.service_id, io.operation
|
|
|
|
|
from instance_operation io
|
|
|
|
|
join instance e on (io.instance_uid=e.instance_uid)
|
|
|
|
|
where io.instance_operation_uid=<cfqueryparam cfsqltype="cf_sql_other" value="#arguments.instanceOperationUid#"/>
|
|
|
|
|
</cfquery>
|
|
|
|
|
<cfquery name="local.qTemplateSvc" result="local.result">
|
|
|
|
|
select so.svc_id
|
|
|
|
|
select so.svc_id, so.operation
|
|
|
|
|
from svc_operation_cfs_param sop
|
|
|
|
|
join svc_operation so on (sop.svc_operation_id=so.svc_operation_id)
|
|
|
|
|
where sop.svc_operation_cfs_param_id=<cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.svcOperationCfsParamId#"/>
|
|
|
|
|
</cfquery>
|
|
|
|
|
<cfif local.qInstanceService.service_id NEQ local.qTemplateSvc.svc_id>
|
|
|
|
|
<cfreturn representationOf(this.helper.formatMessage("Invalid CFS parameter", "Parameter specified does not belong to this service")).withStatus(400)/>
|
|
|
|
|
</cfif>
|
|
|
|
|
</cfif>
|
|
|
|
|
<cfif local.qInstanceService.operation NEQ local.qTemplateSvc.operation>
|
|
|
|
|
<cfreturn representationOf(this.helper.formatMessage("Invalid CFS parameter", "Parameter specified does not belong to this operation")).withStatus(400)/>
|
|
|
|
|
</cfif>
|
|
|
|
|
|
|
|
|
|
<cfset var msg=checkParam(arguments.svcOperationCfsParamId, arguments.paramValue)/>
|
|
|
|
|
<!--- <cfset var msg=checkParam(arguments.svcOperationCfsParamId, arguments.paramValue)/>
|
|
|
|
|
<cfif len(msg)>
|
|
|
|
|
<cfreturn representationOf(this.helper.formatMessage("Invalid CFS parameter value", msg)).withStatus(400)/>
|
|
|
|
|
</cfif>
|
|
|
|
|
</cfif> --->
|
|
|
|
|
|
|
|
|
|
<cfquery name="local.qSave">
|
|
|
|
|
insert into instance_operation_cfs_param (
|
|
|
|
@@ -200,10 +205,12 @@
|
|
|
|
|
,<cfqueryparam cfsqltype="cf_sql_timestamp" value="#Now()#" />
|
|
|
|
|
,<cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.usrId#" />
|
|
|
|
|
);
|
|
|
|
|
</cfquery>
|
|
|
|
|
|
|
|
|
|
<cfcatch type="any"><!--- <cfrethrow/> --->
|
|
|
|
|
<cfreturn representationOf(this.helper.formatException(cfcatch, "Internal Error")).withStatus(500)/><!--- это не нужно показывать в продуктиве --->
|
|
|
|
|
</cfquery>
|
|
|
|
|
<!--- <cfcatch type="invalidParamValue">
|
|
|
|
|
<cfreturn representationOf(this.helper.formatBadRequestError(cfcatch)).withStatus(400)/>
|
|
|
|
|
</cfcatch> --->
|
|
|
|
|
<cfcatch type="any">
|
|
|
|
|
<cfreturn representationOf(this.helper.formatException(cfcatch, "Internal Error")).withStatus(500)/>
|
|
|
|
|
</cfcatch>
|
|
|
|
|
</cftry>
|
|
|
|
|
|
|
|
|
@@ -211,13 +218,13 @@
|
|
|
|
|
.withHeaders({location: "./#local.instanceOperationCfsParamUid#"})
|
|
|
|
|
.withStatus(201, "Created")
|
|
|
|
|
/>
|
|
|
|
|
</cffunction>
|
|
|
|
|
</cffunction>
|
|
|
|
|
|
|
|
|
|
<cffunction name="checkParam">
|
|
|
|
|
<cfargument name="svcOperationCfsParamId" type="numeric" required=true/>
|
|
|
|
|
<cfargument name="paramValue" required=true/>
|
|
|
|
|
<!--- *** Вероятно, стоит возвращать конкретную ругань --->
|
|
|
|
|
|
|
|
|
|
<!--- принадлежит ли параметр к данному сервису, проверяется выше --->
|
|
|
|
|
<cfquery name="qSvcOperationCfsParam">
|
|
|
|
|
select sop.svc_operation_cfs_param
|
|
|
|
|
,sop.value_list
|
|
|
|
@@ -232,24 +239,31 @@
|
|
|
|
|
</cfquery>
|
|
|
|
|
|
|
|
|
|
<cfif qSvcOperationCfsParam.is_required AND len(arguments.paramValue) EQ 0>
|
|
|
|
|
<cfreturn "Missing required parameter (#qSvcOperationCfsParam.svc_operation_cfs_param#)"/>
|
|
|
|
|
<!--- <cfreturn "Missing required parameter (#qSvcOperationCfsParam.svc_operation_cfs_param#)"/> --->
|
|
|
|
|
<cfthrow type="invalidParamValue" message="Missing required parameter (#qSvcOperationCfsParam.svc_operation_cfs_param#)"/>
|
|
|
|
|
<cfelseif len(arguments.paramValue) AND NOT checkValue(arguments.paramValue,qSvcOperationCfsParam.data_type)>
|
|
|
|
|
<cfreturn "Invalid format (#qSvcOperationCfsParam.svc_operation_cfs_param#)"/>
|
|
|
|
|
<!--- <cfreturn "Invalid format (#qSvcOperationCfsParam.svc_operation_cfs_param#)"/> --->
|
|
|
|
|
<cfthrow type="invalidParamValue" message="Invalid format (#qSvcOperationCfsParam.svc_operation_cfs_param#)"/>
|
|
|
|
|
</cfif>
|
|
|
|
|
|
|
|
|
|
<cfif len(arguments.paramValue) AND listLen(qSvcOperationCfsParam.value_list) GT 0 AND NOT listFind(qSvcOperationCfsParam.value_list, arguments.paramValue)>
|
|
|
|
|
<cfreturn "Значение параметра #qSvcOperationCfsParam.svc_operation_cfs_param# отсутствует в списке #qSvcOperationCfsParam.value_list#"/>
|
|
|
|
|
<!--- <cfreturn "Значение параметра #qSvcOperationCfsParam.svc_operation_cfs_param# отсутствует в списке #qSvcOperationCfsParam.value_list#"/> --->
|
|
|
|
|
<cfthrow type="invalidParamValue" message="Значение параметра #qSvcOperationCfsParam.svc_operation_cfs_param# отсутствует в списке #qSvcOperationCfsParam.value_list#"/>
|
|
|
|
|
</cfif>
|
|
|
|
|
<cfif len(arguments.paramValue) AND qSvcOperationCfsParam.maxlength GT 0 AND len(arguments.paramValue) GT qSvcOperationCfsParam.maxlength>
|
|
|
|
|
<cfreturn "Длина #qSvcOperationCfsParam.svc_operation_cfs_param# превышает #qSvcOperationCfsParam.maxlength#"/>
|
|
|
|
|
<!--- <cfreturn "Длина #qSvcOperationCfsParam.svc_operation_cfs_param# превышает #qSvcOperationCfsParam.maxlength#"/> --->
|
|
|
|
|
<cfthrow type="invalidParamValue" message="Длина #qSvcOperationCfsParam.svc_operation_cfs_param# превышает #qSvcOperationCfsParam.maxlength#"/>
|
|
|
|
|
</cfif>
|
|
|
|
|
<cfif len(arguments.paramValue) AND qSvcOperationCfsParam.minlength GT 0 AND len(arguments.paramValue) LT qSvcOperationCfsParam.minlength>
|
|
|
|
|
<cfreturn "Длина #qSvcOperationCfsParam.svc_operation_cfs_param# меньше #qSvcOperationCfsParam.minlength#"/> <!--- *** попробовать cfparam type="regex" --->
|
|
|
|
|
<!--- <cfreturn "Длина #qSvcOperationCfsParam.svc_operation_cfs_param# меньше #qSvcOperationCfsParam.minlength#"/> ---> <!--- *** попробовать cfparam type="regex" --->
|
|
|
|
|
<cfthrow type="invalidParamValue" message="Длина #qSvcOperationCfsParam.svc_operation_cfs_param# меньше #qSvcOperationCfsParam.minlength#"/>
|
|
|
|
|
</cfif>
|
|
|
|
|
<cfif len(arguments.paramValue) AND len(qSvcOperationCfsParam.regex) AND reFind(qSvcOperationCfsParam.regex,arguments.paramValue) EQ 0>
|
|
|
|
|
<cfreturn 'Pattern "#qSvcOperationCfsParam.regex#" does not match "#arguments.paramValue#"'/>
|
|
|
|
|
<!--- <cfreturn 'Pattern "#qSvcOperationCfsParam.regex#" does not match "#arguments.paramValue#"'/> --->
|
|
|
|
|
<cfthrow type="invalidParamValue" message='Pattern "#qSvcOperationCfsParam.regex#" does not match "#arguments.paramValue#"'/>
|
|
|
|
|
</cfif>
|
|
|
|
|
|
|
|
|
|
<!--- *** интересно, как мы ухитряемся проверить уникальность параметра, если он относится к операции, а не к экземпляру. Нам-то нужна уникальность для стейта (и то, скорее, единовременная, и интересовать будут только успешные операции) --->
|
|
|
|
|
<cfswitch expression=#qSvcOperationCfsParam.unique_scope#>
|
|
|
|
|
<cfcase value="provider">
|
|
|
|
|
<cfquery name="qUnique">
|
|
|
|
@@ -263,7 +277,8 @@
|
|
|
|
|
</cfquery>
|
|
|
|
|
<!--- <cfdump var=#qUnique#/> --->
|
|
|
|
|
<cfif qUnique.cnt GT 0>
|
|
|
|
|
<cfreturn '#qSvcOperationCfsParam.svc_operation_cfs_param# = "#arguments.paramValue#" is not unique in the provider scope'/>
|
|
|
|
|
<!--- <cfreturn '#qSvcOperationCfsParam.svc_operation_cfs_param# = "#arguments.paramValue#" is not unique in the provider scope'/> --->
|
|
|
|
|
<cfthrow type="invalidParamValue" message='#qSvcOperationCfsParam.svc_operation_cfs_param# = "#arguments.paramValue#" is not unique in the provider scope'/>
|
|
|
|
|
</cfif>
|
|
|
|
|
</cfcase>
|
|
|
|
|
<cfcase value="tenant">
|
|
|
|
@@ -286,14 +301,13 @@
|
|
|
|
|
</cfquery>
|
|
|
|
|
<!--- <cfdump var=#qUnique#/> --->
|
|
|
|
|
<cfif qUnique.cnt GT 0>
|
|
|
|
|
<cfreturn '#qSvcOperationCfsParam.svc_operation_cfs_param# = "#arguments.paramValue#" is not unique in the tenant scope'/>
|
|
|
|
|
</cfif>
|
|
|
|
|
|
|
|
|
|
<!--- <cfreturn '#qSvcOperationCfsParam.svc_operation_cfs_param# = "#arguments.paramValue#" is not unique in the tenant scope'/> --->
|
|
|
|
|
<cfthrow type="invalidParamValue" message='#qSvcOperationCfsParam.svc_operation_cfs_param# = "#arguments.paramValue#" is not unique in the tenant scope'/>
|
|
|
|
|
</cfif>
|
|
|
|
|
</cfcase>
|
|
|
|
|
<cfdefaultcase></cfdefaultcase>
|
|
|
|
|
</cfswitch>
|
|
|
|
|
|
|
|
|
|
<cfreturn ""/>
|
|
|
|
|
</cfswitch>
|
|
|
|
|
<!--- <cfreturn ""/> --->
|
|
|
|
|
</cffunction>
|
|
|
|
|
|
|
|
|
|
<cffunction name="checkValue" returnType="boolean">
|
|
|
|
|