Node types
Each node in a JCR workspace has a node type that defines the child nodes and properties it may (or must) have. Magnolia CMS uses the node types to define a custom content model while Jackrabbit enforces the constraints of that model at the repository level. For more information see Apache Jackrabbit Node Types.
Magnolia CMS does not use the Jackrabbit JcrConstants as they are not comprised of both prefixes and suffixes. This has query limitations, for example, if a NodeType starts with MgnlNodeType.JCR_PREFIX.
Magnolia node types are registered by the MgnlNodeType Java class. Both prefixes and suffixes are defined.
Prefixes
| Name | Syntax |
|---|---|
| nodeType | nt: |
| mixin | mix: |
| mgnl-properties | mgnl: |
| jcr-properties | jcr: |
Node Types
Magnolia node types
| Node type | Prefix/Syntax |
|---|---|
| base | nt:base |
| unstructured | nt:unstructured |
| hierarchy node | nt:hierarchyNode |
| folder | mgnl:folder |
| file | nt:file |
| resource | mgnl:resource |
| metadata | mgnl:metadata |
| content | mgnl:content |
| content node | mgnl:contentNode |
| page | mgnl:page |
| area | mgnl:area |
| component | mgnl:component |
| node data | mgnl:nodeData |
| frozen node | nt:frozenNode |
| user | mgnl:user |
| role | mgnl:role |
| group | mgnl:group |
| system | mgnl:reserve |
Mixin node types
| Node type | Prefix/Syntax |
|---|---|
| access control | mix:accessControllable |
| reference | mix:referencable |
| version | mix:versionable |
| lock | mix:lockable |
| deleted | mgnl:deleted |
JCR properties
| Node type | Prefix/Syntax |
|---|---|
| JCR primary type | jcr:primaryType |
| JCR frozen node | jcr:frozenNode |
| JCR frozen primary type | jcr:frozenPrimaryType |
| JCR data | jcr:data |
| JCR content | jcr:content |
Queries
Magnolia CMS supports the SQL and JCR-SQL2 query languages. Although deprecated, XPath remains available and will be supported for the foreseeable future.
JCR query tools
Query tools are available at Tools > JCR Queries.
The Dump tool creates a repository dump:
- Select a repository (workspace).
- Type a path.
- Select the number of levels.
- Click Execute
The results are displayed in the Result box. A dump returns all nodes in the JCR that comply with the selected criteria. Here are a few sample results for the above dump.
/demo-project/about/jcr:uuid=f312fc16-8f66-451c-bdf0-a72913b74c2d /demo-project/about/jcr:primaryType=mgnl:page /demo-project/about/MetaData/mgnl:activatorid=superuser /demo-project/about/extras/jcr:ixinTypes=mix:lockable /demo-project/about/subsection-articles/hideInNav=false /demo-project/about/history/promos[mgnl:area]
The Query tool executes the results of a specific query:
- Select the repository and the query language.
- Define the result ItemType, if any.
- Type the query in the main box.
- Click Execute.
The results are displayed in the Result box.
Sample queries
A few tips for writing and testing queries:
- Use the query tool to validate queries used in code.
- An incorrect query often returns empty results which complicates debugging
- Make your queries additive. Test the basics and then refine them to be more precise.
- Case insensitive searches are not supported. As workaround, ensure that both parts of the search condition use same case.
| Workspace | Result | SQL query |
|---|---|---|
| website | All pages | select * from mgnl:page |
| Pages in the About section | select * from mgnl:page where jcr:path like '/demo-project/about/%' |
|
| Pages with "News" in the title | select * from mgnl:page where title like '%News%' |
|
| Pages with "News" in the title (case sensitive) | select * from mgnl:content where title like 'News' |
|
| Pages that use a specific DMS image | select * from mgnl:content where imageDmsUUID='01d1b9bc-93e8-471f-96db-2c81855ce65d' |
|
| Pages that link to a contact | select * from nt:base where linkTitle like '%Contact%' and linkType='internal' |
|
| config | Component types | select * from nt:base where jcr:path like '/modules/%/components/%' and type is not null |
| users | User with email eric@example.com | select * from mgnl:user where email = 'eric@example.com' |
| data | Data categories that have related categories | select * from nt:base where jcr:path like
'/categorization/%' and relatedUUID is not null |
| dms | JPEG images in the DMS | select * from nt:base where type='jpg' |