jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Jackrabbit Wiki] Update of "ApacheSling/SlingContent" by FelixMeschberger
Date Mon, 09 Jul 2007 13:22:26 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Jackrabbit Wiki" for change notification.

The following page has been changed by FelixMeschberger:

New page:
= Content Loading and Nodetype Support =

The {{{sling-content-jcr}}} bundle provides low-level repository operations which are at the
heart of the functionality of Sling:

 Node Type Definitions:: The class {{{org.apache.sling.content.jcr.NodeTypeLoader}}} provides
methods to register custom node types with a repository given a repository session and a node
type definition file in CND format. This class is also used by this bundle to register node
types on behalf of other bundles. See below.
 Content Mapping:: The bundle provides the {{{org.apache.sling.content.jcr.JcrContentManagerFactory}}}
service which creates {{{org.apache.sling.content.jcr.JcrContentManager}}} objects, which
in turn implement mapping of Java objects to repository items and vice versa. See below.

Besides the {{{NodeTypeLoader}}} and the {{{ContentManagerFactory}}} service, the {{{sling-content-jcr}}}
bundle provides automatisms for bundles to register declared node types, content loading and
object mappings.

== Declared Node Type Registration ==

Bundles may list node type definition files in CND format in the {{{Sling-Nodetypes}}} bundle
header. This header is a comma-separated list of resources in the respective bundle. Each
resource is taken and fed to the {{{NodeTypeLoader}}} to define the node types. 

After a bundle has entered the ''resolved'' state, the node types listed in the {{{Sling-Nodetypes}}}
bundle header are registered with the repository.

Node types installed by this mechanism will never be removed again by the {{{sling-content-jcr}}}
bundle. Likewise, registered node types cannot currently be modified using this feature. The
{{{NodeTypeLoader}}} will try to load nodes defined and fail with a log message if a node
type has already been defined. To update existing node type definitions, native repository
functionality has to be used.

Nodetype management is problematic issue currently, as the only API available is contained
in the Jackrabbit Core library, which is generally not available to client applications -
unless running in the same VM and class loader hierarchy as the Repository. Version 2 of the
JCR Specification currently being developped as JSR-283 should fix this issue by providing
an official node type management API. Until then, this approach is about the only solution
we have.

== Initial Content Loading ==

Bundles provide initial content, which is loaded into the repository when the bundle has entered
the ''resolved'' state. Such content is expected to be contained in the bundles accessible
through the Bundle entry API methods. Content to be loaded is declared in the {{{Sling-Initial-Content}}}
bundle manifest header. This header takes a comma-separated list of bundle entry paths. Each
entry and all its child entries are accessed and entered into starting with the child entries
of the listed entries. 

Adding this content preserves the paths of the entries as show in this table, which assumes
a {{{Sling-Initial-Content}}} header entry of {{{SLING-INF/content}}}:

|| '''Entry''' || '''Repository Path''' ||
|| {{{SLING-INF/content/home}}} || {{{/home}}} ||
|| {{{SLING-INF/content/content/playground/en/home}}} || {{{/content/playground/en/home}}}

Bundle entries are installed as follows:

|| '''Entry Type''' || '''Installation method''' ||
|| Directory || Created as a node of type {{{nt:folder}}} unless a content definition file
of the same name exists in the same directory as the directory to be installed. Example: A
directory {{{SLING-INF/content/dir}}} is installed as node {{{/dir}}} of type {{{nt:folder}}}
unless a {{{SLING-INF/content/dir.xml}}} or {{{SLING-INF/content/dir.json}}} file exists which
defines the content for the {{{/dir}}} node. ||
|| File || Unless the file is a content definition file (see below) an {{{nt:file}}} node
is created for the file and an {{{nt:resource}}} node is created as its {{{jcr:content}}}
child node to take the contents of the bundle file. The properties {{{nt:resource}}} node
are set from file information as available. If the file is a content definition file, the
content is created as defined in the file. See below for the content definition file specification.

=== Content Definition File Specification ===

Structured content may be specified in content specification file in [http://www.json.org
JSON] or XML format which define subtrees of content. A content definition file contains the
definition of a single node with optional properties and child nodes. Each child node may
again have its properties and child nodes. The definition of a node is as follows:


{{{Node Object: {
      name: Name of the node (String, default see below)
      primaryNodeType: Primary node type (String, default: nt:unstructured)
      mixinNodeTypes: Mixin node types (Array of String, default: none)
      properties: Properties of the node (Properties Object)
      nodes: Child nodes (Array of Node Objects)

Properties Object: {
      <propertyName>: String value or Value Object

Value Object: {
      value: String representation of the value (String)
                  or Array of String representations of multi-values (Array of String)
      type: JCR Property type name (String, default: String)



... *TODO* ...

Remarks on JSON:
   * If the name of the node is defined in the {{{name}}} property, the name is derived from
the node definition file (for the toplevel node) or the index of the node in the child node
   * The name of the {{{value}}} property in a {{{Value Object}}} may also be defined as {{{values}}}.
If both are specified, the {{{value}}} property is used.
   * The {{{Properties Object}}} keys are used as the names for the node properties. Only
unprotected properties may be set.

'''TODO''': Specify JSON Format

'''TODO''': Specify XML format

View raw message