diff --git a/src/acdhOeaw/arche/doorkeeper/Doorkeeper.php b/src/acdhOeaw/arche/doorkeeper/Doorkeeper.php index ba7fd6a..bdbc8ad 100644 --- a/src/acdhOeaw/arche/doorkeeper/Doorkeeper.php +++ b/src/acdhOeaw/arche/doorkeeper/Doorkeeper.php @@ -486,6 +486,12 @@ static private function checkPropertyRangeUri(DatasetNodeInterface $meta, try { $norm->resolve((string) $obj); RC::$log->debug("\t\t$prop value $obj resolved successfully"); + + $objNorm = $norm->normalize((string) $obj); + if ($objNorm !== (string) $obj) { + $objNorm = DF::namedNode($objNorm); + $meta->forEach(fn($q) => $q->withObject($objNorm), new PT($prop, $obj)); + } } catch (UriNormalizerException $ex) { throw new DoorkeeperException($ex->getMessage(), $ex->getCode(), $ex); } diff --git a/tests/ResourceTest.php b/tests/ResourceTest.php index ee304a4..7a038e0 100644 --- a/tests/ResourceTest.php +++ b/tests/ResourceTest.php @@ -41,6 +41,7 @@ use termTemplates\NamedNodeTemplate as NNT; use acdhOeaw\arche\lib\RepoResource; use acdhOeaw\arche\lib\BinaryPayload; +use acdhOeaw\arche\lib\exception\NotFound; /** * Description of DoorkeeperTest @@ -964,6 +965,23 @@ public function testTechnicalProperty(): void { } self::$repo->rollback(); } + + public function testNormalizeObjectValue(): void { + $prop = 'https://vocabs.acdh.oeaw.ac.at/schema#hasActor'; + $value = 'https://orcid.org/0000-0001-5853-2534/'; + $class = DF::namedNode('https://vocabs.acdh.oeaw.ac.at/schema#Collection'); + $meta = self::createMetadata([$prop => $value], $class); + self::$repo->begin(); + $res = self::$repo->createResource($meta); + $ref = self::$repo->getResourceById(substr($value, 0, -1)); // normalized form + try { + self::$repo->getResourceById($value); + $this->assertTrue(false); + } catch (NotFound $ex) { + $this->assertTrue(true); + } + self::$repo->rollback(); + } // public function testRangeUri(): void { // \acdhOeaw\arche\lib\ingest\MetadataCollection::$debug = true; // $graph = new \acdhOeaw\arche\lib\ingest\MetadataCollection(self::$repo, __DIR__ . '/kraus_processed.nt');