diff --git a/tests/features/joinup_core/persistent_uris.feature b/tests/features/joinup_core/persistent_uris.feature index 7bea4309d2..8384eca5c4 100644 --- a/tests/features/joinup_core/persistent_uris.feature +++ b/tests/features/joinup_core/persistent_uris.feature @@ -45,7 +45,7 @@ Feature: And "eira" terms: | tid | name | description | - | http://data.europa.eu/dr8/DreamDomain | Dream Domain | You're safe from pain in the dream domain. | + | http://data.europa.eu/dr8/Dream/Domain | Dream Domain | You're safe from pain in the dream domain. | And discussion content: | title | body | collection | state | @@ -103,34 +103,23 @@ Feature: # Our semantic content has a persistent canonical path at Europe's # official data portal: "http://data.europa.eu/w21/{uuid}". The data portal - # links back to the Joinup servers. In order to resolve the UUIDs we employ - # the intermediate path '/data/{uuid}' which will forward the request to the - # actual page that contains the content in human digestible format. - Given I am on "data/ffb0ffc9-7704-45d3-95b3-42706b6320e5" - Then I should see the heading "Persistent solution" - And I am on "data/w21/ffb0ffc9-7704-45d3-95b3-42706b6320e5" + # links back to the Joinup servers. + Given I am on "data/w21/ffb0ffc9-7704-45d3-95b3-42706b6320e5" Then I should see the heading "Persistent solution" - Given I am on "data/37b8103e-26e5-4c81-8ce5-43ced02ff7d0" - Then I should see the heading "Persistent collection" - And I am on "data/w21/37b8103e-26e5-4c81-8ce5-43ced02ff7d0" + Given I am on "data/w21/37b8103e-26e5-4c81-8ce5-43ced02ff7d0" Then I should see the heading "Persistent collection" - Given I am on "data/98004ec9-62f3-4734-a1b6-af7e4838b09c" - Then I should see the heading "Persistent release 23" - And I am on "data/w21/98004ec9-62f3-4734-a1b6-af7e4838b09c" + Given I am on "data/w21/98004ec9-62f3-4734-a1b6-af7e4838b09c" Then I should see the heading "Persistent release 23" - Given I am on "data/643a2a52-da3b-4594-92bb-295d8134e1fb" - Then I should see the heading "Persistent distribution" - And I am on "data/w21/643a2a52-da3b-4594-92bb-295d8134e1fb" + Given I am on "data/w21/643a2a52-da3b-4594-92bb-295d8134e1fb" Then I should see the heading "Persistent distribution" - Given I am on "data/4205229d-92b6-4cac-80af-d8c2296d923c" - Then I should see the heading "Persistent licence" - And I am on "data/w21/4205229d-92b6-4cac-80af-d8c2296d923c" + Given I am on "data/w21/4205229d-92b6-4cac-80af-d8c2296d923c" Then I should see the heading "Persistent licence" - Given I am on "data/dr8/DreamDomain" + Given I am on "data/dr8/Dream/Domain" Then I should see the heading "Dream Domain" And I should see "You're safe from pain in the dream domain." + And the url should match "/taxonomy/term/http_e_f_fdata_ceuropa_ceu_fdr8_fDream_fDomain" diff --git a/web/modules/custom/joinup_core/joinup_core.routing.yml b/web/modules/custom/joinup_core/joinup_core.routing.yml index 448f032fd6..8a1bf7da31 100644 --- a/web/modules/custom/joinup_core/joinup_core.routing.yml +++ b/web/modules/custom/joinup_core/joinup_core.routing.yml @@ -14,21 +14,17 @@ joinup_core.file_field_info: requirements: _permission: 'administer content types' -# @todo Remove this when the w21 redirect has been updated. -joinup_core.id_redirect.deprecated: - path: '/data/{uuid}' - defaults: - _controller: '\Drupal\joinup_core\Controller\IdRedirect::redirectToRdfEntity' - namespace: w21 - requirements: - _access: 'TRUE' - joinup_core.id_redirect: path: '/data/{namespace}/{uuid}' defaults: _controller: '\Drupal\joinup_core\Controller\IdRedirect::redirectToRdfEntity' requirements: _access: 'TRUE' + # Even though we are using a custom processor to alter the UUID value to not + # include the /, we need to set the value of UUID to match '.+' because the + # Drupal routing system uses by default the '[^/]' for route parameters. + # @see \Drupal\Core\Routing\Router::doMatchCollection() + uuid: '.+' joinup_core.rdf_entity_uri_web_converter_page: path: '/rdf' diff --git a/web/modules/custom/joinup_core/joinup_core.services.yml b/web/modules/custom/joinup_core/joinup_core.services.yml index ff9a5e23df..a49001027b 100644 --- a/web/modules/custom/joinup_core/joinup_core.services.yml +++ b/web/modules/custom/joinup_core/joinup_core.services.yml @@ -1,12 +1,16 @@ services: + joinup_core.joinup_version: class: Drupal\joinup_core\JoinupVersion + logger.channel.joinup_core: parent: logger.channel_base arguments: ['joinup_core'] + joinup_core.requirements_helper: class: Drupal\joinup_core\RequirementsHelper arguments: ['@database'] + joinup_core.local_task_links_helper: class: Drupal\joinup_core\LocalTaskLinksHelper arguments: ['@entity_type.manager'] @@ -15,3 +19,8 @@ services: arguments: ['@entity_field.manager'] tags: - { name: event_subscriber } + + path_processor.joinup_core: + class: Drupal\joinup_core\PathProcessor\IdRedirectUuidProcessor + tags: + - { name: path_processor_inbound, priority: 200 } diff --git a/web/modules/custom/joinup_core/src/Controller/IdRedirect.php b/web/modules/custom/joinup_core/src/Controller/IdRedirect.php index 0468b5a49e..8c86c91bcf 100644 --- a/web/modules/custom/joinup_core/src/Controller/IdRedirect.php +++ b/web/modules/custom/joinup_core/src/Controller/IdRedirect.php @@ -28,6 +28,9 @@ public function redirectToRdfEntity(string $namespace, string $uuid): RedirectRe return $this->redirect('joinup_core.not_found', [], [], 404); } + // The UUID has been encoded early to allow slashes. + // @see \Drupal\joinup_core\PathProcessor\IdRedirectNamespaceProcessor::processInbound() + $uuid = urldecode($uuid); return $this->redirect("entity.$entity_type_id.canonical", [ $entity_type_id => "http://data.europa.eu/$namespace/$uuid", ], [], 301); diff --git a/web/modules/custom/joinup_core/src/PathProcessor/IdRedirectUuidProcessor.php b/web/modules/custom/joinup_core/src/PathProcessor/IdRedirectUuidProcessor.php new file mode 100644 index 0000000000..f5f34a7557 --- /dev/null +++ b/web/modules/custom/joinup_core/src/PathProcessor/IdRedirectUuidProcessor.php @@ -0,0 +1,38 @@ +query->has('uuid')) { + preg_match('#^/data/(?[^/]+)/(?.+)$#', $path, $matches); + if (!empty($matches['namespace']) && !empty($matches['uuid'][0]) && IdRedirect::getEntityTypeFromPersistentUriNamespace($matches['namespace'])) { + return '/data/' . $matches['namespace'] . '/' . urlencode($matches['uuid']); + } + } + return $path; + } + +}