Return-Path: X-Original-To: apmail-jackrabbit-commits-archive@www.apache.org Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C8C5A17C86 for ; Thu, 2 Apr 2015 07:14:00 +0000 (UTC) Received: (qmail 63230 invoked by uid 500); 2 Apr 2015 07:14:00 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 63083 invoked by uid 500); 2 Apr 2015 07:14:00 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 62734 invoked by uid 99); 2 Apr 2015 07:14:00 -0000 Received: from eris.apache.org (HELO hades.apache.org) (140.211.11.105) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Apr 2015 07:14:00 +0000 Received: from hades.apache.org (localhost [127.0.0.1]) by hades.apache.org (ASF Mail Server at hades.apache.org) with ESMTP id 24FB2AC05A3 for ; Thu, 2 Apr 2015 07:14:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1670829 [6/7] - in /jackrabbit/site/trunk: ./ attic/ attic/cgi-bin/ attic/content/ attic/lib/ attic/templates/ cgi-bin/ content/ lib/ src/ src/site/ src/site/markdown/ src/site/resources/ src/site/resources/css/ src/site/resources/images/ ... Date: Thu, 02 Apr 2015 07:13:58 -0000 To: commits@jackrabbit.apache.org From: tripod@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20150402071400.24FB2AC05A3@hades.apache.org> Added: jackrabbit/site/trunk/src/site/markdown/node-type-notation.md URL: http://svn.apache.org/viewvc/jackrabbit/site/trunk/src/site/markdown/node-type-notation.md?rev=1670829&view=auto ============================================================================== --- jackrabbit/site/trunk/src/site/markdown/node-type-notation.md (added) +++ jackrabbit/site/trunk/src/site/markdown/node-type-notation.md Thu Apr 2 07:13:56 2015 @@ -0,0 +1,656 @@ +Title: Node Type Notation +The Compact Namespace and Node Type Definition (CND) notation provides a +compact standardized syntax for defining node types and making namespace +declarations. The notation is intended both for documentation and for +programmatically registering node types (if you are unfamiliar with JCR +node types, you may want to read the general Node Types section first). + +Here is a "worst-case scenario" example that demonstrates all the features +of the notation: + + + /* An example node type definition */ + + // The namespace declaration + + + // Node type name + [ns:NodeType] + + // Supertypes + > ns:ParentType1, ns:ParentType2 + + // This node type supports orderable child nodes + orderable + + // This is a mixin node type + mixin + + // Nodes of this node type have a property called 'ex:property' of type +STRING + - ex:property (string) + + // The default values for this + // (multi-value) property are... + = 'default1', 'default2' + + // This property is the primary item + primary + + // and it is... + mandatory autocreated protected + + // and multi-valued + multiple + + // It has an on-parent-version setting of ... + version + + // The constraint settings are... + < 'constraint1', 'constraint2' + + // Nodes of this node type have a child node called ns:node which must be +of + // at least the node types ns:reqType1 and ns:reqType2 + + ns:node (ns:reqType1, ns:reqType2) + + // and the default primary node type of the child node is... + = ns:defaultType + + // This child node is... + mandatory autocreated protected + + // and supports same name siblings + multiple + + // and has an on-parent-version setting of ... + version + + +This definition can be written more compactly and with indentation: + + + /* An example node type definition */ + + [ns:NodeType] + > ns:ParentType1, ns:ParentType2 + orderable mixin + - ex:property (string) + = 'default1', 'default2' + primary mandatory autocreated protected multiple + version + < 'constraint1', 'constraint2' + + ns:node (ns:reqType1, ns:reqType2) + = ns:defaultType + mandatory autocreated protected multiple version + + +or, using short forms for the attributes, even like this: + + + + [ns:NodeType] +>ns:ParentType1, ns:ParentType2 o m + -ex:property='default1','default2' ! m a p * version + <'constraint1', 'constraint2' + +ns:node(ns:reqType1,ns:reqType2)=ns:defaultType + m a p * version + + + +## Grammar + +The following grammar defines the CND notation. Terminal symbols are in +double quotes. + + + cnd ::= {ns_mapping | node_type_def} + + ns_mapping ::= "<" prefix "=" uri ">" + + prefix ::= string + + uri ::= string + + node_type_def ::= node_type_name [supertypes] + [options] + {property_def | child_node_def} + + node_type_name ::= "[" string "] +" + + supertypes ::= ">" string_list + + options ::= orderable_opt | mixin_opt | orderable_opt + mixin_opt | mixin_opt orderable_opt + + orderable_opt ::= "orderable" | "ord" | "o" + + mixin_opt ::= "mixin" | "mix" | "m" + + property_def ::= "-" property_name [property_type_decl] + [default_values] + [attributes] + [value_constraints] + + property_name ::= string + + property_type_decl ::= "(" property_type ")" + + property_type ::= "STRING" | "String" |"string" | + "BINARY" | "Binary" | "binary" | + "LONG" | "Long" | "long" | + "DOUBLE" | "Double" | "double" | + "BOOLEAN" | "Boolean" | "boolean" | + "DATE" | "Date" | "date" | + "NAME | "Name | "name" | + "PATH" | "Path" | "path" | + "REFERENCE" | "Reference" | + "reference" | + "UNDEFINED" | "Undefined" | + "undefined" | "*" + + default_values ::= "=" string_list + + value_constraints ::= "<" string_list + + node_def ::= "+" node_name [required_types] + [default_type] + [attributes] + + node_name ::= string + + required_types ::= "(" string_list ")" + + default_type ::= "=" string + + attributes ::= "primary" | "pri" | "!" | + "autocreated" | "aut" | "a" | + "mandatory" | "man" | "m" | + "protected" | "pro" | "p" | + "multiple" | "mul" | "*" | + "COPY" | "Copy" | "copy" | + "VERSION" | "Version" | "version" | + "INITIALIZE" | "Initialize" | + "initialize" | + "COMPUTE" | "Compute" | "compute" | + "IGNORE" | "Ignore" | "ignore" | + "ABORT" | "Abort" | "abort" + + string_list ::= string {"," string} + + string ::= quoted_string | unquoted_string + + quoted_string :: = "'" unquoted_string "'" + + unquoted_string ::= [A-Za-z0-9:_] ++ + + + +## CND Notation in Detail + + + cnd ::= {ns_mapping | node_type_def} + + +A CND consists of zero or more blocks, each of which is either namespace +declaration or a node type definition. Namespace prefixes referenced in a +node type definition block must be declared in a preceding namespace +declaration block. + + +### Namespace Declaration + + + ns_mapping ::= "<" prefix "=" uri ">" + + prefix ::= string + + uri ::= string + + +A namespace declaration consists of prefix/URI pair. The prefix must be a +valid JCR namespace prefix, which is the same as a valid XML namespace +prefix. The URI can in fact be any string. Just as in XML, it need not +actually be a URI, though adhering to that convention is recommended. + + +### Node Type Definition + + + node_type_def ::= node_type_name [super_types] + [options] + {property_def | child_node_def} + + +A node type definition consists of a node type name followed by an optional +supertypes block, an optional options block and zero or more blocks, each +either a property or node definition. + + +### Node Type Name + + + node_type_name ::= "[" string "] +" + + +The node type name is delimited by square brackets and must be a valid JCR +name. It may be single-quoted (see Quoting, below). This element is the +only strictly required element within a node type definition, though a +definition consisting only of a node type name would simply define a new +node type identical to nt:base. + + +### Supertypes + + + supertypes ::= ">" string_list + + +After the node type name comes the optional list of supertypes. If this +element is not present and the node type is not a mixin (see ?1.3.5 +Options), then a supertype of nt:base is assumed. If present, the element +consists of a greater-than sign followed by a comma delimited list of node +type names, each of which may optionally be single-quoted (see Quoting +below). In Jackrabbit, multiple inheritance of node types is supported, so +this list can be greater than one item in length. + + +### Options + + + options ::= orderable_opt | mixin_opt | orderable_opt + mixin_opt | mixin_opt orderable_opt + + orderable_opt ::= "orderable" | "ord" | "o" + + mixin_opt ::= "mixin" | "mix" | "m" + + +The option indicators follow the node type name and optional supertype +list. + +If the keyword orderable (or a short form) is present, then the orderable +child node setting of the node type is true. If the keyword is missing, +then the setting is false. + +If the keyword mixin (or a short form) is present, then this is a mixin +node type. If the keyword is missing, then this is a primary node type. + + +### Property Definition + + + property_def ::= "-" property_name [property_type_decl] + [default_values] + [attributes] + [value_constraints] + + +A property definition consists of a minus sign followed by a property name, +followed in turn by optional elements defining the property type, the +default values, the property attributes and the value constraints. + + +### Property Name + + + property_name ::= string + + +The property name must be a valid JCR name or *, to indicate a residual +property definition. It may be single-quoted. + + +### Property Type + + + property_type_decl ::= "(" property_type ")" + + property_type ::= "STRING" | "String |"string" | + "BINARY" | "Binary" | "binary" | + "LONG" | "Long" | "long" | + "DOUBLE" | "Double" | "double" | + "BOOLEAN" | "Boolean" | "boolean" | + "DATE" | "Date" | "date" | + "NAME | "Name | "name" | + "PATH" | "Path" | "path" | + "REFERENCE" | "Reference" | "reference" | + "UNDEFINED" | "Undefined" | "undefined" | "*" + + +The property type is indicated by a keyword delimited by parentheses. If +the property type declaration is missing a type of STRING is assumed. + + +### Default Values + + + default_values ::= "=" string_list + + +The default value or values, in the case of a multi-value property, are +indicated by an equal sign followed by either a single value in string form +or a comma-delimited list of values. The values may be single-quoted. If +the default value definition is missing then no default value is set. + + +### Attributes + + + attributes ::= "primary" | "pri" | "!" | + "autocreated" | "aut" | "a" | + "mandatory" | "man" | "m" | + "protected" | "pro" | "p" | + "multiple" | "mul" | "*" | + "COPY" | "Copy" | "copy" | + "VERSION" | "Version" | "version" | + "INITIALIZE" | "Initialize" | "initialize" | + "COMPUTE" | "Compute" | "compute" | + "IGNORE" | "Ignore" | "ignore" | + "ABORT" | "Abort" | "abort" + + +The attribute indicators describe the characteristics of the property. The +presence of an attribute keyword indicates that the corresponding +characteristic applies to this property. It's absence indicates that the +corresponding characteristic does not apply. + +The primary keyword indicates that this property is the primary item. It +may appear on a maximum of one property or child node definition within a +node type definition. + +The multiple keyword indicates that this property is multi-valued. + +A maximum of one on-version indicator may be present. If none is present +then an on-version setting of COPY is assumed. + + +### Value Constraints + + + value_constraints ::= "<" string_list + + +Value constraint are specified by a less-than sign followed by a +comma-delimited list of constraint strings, each optionally single-quoted. + + +### Child Node Definition + + + child_node_def ::= "+" node_name [required_types] + [default_type] + [attributes] + + +A child node definition consists of a plus sign followed by a property +name, followed in turn by optional elements defining the required primary +node types, the default node type, and the node attributes. + + +### Node Name + + + node_name ::= string + + +The node name must be a valid JCR name or *, to indicate a residual child +node definition. It may be single-quoted. + + +### Required Primary Node Types + + + required_types ::= "(" string_list ")" + + +The required node types of the child node are indicated by a +comma-delimited list of node types, within parentheses. If this element is +missing then a required primary node type of nt:base is assumed. This is +the least restrictive setting possible. + + +### Default Primary Node Type + + + default_type ::= "=" string + + +The default primary node type is indicated by an equals-sign followed by a +node type name, which may be single-quoted. If this element is missing then +no default primary node type is set. + + +### Attributes + + + attributes ::= "primary" | "pri" | "!" | + "autocreated" | "aut" | "a" | + "mandatory" | "man" | "m" | + "protected" | "pro" | "p" | + "multiple" | "mul" | "*" | + "COPY" | "Copy" | "copy" | + "VERSION" | "Version" | "version" | + "INITIALIZE" | "Initialize" | "initialize" | + "COMPUTE" | "Compute" | "compute" | + "IGNORE" | "Ignore" | "ignore" | + "ABORT" | "Abort" | "abort" + + +The attribute indicators describe the characteristics of the child node. +The presence of an attribute keyword indicates that the corresponding +characteristic applies to this child node. It's absence indicates that the +corresponding characteristic does not apply. + +The primary keyword indicates that this child node is the primary item. It +may appear on a maximum of one property or child node definition within a +node type definition. + +The multiple keyword indicates that this child node may have same-name +siblings. + +A maximum of one on-version indicator may be present. If none is present +then an on-version setting of COPY is assumed. + + +### Quoting + + + string_list ::= string {"," string} + + string ::= quoted_string | unquoted_string + + quoted_string :: = "'" unquoted_string "'" + + unquoted_string ::= /* a string */ + + +Single quotes (') are used to allow for strings (i.e., names, prefixes, +URIs, values or constraint strings) with characters that would otherwise be +interpreted as delimiters. + + +### Escaping + +The standard Java escape sequences are also supported: + + + \n newline + \t tab + \b backspace + \f form feed + \r return + \" double quote + \' single quote + \\ back slash + \uHHHH Unicode character in hexadecimal + + + +### Comments + +Comment can also be included in the notation using either of the standard +Java forms: + + + // A comment + + /* Another comment */ + + + +### Whitespace and Short Forms + +The notation can be compacted by taking advantage of the following the fact that spacing around keychars ([ ](-.html) + > , - ( ) = <), newlines and indentation are not required. So, the +following is also well-formed: + + + [x] +>y,z orderable mixin -p(date)=a,b primary mandatory autocreated protected +multiple version y,z o m-p(date)=a,b ! m a p * version +### Why this Weird Notation? + +Here's why: + +Old Documentation Notation + +Here is the definition of the built-in node type nt:resource using the old +documentation notation (used in v1.0 of the JCR specification, for +example): + + + NodeTypeName + nt:resource + Supertypes + nt:base + mix:referenceable + IsMixin + false + HasOrderableChildNodes + false + PrimaryItemName + jcr:data + PropertyDefinition + Name jcr:encoding + RequiredType STRING + ValueConstraints [] + DefaultValues null + AutoCreated false + Mandatory false + OnParentVersion COPY + Protected false + Multiple false + PropertyDefinition + Name jcr:mimeType + RequiredType STRING + ValueConstraints [] + DefaultValues null + AutoCreated false + Mandatory true + OnParentVersion COPY + Protected false + Multiple false + PropertyDefinition + Name jcr:data + RequiredType BINARY + ValueConstraints [] + DefaultValues null + AutoCreated false + Mandatory true + OnParentVersion COPY + Protected false + Multiple false + PropertyDefinition + Name jcr:lastModified + RequiredType DATE + ValueConstraints [] + DefaultValues null + AutoCreated false + Mandatory true + OnParentVersion IGNORE + Protected false + Multiple false + + +Old Configuration Notation + +Here is the same node type in the standard XML notation (used in +configuration files in the Jackrabbit project, for example): + + + + + nt:base + mix:referenceable + + + + + + + + +New Format + +And, here it is in the new CND notation: + + + [nt:resource] + > mix:referenceable + - jcr:encoding + - jcr:mimeType mandatory + - jcr:data (binary) mandatory + - jcr:lastModified (date) mandatory ignore + + +Case closed. + + +## Syntax hightlighting for text editors + +Here is a TextMate bundle for CND syntax highlighting: [^CND.zip](^cnd.zip.html) Added: jackrabbit/site/trunk/src/site/markdown/node-type-visualization.md URL: http://svn.apache.org/viewvc/jackrabbit/site/trunk/src/site/markdown/node-type-visualization.md?rev=1670829&view=auto ============================================================================== --- jackrabbit/site/trunk/src/site/markdown/node-type-visualization.md (added) +++ jackrabbit/site/trunk/src/site/markdown/node-type-visualization.md Thu Apr 2 07:13:56 2015 @@ -0,0 +1,153 @@ +Title: Node Type Visualization +Visualizing the Node Type Hierarchy is non-trivial, even in the case of a +repository containing only the default Jackrabbit node types. Here, +GraphViz can help: + +!jackrabbit-nodetypes.png! +Node Type Hierarchy for Jackrabbit ([SVG version](^jackrabbit-nodetypes.svg.html) +) + +In this diagram, the rounded boxes represent node types (green for mixins, +gold for primrary types), with the arrows indicating the node inheritance. +The square boxes represent child node and property definitions. + +To generate these diagrams, you will need: + +1. A system view export of "/jcr:system/jcr:nodeTypes". +1. An XSLT processor and the XSLT code below. +1. The [GraphViz](http://graphviz.org/) + tool + + + + + + + + + + + + digraph { + rankdir=LR; + + } + + + + " + + " + + + [style = "filled, rounded", fillcolor = greenyellow] +; + + + [style = "filled, rounded", fillcolor = gold] +; + + + + + + " + + " -> " + + " [dir = back, tooltip = "supertype"] +; + + + + + + + + + + * + + + + + + + + " + + " -> " + + + + " [tooltip = "is mandatory child node of", dir = back] +; + + + " [style = dotted, tooltip = "is child node of", dir = back] +; + + + + " + + " -> " + + " [dir = back, tooltip = "has primary type"] +; + + + + + + + Added: jackrabbit/site/trunk/src/site/markdown/node-types.md URL: http://svn.apache.org/viewvc/jackrabbit/site/trunk/src/site/markdown/node-types.md?rev=1670829&view=auto ============================================================================== --- jackrabbit/site/trunk/src/site/markdown/node-types.md (added) +++ jackrabbit/site/trunk/src/site/markdown/node-types.md Thu Apr 2 07:13:56 2015 @@ -0,0 +1,199 @@ +Title: Node Types +Each node in a Jackrabbit workspace tree has a node type that defines the +child nodes and properties it may (or must) have. Developers can use node +types to define a custom content model for their application domain and +have Jackrabbit enforce the constraints of that model at the repository +level. + + +## Primary vs Mixin + +There are two categories of node types, *primary* and *mixin*. Every node +has a primary node type assigned to it upon creation (see *Node.addNode* +in the JCR API). In addition, a mixin node type may be added to a node +later in its lifecycle (see *Node.addMixin*). + +The primary node type of a node usually defines node structure (i.e., +allowed and required child nodes and properties) related to the problem +domain being modeled. For example, a node used in storing content about +business contacts might have the primary type *myapp:Contact* which +defines properties such as *myapp:givenName*, *myapp:familyName* and so +forth. + +Mixin node types usually specify additional properties or child nodes +related to a capability being added to the node. These capabilities may +include generic repository-level functions as in the case of the built-in +mixins *mix:versionable* and *mix:lockable*, for example, or +domain-level capabilities such as a (hypothetical) *myapp:Emailable* +mixin type that adds the property *myapp:emailAddress* to a node. + + +## Inheritance + +Primary node types are arranged in an inheritance hierarchy. Every primary +node type must be the subtype of at least one existing node type. The +built-in node type *nt:base* serves as the root of this hierarchy. +Jackrabbit supports multiple inheritance of node types so node types can +have more than one supertype. + +Mixin node types do not have to have supertypes. + +The JSR 170 specification and the current public review draft of the JSR +283 specification (section 4.7.7) leave it up to the implementation whether +e.g. the orderable child nodes setting is inherited from supertypes. +Inheritance semantics, especially with multiple inheritance, are +non-trivial at best and up to a certain degree arbitrary. Jackrabbit +therefore, in compliance with the spec, doesn't support inheritance of node +type attributes such as orderable. + + +## Node Type Definition + +A node type definition has the following attributes: + +* *Name* Every node type registered with the repository has a unique name. +The naming conventions for node types are the same as +for items (i.e., they may have a colon delimited prefix). +* *Supertypes* A primary node type (with the exception of *nt:base*) must +extend another node type (and may extend more than one node type). A mixin +node type may extend another node type. +* *Mixin Status* A node type may be either primary or mixin. +* *Orderable Child Nodes Status* A primary node type may specify that child +nodes are client-orderable. If this status is set to true, then +*Node.orderBefore* can be used to set the order of child nodes. Only +primary node types control a node's status in this regard. This setting on +a mixin node type will not have any effect on the node. +* *Property Definitions* A node type contains a set of definitions +specifying the properties that nodes of this node type are allowed (or +required) to have and the characteristics of those properties (see below). +* *Child Node Definitions* A node type contains a set of definitions +specifying the child nodes that nodes of this node type are allowed (or +required) to have and the characteristics of those child nodes (including, +in turn, their node types, see below). +* *Primary Item Name* A node type may specify one child item (property or +node) by name as the primary item. This indicator is used by the method +*Node.getPrimaryItem()*. + + +## Property Definition + +A property definition (within a node type definition) contains the the +following information: + +* *Name* The name of the property to which this definition applies, or +"***" if this definition is a "residual +definition', meaning that it applies to any additional properties with any +names apart from those otherwise defined in this node type. +* *Required Type* The required type of the property. One of +** *STRING* +** *BINARY* +** *LONG* +** *DOUBLE* +** *BOOLEAN* +** *DATE* +** *PATH* +** *NAME* +** *REFERENCE* +** *UNDEFINED* (the property can be of any type) +* *Value Constraints* The value constraints on the property define the +range of values that may be assigned to this +property. +* *Default Value* The value that the property will have if it is +auto-created. +* *Auto-create Status* Whether this property will be auto-created when its +parent node is created. Only properties with a default value can be +auto-created. +* *Mandatory Status* A mandatory property is one that must exist. If a node +of a type that specifies a mandatory property is +created then any attempt to save that node without adding the mandatory +property will fail. Since single-value properties either have a value or do +not exist (there being no concept of the null value) this implies that a +mandatory single-value property must have a value. A mandatory multi-value +property on the other hand may have zero or more values. +* *On-Parent-Version Status* The *onParentVersion* status of specifies +what happens to this property if a new version of +its parent node is created (i.e. a checked-in is done on it). +* *Protected Status* A protected property is one which cannot be modified +(i.e. have child nodes or properties added or removed) or removed from its +parent through the JCR API. +* *Multiple Values Status* Whether this property can have multiple values, +meaning that it stores an array of values, not just one. Note that this +"multiple values" flag is special in that a given node type may have two +property definitions that are identical in every respect except for the +their "multiple values" status. For example, a node type can specify two +string properties both called X, one of which is multi-valued and the other +that is not. An example of such a node type is *nt:unstructured*. + + +## Child Node Definition + +A child node definition (within a node type definition) contains the the +following information: + +* *Name* The name of the child node to which this definition applies or +"***" if this definition is a "residual +definition', meaning that it applies to any additional child nodes with any + names apart from those otherwise defined in this +node type. +* *Required Primary Types* If it specifies only a single node type N then +the primary node type of this child node must be N or a subtype of N. If +this attribute specifies multiple node types N1, N2,..., Nm then the +primary node type of this child node must be a subtype of all the types N1, +N2, ... Nm. Note that this is possible because +Jackrabbit supports multiple inheritance among node types and that each +node still has one and only one primary node type. +* *Default Primary Type* This is the primary node type automatically +assigned if no node type information is specified when the node is created. +* *Auto-create Status* Governs whether this child node will be auto-created +when its parent node is created. +* *Mandatory Status* Governs whether the child node is mandatory. A +mandatory child node is one that must exist. If a mandatory child node is +missing from a parent node then save on the parent node will fail. +* *On-Parent-Version Status* This specifies what to do with the child node +if its parent node is versioned. +* *Protected Status* This governs whether the child node is protected. A +protected node is one which cannot be modified (have child node or +properties added to it or removed from it) or be removed from its + parent through the JCR API. +* *Same-Name Siblings Status* This governs whether this child node can have +same-name siblings, meaning that the parent node can have more than one +child node of this name. + + +## Registering Node Types + +Each Jackrabbit instance has a *NodeTypeRegistry* which is created on +start-up and populated with the set of built-in node types (these include +both those required by the JCR specification and others required by the +Jackrabbit implementation). + +First you define your node types in a text file using the "Compact +Namespace and Node Type Definition" (CND) notation, then register them +using the [*JackrabbitNodeTypeManager*](http://jackrabbit.apache.org/api/1.5/org/apache/jackrabbit/api/JackrabbitNodeTypeManager.html) +. The following code gives an example: + + + import javax.jcr.Session; + import org.apache.jackrabbit.api.JackrabbitNodeTypeManager; + import java.io.FileInputStream; + + public class CustomNodeTypeExample { + public static void RegisterCustomNodeTypes(Session session, String +cndFileName) + throws Exception { + + // Get the JackrabbitNodeTypeManager from the Workspace. + // Note that it must be cast from the generic JCR NodeTypeManager +to the + // Jackrabbit-specific implementation. + JackrabbitNodeTypeManager manager = (JackrabbitNodeTypeManager) + session.getWorkspace().getNodeTypeManager(); + // Register the custom node types defined in the CND file + manager.registerNodeTypes(new FileInputStream(cndFileName), + JackrabbitNodeTypeManager.TEXT_X_JCR_CND); + } + } + + +Continue to [Node Type Notation](node-type-notation.html) + or [Node Type Visualization] Added: jackrabbit/site/trunk/src/site/markdown/object-content-manager.md URL: http://svn.apache.org/viewvc/jackrabbit/site/trunk/src/site/markdown/object-content-manager.md?rev=1670829&view=auto ============================================================================== --- jackrabbit/site/trunk/src/site/markdown/object-content-manager.md (added) +++ jackrabbit/site/trunk/src/site/markdown/object-content-manager.md Thu Apr 2 07:13:56 2015 @@ -0,0 +1,150 @@ +Title: Object Content Manager +The main component in the OCM framework is the ObjectContentManager. It +converts an object graph into JCR nodes and properties and vice versa. The +ObjectContentManager is always associated with a JCR Session. It is used to +retrieve, create, update and delete objects from a JCR content repository. +Usually there is one ObjectContentManager per user session. + +This page describes how an ObjectContentManager is working and how it can +be initialised in your applications. + + +## How does the Object Content Manager work ? + +Thanks to a Mapping Descriptor, the ObjectContentManager is able to use the +appropriate mapping strategy for each persistent object (pojo). The Mapping +Descriptor contains one Class Descriptor per persistent class. Each Class +Descriptor contains mapping information for the corresponding class +attributes. + +In the point of view implementation, the Mappring Descriptor is a java +object injected into the ObjectContentManager (see the interface +org.apache.jackrabbit.ocm.mapper.Mapper). Right now, there are 2 different +Mapping Descriptor implementations: + + * Annotation : each persistent object is annoted in order to provide to +the ObjectContentManager all the required information on its mapping +strategy (see the class +org.apache.jackrabbit.ocm.mapper.impl.annotation.AnnotationMapperImpl). + * XML configuration file : the class descriptors are defined in one or +more XML config files used by the ObjectContentManager when it is +instantiated (see the class +org.apache.jackrabbit.ocm.mapper.impl.digester.DigesterMapperImpl). + +For a business developer, it is not necessary to know how the +ObjectContentManager is using the Class Descriptors. He has to make only a +choice between annoted classes or XML files. Below, you can see how to +setup correctly an ObjectContentManager. + + +## How does an object is persisted into a JCR repository ? + +In all cases, a persistent object (a pojo) is mapped into a JCR node and +its fields are mapped into subnodes or properties depending on their types. + +There are 3 "field types": + +* Atomic fields + Primitive data types and simple objects (String, Long, Double, ...) . +Those fields are mapped into JCR properties. + +* Bean fields + One class can contain an 1..1 association to another bean. In this +case, the field is a custom object. Those fields are mapped into JCR +subnodes or a referenced node. + +* Collection fields + One class can contain an 1..n association to a collection of beans (or +Map). Those fields are mapped into a collection of JCR subnodes or a +collection of referenced nodes. It is also possible to map a java +collection into a multivalue property. + +The Mapping descriptor contains also information on inheritances, interface +mapping strategy, lazy loading, custom converter, cache strategy, etc. + +## Basic setup (with annoted persistent classes) + +When you start your application, you need the following code to initialize +correctly the Object Content Manager. + + + import javax.jcr.Session; + import javax.jcr.Repository; + + import org.apache.jackrabbit.ocm.manager.impl.ObjectContentManagerImpl; + import org.apache.jackrabbit.ocm.mapper.Mapper; + import +org.apache.jackrabbit.ocm.mapper.impl.annotation.AnnotationMapperImpl; + + + // 1. Instantiate a JCR session + Repository repository = ...; + Session session = repository.login(...); + + // 2. Register the different persistent classes + List classes = new ArrayList(); + classes.add(MyContent.class); // Call this method for each persistent class + + + // 3. Instantiate the object content manager + Mapper mapper = new AnnotationMapperImpl(classes); + ObjectContentManager ocm = new ObjectContentManagerImpl(session, mapper); + + + +## Basic setup (with one or more XML Mapping Descriptor files) + +When you start your application, you need the following code to initialize +correctly the Object Content Manager. + + import javax.jcr.Session; + import javax.jcr.Repository; + + import org.apache.jackrabbit.ocm.mapper.Mapper; + import org.apache.jackrabbit.ocm.mapper.impl.digester.DigesterMapperImpl; + import org.apache.jackrabbit.ocm.manager.ObjectContentManager; + import org.apache.jackrabbit.ocm.manager.impl.ObjectContentManagerImpl; + import +org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverterProvider; + import +org.apache.jackrabbit.ocm.manager.atomictypeconverter.impl.DefaultAtomicTypeConverterProvider; + import org.apache.jackrabbit.ocm.manager.objectconverter.ObjectConverter; + import +org.apache.jackrabbit.ocm.manager.objectconverter.impl.ObjectConverterImpl; + import org.apache.jackrabbit.ocm.query.QueryManager; + import org.apache.jackrabbit.ocm.query.impl.QueryManagerImpl; + + // 1. Instantiate a JCR session + Repository repository = ...; + Session session = repository.login(...); + + // 2. Specify the different mapping files + String[] + files = { + "./src/test-config/jcrmapping.xml", + "./src/test-config/jcrmapping-atomic.xml", + "./src/test-config/jcrmapping-beandescriptor.xml" + }; + + // 3. Instantiate the object content manager + ObjectContentManager ocm = new ObjectContentManagerImpl(session, files); + + + + + +## API Overview + +With the current Object Manager API, it is possible to: + +* Manage the object life cycle (insert, update, delete, retrieve). See [Basic OCM operations](basic-ocm-operations.html) +. +* Search single object or collections with criteria. See [OCM Search](ocm-search.html) +. +* Lock objects. See [OCM Locking](ocm-locking.html) +. +* Manage versions (check int, check out, create a new version, show +history). See [OCM Version Management](ocm-version-management.html) +. + +We plan to add other features in a future release. Added: jackrabbit/site/trunk/src/site/markdown/object-content-mapping.md URL: http://svn.apache.org/viewvc/jackrabbit/site/trunk/src/site/markdown/object-content-mapping.md?rev=1670829&view=auto ============================================================================== --- jackrabbit/site/trunk/src/site/markdown/object-content-mapping.md (added) +++ jackrabbit/site/trunk/src/site/markdown/object-content-mapping.md Thu Apr 2 07:13:56 2015 @@ -0,0 +1,61 @@ +Title: Object Content Mapping +{warning:title=Warning} +The Jackrabbit OCM documentation is still in progress. We advise you also +to review [the unit tests](http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/) +to get an overview on current OCM features. +{warning} + +* [Object Content Manager](object-content-manager.html) +** [Basic OCM operations](basic-ocm-operations.html) +** [OCM Search](ocm-search.html) +** [OCM Version Management](ocm-version-management.html) +** [OCM Locking](ocm-locking.html) +* Tutorials +** [5' with Jackrabbit OCM](5-with-jackrabbit-ocm.html) +** [A simple OCM project with Maven & Eclipse](a-simple-ocm-project-with-maven--eclipse.html) +** [How to map associations between objects](how-to-map-associations-between-objects.html) +* [Mapping Stategies](mapping-stategies.html) + (obsolete doc) +** [Mapping Atomic Fields](mapping-atomic-fields.html) + (obsolete doc) +** [Mapping Bean Fields](mapping-bean-fields.html) + (obsolete doc) +** [Mapping Collection Fields](mapping-collection-fields.html) + (obsolete doc) +** [Advanced Mapping Strategies](advanced-mapping-strategies.html) + (obsolete doc) + +Jackrabbit OCM is a framework used to persist java objects (pojos) in a JCR +repository including association, inheritance, polymorphism, composition, +and the Java collections framework. It offers also features like version +support, object locking and express queries with Java-based criteria, as +well as with JCR query languages. + +In order to easily support the JCR specification, any content application +managing an high level object model can use this framework. For example, a +classic Forum application contains objects like "Forum", "Topic" and +"Post". Now, the data objects (pojo) can be managed by our JCR mapping +tools in order to persist them into a JCR compliant repository. + + +## Why an ocm? + +The object content mapping framework was created for the following +different reasons: + +* Sometimes it is very convenient to be able to just access the JCR nodes +and properties directly from your presentation-layer for very simple things +(mostly generic display). When a lot of "business logic" are involved, the +JCR API can be too low level and real business objects (pojo) are more +appreciate in such cases. +* The OCM framework provides more abstraction on the technologies used to +persist your content. The different application layers are less dependent +on the JCR API. +* ORM tools like OJB or Hibernate are not appropriate for content oriented +application. + + +## Prerequisite + +Before using this OCM framework, you should review the JCR specification +and implementations like Apache Jackrabbit. Added: jackrabbit/site/trunk/src/site/markdown/ocm-locking.md URL: http://svn.apache.org/viewvc/jackrabbit/site/trunk/src/site/markdown/ocm-locking.md?rev=1670829&view=auto ============================================================================== --- jackrabbit/site/trunk/src/site/markdown/ocm-locking.md (added) +++ jackrabbit/site/trunk/src/site/markdown/ocm-locking.md Thu Apr 2 07:13:56 2015 @@ -0,0 +1,81 @@ +Title: OCM Locking +Following the Jcr specification, it is possible to lock nodes and their +children (see section 8.4). You can see on this page the OCM API used to +lock on the object level. In order to lock an object, its matching node has +to implement the jcr mixin type "mix:lockable". It is possible to specify +this node type in the class descriptor: + + +## A basic example + + + // +-------------------------------------------------------------------------------- + // Create and store an object graph in the repository + // +-------------------------------------------------------------------------------- + A a = new A(); + a.setPath("/test"); + a.setA1("a1"); + a.setA2("a2"); + B b = new B(); + b.setB1("b1"); + b.setB2("b2"); + a.setB(b); + + C c1 = new C(); + c1.setId("first"); + c1.setName("First Element"); + C c2 = new C(); + c2.setId("second"); + c2.setName("Second Element"); + + C c3 = new C(); + c3.setId("third"); + c3.setName("Third Element"); + + Collection collection = new ArrayList(); + collection.add(c1); + collection.add(c2); + collection.add(c3); + + a.setCollection(collection); + + ocm.insert(a); + ocm.save(); + + + // +-------------------------------------------------------------------------------- + // Check if the object is not locked + // +-------------------------------------------------------------------------------- + if (ocm.isLocked("/test")) + { + System.out.println("Error : The object is locked- humm ??"); + } + + // +-------------------------------------------------------------------------------- + // Lock the object + // +-------------------------------------------------------------------------------- + String lockToken = ocm.lock("/test", true, false); + + // +-------------------------------------------------------------------------------- + // Check if the object is not locked + // +-------------------------------------------------------------------------------- + if (! ocm.isLocked("/test")) + { + System.out.println("Error : The object is not locked- humm ??"); + } + + // +-------------------------------------------------------------------------------- + // Unlock the object + // +-------------------------------------------------------------------------------- + ocm.unlock("/test", lockToken); + Added: jackrabbit/site/trunk/src/site/markdown/ocm-search.md URL: http://svn.apache.org/viewvc/jackrabbit/site/trunk/src/site/markdown/ocm-search.md?rev=1670829&view=auto ============================================================================== --- jackrabbit/site/trunk/src/site/markdown/ocm-search.md (added) +++ jackrabbit/site/trunk/src/site/markdown/ocm-search.md Thu Apr 2 07:13:56 2015 @@ -0,0 +1,50 @@ +Title: OCM Search + + +## Searching a single object + + + QueryManager queryManager = ocm.getQueryManager(); + + // Build the search filter + Filter filter = queryManager.createFilter(Paragraph.class); + filter.addEqualTo("text", "Para 1"); // Text is an attribute in the class +Paragraph + + // Build the query + Query query = queryManager.createQuery(filter); + Paragraph paragraph = (Paragraph) ocm.getObject(query); + + + +## Searching a collection + + + QueryManager queryManager = ocm.getQueryManager(); + Filter filter = queryManager.createFilter(Paragraph.class); + filter.setScope("/test/node1//"); + Query query = queryManager.createQuery(filter); + Collection result = ocm.getObjects(query); + + + +## Searching with an iterator + + + QueryManager queryManager = ocm.getQueryManager(); + Filter filter = queryManager.createFilter(Paragraph.class); + filter.setScope("/test/node1//"); + Query query = queryManager.createQuery(filter); + Iterator iterator = ocm.getObjectIterator(query); + + + +## Remove objects based on a query + + + QueryManager queryManager = ocm.getQueryManager(); + Filter filter = queryManager.createFilter(Paragraph.class); + filter.setScope("/test/node1//"); + Query query = queryManager.createQuery(filter); + ocm.remove(query); + Added: jackrabbit/site/trunk/src/site/markdown/ocm-version-management.md URL: http://svn.apache.org/viewvc/jackrabbit/site/trunk/src/site/markdown/ocm-version-management.md?rev=1670829&view=auto ============================================================================== --- jackrabbit/site/trunk/src/site/markdown/ocm-version-management.md (added) +++ jackrabbit/site/trunk/src/site/markdown/ocm-version-management.md Thu Apr 2 07:13:56 2015 @@ -0,0 +1,118 @@ +Title: OCM Version Management +Right now, the OCM tools provides basic versioning features: + +* Check in, check out. +* Retrieve version history (first version, last version, the complete +history, ...). +* Apply labels. + +Later, we would like to add more advanced versioning support like version +compare, replace, revert, ... Each versioned object has to be mapped to a +mix:versionable JCR node. It is possible to specify this node type in the +xml class descriptor or with an annotation : + + +## Check in - Check out + + + // Create a new page - first version + Page page = new Page(); + page.setPath("/page"); + page.setTitle("Page Title"); + page.addParagraph(new Paragraph("para1")); + page.addParagraph(new Paragraph("para2")); + ocm.insert(page); + ocm.save(); + + // Update the page object and create a new version + page.addParagraph(new Paragraph("para3")); + ocm.checkout("/page"); + ocm.update(page); + ocm.save(); + ocm.checkin("/page"); + + // Update the page object and create a new version + page.addParagraph(new Paragraph("para4")); + ocm.checkout("/page"); + ocm.update(page); + ocm.save(); + ocm.checkin("/page"); + + + +## Retrieve the version history + + + VersionIterator versionIterator = ocm.getAllVersions("/page"); + while (versionIterator.hasNext()) + { + Version version = (Version) versionIterator.next(); + System.out.println("version found : "+ version.getName() + " - " + + version.getPath() + " - " + +version.getCreated().getTime()); + } + + + +## Retrieve version description + + + // Retrieve the first version description + Version baseVersion = ocm.getBaseVersion("/page"); + System.out.println("Base version : " + baseVersion.getName()); + + // Retrieve the latest version description + Version rootVersion = ocm.getRootVersion("/page"); + System.out.println("Root version : " + rootVersion.getName()); + + + +## Retrieve the object state matching to a specific version + + + //Get the object matching to the first version + Page page = (Page) ocm.getObject( "/page", "1.0"); + + + +## Using version labels + + + Page page = new Page(); + page.setPath("/page"); + page.setTitle("Page Title"); + page.addParagraph(new Paragraph("para1")); + page.addParagraph(new Paragraph("para2")); + ocm.insert(page); + ocm.save(); + + // Checkin with some labels + page.addParagraph(new Paragraph("para3")); + ocm.checkout("/page"); + ocm.update(page); + ocm.save(); + ocm.checkin("/page", new String[] + {"A", "B"}); + + // Checkin with some labels + page.addParagraph(new Paragraph("para4")); + ocm.checkout("/page"); + ocm.update(page); + ocm.save(); + ocm.checkin("/page", new String[] + {"C", "D"}); + + // Retrieve all labels + String[] + allLabels = ocm.getAllVersionLabels("/page"); + assertTrue("Incorrect number of labels", allLabels.length == 4); + + // Retrieve labels assigned to the version 1.1 + String[] + versionLabels = ocm.getVersionLabels("/page", "1.1"); + assertTrue("Incorrect number of labels", versionLabels.length == 2); + assertTrue("Incorrect label", versionLabels[0] +.equals("C") || versionLabels[0].equals("D")); + assertTrue("Incorrect label", versionLabels[1] +.equals("C") || versionLabels[0].equals("D")); + Added: jackrabbit/site/trunk/src/site/markdown/privacy-policy.md URL: http://svn.apache.org/viewvc/jackrabbit/site/trunk/src/site/markdown/privacy-policy.md?rev=1670829&view=auto ============================================================================== --- jackrabbit/site/trunk/src/site/markdown/privacy-policy.md (added) +++ jackrabbit/site/trunk/src/site/markdown/privacy-policy.md Thu Apr 2 07:13:56 2015 @@ -0,0 +1,23 @@ +Title: Privacy Policy +Information about your use of this website is collected using server access +logs and a tracking cookie. The collected information consists of the +following: + +1. The IP address from which you access the website; +1. The type of browser and operating system you use to access our site; +1. The date and time you access our site; +1. The pages you visit; and +1. The addresses of pages from where you followed a link to our site. + +Part of this information is gathered using a tracking cookie set by the [Google Analytics](http://www.google.com/analytics/) + service and handled by Google as described in their [privacy policy|http://www.google.com/privacy.html] +. See your browser documentation for instructions on how to disable the +cookie if you prefer not to share this data with Google. + +We use the gathered information to help us make our site more useful to +visitors and to better understand how and when our site is used. We do not +track or collect personally identifiable information or associate gathered +data with any personally identifying information from other sources. + +By using this website, you consent to the collection of this data in the +manner and for the purpose described above. Added: jackrabbit/site/trunk/src/site/markdown/repository-lifecycle.md URL: http://svn.apache.org/viewvc/jackrabbit/site/trunk/src/site/markdown/repository-lifecycle.md?rev=1670829&view=auto ============================================================================== --- jackrabbit/site/trunk/src/site/markdown/repository-lifecycle.md (added) +++ jackrabbit/site/trunk/src/site/markdown/repository-lifecycle.md Thu Apr 2 07:13:56 2015 @@ -0,0 +1,47 @@ +Title: Repository lifecycle +The lifecycle of any Jackrabbit Content Repository starts with a call to +one of the RepositoryFactory.create() methods passing optionally the source +of a repository configuration file (which by convention is called +config.xml) and the RepositoryFactoryHome, which points to a directory from +which the Repository will continue reading further information for start-up +and in many cases will store the actual data that is persisted in the +repository and its workspaces. + +Not supplying the RepositoryFactoryHome will default to the users home dir +from the System property user.dir. + +Not supplying the configuration file parameter will default to the value of +Repository.factory.config System Property and if that is not set it will +default to the config.xml in the RepositoryFactoryHome. + +Calling the create() method will instantiate the RepositoryFactory +singleton that will then, through the getRepository(String name) method, +serve as the factory for Repository instances. + +As per the config.xml a repository are started up with the respectively +configured RepositoryStore, the RepositoryStore defines where the +repository stores information that is visible for the entire Repository +which includes things like the uuid of the root node, repository +properties, the namespace registry, node type definitions or the version +backing store in a file structure as follows. + + + ./meta: + rep.properties + rootUUID + + ./namespaces: + ns_reg.properties + + ./nodetypes: + custom_nodetypes.xml + + ./versions: + + +The RepositoryStore normally points to a regular (i.e. local) file system +but is abstracted through an abstract FileSystem that can be configured to +point to a different FileSystem implementation, in case the above +information should be stored in a different data container. + +... to be continued ... Added: jackrabbit/site/trunk/src/site/markdown/repository-server-howto.md URL: http://svn.apache.org/viewvc/jackrabbit/site/trunk/src/site/markdown/repository-server-howto.md?rev=1670829&view=auto ============================================================================== --- jackrabbit/site/trunk/src/site/markdown/repository-server-howto.md (added) +++ jackrabbit/site/trunk/src/site/markdown/repository-server-howto.md Thu Apr 2 07:13:56 2015 @@ -0,0 +1,78 @@ +Title: Repository Server HOWTO +This document describes how to use a Jackrabbit content repository in the +deployment model 3: The Repository Server. In this deployment model, a +separate repository server is running outside the virtual machine the +client application is running in. A repository server can serve multiple +applications running on separate JVMs on separate network hosts. See the [JCR client application HOWTO](jcr-client-application-howto.html) + for instructions on how to use the configured content repository server. + +Note that JCR specification defines no standard communication protocol for +inter-JVM repository access, and that Jackrabbit supports no such protocol +by default. However, Jackrabbit contains tools for using JCR content +repositories over the RMI and WebDAV protocols (see the jcr-rmi and the +jcr-server, webapp packages). + +This how-to contains instructions for accessing a JCR-RMI server in Tomcat +versions 4.x and 5.x. It should be easy to modify the instructions for +other container environments and communication protocols. + +In addition to the following the instructions in this document, you also +need to have an already running JCR-RMI server. See the JCR-RMI javadocs +for instructions on how to setup such a server. + +Warning: The current JCR-RMI library is designed for simplicity, not +performance. You will probably experience major performance issues if you +try running any non-trivial applications on top of JCR-RMI. + + +## Tomcat instructions + +Follow the steps below to setup a model 3 JCR-RMI client deployment for +your web application in Tomcat 4.x or 5.x. Example code for both versions +of Tomcat is included after this overview. + +Note that these instructions closely follow the Model 1 HOWTO instructions. +By making similar changes (change the factory class and parameters of the +repository) to the Model 2 HOWTO instructions, you can setup a shared +JCR-RMI client deployment for all applications in the container. + +1. Place the JCR-RMI jar file and its dependencies (including the JCR API +jar) under _Tomcat folder_/webapps/_your app_/WEB-INF/lib. +1. Register the JCR-RMI client repository factory in the context scope. + + +### Step 2 - Context configuration + +In Tomcat 4.x and 5.0, add the following snippet in server.xml under the +Context element of your web application. + + + + + + factory + org.apache.jackrabbit.rmi.client.ClientRepositoryFactory + + + url + [The RMI URL of the repository] + + + + +In Tomcat 5.5, add the following snippet in your application's context.xml +file (or in the server.xml file if you prefer central configuration). + + + + Added: jackrabbit/site/trunk/src/site/markdown/search-implementation.md URL: http://svn.apache.org/viewvc/jackrabbit/site/trunk/src/site/markdown/search-implementation.md?rev=1670829&view=auto ============================================================================== --- jackrabbit/site/trunk/src/site/markdown/search-implementation.md (added) +++ jackrabbit/site/trunk/src/site/markdown/search-implementation.md Thu Apr 2 07:13:56 2015 @@ -0,0 +1,91 @@ +Title: Search implementation +Jackrabbit implements both the mandatory XPath and optional SQL query +syntax. Its design follows the goal of the JSR-170 specification that all +the mandatory query features can be expressed either in XPath or in SQL. +Thus, the actual implementation of the query engine is independent of the +query syntax used, though Jackrabbit's query internals are closer to XPath +than SQL, because of the hierarchical structure of a JCR. + +The major parts of the query implementation are: + +* XPath Parser +* SQL Parser +* Abstract Query Tree +* Query engine +* Utilities + + +## XPath Parser + +The XPath query parser is based on the W3C XQuery grammar definition which +is not yet final but can be downloaded as draft here. The reason why +Jackrabbit uses the XQuery grammar, rather than the XPath grammar, is, that +JSR-170 specifies an 'order by' clause for the XPath query syntax. This +'order by' clause is borrowed from the XQuery FLWOR expression syntax. +Before parsing the XPath query in Jackrabbit, the statement is surrounded +with dummy code, to form a valid XQuery FLWOR expression and is then passed +to the XQuery parser. The actual parser is a class generated by JavaCC, +which uses the grammar that can be found in src/grammar/xpath. The parsed +XPath statement is then translated into an Abstract Query Tree. See class: +org.apache.jackrabbit.core.query.xpath.XPathQueryBuilder + + +## SQL Parser + +The SQL query parser is generated from a grammar definition located in +src/grammar/sql. After parsing, the Abstract Syntax Tree is translated into +the Jackrabbit internal Abstract Query Tree. See class: +org.apache.jackrabbit.core.query.sql.JCRSQLQueryBuilder + + +## Abstract Query Tree + +The Abstract Query Tree (AQT) is the common query description format that +allows Jackrabbit to implement a query engine which is (to a certain +extent) independent of the query syntax used (XPath or SQL). The AQT +consists of the classes that are derived from: +org.apache.jackrabbit.core.query.QueryNode + +Please note that the AQT is Jackrabbit internal and not exposed to a client +using the JCR API! + + +## Query Engine + +Now this is where the meat is. The actual implementation of the query +engine is configurable. One needs to implement the interface: +org.apache.jackrabbit.core.query.QueryHandler. Jackrabbit comes with an +implementation that uses a Lucene index: +org.apache.jackrabbit.core.query.lucene.SearchIndex This index is +independent of the persistence manager in use. However it is also possible +to write a QueryHandler implementation which is aware of the underlying +storage (e.g. a database) and executes the query on the 'native' storage. + +The class org.apache.core.query.lucene.LuceneQueryBuilder translates the +Abstract Query Tree into a query that can be executed against the Lucene +index. Jackrabbit implements a couple of extensions to the standard Lucene +classes, primarily to improve performance in an environment with +incremental indexing like Jackrabbit. Instead of a single index, Jackrabbit +uses generations of indexes to circumvent costly IndexReader / IndexWriter +creation. See: org.apache.jackrabbit.core.query.lucene.MultiIndex. The most +recent generation of the search index is held completely in memory. See: +org.apache.jackrabbit.core.query.lucene.VolatileIndex. It is comparable +with the garbage collection in Java, where generations are used to move +living objects from the young into the old generation over time. Queries +are then executed on a MultiReader that spans all the indexes. Every now +and then (depending on the configuration parameters in workspace.xml) +indexes are merged and nodes marked as deleted in the index are removed. +This happens similar to how Lucene merges its internal segments. + + +## Utilities + +The class org.apache.jackrabbit.core.query.QueryParser allows you to +translate a query statement into an Abstract Query Tree and vice versa. +It's a nice tool to see how a query in XPath looks like in SQL or the other +way round. + +The class org.apache.jackrabbit.core.query.PropertyTypeRegistry provides +fast access to the type information based on property names. The Jackrabbit +QueryHandler implementation uses this class to coerce value literals into +other value types. Added: jackrabbit/site/trunk/src/site/markdown/shared-j2ee-resource-howto.md URL: http://svn.apache.org/viewvc/jackrabbit/site/trunk/src/site/markdown/shared-j2ee-resource-howto.md?rev=1670829&view=auto ============================================================================== --- jackrabbit/site/trunk/src/site/markdown/shared-j2ee-resource-howto.md (added) +++ jackrabbit/site/trunk/src/site/markdown/shared-j2ee-resource-howto.md Thu Apr 2 07:13:56 2015 @@ -0,0 +1,82 @@ +Title: Shared J2EE Resource HOWTO +This document describes how to use a Jackrabbit content repository in the +deployment model 2: Shared J2EE Resource. In this deployment model, a +central content repository resource managed by an application server is +used by multiple different applications. See the [JCR client application HOWTO](jcr-client-application-howto.html) + for instructions on how to use the configured content repository. + +This how-to contains instructions for Tomcat versions 4.x and 5.x. It +should be easy to modify the instructions for other container environments. + + +## Tomcat instructions + +Follow the steps below to setup a model 2 Jackrabbit deployment for your +Tomcat 4.x or 5.x installation. Example code for both versions of Tomcat is +included after this overview. + +1. Place the Jackrabbit jar file and all the dependencies (including the JCR +API jar file) under _Tomcat folder_/common/lib. +1. Register the bindable repository factory as a global resource. +1. Link the global resource to a context scoped JNDI address. + + +### Step 2 - Resource configuration + +Note: This step is essentially the same as step 2 in the Model 1 HOWTO. The +only differences are in the (arbitrary) naming of the resource and placing +of the configuration elements. The difference in the end result is that the +configured repository is bound to the global JNDI context instead of a +local one. In Tomcat 4.x and 5.0, add the following snippet in server.xml +under the GlobalNamingResources element. + + + + + + + factory + org.apache.jackrabbit.core.jndi.BindableRepositoryFactory + + + configFilePath + [full path to repository.xml] + + + repHomeDir + [full path to the repository home folder] + + + + +In Tomcat 5.5, add the following snippet in server.xml under the +GlobalNamingResources element. + + + + + + +### Step 3 - Resource link + +In Tomcat versions 4.x and 5.0, add the following snippet in server.xml +under the Context element of your web application. In Tomcat version 5.5, +add the snippet in your application's context.xml or +$CATALINA_HOME/conf/_enginename_/_hostname_/_webappname_.xml. If you prefer +central configuration, you can add the configuration to +$CATALINA_HOME/conf/context.xml. + + + + Added: jackrabbit/site/trunk/src/site/markdown/source-repository.md URL: http://svn.apache.org/viewvc/jackrabbit/site/trunk/src/site/markdown/source-repository.md?rev=1670829&view=auto ============================================================================== --- jackrabbit/site/trunk/src/site/markdown/source-repository.md (added) +++ jackrabbit/site/trunk/src/site/markdown/source-repository.md Thu Apr 2 07:13:56 2015 @@ -0,0 +1,10 @@ +Title: Source Repository +Apache Jackrabbit uses [Subversion](http://subversion.tigris.org/) + to manage source code. See the [Subversion book|http://svnbook.red-bean.com/] + and the Apache [instructions|http://www.apache.org/dev/version-control.html] + for using Subversion. + +The Jackrabbit source code is available at +http://svn.apache.org/repos/asf/jackrabbit/ and can also be browsed using +the [ViewVC](http://viewvc.tigris.org/) + interface at http://svn.apache.org/viewvc/jackrabbit/. Added: jackrabbit/site/trunk/src/site/markdown/standalone-server.md URL: http://svn.apache.org/viewvc/jackrabbit/site/trunk/src/site/markdown/standalone-server.md?rev=1670829&view=auto ============================================================================== --- jackrabbit/site/trunk/src/site/markdown/standalone-server.md (added) +++ jackrabbit/site/trunk/src/site/markdown/standalone-server.md Thu Apr 2 07:13:56 2015 @@ -0,0 +1,192 @@ +Title: Standalone Server +Each Jackrabbit release comes with a pre-built and runnable standalone +server jar. It's the easiest way to get started with Jackrabbit, simply [download](downloads.html) + and start the jar to get a fully functional JCR content repository. The +rest of this page documents what else you can do with the standalone +server. + +{toc:minLevel=2} + + +## Running the standalone server + +You need Java version 5 or higher to run the Jackrabbit standalone server. +To start the server, double-click on the standalone jar file, or invoke it +on the command line. + + $ java -jar jackrabbit-standalone-1.6.0.jar + Welcome to Apache Jackrabbit! + ------------------------------- + Using repository directory jackrabbit + Writing log messages to jackrabbit/log + Starting the server... + Apache Jackrabbit is now running at http://localhost:8080/ + ^C + Shutting down the server... + ------------------------------- + Goodbye from Apache Jackrabbit! + + +After staring the server, you can point your browser to [http://localhost:8080/] + to see Jackrabbit in action. Use the {{--port}} command line option to +specify an alternative if the default port 8080 is already used by another +program. + This is what the server should look like in your browser: + + !standalone500.png|align=center! + + By default the server will look for a content repository in the +{{./jackrabbit}} directory and a repository configuration file in a +{{repository.xml}} file within the repository directory. The repository +directory is automatically created if it does not already exist, and a +configuration file with the default configuration is created if no +configuration is found. + + Server, access, and repository log messages are written to log files in the +{{log}} subdirectory within the repository directory. + + You can stop the server by pressing {{Ctrl-C}} or by sending it a standard +termination signal. The server will then close the content repository and +exit cleanly. + + h2. Command line options + + You can customize the operation of the standalone server with the following +command line options (with defaults in parenthesis). + + $ java -jar jackrabbit-standalone-1.6.0.jar --help + usage: java -jar jackrabbit-standalone-1.6.0.jar [-?] + [-b] + [-c ] + [-C + ] + [-d] + [-f ] + [-h ] + [-l] + [-n] + [-p ] + [-q] + [-r ] + [-R ] + -?,--help print this message + -b,--backup create a backup of the repository + -c,--conf repository configuration file + -C,--backup-conf backup repository configuration file + -d,--debug enable debug logging + -f,--file location of this jar file + -h,--host IP address of the HTTP server + -l,--license print license information + -n,--notice print copyright notices + -p,--port TCP port of the HTTP server (8080) + -q,--quiet disable console output + -r,--repo repository directory (jackrabbit) + -R,--backup-repo backup repository directory (jackrabbit-backupN) + + +You may want to increase the maximum amount of heap memory available to the +Java virtual machine especially if you plan to have lots of concurrent +clients accessing the repository or want to perform large batch operations. + +{code:none} +$ java -Xmx256m -jar jackrabbit-standalone-1.6.0.jar + + + h2. Web interface + + The web interface you see at [http://localhost:8080/] + is a simple web application built on top of the content repository. It +contains some basic instructions on how to access the repository and comes +with the following utility tools: + + * Populate ([http://localhost:8080/populate.jsp] ) + This tool populates the default workspace with example documents found on +the web based on a Google search. This is an easy way to get some +semi-random test content into the repository. + * Search ([http://localhost:8080/search.jsp] +) + This tool uses the full text search feature to find content within the +default workspace of the repository. To see the search feature in action, +first add some content to the repository with the Populate tool and then +try to search for the documents with the Search tool. + * Browse ([http://localhost:8080/repository/default/] +) + The built-in WebDAV feature allows you to browse the file ({{nt:file}}) +and folder ({{nt:folder}}) nodes within the repository. See the WebDAV +section below for all the other things you can do with this tool! Note that +the server will by default accept any username and password combination. + + h2. WebDAV access + + The simple repository browser you can see at [http://localhost:8080/repository/default/] + is actually a fully featured WebDAV server backed by the content +repository. You can mount this address as a WebDAV share to your normal +filesystem and treat it as you would any shared network folder. This +feature is especially useful for copying large amounts of files or folders +to or from the repository. Note that this feature is limited to standard +files and folders, any more fine-grained JCR content will simply not be +visible. + + The repository also exposes an alternative WebDAV access point at [http://localhost:8080/server/] + for more fine-grained content access. This access point implements a +number of advanced WebDAV features that are not normally seen in plain +file-based WebDAV servers. You will need a feature-rich WebDAV or HTTP +client to access the full power of this interface. With the Jackrabbit +spi2dav component you can even get full remote JCR access over the WebDAV +features and some custom extensions available through this access point. + + h2. RMI access + + In addition to the WebDAV access points, the standalone server also +supports remote JCR access over RMI. After adding the JCR API and the +jackrabbit-jcr-rmi jars to your classpath, you can access the repository +remotely with the following code: + + + import org.apache.jackrabbit.rmi.repository.URLRemoteRepository; + + Repository repository = new URLRemoteRepository("http://localhost:8080/rmi"); + + +h2. Backup and migration + +You can also use the standalone server jar to backup existing repositories +or to migrate them to a different configuration. The backup mode is +activated with the {{--backup}} command line option. The essential command +line options and their default values for the backup mode are: + + {code:none} + $ java -jar jackrabbit-standalone-1.6.0.jar --backup \ + --repo=jackrabbit \ + --conf=jackrabbit/repository.xml \ + --backup-repo=jackrabbit-backupN \ + --backup-conf=jackrabbit-backupN/repository.xml + + +Note that the source repository must not be running when you use this +feature. If the target repository already exist, then all content inside it +is overwritten. Note also that the search indexes of the target repository +will be generated only when the repository is next started. This keeps the +disk size of the backup smaller, but causes a notable startup delay +especially for large repositories if you need to restore that backup. + +To migrate a repository to a different configuration, simply point the +*--backup-conf* option to a custom repository configuration file. Note +that by default the backups are made using the default Jackrabbit +repository configuration, regardless of the configuration of the source +repository. + + +## Drawbacks + +The Jackrabbit Standalone server is designed primarily as a quick and easy +way to get a content repository up and running for testing and development +purposes. For more complex deployment scenarios and configuration options +you should look at the [Jackrabbit Web Application](jackrabbit-web-application.html) + and [Jackrabbit JCA Resource Adapter] + packages. + +Note also that RMI remoting layer has not been optimized for performance, +so currently the recommendation for accessing the JCR API in performance +critical applications is to have the repository running locally in the same +process as the client application. Added: jackrabbit/site/trunk/src/site/markdown/supporting-software-attribution.md URL: http://svn.apache.org/viewvc/jackrabbit/site/trunk/src/site/markdown/supporting-software-attribution.md?rev=1670829&view=auto ============================================================================== --- jackrabbit/site/trunk/src/site/markdown/supporting-software-attribution.md (added) +++ jackrabbit/site/trunk/src/site/markdown/supporting-software-attribution.md Thu Apr 2 07:13:56 2015 @@ -0,0 +1,5 @@ +Title: Supporting software attribution +Developers use various tools to assist with their work, such as [IntelliJ IDEA](http://www.jetbrains.com/idea/opensource/) + or [Eclipse|http://www.eclipse.org/] +. Most tools do not require attribution, but some do ([YourKit Java +Profiler|http://www.yourkit.com/]). Added: jackrabbit/site/trunk/src/site/markdown/website.md URL: http://svn.apache.org/viewvc/jackrabbit/site/trunk/src/site/markdown/website.md?rev=1670829&view=auto ============================================================================== --- jackrabbit/site/trunk/src/site/markdown/website.md (added) +++ jackrabbit/site/trunk/src/site/markdown/website.md Thu Apr 2 07:13:56 2015 @@ -0,0 +1,23 @@ +Title: Website +The [Apache Jackrabbit website](http://jackrabbit.apache.org/) + is managed using the [JCR space|http://cwiki.apache.org/confluence/display/JCR] + in the [Confluence wiki|http://cwiki.apache.org/CWIKI/] + at Apache. + +Only [Jackrabbit committers](jackrabbit-team.html) + are allowed to modify the site content. To edit the site content you need +to register for a Confluence account and ask one of the Confluence admins +(currently Jukka and Felix) to add you to the Jackrabbit group. + +The contents of the wiki are automatically exported and synchronized to the +public web server every few hours. The auto-export configuration (including +the site template) is available in the "Administration" section of +Confluence. See the [CWIKI page](http://cwiki.apache.org/CWIKI/) + for more details about the auto-export process. + +In addition to the wiki pages and their attachments the Jackrabbit site +also contains static content like API documentation and stylesheets. This +content is managed using the [site tree](https://svn.apache.org/repos/asf/jackrabbit/site/) + in Subversion. The static site content is automatically updated along with +the auto-exported wiki content. + Added: jackrabbit/site/trunk/src/site/resources/css/site.css URL: http://svn.apache.org/viewvc/jackrabbit/site/trunk/src/site/resources/css/site.css?rev=1670829&view=auto ============================================================================== --- jackrabbit/site/trunk/src/site/resources/css/site.css (added) +++ jackrabbit/site/trunk/src/site/resources/css/site.css Thu Apr 2 07:13:56 2015 @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ + +body { + font-size: 15px; + line-height: 18px; +} +tt { + white-space: nowrap; + border: 1px solid #eaeaea; + background-color: #f5f5f5; +} +pre { + font-size: 12px; +} + +.navbar .brand { + padding: 0px 20px 1px; +} +.navbar-inner { + background: white; +} + +.brand img { + height: 70px; +} + +#banner { + display: none; +} + +body.topBarEnabled { + padding-top: 90px; +} +.navbar .nav { + margin: 30px 10px 0 0; + font-size: 16px; +} + +#topbar .container-fluid { + background: url('../images/logos/asf-logo.gif') no-repeat; + background-size: 266px; + padding-left: 266px; +} + +a.anchor { + margin-top: -80px; + position: absolute; +} \ No newline at end of file Added: jackrabbit/site/trunk/src/site/resources/images/logos/asf-logo.gif URL: http://svn.apache.org/viewvc/jackrabbit/site/trunk/src/site/resources/images/logos/asf-logo.gif?rev=1670829&view=auto ============================================================================== Binary file - no diff available. Propchange: jackrabbit/site/trunk/src/site/resources/images/logos/asf-logo.gif ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: jackrabbit/site/trunk/src/site/resources/images/logos/jlogo.gif URL: http://svn.apache.org/viewvc/jackrabbit/site/trunk/src/site/resources/images/logos/jlogo.gif?rev=1670829&view=auto ============================================================================== Binary file - no diff available. Propchange: jackrabbit/site/trunk/src/site/resources/images/logos/jlogo.gif ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream