project BLF > class BRole > method ApiSynchronizeDefaultRoles
Description
This synchronize method is for loading the default roles from DefaultRoles.xml.
Parameters
olUpdatesDone | output | logical | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
BLF
program code (program9/brole.p)
/* ============ */
/* Get Filename */
/* ============ */
<M-35 run Main (input viSessionID (iiSessionId)) in TApplication>
<M-52 run GetDefaultsFolder (output vcFilePath (ocFolder)) in TApplication>
run gipr_DeleteProcedure in vhFcComponent.
delete procedure vhFcComponent.
assign vcFileName = "defaultroles.xml":U
vcFile = trim(vcFilePath) + trim(vcFileName).
/* ======================================== */
/* Check if the file realy exists as a file */
/* ======================================== */
assign FILE-INFO:FILE-NAME = vcFile no-error.
if error-status:error or
FILE-INFO:FILE-NAME = ? or
FILE-INFO:FILE-TYPE = ? or
INDEX(FILE-INFO:FILE-TYPE,"F":U) = 0
then do :
assign olUpdatesDone = false
vcFileType = file-info:file-type
vcMessage = trim(#T-4'No proper XML file was found by the default roles.':255(8890)T-4#) + chr(10) +
trim(substitute(#T-5'File name: &1.':255(428)T-5#,vcFile)) + chr(10) +
trim(substitute(#T-6'File type: &1.':255(429)T-6#,vcFileType)) + chr(10) +
(if error-status:error = true
then trim(substitute(#T-10'Internal error number: &1.':255(433)T-10#,string(ERROR-STATUS:GET-NUMBER(1)))) + chr(10)
else "":U)
oiReturnStatus = +1.
<M-1 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'W':U (icType),
input 4 (iiSeverity),
input '':U (icRowid),
input 'BLF-177':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BRole>
return.
end. /* if error-status:error or */
/* ============================================ */
/* Import the FactoryDefaults from the XML-file */
/* ============================================ */
<M-2 run apiMaintainByXml
(input ? (imDocument),
input vcFile (icFileName),
output olUpdatesDone (olSuccess),
output tXmlObjects (tXmlObjects),
output viFcReturnSuper (oiReturnStatus)) in BRole>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
/* ================================================================= */
/* olsuccess = no does not mean 'no updates required' */
/* create an error messages */
/* ================================================================= */
if not olUpdatesDone
then do:
assign vcMessage = trim(#T-12'Synchronization of Default Roles Failed.':255(8892)T-12#).
<M-3 run SetMessage
(input vcMessage (icMessage),
input '' (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'BLF-178':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BRole>
assign oiReturnStatus = -3.
return.
end.