Having issue with content type names after migration


#1

Enonic version: 6.15.3
**OS:**10.14

There are migrated contents from CMS with content types person and Person used in enonic XP in same app. This causes issue when deploying via case insensitive file system and only one content type is included in the app. Is there any way to rename the content type without affecting the existing contents that has been migrated from CMS


#2

Hi Gayathri,

Changing the content type can be done in two ways: By manually editing imported files, or programmatically using the Node API.

Manually

  • Create an export (for instance by using the Data Toolbox app)
  • Inside the exported data, using a text editor: do a search-replace that sets content with the old content type to get the new content type
  • Re-import the data

Programmatically

  • Using lib-node, connect() to the cms-repo using principals role:system-admin.
  • On the RepoConnection object that you’ve connected to, query() the content where type = “person”.
  • I’m not sure if the query in the previous step is case sensitive, but you can filter the hits in javascript afterwards if it isn’t. Use lib-node get() to get the content from the IDs returned by the query and then filter based on type.
  • On the repo object that you’ve connected to, modify() using an editor function as described here: http://repo.enonic.com/public/com/enonic/xp/docs/6.15.5/docs-6.15.5-libdoc.zip!/module-node-RepoConnection.html#modify

I haven’t tried the manual method myself, so I’m not sure how well that method works.


#3

I can confirm that the manual method you describe works very well. Export it, open the zip and use Atom or Sublime or similar to search and replace inside all node.xml files for this:
<string name="type">my.app.com:old_contenttype</string>

and replace it with this instead:
<string name="type">my.app.com:new_contenttype</string>

Then create a new zip of all these folders and files, upload it with Data Toolbox, delete the old contents on the server and then run the import/load with Data Toolbox. This should give you what you need in very few steps and no coding.


#4

Also, XP is case-insensitive in most cases, including content types. It does not support two content types with same name and different case.