Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

how to package a new namespace that's been created on staging to our Production environment

Avatar

Level 2

I've created a new namespace on our staging environment and used it for custom metadata properties.

I've seen many articles to import the new namespaces using AEM namespace editor.

Is there a way to package the one we created on our Staging and install it on PROD. (assuming that AMS wouldn't provide access to namespace editor on PROD Environment).

Thank You!

1 Accepted Solution

Avatar

Correct answer by
Level 2

okay i tried something else again.

i went into the package that i got from my local instance with new namespaces added to "\jcr_root\_jcr_system\content.xml"

when i tried installing this package to another instance, it didn't add any new namespaces.

but i found a nodetypes.cnd file in this package "\META-INF\vault\nodetypes.cnd".

i added the new namespaces in this file like this:

1828064_pastedImage_0.png

installed the package with new changes. and YASSSSS! my new namespaces are available on this instance.

please let me know if this is not a best practise and have to be done differently.

Thank You!

View solution in original post

7 Replies

Avatar

Level 3

HI

ASFAIK .. there is no specifc tool for exporting the namespce. you can go to http://localhost:4502/crx/explorer/ui/namespace_editor.jsp and see all namespaces, you might wanty to use  small JS script to extract those namespaces and print them into a nice CND. 

once you get the CND, you can use the import node type (/crx/explorer/nodetypes/index.jsp) and paste the CND's.

this should work for you..

sample script - please test.

  1. (function(){
  2.   var namespacesCnd = "";
  3.   document.querySelectorAll("#mainTable > tbody table > tbody > tr")
  4.   .forEach(tr => {
  5.    var url = tr.children[0].innerHTML.replace(" ", "").trim();
  6.    var prefix = tr.children[1].innerHTML.replace(" ", "").trim();
  7.   namespacesCnd += "<'" + prefix +"'='" + url +"'>\n"
  8.   });
  9.   console.log(namespacesCnd)
  10. })()

Avatar

Employee

Namespaces are stored under /jcr:system/rep:namespaces.

I think you can create a package or migrate to target using the crx2oak tool (--include-paths=jcr:system/rep:namespaces)

Avatar

Employee

You need to use crx2oak to migrate the namespaces

Avatar

Level 2

Vish.dhaliwal

Adding or Deleting namespaces from AEM using CRX/DE is not possible. it gets deleted. but once we save and refresh, they are back to their normal state.

i tried packaging them from my local and installed the package on our dev server. it doesn't install the new ones that i created.

Avatar

Level 2

@husams51669576

is there a reference article or something you could provide for this please.

i found this: Using the CRX2Oak Migration Tool

but it doesn't specify anything about namespace migration.

Please let me know if you find any.

Thank You!

Avatar

Correct answer by
Level 2

okay i tried something else again.

i went into the package that i got from my local instance with new namespaces added to "\jcr_root\_jcr_system\content.xml"

when i tried installing this package to another instance, it didn't add any new namespaces.

but i found a nodetypes.cnd file in this package "\META-INF\vault\nodetypes.cnd".

i added the new namespaces in this file like this:

1828064_pastedImage_0.png

installed the package with new changes. and YASSSSS! my new namespaces are available on this instance.

please let me know if this is not a best practise and have to be done differently.

Thank You!

Avatar

Employee

Yes, I wasn't sure about the package. You should try with crx2oak as I mentioned in my comment earlier. Use --merge-paths=jcr:system/rep:namespaces in the crx2oak migration command.