2. Repository Structure

One of the fundamental steps towards mastering JCR queries in Magnolia is understanding the repository structure. The Java Content Repository (JCR) is the place where all data in Magnolia is stored, including pages, components, assets and user data. This section of the tutorial will guide you through the basics of this structure and help you build a solid foundation for creating queries.

Nodes and Properties

  • JCR organizes data in a hierarchical structure, similar to a file system.
  • At the top of this hierarchy are nodes. Think of nodes as folders in a file system. In Magnolia, everything is a node - a page, an image, a user, etc.
  • Each node can have properties. These are like files in your folders. Properties store actual data - like the title of a page, the source of an image, or the name of a user.

[Practical Tip: Exploring the repository using Magnolia's AdminCentral can give you a hands-on understanding of nodes and properties. Try navigating through different nodes and observe their properties.]

Understanding Node Types

  • Nodes come in different types, defining the structure and behavior of the data they contain. For example, a mgnl:page node type represents a page in Magnolia.
  • Knowing the node types is crucial for writing precise queries. For instance, querying mgnl:contentNode might return different results compared to querying mgnl:page.

[Activity: Look at different node types in the AdminCentral. See if you can identify the differences between them based on their properties.]

Path

  • Each node has a unique path, identifying its location in the hierarchy. For example, the path /website/home might lead to the home page node of your website.
  • Understanding paths is key to navigating and querying the JCR. Paths help you pinpoint the exact node you want to work with.

[Exercise: Try finding the path of a specific node, like the home page or a user profile. Use this path in a simple query to see if it returns the expected node.]

Using the JCR Browser to get familiar with Magnolia node structures

  • Magnolia provides a JCR Browser in the AdminCentral. This tool allows you to visually navigate through the node hierarchy.
  • Spend time with the JCR Browser. Click on different nodes and observe their paths, types, and properties.