#1018: CronSanityCheckJob.kt

projectforge-business/src/main/kotlin/org/projectforge/business/jobs/CronSanityCheckJob.kt Scheduled Job, projectforge-business/src/main/kotlin/org/projectforge/business/jobs/CronSanityCheckJob.kt 136 lines · 94 code · 29 comments · 13 blank
Nightly scheduled sanity check orchestrator. Runs a collection of registered AbstractJob instances, collects results into JobListExecutionContext, and emails the admin (as HTML) if errors are found.

Architecture

Job Registration

Uses @PostConstruct to auto-register built-in jobs: SystemSanityCheckJob and JCRCheckSanityCheckJob. Additional plugin jobs can be registered via registerJob(). Jobs are stored in a mutableListOf().

Execution Flow

  1. @Scheduled(cron="${projectforge.cron.sanityChecks}") triggers cron(), which spawns a background Thread.
  2. execute() iterates all registered jobs, wrapping each in try/catch to prevent one job failure from blocking others.
  3. If the aggregate context has ERRORS status, a mail is sent to SYSTEM_ADMIN_E_MAIL with both summary and full HTML report as attachment.

Report Formatting

The email body uses Bootstrap-like Html.Alert/Html.P classes for pretty HTML formatting. The attachment is a full HTML report named projectforge_sanity-check_TIMESTAMP.html.

Git History

868d6abb7 2025 -> 2026
af1dabd8a KostZuweisungsExport: Konten fixed. MyScriptDao: group-check fixed.
e5bef64bd CronSanityCheckJob sends now mail in pretty printed html format.
034eebd5d Html handling and job handling.
d60585ee4 System sanity check results now in pretty formatted html.
1bd5072f0 Minor improvements
76920e51f cosmetic corrections in SystemService and SanityCheckJobs
1a77630dc Kotlin.Coroutine -> Thread in Cronjobs and SystemService
b309e9be9 MailAttachments improved. E-Mail sent automatically if nightly sanity check has errors.
98f6d080c Sanity check of data transfer and JCR finished.
63081666f Source file headers: 2024-> 2025.
619985f48 Release 8.1 snapshot (#247)
92a1b6185 WIP: Sanity cron job, Schedulers using now Coroutines.