[MGNLCT-36] Update namespace registrations Created: 22/May/18  Updated: 21/Aug/18  Resolved: 07/Jun/18

Status: Closed
Project: Content Types
Component/s: None
Affects Version/s: None
Fix Version/s: 1.0

Type: Task Priority: Neutral
Reporter: Mikaël Geljić Assignee: Hieu Nguyen Duc
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: 0d
Time Spent: 4d 5.5h
Original Estimate: 2d

Issue Links:
Cloners
clones MGNLCT-13 Register namespaces for jackrabbit da... Closed
causality
is causing MGNLCT-40 Data migration upon namespace definit... Open
Template:
Acceptance criteria:
Empty
Task DoR:
Empty
Date of First Response:
Epic Link: Content types foundation
Sprint: Saigon 146, Saigon 147
Story Points: 3

 Description   

Mind that namespaces are registered for the entire repository (and likely cannot be removed); to be checked.



 Comments   
Comment by Hieu Nguyen Duc [ 25/May/18 ]

Namespaces are registered for entire repository. An attempt re-registering the same namespace will throw

... mapping already exists 

Summary of updating namespaces

Based on the changes of content type, we will get namespaces that need to be registered, unregistered and updated.

1) Register new namespaces

Reuse JackrabbitInitializer#registerNamespaces

2) Unregister namespace:

Can't do because NamespaceRegistryImpl#unregisterNamespace doesn't support

/**
 * as we can't guarantee that there are no references to the specified
 * namespace (in names of nodes/properties/node types etc.) we simply
 * don't allow it.Bullet list
 */
throw new NamespaceException("unregistering namespaces is not supported.");

3) Update namespace

  • If prefix is new, register it
  • if URI is new, remap it with current prefix
    • Can't remap because NamespaceRegisterImpl#registerNamespace doesn't support
      • if (prefixToURI.containsKey(prefix)) {
            /**
             * prevent remapping of existing prefixes because this would in effect
             * remove the previously assigned namespace;
             * as we can't guarantee that there are no references to this namespace
             * (in names of nodes/properties/node types etc.) we simply don't allow it.
             */
            throw new NamespaceException("failed to register namespace "
                    + prefix + " -> " + uri
                    + ": remapping existing prefixes is not supported.");
        }
    • Alternative solution: NamespaceRegistryImpl#externalRemap(String oldPrefix, String newPrefix, String uri) // public method, not public API
      • For example, these are steps to remap ("pizza": "https://pizzaria.com") to ("pizza": "https://pizza-shop.com")
        • #externalRemap("pizza", <randomString>, "https://pizzaria.com")
        • #registerNamespace("pizza", "https://pizza-shop.com")
      • Pro: It'll work
      • Con: PermissionAwareNamespaceRegistry can't be cast to NamespaceRegistryImpl. Maybe need to bring #externalRemap into PermissionAwareNamespaceRegistry

(To be updated)

 

Comment by Dai Ha [ 12/Jun/18 ]

QA completed, namespace can be registered/remapped fine.

Generated at Mon Feb 12 00:36:32 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.