-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #251 from micromata/Release-8.1-SNAPSHOT
Release 8.1 snapshot
- Loading branch information
Showing
2,571 changed files
with
4,291 additions
and
3,962 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
...nsfer/src/main/kotlin/org/projectforge/plugins/datatransfer/DataTransferSanityCheckJob.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
///////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Project ProjectForge Community Edition | ||
// www.projectforge.org | ||
// | ||
// Copyright (C) 2001-2025 Micromata GmbH, Germany (www.micromata.com) | ||
// | ||
// ProjectForge is dual-licensed. | ||
// | ||
// This community edition is free software; you can redistribute it and/or | ||
// modify it under the terms of the GNU General Public License as published | ||
// by the Free Software Foundation; version 3 of the License. | ||
// | ||
// This community edition is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
// Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License along | ||
// with this program; if not, see http://www.gnu.org/licenses/. | ||
// | ||
///////////////////////////////////////////////////////////////////////////// | ||
|
||
package org.projectforge.plugins.datatransfer | ||
|
||
import jakarta.annotation.PostConstruct | ||
import org.projectforge.business.jobs.CronSanityCheckJob | ||
import org.projectforge.framework.jcr.AttachmentsService | ||
import org.projectforge.jobs.AbstractJob | ||
import org.projectforge.jobs.JobExecutionContext | ||
import org.projectforge.plugins.datatransfer.rest.DataTransferAreaPagesRest | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.stereotype.Service | ||
|
||
@Service | ||
class DataTransferSanityCheckJob : AbstractJob("Check data transfer files.") { | ||
@Autowired | ||
private lateinit var attachmentsService: AttachmentsService | ||
|
||
@Autowired | ||
private lateinit var dataTransferAreaDao: DataTransferAreaDao | ||
|
||
@Autowired | ||
private lateinit var dataTransferAreaPagesRest: DataTransferAreaPagesRest | ||
|
||
@Autowired | ||
private lateinit var cronSanityCheckJob: CronSanityCheckJob | ||
|
||
@PostConstruct | ||
private fun postConstruct() { | ||
cronSanityCheckJob.registerJob(this) | ||
} | ||
|
||
override fun execute(jobContext: JobExecutionContext) { | ||
var areaCounter = 0 | ||
var missingInJcrCounter = 0 | ||
var orphanedCounter = 0 | ||
dataTransferAreaDao.selectAll(checkAccess = false).forEach { area -> | ||
++areaCounter | ||
val areaName = "'${area.displayName}'" | ||
try { | ||
val attachments = attachmentsService.getAttachments( | ||
dataTransferAreaPagesRest.jcrPath!!, | ||
area.id!!, | ||
dataTransferAreaPagesRest.attachmentsAccessChecker, | ||
checkAccess = false, | ||
) | ||
val attachmentsCounter = area.attachmentsCounter ?: 0 | ||
if (attachmentsCounter == 0 && attachments.isNullOrEmpty()) { | ||
// No attachments given/expected, nothing to check. | ||
return@forEach | ||
} | ||
jobContext.addMessage("Checking data transfer area $areaName with ${attachmentsCounter} attachments.") | ||
attachments?.forEach { attachment -> | ||
if (attachment.size == 0L) { | ||
jobContext.addWarning("Empty attachment ${attachment.name} in area $areaName.") | ||
} | ||
} | ||
if (attachmentsCounter != attachments?.size) { | ||
jobContext.addWarning("Attachments counter in area $areaName is ${attachmentsCounter}, but found ${attachments?.size} attachments.") | ||
} | ||
val areaAttachmentIds = area.attachmentsIds?.split(" ")?.filter { it.isNotBlank() } ?: emptyList() | ||
val jcrAttachmentIds = attachments?.map { it.fileId.toString() } ?: emptyList() | ||
val missingInJcr = areaAttachmentIds - jcrAttachmentIds | ||
val unknown = jcrAttachmentIds - areaAttachmentIds | ||
if (missingInJcr.isNotEmpty()) { | ||
jobContext.addError("${missingInJcr.size}/$attachmentsCounter attachments missing in JCR for area $areaName: ${missingInJcr.joinToString()}") | ||
missingInJcrCounter += missingInJcr.size | ||
} | ||
if (unknown.isNotEmpty()) { | ||
jobContext.addWarning("${unknown.size} unknown (orphaned) attachments in JCR for area $areaName: ${unknown.joinToString()}") | ||
orphanedCounter += unknown.size | ||
} | ||
} catch (ex: Exception) { | ||
jobContext.addWarning("Error while checking data transfer area $areaName: ${ex.message}") | ||
} | ||
} | ||
if (missingInJcrCounter > 0 || orphanedCounter > 0) { | ||
jobContext.addError("Checked $areaCounter data transfer areas: $missingInJcrCounter missed, $orphanedCounter orphaned attachments.") | ||
} | ||
jobContext.addMessage("Checked $areaCounter data transfer areas.") | ||
} | ||
} |
Oops, something went wrong.