028 prevent repeated run
This commit is contained in:
@@ -10,33 +10,50 @@
|
||||
<cfargument name="instanceOperationUid" type="string" required=true hint="type:guid"/>
|
||||
|
||||
<cfset local={}/>
|
||||
<cfset local.instanceUid=#createGUID()#/>
|
||||
<!--- <cfset local.instanceUid=#createGUID()#/> --->
|
||||
|
||||
<!--- *** Проверить наличие обязательных CFS параметров
|
||||
Создать RFS параметры
|
||||
(валидируем CFS параметры при создании, а не сейчас) --->
|
||||
(валидируем CFS параметры при создании, а не сейчас)
|
||||
Проверить, что операция уже не выполняется
|
||||
--->
|
||||
|
||||
<cftry>
|
||||
<!---NOT NULL fields--->
|
||||
<cfset this.helper.keyExistsAndValid(arguments, "instanceOperationUid", "guid")/>
|
||||
|
||||
|
||||
<!--- Check operation status --->
|
||||
<cfquery name="local.qCheckStarted" result="local.result">
|
||||
select io.dt_submit, io.dt_finish, io.submit_result
|
||||
from instance_operation io
|
||||
where io.instance_operation_uid=<cfqueryparam cfsqltype="cf_sql_other" value="#arguments.instanceOperationUid#" null=#!isValid('guid',arguments.instanceOperationUid)#/>
|
||||
</cfquery> <!--- <cfdump var=#local.qCheckStarted.dt_finish#/><cfabort/> --->
|
||||
<cfif local.qCheckStarted.recordCount EQ 0>
|
||||
<cfreturn representationOf(this.helper.formatMessage("There is no configured instance operation with uid #arguments.instanceOperationUid#","Instance operation not found")).withStatus(404)/>
|
||||
<cfelseif left(local.qCheckStarted.submit_result,1) EQ "2" AND len(local.qCheckStarted.dt_finish EQ 0)><!--- 201 etc --->
|
||||
<cfreturn representationOf(this.helper.formatMessage("Operation already started", "Parameter creation disabled for started operation")).withStatus(422)/>
|
||||
</cfif>
|
||||
|
||||
<cfset generateRfsParams(arguments.instanceOperationUid, arguments.usrId)/>
|
||||
<cfset submitJob(arguments.instanceOperationUid)/>
|
||||
|
||||
<cfcatch type="invalidParamValue">
|
||||
<cfreturn representationOf(this.helper.formatBadRequestError(cfcatch)).withStatus(400)/>
|
||||
</cfcatch>
|
||||
<cfcatch type="missingDependency">
|
||||
<cfreturn representationOf(this.helper.formatException(cfcatch,"Missing Dependency")).withStatus(424)/>
|
||||
</cfcatch>
|
||||
</cftry>
|
||||
<!--- <cfreturn representationOf("Not Implemented yet").withStatus(501)/> --->
|
||||
|
||||
<cfset generateRfsParams(arguments.instanceOperationUid)/>
|
||||
|
||||
|
||||
<cfreturn noData()
|
||||
.withHeaders({location: "./#local.instanceUid#"})
|
||||
.withStatus(201, "Created")
|
||||
/>
|
||||
<!--- --->
|
||||
<cfreturn noData().withStatus(201, "Created") />
|
||||
</cffunction>
|
||||
|
||||
|
||||
|
||||
<cffunction name="generateRfsParams">
|
||||
<cfargument name="instanceOperationUid" type="guid"/>
|
||||
<cfargument name="usrId" type="numeric"/>
|
||||
@@ -129,21 +146,36 @@
|
||||
where instance_operation_uid=<cfqueryparam cfsqltype="cf_sql_other" value=#arguments.instanceOperationUid#/>
|
||||
</cfquery>
|
||||
|
||||
<cfhttp method="post"
|
||||
url="#qInstanceOperation.url#"
|
||||
multipart=true
|
||||
multipartType="form-data"
|
||||
timeout="3"
|
||||
charset="utf-8"
|
||||
result="orchestrator"
|
||||
>
|
||||
<cfhttpparam type="HEADER" name="Authorization" value="#request.ORCHESTRATOR_AUTH#"/>
|
||||
<cfhttpparam type="HEADER" name="Accept" value="application/json"/>
|
||||
<cfhttpparam type="formfield" name="delay" value="0sec"/>
|
||||
<cfloop query="qInstanceOperationParam">
|
||||
<cfhttpparam type="formfield" name="#param#" value="#param_value#"/>
|
||||
</cfloop>
|
||||
</cfhttp>
|
||||
|
||||
|
||||
<cftry>
|
||||
<cfhttp method="post"
|
||||
url="#qInstanceOperation.url#"
|
||||
multipart=true
|
||||
multipartType="form-data"
|
||||
timeout="3"
|
||||
charset="utf-8"
|
||||
result="orchestrator"
|
||||
>
|
||||
<cfhttpparam type="HEADER" name="Authorization" value="#request.ORCHESTRATOR_AUTH#"/>
|
||||
<cfhttpparam type="HEADER" name="Accept" value="application/json"/>
|
||||
<cfhttpparam type="formfield" name="delay" value="0sec"/>
|
||||
<cfloop query="qInstanceOperationParam">
|
||||
<cfhttpparam type="formfield" name="#param#" value="#param_value#"/>
|
||||
</cfloop>
|
||||
</cfhttp>
|
||||
|
||||
<cfcatch type="any">
|
||||
<cfthrow message="Cannot initiate connection to the orchestrator #cfcatch.message#" detail="#cfcatch.detail#"/>
|
||||
<!--- <cfdump var=#qInstanceOperation#/>
|
||||
<cfabort/> --->
|
||||
</cfcatch>
|
||||
</cftry>
|
||||
|
||||
<cfif len(orchestrator.errorDetail)>
|
||||
<cfthrow type="missingDependency" message="Orchestrator communication error" detail="#orchestrator.errorDetail#"/>
|
||||
<!--- лучше бы возвращать 503 или 424 --->
|
||||
</cfif>
|
||||
|
||||
<cfquery name="qMarkOperationSubmit">
|
||||
update instance_operation
|
||||
|
||||
Reference in New Issue
Block a user