Page tree
Skip to end of metadata
Go to start of metadata

Magnolia stores data in a Java Content Repository. The repository is a hierarchical object database that is particularly well-suited for storing content. In a content management system you need to be able to store text, documents, images and other binary objects along with their metadata. The data is structured as a tree of nodes. Each node can have one or more types. The type defines what kind of properties the node has, the number and type of its child nodes, and its behavior. See Jackrabbit Node Types for more information and Node Type Visualization for a diagram of the node type hierarchy.

In Magnolia we define custom node types that define Magnolia's custom content model. The JCR in turn enforces the constraints of that model at the repository level. If you need to reference JCR node types in your code, Jackrabbit's JcrConstants is useful. We provide constants also for Magnolia's custom node types but also convenience methods. For example, to update the last modification date of a node, use the NodeTypes.LastModified.update(node) convenience method. Magnolia node types are registered by the  NodeTypes  Java class.

Prefixes

Node type

Prefix

Notes

JCR primary node type

nt:


Mixin node type

mix:


Magnolia node type

mgnl:

The mgnl prefix does not tell you whether the node is a primary node or a mixin. To find out which type a mgnl node is, check the magnolia-types.xml file.

Node type hierarchy

In this simplified node type hierarchy diagram you can see what extends what. For example, mgnl:page extends mgnl:versionable. This means that page is an object you can version. In contrast, mgnl:area and mgnl:component are not versionable – they are subnodes that must be activated together with the parent page. However, all three node types (page, area, component) are renderable which means you can render a component on its own without its parent page. See the magnolia-types.xml file for a full view of the Magnolia node type hierarchy.

Primary node types

Every node has a primary node type assigned to it upon creation. The primary node type defines node structure such as allowed and required child nodes and properties. Primary types reflect the business that is represented in the repository. Magnolia's primary node types define content management nodes such as pages, areas, components and resources.

JCR primary node types

Notation

Description

nt:base

The base type of all primary node types.

nt:unstructured

Unstructured node type that allows any properties and child nodes.

nt:hierarchyNode

Abstract base type for nodes in a structured node hierarchy.

nt:file

JCR representation of a file.

nt:frozenNode

This node type is used in the versioning system.

Magnolia primary node types

The primary Magnolia node types are defined in:

