project BLF > class BEventDestination > method ValidateComponent
Description
Write here all tests on database update (new / modify / delete) that cannot be coded with a validation mask.
The type of update can be found in tc_status (N/C/D).
If you find incorrect data, you must write an entry in tFcMessages (using SetMessage) and set the return status of this method to either +1 or -1.
Return status +1 = data will still be accepted.
Return status -1 = data will not be accepted.
This method is run from SetPublicTables, before transferring the received data into the class temp-tables.
Parameters
oiReturnStatus | output | integer | |
Internal usage
unused
program code (program/beventdestination.p)
<ANCESTOR-CODE>
for each t_sEventDestination where
t_sEventDestination.tc_Status = 'C':U or
t_sEventDestination.tc_Status = 'N':U on error undo, throw:
if t_sEventDestination.EventDestinationType = {&EVENTDESTINATIONTYPE-DIRECTAPPSERVER}
then do:
if t_sEventDestination.EventDestinationASName = "" or t_sEventDestination.EventDestinationASName = ?
then do:
assign vcMessage = trim(#T-1'This field is mandatory when choosing type $1.':255(9031)T-1#)
oiReturnStatus = -1.
<M-2 run SetMessage
(input vcMessage (icMessage),
input {&EVENTDESTINATIONTYPE-DIRECTAPPSERVER-TR} (icArguments),
input 'tEventDestination.EventDestinationASName':U (icFieldName),
input t_sEventDestination.EventDestinationASName (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sEventDestination.tc_Rowid (icRowid),
input 'BLF-84':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BEventDestination>
end.
if t_sEventDestination.EventDestinationASProc = "" or t_sEventDestination.EventDestinationASProc = ?
then do:
assign vcMessage = trim(#T-4'This field is mandatory when choosing type $1.':255(9031)T-4#)
oiReturnStatus = -1.
<M-3 run SetMessage
(input vcMessage (icMessage),
input {&EVENTDESTINATIONTYPE-DIRECTAPPSERVER-TR} (icArguments),
input 'tEventDestination.EventDestinationASProc':U (icFieldName),
input t_sEventDestination.EventDestinationASProc (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sEventDestination.tc_Rowid (icRowid),
input 'BLF-85':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BEventDestination>
end.
if t_sEventDestination.EventDestinationDir <> "" and t_sEventDestination.EventDestinationDir <> ?
then do:
assign vcMessage = trim(#T-6'This field is needs to be empty when choosing type $1.':255(9032)T-6#)
oiReturnStatus = -1.
<M-5 run SetMessage
(input vcMessage (icMessage),
input {&EVENTDESTINATIONTYPE-DIRECTAPPSERVER-TR} (icArguments),
input 'tEventDestination.EventDestinationDir':U (icFieldName),
input t_sEventDestination.EventDestinationDir (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sEventDestination.tc_Rowid (icRowid),
input 'BLF-86':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BEventDestination>
end.
/*try to connect to the appserver*/
if oiReturnStatus >= 0
then do:
/*get connection*/
if (t_sEventDestination.EventDestinationASName = {&EVENTDESTINATION-DEFAULTCONN})
then do:
assign vcFile = search ("server.xml":U)
vhFcComponent = ?.
<M-18 run MainBlock () in XML>
assign vhXMLhandle = vhFcComponent.
<M-19 run ReadXML
(input vcFile (icXMLFile),
input 'appServerConnection':U (icStartTag),
output tNodesED (tNodes),
output viFcReturnSuper (oiReturnStatus)) in XML>
run gipr_DeleteProcedure in vhXMLhandle.
delete procedure vhXMLHandle.
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
find first tNodesED where
trim(tNodesED.tcNodeName) = "serviceInstanceKey":U and
trim(tNodesED.tcNodeValue) = "Publish":U no-error.
if available tNodesED
then do:
assign viFcCount1 = tNodesED.tiNodeParentId.
find first tNodesED where
tNodesED.tiNodeParentId = viFcCount1 and
trim(tNodesED.tcNodeName) = "appServiceURL":U no-error.
if available tNodesED
then assign vcConnect = "-URL " + trim(tNodesED.tcNodeValue).
end.
end.
else assign vcConnect = "-URL " + t_sEventDestination.EventDestinationASName.
/* connect to the appserver */
if vhAppserver = ?
then create server vhAppserver.
vhAppserver:connect (vcConnect) no-error.
if vhAppserver:connected()
then vhAppserver:disconnect().
else do:
assign vcMessage = trim(#T-17'Could not connect to appserver. Please check the connection URL.':255(9045)T-17#)
oiReturnStatus = -1.
<M-16 run SetMessage
(input vcMessage (icMessage),
input '' (icArguments),
input 'tEventDestination.EventDestinationASName':U (icFieldName),
input t_sEventDestination.EventDestinationASName (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sEventDestination.tc_Rowid (icRowid),
input 'BLF-90':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BEventDestination>
end.
delete object vhAppserver.
vhAppserver = ?.
end.
end. /*if t_sEventDestination.EventDestinationType = {&EVENTDESTINATIONTYPE-DIRECTAPPSERVER}*/
if t_sEventDestination.EventDestinationType = {&EVENTDESTINATIONTYPE-TODIR}
then do:
if t_sEventDestination.EventDestinationASName <> "" and t_sEventDestination.EventDestinationASName <> ?
then do:
assign vcMessage = trim(#T-15'This field needs to be empty when choosing type $1.':255(9395)T-15#)
oiReturnStatus = -1.
<M-7 run SetMessage
(input vcMessage (icMessage),
input {&EVENTDESTINATIONTYPE-TODIR-TR} (icArguments),
input 'tEventDestination.EventDestinationASName':U (icFieldName),
input t_sEventDestination.EventDestinationASName (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sEventDestination.tc_Rowid (icRowid),
input 'BLF-87':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BEventDestination>
end.
if t_sEventDestination.EventDestinationASProc <> "" and t_sEventDestination.EventDestinationASProc <> ?
then do:
assign vcMessage = trim(#T-13'This field needs to be empty when choosing type $1.':255(9395)T-13#)
oiReturnStatus = -1.
<M-8 run SetMessage
(input vcMessage (icMessage),
input {&EVENTDESTINATIONTYPE-TODIR-TR} (icArguments),
input 'tEventDestination.EventDestinationASProc':U (icFieldName),
input t_sEventDestination.EventDestinationASProc (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sEventDestination.tc_Rowid (icRowid),
input 'BLF-88':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BEventDestination>
end.
if t_sEventDestination.EventDestinationDir = "" or t_sEventDestination.EventDestinationDir = ?
then do:
assign vcMessage = trim(#T-14'This field is mandatory when choosing type $1.':255(9031)T-14#)
oiReturnStatus = -1.
<M-9 run SetMessage
(input vcMessage (icMessage),
input {&EVENTDESTINATIONTYPE-TODIR-TR} (icArguments),
input 'tEventDestination.EventDestinationDir':U (icFieldName),
input t_sEventDestination.EventDestinationDir (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sEventDestination.tc_Rowid (icRowid),
input 'BLF-89':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BEventDestination>
end.
/*check dir*/
<M-29 run Main (input viSessionId (iiSessionId)) in TDaemonUtility>
<M-30 run GetFileType
(input {&EVENTDAEMON} (icDaemonName),
input t_sEventDestination.EventDestinationDir (icFileName),
input '' (icDaemonAppserverUrl),
output vcFileType (ocFileType),
output vcMessage (ocMessage),
output viFcReturnSuper (oiReturnStatus)) in TDaemonUtility>
run gipr_DeleteProcedure in vhFcComponent.
delete procedure vhFcComponent.
if vcMessage <> ""
then do:
<M-31 run SetMessage
(input vcMessage (icMessage),
input '' (icArguments),
input 'tEventDestination.EventDestinationDir' (icFieldName),
input t_sEventDestination.EventDestinationDir (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sEventDestination.tc_Rowid (icRowid),
input 'BLF-92':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BEventDestination>
end.
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
if vcFileType = ? or
not vcFileType matches '*D*':U or
not vcFileType matches '*W*':U
then do:
assign
vcMessage = Trim(#T-24'The specified directory does not exist or is not writable.':100(9034)T-24#)
oiReturnStatus = -1.
<M-28 run SetMessage
(input vcMessage (icMessage),
input '' (icArguments),
input 'tEventDestination.EventDestinationDir' (icFieldName),
input t_sEventDestination.EventDestinationDir (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sEventDestination.tc_Rowid (icRowid),
input 'BLF-91':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BEventDestination>
end.
end. /*if t_sEventDestination.EventDestinationType = {&EVENTDESTINATIONTYPE-TODIR}*/
end.