project BLF > class BBaseDaemon > 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/bbasedaemon.p)
empty temp-table tDirectoryToCreate.
<ANCESTOR-CODE>
For Each t_sfcDaemon Where
t_sfcDaemon.tc_Status = 'C':U Or
t_sfcDaemon.tc_Status = 'N':U on error undo, throw:
If t_sfcDaemon.DaemonRunningProcesses > t_sfcDaemon.DaemonMaxNumberOfInstances
Then Do:
Assign vcMessage = Trim(#T-4'You can not start more daemons then the maximum specified.':100(5057)T-4#).
<M-3 run SetMessage
(input vcMessage (icMessage),
input '' (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sfcDaemon.tc_Rowid (icRowid),
input 'BLF-23':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBaseDaemon>
Assign oiReturnStatus = -1.
End.
<M-8 run ValidateDirectories
(input t_sfcdaemon.tc_Rowid (ictcRowid),
output viFcReturnSuper (oiReturnStatus)) in BBaseDaemon>
if viFcReturnSuper <> 0
and oiReturnStatus >= 0
then assign oiReturnStatus = viFcReturnSuper.
End.
for each t_sfcDaemon where
t_sfcDaemon.tc_Status = "N":U or
t_sfcDaemon.tc_Status = "C":U on error undo, throw:
/* ================================================================= */
/* Check if the selected user is linked to all existing companies */
/* 1. fetch all companies */
/* 2. fetch the companies that are linked to the selected user */
/* 3. Check if user has all companies linked */
/* --> if not --> Error */
/* ================================================================= */
assign vcExtra = '':U
vlValidUser = true.
<Q-45 run DomainsByActive (all) (Read) (NoCache)
(input true, (DomainIsActive)
output dataset tqDomainsByActive) in BDomain >
<Q-28 run CompanyByDomainActive (all) (Read) (NoCache)
(input ?, (CompanyId)
input ?, (DomainId)
input True, (CompanyIsActive)
output dataset tqCompanyByDomainActive) in BCompany >
<Q-36 run UserCompanies
(Start) in BUser >
For each tqDomainsByActive on error undo, throw:
<Q-35 run UserCompanies (all) (Read) (NoCache)
(input t_sfcDaemon.DaemonLogin, (UserLogin)
input 0, (CyId)
input tqDomainsByActive.tiDomain_ID, (DomainId)
output dataset tqUserCompanies) in BUser >
for each tqCompanyByDomainActive Where
tqCompanyByDomainActive.tcDomainCode = tqDomainsByActive.tcDomainCode
break by tqCompanyByDomainActive.tcCompanyCode
on error undo, throw:
if vcExtra = '':U
then assign vcExtra = 'CompanyCode':U + chr(2) + tqCompanyByDomainActive.tcCompanyCode.
if not can-find(tqUserCompanies where
tqUserCompanies.tiCompany_ID = tqCompanyByDomainActive.tiCompany_ID)
then do:
assign oiReturnStatus = -1
vlValidUser = false.
<M-33 run SetMessage
(input #T-34'The selected user should be linked to all entities.':100(389)T-34# (icMessage),
input '':U (icArguments),
input 't_sfcDaemon.DaemonLogin':U (icFieldName),
input t_sfcDaemon.DaemonLogin (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sfcDaemon.tc_Rowid (icRowid),
input 'BLF-28':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBaseDaemon>
leave.
end. /* not can-find(tqUserCompanies ...) */
end. /* for each tqCompanyByDomainActive */
End. /*For each tqDomainsByActive:*/
<Q-37 run UserCompanies
(Stop) in BUser >
empty temp-table tqDomainsByActive.
empty temp-table tqCompanyByDomainActive.
empty temp-table tqUserCompanies.
/* ================================== */
/* Check DaemonNrOfRequestsInLoop > 0 */
/* ================================== */
if not t_sfcDaemon.DaemonNrOfRequestsInLoop > 0
then do:
assign oiReturnStatus = -1.
<M-11 run SetMessage (input #T-13'Number Of Requests In Loop must be positive.':100(5908)T-13# (icMessage),
input '':U (icArguments),
input 't_sfcDaemon.DaemonNrOfRequestsInLoop':U (icFieldName),
input t_sfcDaemon.DaemonNrOfRequestsInLoop (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sfcDaemon.tc_Rowid (icRowid),
input 'BLF-24':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBaseDaemon>
end.
end.
/* ================================================================= */
/* Check validity of password */
/* ================================================================= */
if vlValidUser = true
and can-find (first t_sfcDaemon where
t_sfcDaemon.tc_Status = "N":U or
t_sfcDaemon.tc_Status = "C":U )
then do:
<I-47 {bFcOpenInstance
&CLASS = "Session"}>
for each t_sfcDaemon where
t_sfcDaemon.tc_Status = "N":U or
t_sfcDaemon.tc_Status = "C":U on error undo, throw:
<M-46 run ValidateLogin
(input t_sfcDaemon.DaemonLogin (icUsrLogin),
input t_sfcDaemon.DaemonPassword (icUsrPassword),
output viFcReturnSuper (oiReturnStatus)) in Session>
if viFcReturnSuper < 0
then Do:
oiReturnStatus = viFcReturnSuper.
<M-2 run SetMessage
(input #T-17'One or more errors occurred while validating user and password.':255(8459)T-17# (icMessage),
input '' (icArguments),
input 't_sfcDaemon.DaemonLogin':U (icFieldName),
input t_sfcDaemon.DaemonLogin (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sfcDaemon.tc_Rowid (icRowid),
input 'BLF-22':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBaseDaemon>
end.
end.
<I-10 {bFcCloseInstance
&CLASS = "Session"}>
end.
/* =============================================================================== */
/* Warn user about deleting a Daemon */
/* Delete while running is only allowed for the ScbaAdmin and for the Daemon-Login */
/* itself. Warning for these users, errors for the others. */
/* =============================================================================== */
for each t_sfcDaemon where
t_sfcDaemon.tc_Status = "D":U on error undo, throw :
<Q-48 run DaemonInfoLimited (all) (Read) (NoCache)
(input t_sfcDaemon.DaemonId, (DaemonId)
input '', (DaemonName)
input '', (DaemonStatus)
input '', (DaemonStatusDiffersFrom)
output dataset tqDaemonInfoLimited) in BBaseDaemon >
find first tqDaemonInfoLimited where
tqDaemonInfoLimited.tiDaemonID = t_sfcDaemon.DaemonID
no-lock no-error.
if available tqDaemonInfoLimited
then do :
if tqDaemonInfoLimited.tcDaemonStatus = {&DAEMONSTATUS-INACTIVE}
then do :
if oiReturnStatus >= 0
then assign oiReturnStatus = +1.
assign vcMessage = trim(substitute(#T-15'Removing this daemon (&1/&2) from the system implies that you will no longer be able to run it and that it will no longer be started by server processes.':255(6570)T-15#,t_sfcDaemon.DaemonName,string(t_sfcDaemon.DaemonId))) + chr(10) +
trim(#T-16'Are you sure you want to delete this daemon?':255(6565)T-16#).
<M-25 run SetMessage (input vcMessage (icMessage),
input '' (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'W':U (icType),
input 3 (iiSeverity),
input t_sfcDaemon.tc_Rowid (icRowid),
input 'BLF-27':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBaseDaemon>
end. /* if tqDaemonInfoLimited.tcDaemonStatus = {&DAEMONSTATUS-INACTIVE} */
else do :
if vcUserName = tqDaemonInfoLimited.tcDaemonLogin or
vcUserName = "mfg":U
then do :
if oiReturnStatus >= 0
then assign oiReturnStatus = +1.
assign vcMessage = trim(#T-26'There was a delete request for the daemon while it is still active.':150(6573)T-26#) + chr(10) +
trim(#T-27'Are you sure you want to delete this daemon?':255(6565)T-27#).
<M-23 run SetMessage (input vcMessage (icMessage),
input '' (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'W':U (icType),
input 3 (iiSeverity),
input t_sfcDaemon.tc_Rowid (icRowid),
input 'BLF-25':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBaseDaemon>
end. /* if vcUserName = tqDaemonInfoLimited.tcDaemonLogin or */
else do :
assign oiReturnStatus = -1
vcMessage = trim(#T-19'Unable to delete. The daemon is still active.':255(6567)T-19#) + chr(10) +
trim(substitute(#T-20'Removing an active daemon has been reserved for the mfg user and for the daemon process (&1) itself.':255(8529)T-20#,(if tqDaemonInfoLimited.tcDaemonLogin = ? then "?":U else tqDaemonInfoLimited.tcDaemonLogin))).
<M-24 run SetMessage (input vcMessage (icMessage),
input '' (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sfcDaemon.tc_Rowid (icRowid),
input 'BLF-26':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBaseDaemon>
Return.
end. /* NOT if vcUserName = tqDaemonInfoLimited.tcDaemonLogin or */
end. /* if tqDaemonInfoLimited.tcDaemonStatus <> {&DAEMONSTATUS-INACTIVE} */
end. /* if available */
end. /* for each tDaemon.tc_Status = "D":U */