Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exporting node types #199

Closed
pun-ky opened this issue Jul 10, 2020 · 5 comments · Fixed by #201
Closed

Exporting node types #199

pun-ky opened this issue Jul 10, 2020 · 5 comments · Fixed by #201
Assignees

Comments

@pun-ky
Copy link
Contributor

pun-ky commented Jul 10, 2020

is there any way to export node types via some endpoint / similar feature like: https://www.bounteous.com/sites/default/files/export-node-frpm-crx-lite.png
?

sample output file nodetypes.cnd:

<'sling'='http://sling.apache.org/jcr/sling/1.0'>
<'nt'='http://www.jcp.org/jcr/nt/1.0'>
<'oak'='http://jackrabbit.apache.org/oak/ns/1.0'>
<'jcr'='http://www.jcp.org/jcr/1.0'>
<'mix'='http://www.jcp.org/jcr/mix/1.0'>
<'rep'='internal'>
<'slingevent'='http://sling.apache.org/jcr/event/1.0'>

[sling:OrderedFolder] > sling:Folder
  orderable
  + * (nt:base) = sling:OrderedFolder version

[oak:Unstructured]
  - * (undefined) multiple
  - * (undefined)
  + * (nt:base) = oak:Unstructured version

[nt:linkedFile] > nt:hierarchyNode
  primaryitem jcr:content
  - jcr:content (reference) mandatory
@pun-ky
Copy link
Contributor Author

pun-ky commented Jul 20, 2020

seems that https://jackrabbit.apache.org/api/2.12/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefWriter.html need to be used and exposed in some servlet:

  final CompactNodeTypeDefWriter cnd = new CompactNodeTypeDefWriter((Writer)res.getWriter(), session, true);
            final NodeTypeIterator iter = session.getWorkspace().getNodeTypeManager().getAllNodeTypes();
            while (iter.hasNext()) {
                cnd.write((NodeTypeDefinition)iter.nextNodeType());
            }
            cnd.close();

I need this to be able to provide nodetypes.cnd file to OakPAL tool which validates packages before installing them on Sling.

@stoerr
Copy link
Member

stoerr commented Jul 21, 2020

What do you actually need here - an export of one or several nodetypes given in the request (e.g. all nodetypes whose name is matching a given pattern), or the export of the nodetype(s) that apply to a given resource, or something else?

@pun-ky
Copy link
Contributor Author

pun-ky commented Jul 21, 2020

@stoerr as you can see on snippet above, it prints all nodetypes registered in oak repository. I need them to perform offline validation of package to be deployed using in-memory oak repository which will be fed by exported node types using this missing endpoint/servlet.

all nodetypes whose name is matching a given pattern

all node types without any filtering.

FYI I am upgrading Gradle Sling Plugin (fork of Gradle AEM Plugin) so that it will have all features of GAP too... but I got stuck on automatic node types synchronization because Composum/Sling does not provide endpoint/servlet for exporting these node types, I mean something like http://localhost:4502/crx/de/exportnodetype.jsp on AEM.

@stoerr
Copy link
Member

stoerr commented Aug 11, 2020

@pun-ky Since you asked so nicely :-) and even provided the crucial code yourself, I whipped up a quick implementation for that. I hope that's what you need - it's in the new release 1.2.12 of the composum core. It's URL is /bin/cpm/nodes/debug/nodetypes and has an optional nameregex parameter where you could restrict the types if you need to - since you don't it's fine if you skip it and thus get everything. I also provided it in form of a Sling console plugin, since that was the form in which I had wished for it sometimes. Please let us know if there is some trouble.

@stoerr stoerr closed this as completed Aug 11, 2020
@stoerr stoerr linked a pull request Aug 11, 2020 that will close this issue
@stoerr stoerr self-assigned this Aug 11, 2020
@pun-ky
Copy link
Contributor Author

pun-ky commented Aug 12, 2020

It's okay. Thank you very much 👌🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants