{auditing/include/_aud-cache.i}
/* Define the temp-tables */ {auditing/ttdefs/ _audpolicytt.i} {auditing/ttdefs/_audfilepolicytt.i} {auditing/ttdefs/_audfieldpolicytt.i} {auditing/ttdefs/_audeventpolicytt.i} /* Call either registerAuditTableHandle for each table or set-tt-hdls-for-dataset to pass the four table handles */ /* RUN registerAuditTableHandle IN hAuditCacheMgr ("policy", TABLE ttAuditPolicy:HANDLE). RUN registerAuditTableHandle IN hAuditCacheMgr ("file-policy", TABLE ttAuditFilePolicy:HANDLE). RUN registerAuditTableHandle IN hAuditCacheMgr ("field-policy", TABLE ttAuditFieldPolicy:HANDLE). RUN registerAuditTableHandle IN hAuditCacheMgr ("event-policy", TABLE ttAuditFieldPolicy:HANDLE). */ RUN set-tt-hdls-for-dataset IN hAuditCacheMgr(TABLE ttAuditPolicy:HANDLE, TABLE ttAuditFilePolicy:HANDLE, TABLE ttAuditFieldPolicy:HANDLE, TABLE ttAuditEvent Policy:HANDLE). /* Populate temp-tables with policies from connected database */ RUN changeAuditDatabase IN hAuditCacheMgr (ldbname(1)). /* load policies from XML file */ RUN import-policies-from-xml IN hAuditCacheMgr (INPUT cFileName, OUTPUT cDupList, OUTPUT errorMsg). /* Either display error message or confirmation that the policies were imported */ IF errorMsg <> "":U THEN RETURN ERROR errorMsg. ELSE DO: /* Check if XML file has policies which already exist */ IF cDupList <> "" THEN DO: MESSAGE "The following policies already exist:" SKIP REPLACE(cDupList,",",CHR(10)) SKIP "Do you want to override them?" SKIP "(If Yes, the listed policies will be deleted and re-imported)" VIEW-AS ALERT-BOX QUESTION BUTTON YES-NO UPDATE lChoice AS LOGICAL. IF lChoice THEN DO: /* User confirmed that he wants to override existing policies, so let's pick up from where we left off. Keep the changes. */ RUN setcursor ("WAIT":U). RUN resubmit-import-from-xml IN hAuditCacheMgr(OUTPUT errorMsg). RUN setcursor ("":U). IF errorMsg <> "" THEN RETURN ERROR errorMsg. END. ELSE DO: /* User doesn't want to override policies, so cancel the previous request */ RUN cancel-import-from-xml IN hAuditCacheMgr. MESSAGE "Import canceled" VIEW-AS ALERT-BOX INFO. END. END. /* cDupList <> "" */ /* Make some changes to the policies by updating the temp-tables. Check if there are pending changes and save them to the database */ RUN getDataModified IN hAuditCacheMgr (OUTPUT lMod). IF lMod THEN DO: /* changes pending */ RUN saveChangesAuditDatabase IN hAuditCacheMgr. ASSIGN errorMsg = RETURN-VALUE. IF errorMsg <> "":U THEN DO: /* Let's reject everything and get out */ RUN rejectChangesAuditDatabase IN hAuditCacheMgr. RETURN ERROR errorMsg. END. /* Export changed policies to an XML file. Call the procedure in the auditUtils procedure to do the job */ RUN export-policies-to-xml IN hAuditCacheMgr (INPUT cList, INPUT cFileName, OUTPUT errorMsg). IF errorMsg <> "":U THEN RETURN ERROR errorMsg. END. |