Skip to content
Merged
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
8 changes: 6 additions & 2 deletions lib/Controller/NoticeOfDefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use DateTimeImmutable;
use OCA\Dossiq\Service\NoticeOfDefaultService;
use OCA\Dossiq\Service\SettingsService;
use OCA\Dossiq\Service\Support\SearchesObjects;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\JSONResponse;
Expand All @@ -41,6 +42,9 @@
* @psalm-suppress UnusedClass
*/
class NoticeOfDefaultController extends Controller {

use SearchesObjects;

/**
* Constructor.
*
Expand Down Expand Up @@ -150,12 +154,12 @@ public function show(string $id): JSONResponse {
}

try {
$row = $objectService->find($id, register: $register, schema: $schema);
$row = $this->findObjectAsArray(objectService: $objectService, register: $register, schema: $schema, id: $id);
} catch (Throwable $e) {
return new JSONResponse(['message' => 'Not found'], Http::STATUS_NOT_FOUND);
}

if (is_array($row) === false) {
if ($row === null) {
return new JSONResponse(['message' => 'Not found'], Http::STATUS_NOT_FOUND);
}

Expand Down
17 changes: 10 additions & 7 deletions lib/Controller/VoorstelBesluitController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use OCA\Dossiq\AppInfo\Application;
use OCA\Dossiq\Service\AdviceDelegationService;
use OCA\Dossiq\Service\SettingsService;
use OCA\Dossiq\Service\Support\SearchesObjects;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
Expand All @@ -48,6 +49,9 @@
* Controller for the voorstel besluit-registration delegation node.
*/
class VoorstelBesluitController extends Controller {

use SearchesObjects;

/**
* Constructor.
*
Expand Down Expand Up @@ -157,20 +161,19 @@ private function loadProposal(string $proposalId): ?array {
}

try {
$proposal = $objectService->find($proposalId, register: $register, schema: $proposalSchema);
return $this->findObjectAsArray(
objectService: $objectService,
register: $register,
schema: $proposalSchema,
id: $proposalId
);
} catch (Throwable $e) {
$this->logger->warning(
'Dossiq: voorstel lookup failed during IDOR gate: ' . $e->getMessage(),
['app' => Application::APP_ID]
);
return null;
}

if (is_array($proposal) === true) {
return $proposal;
}

return null;
}//end loadVoorstel()

/**
Expand Down
13 changes: 11 additions & 2 deletions lib/Listener/BeroepEscalationListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

use DateTimeImmutable;
use OCA\Dossiq\Service\SettingsService;
use OCA\Dossiq\Service\Support\SearchesObjects;
use OCA\OpenRegister\Event\ObjectCreatedEvent;
use OCA\OpenRegister\Event\ObjectUpdatedEvent;
use OCP\EventDispatcher\Event;
Expand All @@ -52,6 +53,9 @@
* @spec openspec/specs/beroep-escalation/spec.md
*/
class BeroepEscalationListener implements IEventListener {

use SearchesObjects;

/**
* Status values that close a bezwaar (terminal per bezwaar-lifecycle).
*
Expand Down Expand Up @@ -157,8 +161,13 @@ private function deriveDwingendStatus(Event $event): void {
return;
}

$objection = $objectService->find($sourceObjectionId, register: $register, schema: $objectionSchema);
if (is_array($objection) === false) {
$objection = $this->findObjectAsArray(
objectService: $objectService,
register: $register,
schema: $objectionSchema,
id: $sourceObjectionId
);
if ($objection === null) {
return;
}

Expand Down
42 changes: 31 additions & 11 deletions lib/Service/Bezwaar/AdvisoryCommitteeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
use OCA\Dossiq\AppInfo\Application;
use OCA\Dossiq\Service\AdviceDelegationService;
use OCA\Dossiq\Service\SettingsService;
use OCA\Dossiq\Service\Support\SearchesObjects;
use OCA\Dossiq\Service\Transitions\GuardFailedException;
use Psr\Log\LoggerInterface;
use RuntimeException;
Expand All @@ -56,6 +57,8 @@
*/
class AdvisoryCommitteeService {

use SearchesObjects;

/**
* Allowed advice-request lifecycle states.
*/
Expand Down Expand Up @@ -151,9 +154,15 @@ public function assignToCommittee(
);
}

// Validate committee exists and is active.
$committee = $objectService->find($commissieId, register: $register, schema: $committeeSchema);
if (is_array($committee) === false) {
// Validate committee exists and is active. find() returns an
// ObjectEntity (never an array), so go through the array bridge.
$committee = $this->findObjectAsArray(
objectService: $objectService,
register: $register,
schema: $committeeSchema,
id: $commissieId
);
if ($committee === null) {
throw new RuntimeException('Committee not found');
}

Expand Down Expand Up @@ -202,7 +211,7 @@ public function assignToCommittee(
);

try {
return $objectService->saveObject(object: $record, register: $register, schema: $requestSchema);
return ($this->saveObjectAsArray(objectService: $objectService, register: $register, schema: $requestSchema, object: $record) ?? $record);
} catch (\Throwable $e) {
$this->logger->error(
'Dossiq BAC: failed to create advice request: ' . $e->getMessage()
Expand Down Expand Up @@ -249,8 +258,13 @@ public function transitionAdviceStatus(
key: 'bac_advice_request_schema'
);

$current = $objectService->find($requestId, register: $register, schema: $requestSchema);
if (is_array($current) === false) {
$current = $this->findObjectAsArray(
objectService: $objectService,
register: $register,
schema: $requestSchema,
id: $requestId
);
if ($current === null) {
throw new RuntimeException('Advice request not found');
}

Expand Down Expand Up @@ -293,12 +307,13 @@ public function transitionAdviceStatus(
);

try {
return $objectService->saveObject(
object: $update,
return ($this->saveObjectAsArray(
objectService: $objectService,
register: $register,
schema: $requestSchema,
object: $update,
uuid: (string)$requestId
);
) ?? array_merge($current, $update));
} catch (\Throwable $e) {
$this->logger->error(
'Dossiq BAC: failed to transition advice request '
Expand Down Expand Up @@ -376,8 +391,13 @@ public function recordCouncilDeviation(
);

try {
$current = $objectService->find($requestId, register: $register, schema: $requestSchema);
if (is_array($current) === false) {
$current = $this->findObjectAsArray(
objectService: $objectService,
register: $register,
schema: $requestSchema,
id: $requestId
);
if ($current === null) {
return;
}

Expand Down
56 changes: 41 additions & 15 deletions lib/Service/Bezwaar/BeroepService.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
use DateTimeImmutable;
use OCA\Dossiq\Service\SettingsService;
use OCA\Dossiq\Service\StatusTransitionService;
use OCA\Dossiq\Service\Support\SearchesObjects;
use Psr\Log\LoggerInterface;
use RuntimeException;
use Throwable;
Expand All @@ -68,6 +69,9 @@
* @spec openspec/specs/beroep-escalation/spec.md
*/
class BeroepService {

use SearchesObjects;

/*
* NO VALID_OUTCOMES HERE — it was the whitelist `recordJudgment()` validated
* against, and that method is gone (see the note further down). The list of
Expand Down Expand Up @@ -178,8 +182,13 @@ public function register(
);
}

$contested = $objectService->find($contestedDecisionId, register: $register, schema: $appealDecisionSchema);
if (is_array($contested) === false) {
$contested = $this->findObjectAsArray(
objectService: $objectService,
register: $register,
schema: $appealDecisionSchema,
id: $contestedDecisionId
);
if ($contested === null) {
throw new RuntimeException('Contested beslissing not found');
}

Expand Down Expand Up @@ -207,7 +216,7 @@ public function register(
);

try {
return $objectService->saveObject(object: $record, register: $register, schema: $appealSchema);
return ($this->saveObjectAsArray(objectService: $objectService, register: $register, schema: $appealSchema, object: $record) ?? $record);
} catch (Throwable $e) {
$this->logger->error(
'Dossiq beroep: failed to register: ' . $e->getMessage()
Expand Down Expand Up @@ -249,8 +258,13 @@ public function addFileInspectionRequest(
key: 'beroep_schema'
);

$current = $objectService->find($appealId, register: $register, schema: $appealSchema);
if (is_array($current) === false) {
$current = $this->findObjectAsArray(
objectService: $objectService,
register: $register,
schema: $appealSchema,
id: $appealId
);
if ($current === null) {
throw new RuntimeException('Beroep not found');
}

Expand All @@ -271,12 +285,13 @@ public function addFileInspectionRequest(
$requests[] = $entry;

try {
return $objectService->saveObject(
object: ['fileInspectionRequests' => $requests],
return ($this->saveObjectAsArray(
objectService: $objectService,
register: $register,
schema: $appealSchema,
object: ['fileInspectionRequests' => $requests],
uuid: (string)$appealId
);
) ?? array_merge($current, ['fileInspectionRequests' => $requests]));
} catch (Throwable $e) {
$this->logger->error(
'Dossiq beroep: failed to add file-inspection request: '
Expand Down Expand Up @@ -343,8 +358,13 @@ public function executeCascade(string $appealId, string $action): array {
key: 'bezwaar_schema'
);

$current = $objectService->find($appealId, register: $register, schema: $appealSchema);
if (is_array($current) === false) {
$current = $this->findObjectAsArray(
objectService: $objectService,
register: $register,
schema: $appealSchema,
id: $appealId
);
if ($current === null) {
throw new RuntimeException('Beroep not found');
}

Expand Down Expand Up @@ -382,12 +402,13 @@ public function executeCascade(string $appealId, string $action): array {
}

try {
return $objectService->saveObject(
object: $patch,
return ($this->saveObjectAsArray(
objectService: $objectService,
register: $register,
schema: $appealSchema,
object: $patch,
uuid: (string)$appealId
);
) ?? array_merge($current, $patch));
} catch (Throwable $e) {
$this->logger->error(
'Dossiq beroep: failed to persist cascade: ' . $e->getMessage()
Expand Down Expand Up @@ -423,8 +444,13 @@ private function reopenSourceObjectionCase(
return null;
}

$sourceObjection = $objectService->find($sourceObjectionId, register: $register, schema: $objectionSchema);
if (is_array($sourceObjection) === false) {
$sourceObjection = $this->findObjectAsArray(
objectService: $objectService,
register: $register,
schema: $objectionSchema,
id: $sourceObjectionId
);
if ($sourceObjection === null) {
return null;
}

Expand Down
22 changes: 14 additions & 8 deletions lib/Service/Bezwaar/BezwaarCreationHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
namespace OCA\Dossiq\Service\Bezwaar;

use OCA\Dossiq\Service\SettingsService;
use OCA\Dossiq\Service\Support\SearchesObjects;
use OCP\IUserSession;
use Psr\Log\LoggerInterface;
use RuntimeException;
Expand All @@ -51,6 +52,9 @@
* @spec openspec/specs/bezwaar-beroep-workflow/spec.md
*/
class BezwaarCreationHook {

use SearchesObjects;

/**
* Constructor.
*
Expand Down Expand Up @@ -103,12 +107,13 @@ public function onBezwaarCreated(

$schemas = $this->resolveSchemas();

$decision = $objectService->find(
$contestedDecisionId,
$decision = $this->findObjectAsArray(
objectService: $objectService,
register: $schemas['register'],
schema: $schemas['decision']
schema: $schemas['decision'],
id: $contestedDecisionId
);
if (is_array($decision) === false) {
if ($decision === null) {
throw new RuntimeException('Contested decision not found');
}

Expand Down Expand Up @@ -220,12 +225,13 @@ private function linkRelatedCase(
string $objectionCaseId,
string $relatedCaseId,
): void {
$case = $objectService->find(
$objectionCaseId,
$case = $this->findObjectAsArray(
objectService: $objectService,
register: $register,
schema: $caseSchema
schema: $caseSchema,
id: $objectionCaseId
);
if (is_array($case) === false) {
if ($case === null) {
throw new RuntimeException('Bezwaar case not found');
}

Expand Down
Loading
Loading