Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -516,5 +516,40 @@

// GraphQL Subscriptions (SSE).
['name' => 'graphQLSubscription#subscribe', 'url' => '/api/graphql/subscribe', 'verb' => 'GET'],

// Retention management: archival settings.
['name' => 'Settings\ConfigurationSettings#getArchivalSettings', 'url' => '/api/settings/archival', 'verb' => 'GET'],
['name' => 'Settings\ConfigurationSettings#updateArchivalSettings', 'url' => '/api/settings/archival', 'verb' => 'PUT'],
['name' => 'Settings\ConfigurationSettings#updateArchivalSettings', 'url' => '/api/settings/archival', 'verb' => 'PATCH'],

// Retention management: destruction list approval workflow.
['name' => 'retention#approveDestructionList', 'url' => '/api/retention/destruction-lists/{id}/approve', 'verb' => 'POST', 'requirements' => ['id' => '[^/]+']],
['name' => 'retention#rejectDestructionList', 'url' => '/api/retention/destruction-lists/{id}/reject', 'verb' => 'POST', 'requirements' => ['id' => '[^/]+']],

// Retention management: legal holds.
['name' => 'retention#placeLegalHold', 'url' => '/api/retention/legal-holds', 'verb' => 'POST'],
['name' => 'retention#releaseLegalHold', 'url' => '/api/retention/legal-holds/{id}', 'verb' => 'DELETE', 'requirements' => ['id' => '[^/]+']],
['name' => 'retention#placeBulkLegalHold', 'url' => '/api/retention/legal-holds/bulk', 'verb' => 'POST'],

// Archival destruction workflow endpoints (spec-compliant /api/archival/ prefix).
['name' => 'archival#listDestructionLists', 'url' => '/api/archival/destruction-lists', 'verb' => 'GET'],
['name' => 'archival#getDestructionList', 'url' => '/api/archival/destruction-lists/{id}', 'verb' => 'GET', 'requirements' => ['id' => '[^/]+']],
['name' => 'archival#approveDestructionList', 'url' => '/api/archival/destruction-lists/{id}/approve', 'verb' => 'POST', 'requirements' => ['id' => '[^/]+']],
['name' => 'archival#rejectDestructionList', 'url' => '/api/archival/destruction-lists/{id}/reject', 'verb' => 'POST', 'requirements' => ['id' => '[^/]+']],
['name' => 'archival#createLegalHold', 'url' => '/api/archival/legal-holds', 'verb' => 'POST'],
['name' => 'archival#releaseLegalHold', 'url' => '/api/archival/legal-holds/{id}', 'verb' => 'DELETE', 'requirements' => ['id' => '[^/]+']],
['name' => 'archival#listLegalHolds', 'url' => '/api/archival/legal-holds', 'verb' => 'GET'],
['name' => 'archival#listCertificates', 'url' => '/api/archival/certificates', 'verb' => 'GET'],

// e-Depot transfer settings.
['name' => 'Settings\EdepotSettings#getEdepotSettings', 'url' => '/api/settings/edepot', 'verb' => 'GET'],
['name' => 'Settings\EdepotSettings#updateEdepotSettings', 'url' => '/api/settings/edepot', 'verb' => 'PUT'],
['name' => 'Settings\EdepotSettings#updateEdepotSettings', 'url' => '/api/settings/edepot', 'verb' => 'PATCH'],
['name' => 'Settings\EdepotSettings#testEdepotConnection', 'url' => '/api/settings/edepot/test', 'verb' => 'POST'],

// e-Depot transfer management.
['name' => 'transfer#index', 'url' => '/api/transfers', 'verb' => 'GET'],
['name' => 'transfer#show', 'url' => '/api/transfers/{id}', 'verb' => 'GET', 'requirements' => ['id' => '[^/]+']],
['name' => 'transfer#create', 'url' => '/api/transfers', 'verb' => 'POST'],
],
];
98 changes: 98 additions & 0 deletions lib/BackgroundJob/BulkLegalHoldJob.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?php

/**
* OpenRegister Bulk Legal Hold Background Job
*
* Queued background job that places legal holds on all objects in a schema.
*
* @category BackgroundJob
* @package OCA\OpenRegister\BackgroundJob
*
* @author Conduction Development Team <dev@conduction.nl>
* @copyright 2024 Conduction B.V.
* @license EUPL-1.2 https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
*
* @version GIT: <git_id>
*
* @link https://www.OpenRegister.app
*/

declare(strict_types=1);

namespace OCA\OpenRegister\BackgroundJob;

use DateTime;
use Exception;
use OCA\OpenRegister\Service\RetentionService;
use OCA\OpenRegister\Db\MagicMapper;
use OCA\OpenRegister\Db\AuditTrailMapper;
use OCP\BackgroundJob\QueuedJob;
use OCP\AppFramework\Utility\ITimeFactory;
use Psr\Log\LoggerInterface;

/**
* Queued job for placing legal holds on all objects in a schema.
*/
class BulkLegalHoldJob extends QueuedJob
{
/**
* Constructor.
*
* @param ITimeFactory $time Time factory
*/
public function __construct(ITimeFactory $time)
{
parent::__construct(time: $time);
}//end __construct()

/**
* Execute the bulk legal hold operation.
*
* @param mixed $argument Job arguments with schemaId, reason, userId
*
* @return void
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
protected function run($argument): void
{
$logger = \OC::$server->get(LoggerInterface::class);

$schemaId = $argument['schemaId'] ?? null;
$reason = $argument['reason'] ?? '';
$userId = $argument['userId'] ?? 'system';

if ($schemaId === null) {
$logger->error('[BulkLegalHoldJob] No schemaId provided');
return;
}

$logger->info('[BulkLegalHoldJob] Placing legal holds on schema: '.$schemaId);

try {
$retentionService = \OC::$server->get(RetentionService::class);
$objectMapper = \OC::$server->get(MagicMapper::class);

$objects = $objectMapper->findAll(
filters: [],
schema: $schemaId,
_rbac: false,
_multitenancy: false
);

$count = 0;

foreach ($objects as $object) {
$retentionService->placeLegalHold($object, $reason);
$objectMapper->update($object);
$count++;
}

if ($count > 0) {
$logger->info('[BulkLegalHoldJob] Placed legal holds on '.$count.' objects');
}
} catch (Exception $e) {
$logger->error('[BulkLegalHoldJob] Error: '.$e->getMessage(), ['exception' => $e]);
}//end try
}//end run()
}//end class
Loading
Loading