Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Table of Contents
maxLevel2


...

Introduction to JCR

 


Expand
titleClick here for an introduction to the Content Repository API for Java (JCR)

A Java Content Repository (JCR) is a database with a standardized Java Application Programming Interface (API). A JCR allows different applications to access one centralized database. Other technologies that are comparable to JCR are JDBC, Hibernate and WebDAV. Unlike relational databases, a JCR has a hierarchical tree structure. The tree consists of nodes and properties. The properties are the leaves of the tree and represent the actual pieces of database content. A property is of one of the following types: string, binary, date, a number type, boolean, name, path or reference.




In addition, a node contains attributes that are related to the node itself, for example the name of the node, its path in the tree, its depth in the tree and its type. Therefore, a node has attributes and it contains properties. The organization of the repository into a tree structure is done by the JCR Browser: Internally the content may be stored in a relational database.

Node Types

Every node has one primary node type. The primary node type defines the properties and child nodes that it is allowed or required to have. Every node has a special property called jcr:primaryType that records the name of its primary node type. In addition to its primary node type, a node may also have one or more mixin types. A mixin node type can mandate more child nodes and properties in addition to those enforced by its primary node type.

Multi-value Properties

In some cases, a property may have more than one value. A property that may have more than one value is referred to as a multi-value property. The property definition determines whether a particular property is a multi-value property.

Standardized by JCP

JCR has been standardized by the Java Community Process (JCP) in JSR 170 (API version 1.0) and JSR 283 (API version 2.0). Depending on the API version and compliance level, a JCR may support the following:

  • Read-only or read/write access
  • Different types of nodes and properties
  • Simple or full versioning and multiple languages
  • Query languages like XPath, SQL, SQL2, AQM, JQOM
  • Locking
  • Observation of content changes
  • Export and import of content via XML files
  • JTA (XA transactions)
 


See also: http://jcp.org

 



...

Using the XperienCentral JCR Browser

...

When you select a node, the following attributes are shown in the "Node Attributes" section: 


AttributeDescription
NameThe name of the node.
Value (primary item)This attribute is not used in XperienCentral. It is "undefined" for all nodes.
PathThe path the node belongs to. This is relative to the depth 1 parent mode of the current node. The root node is not shown in the path.
UUIDThe hexadecimal identifier of the node, 1b8c88d37f0000020084433d3af4941f, for example.
DepthThe depth of the node relative to the root node. The first depth is 1. The depth of the root node is 0 and is the only node with this value.
Primary node typeThe node's type. See http://jackrabbit.apache.org/jcr/node-types.html for an explanation of the possible node types.

...

When you select a node, the following attributes are shown in the "Node Properties" section: 


PropertyDescription
NameThe name of the node.
TypeThis attribute is not used in XperienCentral. It is "undefined" for all nodes.
ValueThe path the node belongs to. This is relative to the depth 1 parent mode of the current node. The root node is not shown in the path.
DeleteUUIDThe hexadecimal identifier of the node, 1b8c88d37f0000020084433d3af4941f, for example.
DepthThe depth of the node relative to the root node. The first depth is 1. The depth of the root node is 0 and is the only node with this value.
Primary node typeThe node's type. See http://jackrabbit.apache.org/jcr/node-types.html for an explanation of the possible node types.

...

If a property is a reference in the JCR tree, its value is shown as a link. Click on the link to navigate to the referenced node in the JCR tree. For example:

 



Back to top


...

Operations with Nodes

...

Query Examples: SQL Versus XPath

...


SQLXPath
SELECT * FROM nt:base//*
SELECT * FROM my:type//element(*, my:type)
SELECT my:title FROM my:type//element(*, my:type)/@my:title
SELECT my:title, my:text FROM my:type//element(*, my:type)/ (@my:title | @my:text)
SELECT * FROM my:type WHERE jcr:path LIKE '/nodes[%]/%'/jcr:root/nodes// element(*, my:type)
SELECT * FROM my:type WHERE my:title='JSR 170'//element(*, my:type) [@my:title = 'JSR 170']
SELECT * FROM my:type WHERE my:title <> 'JSR 170'//element(*, my:type) [@my:title != 'JSR 170']
SELECT * FROM my:type WHERE my:title = 'JSR 170' AND my:author = 'David'//element(*, my:type) [@my:title = 'JSR 170' and @my:author = 'David']
SELECT * FROM my:type WHERE NOT (my:title = 'JSR 170')//element(*, my:type) [not(@my:title = 'JSR 170')]
SELECT * FROM my:type WHERE my:title IS NOT NULL//element(*, my:type) [@my:title]
SELECT * FROM my:type WHERE my:title IS NULL//element(*, my:type) [not(@my:title)]
SELECT * FROM my:type WHERE my:title LIKE 'JSR 170%'//element(*, my:type) [jcr:like(@my:title, 'JSR 170%')]
SELECT * FROM my:type WHERE CONTAINS(*, 'JSR 170')//element(*, my:type) [jcr:contains(., 'JSR 170')]
SELECT * FROM my:type WHERE jcr:path LIKE'/some[%]/nodes[%]'/jcr:root/some/ element(nodes, my:type)
SELECT * FROM my:type WHERE jcr:path = '/some/nodes'/jcr:root/some[1]/element(nodes, my:type)[1]
SELECT * FROM my:type WHERE jcr:path LIKE '/some[%]/nodes[%]/%' AND NOT jcr:path LIKE '/some[%]/nodes[%]/%/%'/jcr:root/some/nodes/ element(*, my:type)
SELECT * FROM my:type WHERE jcr:path LIKE '/some/nodes/%' AND NOT jcr:path LIKE '/some/nodes/%/%'/jcr:root/some[1]/nodes[1]/ element(*, my:type)
SELECT * FROM my:type WHERE jcr:path LIKE '/some[%]/nodes[%]/%'/jcr:root/some/nodes// element(*, my:type)
SELECT * FROM my:type WHERE jcr:path LIKE '/some/nodes/%'/jcr:root/some[1]/nodes[1]// element(*, my:type)
SELECT * FROM my:type WHERE jcr:path LIKE '/some[%]/nodes[%]' OR jcr:path LIKE '/some[%]/nodes[%]/%'/jcr:root/some/nodes// element(*, my:type)
SELECT * FROM my:type WHERE jcr:path = '/some/nodes' OR jcr:path LIKE '/some/nodes/%'/jcr:root/some[1]/nodes[1]// element(*, my:type)

...