magnolia-nodetypes.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
  /*
  * Copyright 2004-2005 The Apache Software Foundation or its licensors,
  *                     as applicable.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-->
<!--
<!DOCTYPE nodeTypes [
  <!ELEMENT nodeTypes (nodeType)*>
    <!ELEMENT nodeType (supertypes?|propertyDefinition*|childNodeDefinition*)>

    <!ATTLIST nodeType
      name CDATA #REQUIRED
      isMixin (true|false) #REQUIRED
      hasOrderableChildNodes (true|false) #REQUIRED
      primaryItemName CDATA #REQUIRED
    >
    <!ELEMENT supertypes (supertype+)>
    <!ELEMENT supertype (CDATA)>

    <!ELEMENT propertyDefinition (valueConstraints?|defaultValues?)>
    <!ATTLIST propertyDefinition
      name CDATA #REQUIRED
      requiredType (String|Date|Path|Name|Reference|Binary|Double|Long|Boolean|undefined) #REQUIRED
      autoCreated (true|false) #REQUIRED
      mandatory (true|false) #REQUIRED
      onParentVersion (COPY|VERSION|INITIALIZE|COMPUTE|IGNORE|ABORT) #REQUIRED
      protected (true|false) #REQUIRED
      multiple  (true|false) #REQUIRED
    >
    <!ELEMENT valueConstraints (valueConstraint+)>
    <!ELEMENT valueConstraint (CDATA)>
    <!ELEMENT defaultValues (defaultValue+)>
    <!ELEMENT defaultValue (CDATA)>

    <!ELEMENT childNodeDefinition (requiredPrimaryTypes)>
    <!ATTLIST childNodeDefinition
      name CDATA #REQUIRED
      defaultPrimaryType  CDATA #REQUIRED
      autoCreated (true|false) #REQUIRED
      mandatory (true|false) #REQUIRED
      onParentVersion (COPY|VERSION|INITIALIZE|COMPUTE|IGNORE|ABORT) #REQUIRED
      protected (true|false) #REQUIRED
      sameNameSiblings (true|false) #REQUIRED
    >
    <!ELEMENT requiredPrimaryTypes (requiredPrimaryType+)>
    <!ELEMENT requiredPrimaryType (CDATA)>
]>
-->

<nodeTypes
    xmlns:rep="internal"
    xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
    xmlns:mix="http://www.jcp.org/jcr/mix/1.0"
    xmlns:mgnl="http://www.magnolia.info/jcr/mgnl"
    xmlns:jcr="http://www.jcp.org/jcr/1.0">

  <!-- custom node types -->
  <!-- MetaData has to be kept until it is no longer used as primaryType in any module-->
  <nodeType name="mgnl:metaData" isMixin="false" hasOrderableChildNodes="true" primaryItemName="">
    <supertypes>
      <supertype>nt:hierarchyNode</supertype>
      <supertype>mix:referenceable</supertype>
    </supertypes>
    <propertyDefinition name="*" requiredType="undefined" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false"/>
  </nodeType>

  <nodeType name="mgnl:lastModified" isMixin="true">
    <propertyDefinition name="mgnl:lastModified" requiredType="Date" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false"/>
    <propertyDefinition name="mgnl:lastModifiedBy" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false"/>
  </nodeType>

  <nodeType name="mgnl:activatable" isMixin="true">
    <supertypes>
      <supertype>mix:lockable</supertype>
    </supertypes>
    <propertyDefinition name="mgnl:lastActivated" requiredType="Date" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false"/>
    <propertyDefinition name="mgnl:lastActivatedBy" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false"/>
    <propertyDefinition name="mgnl:activationStatus" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false"/>
  </nodeType>

  <nodeType name="mgnl:renderable" isMixin="true">
    <propertyDefinition name="mgnl:template" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false"/>
  </nodeType>

  <nodeType name="mgnl:created" isMixin="true">
    <propertyDefinition name="mgnl:created" requiredType="Date" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false"/>
    <propertyDefinition name="mgnl:createdBy" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false"/>
  </nodeType>

  <nodeType name="mgnl:versionable" isMixin="true">
    <supertypes>
      <supertype>mix:lockable</supertype>
    </supertypes>
    <propertyDefinition name="mgnl:comment" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false"/>
  </nodeType>

  <nodeType name="mgnl:deleted" isMixin="true">
    <supertypes>
      <supertype>mgnl:versionable</supertype>
    </supertypes>
    <propertyDefinition name="mgnl:deleted" requiredType="Date" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false"/>
    <propertyDefinition name="mgnl:deletedBy" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false"/>
  </nodeType>

  <nodeType name="mgnl:content" isMixin="false" hasOrderableChildNodes="true" primaryItemName="">
    <supertypes>
      <supertype>nt:hierarchyNode</supertype>
      <supertype>mix:referenceable</supertype>
      <supertype>mgnl:created</supertype>
      <supertype>mgnl:activatable</supertype>
      <supertype>mgnl:lastModified</supertype>
      <supertype>mgnl:renderable</supertype>
      <supertype>mgnl:versionable</supertype>
    </supertypes>
    <childNodeDefinition name="*" defaultPrimaryType="" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" sameNameSiblings="false">
      <requiredPrimaryTypes>
        <requiredPrimaryType>nt:base</requiredPrimaryType>
      </requiredPrimaryTypes>
    </childNodeDefinition>
    <propertyDefinition name="*" requiredType="undefined" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false"/>
    <propertyDefinition name="*" requiredType="undefined" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="true"/>
  </nodeType>

  <nodeType name="mgnl:contentNode" isMixin="false" hasOrderableChildNodes="true" primaryItemName="">
    <supertypes>
      <supertype>nt:hierarchyNode</supertype>
      <supertype>mix:referenceable</supertype>
      <supertype>mgnl:created</supertype>
      <supertype>mgnl:activatable</supertype>
      <supertype>mgnl:lastModified</supertype>
      <supertype>mgnl:renderable</supertype>
    </supertypes>
    <childNodeDefinition name="*" defaultPrimaryType="" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" sameNameSiblings="false">
      <requiredPrimaryTypes>
        <requiredPrimaryType>nt:base</requiredPrimaryType>
      </requiredPrimaryTypes>
    </childNodeDefinition>
    <propertyDefinition name="*" requiredType="undefined" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false"/>
    <propertyDefinition name="*" requiredType="undefined" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="true"/>
  </nodeType>

  <nodeType name="mgnl:folder" isMixin="false" hasOrderableChildNodes="true" primaryItemName="">
    <supertypes>
      <supertype>nt:folder</supertype>
      <supertype>mix:referenceable</supertype>
      <supertype>mgnl:created</supertype>
      <supertype>mgnl:activatable</supertype>
      <supertype>mgnl:lastModified</supertype>
    </supertypes>
    <childNodeDefinition name="*" defaultPrimaryType="" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" sameNameSiblings="false">
      <requiredPrimaryTypes>
        <requiredPrimaryType>nt:base</requiredPrimaryType>
      </requiredPrimaryTypes>
    </childNodeDefinition>
    <propertyDefinition name="*" requiredType="undefined" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false"/>
    <propertyDefinition name="*" requiredType="undefined" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="true"/>
  </nodeType>

  <nodeType name="mgnl:resource" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
    <supertypes>
      <supertype>nt:resource</supertype>
      <supertype>mgnl:created</supertype>
      <supertype>mgnl:activatable</supertype>
      <supertype>mgnl:lastModified</supertype>
    </supertypes>
    <propertyDefinition name="*" requiredType="undefined" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false"/>
  </nodeType>

  <nodeType name="mgnl:reserve" isMixin="false" hasOrderableChildNodes="true" primaryItemName="">
    <supertypes>
      <supertype>nt:hierarchyNode</supertype>
    </supertypes>
    <childNodeDefinition name="*" defaultPrimaryType="" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" sameNameSiblings="false">
      <requiredPrimaryTypes>
        <requiredPrimaryType>nt:base</requiredPrimaryType>
      </requiredPrimaryTypes>
    </childNodeDefinition>
    <propertyDefinition name="*" requiredType="undefined" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false"/>
  </nodeType>

  <nodeType name="mgnl:page" isMixin="false" hasOrderableChildNodes="true" primaryItemName="">
    <supertypes>
      <supertype>mgnl:content</supertype>
    </supertypes>
  </nodeType>

  <nodeType name="mgnl:area" isMixin="false" hasOrderableChildNodes="true" primaryItemName="">
    <supertypes>
      <supertype>mgnl:contentNode</supertype>
    </supertypes>
  </nodeType>

  <nodeType name="mgnl:component" isMixin="false" hasOrderableChildNodes="true" primaryItemName="">
    <supertypes>
      <supertype>mgnl:contentNode</supertype>
    </supertypes>
  </nodeType>

  <nodeType name="mgnl:user" isMixin="false" hasOrderableChildNodes="true" primaryItemName="">
    <supertypes>
      <supertype>mgnl:content</supertype>
    </supertypes>
  </nodeType>

  <nodeType name="mgnl:role" isMixin="false" hasOrderableChildNodes="true" primaryItemName="">
    <supertypes>
      <supertype>mgnl:content</supertype>
    </supertypes>
  </nodeType>

  <nodeType name="mgnl:group" isMixin="false" hasOrderableChildNodes="true" primaryItemName="">
    <supertypes>
      <supertype>mgnl:content</supertype>
    </supertypes>
  </nodeType>

  <nodeType name="mgnl:hasVersion" isMixin="true">
  </nodeType>
</nodeTypes>
These types are required for the basic features of Magnolia to function: configuration, page-editing and rendering as well as activation from author to public (which relies on versioning).

Notation

Description

mgnl:area

Area

mgnl:component

Component

mgnl:content

Activatable and versionable content objects such as pages.

mgnl:contentNode

Activatable but not versionable content objects which can be rendered independently. For example, blocks or objects below page level such as such as area or component.

mgnl:folder

Folder

mgnl:group

Group

mgnl:metaData

Metadata

mgnl:nodeData

Property

mgnl:page

Page

mgnl:reserve

Reserved for system use.

mgnl:resource

Resource
mgnl:role Role

mgnl:user

User

Mixin node types

Mixin node types specify additional properties or characteristics to the node. A node can have a primary type and several mixin types at the same time. JCR mixins add repository-level functionality such as versioning and locking. Magnolia mixins add content management capabilities such as activating and rendering.

JCR mixin node types

Notation

Description

mix:referenceable Mixin type for referenceable nodes. Provides an auto-created jcr:uuid property that gives the node a unique, referenceable identifier.
mix:versionableMixin type for versionable nodes.
mix:lockableEnables locking capabilities for a node.

Magnolia mixin node types

Notation

Properties

Description

mgnl:deleted

mgnl:deleted (DATE)

mgnl:deletedBy (STRING)

Date the node was deleted, the user who deleted it and the deletion comment.

mgnl:lastModified

mgnl:lastModified (DATE)

mgnl:lastModifiedBy (STRING)

Date the node was last modified and the user who modified it.
mgnl:activatable

mgnl:lastActivated (DATE)

mgnl:lastActivatedBy (STRING)

mgnl:activationStatus (STRING)

Date the node was activated, the user who activated it and its current activation status.


Note that on the public instance, lastActionDate always contains the date of the previous activation, not the current one. This is because the lastActionDate is updated only after the content is sent to the public instance.

mgnl:created

mgnl:created (DATE)

mgnl:createdBy (STRING)

Date the node was created and the user who created it.
mgnl:renderablemgnl:template (STRING)Associates a template with the node for rendering.
mgnl:versionablemgnl:comment (STRING)Allows the user to leave a comment on the version.

Same name siblings are not allowed

The Magnolia node type definition magnolia-types.xml  does not allow same name siblings. This means that you cannot have two nodes at the same level in the node hierarchy with the same name. Typically same name siblings is not an issue because Magnolia enforces the constraint automatically during normal usage. However, if prior to Magnolia 5.2 you imported an XML file that was created outside of Magnolia or was edited by hand, it is possible that the XML import created a same name sibling.

Use the siblings.groovy script to find same name siblings in your repository. The example below searches for identically named areas (returnItemType is mgnl:area) in the website workspace under the /travel/about page. See Groovy module for instructions on how to execute Groovy scripts.

siblings.groovy
import info.magnolia.cms.util.QueryUtil;
import info.magnolia.cms.core.search.Query;
import info.magnolia.cms.core.Path;
import info.magnolia.jcr.util.NodeUtil;
import info.magnolia.context.MgnlContext;
import javax.jcr.Session;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import org.apache.commons.lang.StringUtils;
import java.util.LinkedList;
def siblings(workspace,path,returnItemType) {
    query = "/jcr:root" + path + "//* order by @name";  //i.e. path=/travel/about
    try {
        NodeIterator nodes = QueryUtil.search(workspace,query,Query.XPATH,returnItemType);
        
        Session session = MgnlContext.getJCRSession(workspace);
        def siblings = []; 
        while (nodes.hasNext()) {
            Node node = nodes.nextNode();
            nodePath = node.getPath();
            if (StringUtils.contains(nodePath,"[")) {
              println "found same name sibling of '${node.getName()}' at ${nodePath}";
              siblings.add(node);
            }
        }
        siblings.each {
            nodePath = node.getPath();
            newName = Path.getUniqueLabel(session,nodePath,node.getName());
            NodeUtil.renameNode(node,newName);
            println "${nodePath} was renamed to ${newName}";
        }
        session.save();
    } catch (Exception e) {
        println e;
    }
}
//example
siblings("website", "/travel/about", "mgnl:area");

Options from the expandable Groovy script above:

  • workspace: Any Magnolia workspace.
  • path: A valid path in the workspace. / will search for everything under the workspace root.
  • returnItemType: A valid JCR node type. The query goes through all node types but the results are filtered to the node type you specify. Use nt:base as a "wildcard". 

Module-specific node types

The following sections list node types that are provided by individual Magnolia modules. You can define several node types per module if you so require. Almost all the node types added inherit from mgnl:contentNode or mgnl:content.

Content Editor module

Defined in content-editor-nodetypes.xml .

Notation

Description

mgnl:blockContent editor block objects containing text, image or similar content. Inherits from mgnl:contentNode and are activatable but not versionable.
mgnl:compositionCompositions are activatable and versionable as a whole and contain ordered subnodes of type mgnl:block.
mgnl:collectionCollection of unordered content editor compositions.

Password manager module

Defined in magnolia-keystore-nodetypes.xml .

Notation

Description

mgnl:passwordAn object containing a password. The object is both activatable and versionable.


Personalization module

Notation

Description

mgnl:componentVariantA personalized variant of a component node.
  • No labels