Skip to content

Commit

Permalink
Added webform ID to audit logging messages
Browse files Browse the repository at this point in the history
  • Loading branch information
jekuaitk committed Dec 9, 2024
1 parent 9547f42 commit e6155c9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ about writing changes to this log.

## [Unreleased]

## [1.3.1] 09.12.2024

* Added webform ID to audit logging messages.

## [1.3.0] 06.12.2024

* Added audit logging.
Expand Down Expand Up @@ -47,7 +51,8 @@ about writing changes to this log.

## [1.0.0] 29.03.2023

[Unreleased]: https://github.com/OS2Forms/os2forms_get_organized/compare/1.3.0...HEAD
[Unreleased]: https://github.com/OS2Forms/os2forms_get_organized/compare/1.3.1...HEAD
[1.3.1]: https://github.com/OS2Forms/os2forms_get_organized/compare/1.3.0...1.3.1
[1.3.0]: https://github.com/OS2Forms/os2forms_get_organized/compare/1.2.0...1.3.0
[1.2.0]: https://github.com/OS2Forms/os2forms_get_organized/compare/1.1.5...1.2.0
[1.1.5]: https://github.com/OS2Forms/os2forms_get_organized/compare/1.1.4...1.1.5
Expand Down
24 changes: 12 additions & 12 deletions src/Helper/ArchiveHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ private function archiveToCitizen(string $submissionId, array $handlerConfigurat
$parentCaseCount = count($caseInfo);

if (0 === $parentCaseCount) {
$parentCaseId = $this->createCitizenCase($cprElementValue, $cprNameElementValue);
$parentCaseId = $this->createCitizenCase($cprElementValue, $cprNameElementValue, $submission->getWebform()->id());
}
elseif (1 < $parentCaseCount) {
$message = sprintf('Too many (%d) parent cases.', $parentCaseCount);
Expand Down Expand Up @@ -248,7 +248,7 @@ private function archiveToCitizen(string $submissionId, array $handlerConfigurat
$subCaseCount = count($subCases['CasesInfo']);

if (0 === $subCaseCount) {
$subCaseId = $this->createSubCase($parentCaseId, $subcaseName);
$subCaseId = $this->createSubCase($parentCaseId, $subcaseName, $submission->getWebform()->id());
}
elseif (1 === $subCaseCount) {
$subCaseId = $subCases['CasesInfo'][0]['CaseID'];
Expand All @@ -269,7 +269,7 @@ private function archiveToCitizen(string $submissionId, array $handlerConfigurat
/**
* Creates citizen parent case in GetOrganized.
*/
private function createCitizenCase(string $cprElementValue, string $cprNameElementValue): string {
private function createCitizenCase(string $cprElementValue, string $cprNameElementValue, string $webformId): string {

$metadataArray = [
'ows_Title' => $cprElementValue . ' - ' . $cprNameElementValue,
Expand All @@ -290,7 +290,7 @@ private function createCitizenCase(string $cprElementValue, string $cprNameEleme
// {"CaseID":"BOR-2022-000046","CaseRelativeUrl":"\/cases\/BOR12\/BOR-2022-000046",...}.
$caseId = $response['CaseID'];

$msg = sprintf('Created GetOrganized case %s', $caseId);
$msg = sprintf('Created GetOrganized case %s. Webform id %s.', $caseId, $webformId);
$this->auditLogger->info('GetOrganized', $msg);

return $caseId;
Expand All @@ -299,7 +299,7 @@ private function createCitizenCase(string $cprElementValue, string $cprNameEleme
/**
* Creates citizen subcase in GetOrganized.
*/
private function createSubCase(string $caseId, string $caseName): string {
private function createSubCase(string $caseId, string $caseName, string $webformId): string {
$metadataArray = [
'ows_Title' => $caseName,
'ows_CCMParentCase' => $caseId,
Expand All @@ -315,7 +315,7 @@ private function createSubCase(string $caseId, string $caseName): string {
// {"CaseID":"BOR-2022-000046-001","CaseRelativeUrl":"\/cases\/BOR12\/BOR-2022-000046",...}.
$caseId = $response['CaseID'];

$msg = sprintf('Created GetOrganized case %s', $caseId);
$msg = sprintf('Created GetOrganized case %s. Webform id %s.', $caseId, $webformId);
$this->auditLogger->info('GetOrganized', $msg);

return $caseId;
Expand Down Expand Up @@ -347,7 +347,7 @@ private function uploadDocumentToCase(string $caseId, string $webformAttachmentE

$getOrganizedFilename = $this->sanitizeFilename($getOrganizedFilename);

$parentDocumentId = $this->archiveDocumentToGetOrganizedCase($caseId, $getOrganizedFilename, $fileContent);
$parentDocumentId = $this->archiveDocumentToGetOrganizedCase($caseId, $getOrganizedFilename, $fileContent, $submission->getWebform()->id());

$documentIdsForFinalizing[] = $parentDocumentId;

Expand All @@ -368,7 +368,7 @@ private function uploadDocumentToCase(string $caseId, string $webformAttachmentE

$fileContent = file_get_contents($file->getFileUri());

$childDocumentId = $this->archiveDocumentToGetOrganizedCase($caseId, $getOrganizedFilename, $fileContent);
$childDocumentId = $this->archiveDocumentToGetOrganizedCase($caseId, $getOrganizedFilename, $fileContent, $submission->getWebform()->id());

$childDocumentIds[] = $childDocumentId;
}
Expand All @@ -378,15 +378,15 @@ private function uploadDocumentToCase(string $caseId, string $webformAttachmentE
if (!empty($childDocumentIds)) {
$this->documentService->RelateDocuments($parentDocumentId, $childDocumentIds, 1);

$msg = sprintf('Added relation between document %s and documents %s', $parentDocumentId, implode(', ', $childDocumentIds));
$msg = sprintf('Added relation between document %s and documents %s. Webform id %s.', $parentDocumentId, implode(', ', $childDocumentIds), $submission->getWebform()->id());
$this->auditLogger->info('GetOrganized', $msg);
}
}

if ($shouldBeFinalized) {
$this->documentService->FinalizeMultiple($documentIdsForFinalizing);

$msg = sprintf('Finalized documents %s', implode(', ', $documentIdsForFinalizing));
$msg = sprintf('Finalized documents %s. Webform id %s.', implode(', ', $documentIdsForFinalizing), $submission->getWebform()->id());
$this->auditLogger->info('GetOrganized', $msg);
}
}
Expand All @@ -410,7 +410,7 @@ private function getAvailableElementsByType(string $type, array $elements): arra
/**
* Archives file content to GetOrganized case.
*/
private function archiveDocumentToGetOrganizedCase(string $caseId, string $getOrganizedFileName, string $fileContent): int {
private function archiveDocumentToGetOrganizedCase(string $caseId, string $getOrganizedFileName, string $fileContent, string $webformId): int {
$tempFile = tempnam('/tmp', $caseId . '-' . uniqid());

try {
Expand All @@ -428,7 +428,7 @@ private function archiveDocumentToGetOrganizedCase(string $caseId, string $getOr
unlink($tempFile);
}

$msg = sprintf('Archived document %s to GetOrganized case %s', $getOrganizedFileName, $caseId);
$msg = sprintf('Archived document %s to GetOrganized case %s. Webform id %s.', $getOrganizedFileName, $caseId, $webformId);
$this->auditLogger->info('GetOrganized', $msg);

return (int) $documentId;
Expand Down

0 comments on commit e6155c9

Please sign in to comment.