chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r785867 [4/7] - in /websites/staging/chemistry/trunk/content: ./ dotnet/ java/ php/ python/
Date Mon, 21 Feb 2011 14:22:50 GMT
Added: websites/staging/chemistry/trunk/content/java/opencmis-client-bindings.html
==============================================================================
--- websites/staging/chemistry/trunk/content/java/opencmis-client-bindings.html (added)
+++ websites/staging/chemistry/trunk/content/java/opencmis-client-bindings.html Mon Feb 21 14:22:49 2011
@@ -0,0 +1,341 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!--
+
+    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.
+
+-->
+<html>
+  <head>
+    <link type="text/css" rel="stylesheet" href="/resources/site.css"></link>
+    <script src="/resources/space.js" type="text/javascript"></script>
+    <meta name="keywords" content="CMIS, Content Management Interoperability Service, ECM, Enterprise Content Management, OASIS, integration standards, Chemistry, OpenCMIS"/>
+    <meta name="description" content="Apache Chemistry, CMIS Implementation" />
+    <title>
+Apache Chemistry - OpenCMIS Client Bindings
+    </title>
+  </head>
+<body onload="init()">
+  <table width="100%" cellpadding="0" cellspacing="0">
+    <tr width="100%">
+      <td id="cell-0-0">&nbsp;</td>
+      <td id="cell-0-1">&nbsp;</td>
+      <td id="cell-0-2">&nbsp;</td>
+    </tr>
+    <tr width="100%">
+      <td id="cell-1-0">&nbsp;</td>
+      <td id="cell-1-1">
+        <div style="padding: 5px;">
+          <div id="banner">
+          <!-- Banner -->
+<TABLE border="0" cellpadding="0" cellspacing="0" width="100%">
+<TR>
+<TD align="left" class="topbardiv" nowrap="">
+  <A href="http://chemistry.apache.org/" title="Apache Chemistry">
+    <IMG border="0" src="/images/chemistry_tm_logo_small.png"/>
+  </A>
+</TD>
+<TD align="right" nowrap="">
+  <A href="http://www.apache.org/" title="The Apache Software Foundation">
+    <IMG border="0" src="/images/asf-logo.png"/>
+  </A>
+</TD>
+</TR>
+</TABLE>
+          <!-- Banner -->
+          </div>
+        </div>
+        <div id="top-menu">
+          <table border="0" cellpadding="1" cellspacing="0" width="100%">
+            <tr>
+              <td>
+                <div align="left">
+                <!-- Breadcrumbs -->
+<a href="/">Home</a>&nbsp;&raquo&nbsp;<a href="/java">Java</a>&nbsp;&raquo&nbsp;<a href="/java/opencmis.html">OpenCMIS</a>&nbsp;&raquo&nbsp;<a href="/java/opencmis-client-bindings.html">OpenCMIS Client Bindings</a>
+                <!-- Breadcrumbs -->
+                </div>
+              </td>
+              <td>
+                <div align="right">
+                <!-- Quicklinks -->
+<P>
+<A href="http://www.apache.org/" class="external-link" rel="nofollow">Apache</A>
+|
+<A href="http://www.apache.org/licenses/LICENSE-2.0.html" class="external-link" rel="nofollow">License</A>
+|
+<A href="sitemap.html" title="SiteMap">Site Map</A>
+</P>
+                <!-- Quicklinks -->
+                </div>
+              </td>
+            </tr>
+          </table>
+        </div>
+      </td>
+      <td id="cell-1-2">&nbsp;</td>
+    </tr>
+    <tr width="100%">
+      <td id="cell-2-0">&nbsp;</td>
+      <td id="cell-2-1">
+        <table>
+          <tr height="100%" valign="top">
+            <td height="100%">
+              <div id="wrapper-menu-page-right">
+                <div id="wrapper-menu-page-top">
+                  <div id="wrapper-menu-page-bottom">
+                    <div id="menu-page">
+                    <!-- NavigationBar -->
+                    <H3><A name="Navigation-Overview"></A>Overview</H3>
+
+<UL class="alternate" type="square">
+   <LI><A href="http://www.apache.org/licenses/LICENSE-2.0.html" class="external-link" rel="nofollow">License</A></LI>
+   <LI><A href="sitemap.html" title="SiteMap">Site Map</A></LI>
+   <LI><A href="http://mail-archives.apache.org/mod_mbox/incubator-chemistry-dev/" class="external-link" rel="nofollow">Mailing List</A></LI>
+   <LI><A href="https://issues.apache.org/jira/browse/CMIS" class="external-link" rel="nofollow">Issue Tracking</A></LI>
+</UL>
+
+
+<H3><A name="Navigation-Search"></A>Search</H3>
+
+<DIV style="padding: 0px 0px 0px 20px;">
+<FORM action="http://www.google.com/search" method="get" style="font-size: 10px;">
+<INPUT name="ie" type="hidden" value="UTF-8"></INPUT>
+<INPUT name="oe" type="hidden" value="UTF-8"></INPUT>
+  <INPUT maxlength="255" name="q" size="12" type="text" value=""></INPUT>
+  <INPUT name="btnG" type="submit" value="Search"></INPUT>
+  <INPUT name="domains" type="hidden" value="incubator.apache.org/chemistry"></INPUT>
+  <INPUT name="sitesearch" type="hidden" value="incubator.apache.org/chemistry"></INPUT>
+</FORM>
+</DIV>
+
+
+<H3><A name="Navigation-CMISforJava"></A>CMIS for Java</H3>
+
+<UL class="alternate" type="square">
+   <LI><A href="opencmis.html" title="OpenCMIS">OpenCMIS</A></LI>
+   <LI><A href="opencmis-modules.html" title="OpenCMIS Modules">Overview</A></LI>
+   <LI><A href="opencmis-client-api.html" title="OpenCMIS Client API">Client API</A></LI>
+   <LI><A href="https://svn.apache.org/repos/asf/chemistry/opencmis/trunk" class="external-link" rel="nofollow">Source Code</A></LI>
+   <LI><A href="http://incubator.apache.org/chemistry/javadoc/index.html" class="external-link" rel="nofollow">JavaDoc</A></LI>
+</UL>
+
+
+<H3><A name="Navigation-CMISforPython"></A>CMIS for Python</H3>
+
+<UL class="alternate" type="square">
+   <LI><A href="cmislib.html" title="cmislib">cmislib</A></LI>
+   <LI><A href="http://incubator.apache.org/chemistry/cmislib-doc/" class="external-link" rel="nofollow">cmislib Documentation</A></LI>
+   <LI><A href="https://svn.apache.org/repos/asf/chemistry/cmislib/trunk" class="external-link" rel="nofollow">Source Code</A></LI>
+</UL>
+
+
+<H3><A name="Navigation-CMISforPHP"></A>CMIS for PHP</H3>
+
+<UL class="alternate" type="square">
+   <LI><A href="phpclient.html" title="phpclient">CMIS PHP Client</A></LI>
+   <LI><A href="https://svn.apache.org/repos/asf/chemistry/phpclient/trunk" class="external-link" rel="nofollow">Source Code</A></LI>
+</UL>
+
+
+<H3><A name="Navigation-CMISfor.NET"></A>CMIS for .NET</H3>
+
+<UL class="alternate" type="square">
+   <LI><A href="dotcmis.html" title="DotCMIS">DotCMIS</A></LI>
+   <LI><A href="https://svn.apache.org/repos/asf/chemistry/dotcmis/trunk" class="external-link" rel="nofollow">Source Code</A></LI>
+</UL>
+
+
+<H3><A name="Navigation-Sponsorship"></A>Sponsorship</H3>
+
+<UL class="alternate" type="square">
+   <LI><A href="http://www.apache.org/foundation/thanks.html" class="external-link" rel="nofollow">Thanks</A></LI>
+   <LI><A href="http://www.apache.org/foundation/sponsorship.html" class="external-link" rel="nofollow">Sponsoring Apache</A></LI>
+</UL>
+
+                    <!-- NavigationBar -->
+                    </div>
+                </div>
+              </div>
+            </div>
+           </td>
+           <td height="100%">
+             <!-- Content -->
+             <div class="wiki-content"><h1 id="opencmis_client_bindings">OpenCMIS Client Bindings</h1>
+<p><a name="OpenCMISClientBindings-OpenCMISClientBindings"></a></p>
+<p>The OpenCMIS client bindings layer hides the CMIS AtomPub and Web Services
+bindings and provides an interface that is very similar to the <a href="http://docs.oasis-open.org/cmis/CMIS/v1.0/cs01/cmis-spec-v1.0.html#_Toc243905381">CMIS domain model</a>
+. The services, operations, parameters, and structures are named after the
+CMIS domain model and behave as described in the CMIS specification.</p>
+<p>The primary objective of the client bindings layer is to be complete,
+covering all CMIS operations and extension points. The result is a somewhat
+clunky interface. The <a href="opencmis-client-api.html">OpenCMIS Client API</a>
+ sits on top of the provider layer and exposes a nicer and simpler to use
+interface. It is the better choice for most applications.</p>
+<p>A connection to a CMIS repository is represented by a <a href="http://incubator.apache.org/chemistry/javadoc/org/apache/chemistry/opencmis/commons/spi/CmisBinding.html"><em>CmisBinding</em></a>
+ object. Such an object can be created by the <a href="http://incubator.apache.org/chemistry/javadoc/org/apache/chemistry/opencmis/client/bindings/CmisBindingFactory.html"><code>CmisBindingFactory</code></a>.
+The factory provides three main methods, one for each binding and third
+one for a local connection (same JVM), that require binding specific
+connection information. The created <code>CmisBinding</code> object exposes a
+binding agnostic interface.</p>
+<p><code>CmisBinding</code> is the entry point to the CMIS services and a few utility
+operations. It contains a transparent cache for repository infos and type
+definitions. The object is serializable, although dehydrating can be
+expensive. <code>CmisBinding</code> is thread-safe.</p>
+<p>The get*Service() methods provide access to the CMIS services. Some
+service operations take provider layer specific objects. These objects
+should be created with the <a href="http://incubator.apache.org/chemistry/javadoc/org/apache/chemistry/opencmis/commons/spi/BindingsObjectFactory.html"><code>BindingsObjectFactory</code></a>.
+This factory can be obtained through the <code>getObjectFactory()</code> method of the <code>CmisBinding</code> object.</p>
+<p>Please refer to the OpenCMIS Commons <a href="http://incubator.apache.org/chemistry/javadoc/">JavaDoc</a>
+ and OpenCMIS Client Binding <a href="http://incubator.apache.org/chemistry/javadoc/">JavaDoc</a>
+ for more details on the interfaces.</p>
+<p><a name="OpenCMISClientBindings-SampleCode"></a></p>
+<h2 id="sample_code">Sample Code</h2>
+<p><a name="OpenCMISClientBindings-CreatinganAtomPubbindinginstance"></a></p>
+<h3 id="creating_an_atompub_binding_instance">Creating an AtomPub binding instance</h3>
+<p>The AtomPub binding requires the URL of the CMIS service document. HTTP
+basic authentication is enabled by default and a username and a password
+have to be provided.</p>
+<div class="codehilite"><pre><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="p">,</span> <span class="n">String</span><span class="o">&gt;</span> <span class="n">parameters</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="p">,</span> <span class="n">String</span><span class="o">&gt;</span><span class="p">();</span>
+
+<span class="n">parameters</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">SessionParameter</span><span class="o">.</span><span class="n">USER</span><span class="p">,</span> <span class="n">user</span><span class="p">);</span>
+<span class="n">parameters</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">SessionParameter</span><span class="o">.</span><span class="n">PASSWORD</span><span class="p">,</span> <span class="n">password</span><span class="p">);</span>
+
+<span class="n">parameters</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">SessionParameter</span><span class="o">.</span><span class="n">ATOMPUB_URL</span><span class="p">,</span> <span class="n">url</span><span class="p">);</span> <span class="sr">//</span> <span class="n">service</span> <span class="n">document</span> <span class="n">URL</span>
+
+<span class="n">CmisBindingFactory</span> <span class="n">factory</span> <span class="o">=</span> <span class="n">CmisBindingFactory</span><span class="o">.</span><span class="n">newInstance</span><span class="p">();</span>
+<span class="n">CmisBinding</span> <span class="n">binding</span> <span class="o">=</span> <span class="n">factory</span><span class="o">.</span><span class="n">createCmisAtomPubBinding</span><span class="p">(</span><span class="n">parameters</span><span class="p">);</span>
+</pre></div>
+
+
+<h3 id="creating_a_web_services_binding_instance">Creating a Web Services binding instance</h3>
+<p>The Web Services binding requires a WSDL URL for each CMIS service. This
+might the same the URL for all services. WS-Security (UsernameToken) is
+enabled by default and a username and a password have to be provided.</p>
+<div class="codehilite"><pre><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="p">,</span> <span class="n">String</span><span class="o">&gt;</span> <span class="n">parameters</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="p">,</span> <span class="n">String</span><span class="o">&gt;</span><span class="p">();</span>
+
+<span class="n">parameters</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">SessionParameter</span><span class="o">.</span><span class="n">USER</span><span class="p">,</span> <span class="n">username</span><span class="p">);</span>
+<span class="n">parameters</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">SessionParameter</span><span class="o">.</span><span class="n">PASSWORD</span><span class="p">,</span> <span class="n">password</span><span class="p">);</span>
+
+<span class="n">parameters</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">SessionParameter</span><span class="o">.</span><span class="n">WEBSERVICES_REPOSITORY_SERVICE</span><span class="p">,</span> <span class="n">repositoryServiceWsdlUrl</span><span class="p">);</span>
+<span class="n">parameters</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">SessionParameter</span><span class="o">.</span><span class="n">WEBSERVICES_NAVIGATION_SERVICE</span><span class="p">,</span> <span class="n">navigationServiceWsdlUrl</span><span class="p">);</span>
+<span class="n">parameters</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">SessionParameter</span><span class="o">.</span><span class="n">WEBSERVICES_OBJECT_SERVICE</span><span class="p">,</span> <span class="n">objectServiceWsdlUrl</span><span class="p">);</span>
+<span class="n">parameters</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">SessionParameter</span><span class="o">.</span><span class="n">WEBSERVICES_VERSIONING_SERVICE</span><span class="p">,</span> <span class="n">versioningServiceWsdlUrl</span><span class="p">);</span>
+<span class="n">parameters</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">SessionParameter</span><span class="o">.</span><span class="n">WEBSERVICES_DISCOVERY_SERVICE</span><span class="p">,</span> <span class="n">discoveryServiceWsdlUrl</span><span class="p">);</span>
+<span class="n">parameters</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">SessionParameter</span><span class="o">.</span><span class="n">WEBSERVICES_RELATIONSHIP_SERVICE</span><span class="p">,</span> <span class="n">relationshipServiceWsdlUrl</span><span class="p">);</span>
+<span class="n">parameters</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">SessionParameter</span><span class="o">.</span><span class="n">WEBSERVICES_MULTIFILING_SERVICE</span><span class="p">,</span> <span class="n">multiFilingServiceWsdlUrl</span><span class="p">);</span>
+<span class="n">parameters</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">SessionParameter</span><span class="o">.</span><span class="n">WEBSERVICES_POLICY_SERVICE</span><span class="p">,</span> <span class="n">policyServiceWsdlUrl</span><span class="p">);</span>
+<span class="n">parameters</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">SessionParameter</span><span class="o">.</span><span class="n">WEBSERVICES_ACL_SERVICE</span><span class="p">,</span> <span class="n">aclServiceWsdlUrl</span><span class="p">);</span>
+
+<span class="n">CmisBindingFactory</span> <span class="n">factory</span> <span class="o">=</span> <span class="n">CmisBindingFactory</span><span class="o">.</span><span class="n">newInstance</span><span class="p">();</span>
+<span class="n">CmisBinding</span> <span class="n">binding</span> <span class="o">=</span> <span class="n">factory</span><span class="o">.</span><span class="n">createCmisWebServicesBinding</span><span class="p">(</span><span class="n">parameters</span><span class="p">);</span>
+</pre></div>
+
+
+<p><a name="OpenCMISClientBindings-CreatingaLocalbindinginstance"></a></p>
+<h3 id="creating_a_local_binding_instance">Creating a Local binding instance</h3>
+<p>The Local binding connects to an OpenCMIS server in the same JVM. The
+server factory class name has to be supplied.</p>
+<div class="codehilite"><pre><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="p">,</span> <span class="n">String</span><span class="o">&gt;</span> <span class="n">parameters</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="p">,</span> <span class="n">String</span><span class="o">&gt;</span><span class="p">();</span>
+
+<span class="n">parameters</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">SessionParameter</span><span class="o">.</span><span class="n">USER</span><span class="p">,</span> <span class="n">user</span><span class="p">);</span>
+<span class="n">parameters</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">SessionParameter</span><span class="o">.</span><span class="n">PASSWORD</span><span class="p">,</span> <span class="n">password</span><span class="p">);</span>
+
+<span class="n">parameters</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">SessionParameter</span><span class="o">.</span><span class="n">LOCAL_FACTORY</span><span class="p">,</span> <span class="n">factoryClassName</span><span class="p">);</span>
+
+<span class="n">CmisBindingFactory</span> <span class="n">factory</span> <span class="o">=</span> <span class="n">CmisBindingFactory</span><span class="o">.</span><span class="n">newInstance</span><span class="p">();</span>
+<span class="n">CmisBinding</span> <span class="n">binding</span> <span class="o">=</span> <span class="n">factory</span><span class="o">.</span><span class="n">createCmisLocalBinding</span><span class="p">(</span><span class="n">parameters</span><span class="p">);</span>
+</pre></div>
+
+
+<h3 id="getting_an_object">Getting an Object</h3>
+<p>The following snippet gets the name of the object "myObject" in repository
+"myRepository". The parameters of <code>getObject()</code> can be found in the CMIS
+specification.</p>
+<div class="codehilite"><pre><span class="n">CmisBinding</span> <span class="n">binding</span> <span class="o">=</span> <span class="o">...</span>
+
+<span class="n">ObjectData</span> <span class="n">myObject</span> <span class="o">=</span> <span class="n">binding</span><span class="o">.</span><span class="n">getObjectService</span><span class="p">()</span><span class="o">.</span><span class="n">getObject</span><span class="p">(</span><span class="s">&quot;myRepository&quot;</span><span class="p">,</span> <span class="s">&quot;myObject&quot;</span><span class="p">,</span>
+   <span class="s">&quot;*&quot;</span><span class="p">,</span> <span class="n">true</span><span class="p">,</span> <span class="n">IncludeRelationships</span><span class="o">.</span><span class="n">BOTH</span><span class="p">,</span> <span class="s">&quot;cmis:none&quot;</span><span class="p">,</span> <span class="n">true</span><span class="p">,</span> <span class="n">true</span><span class="p">,</span> <span class="n">null</span><span class="p">);</span>
+
+<span class="n">PropertiesData</span> <span class="n">properties</span> <span class="o">=</span> <span class="n">myObject</span><span class="o">.</span><span class="n">getProperties</span><span class="p">();</span>
+<span class="n">PropertyData</span><span class="sr">&lt;String&gt;</span> <span class="n">nameProperty</span> <span class="o">=</span> <span class="n">properties</span><span class="o">.</span><span class="n">getProperties</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">PropertyIds</span><span class="o">.</span><span class="n">NAME</span><span class="p">);</span>
+<span class="n">String</span> <span class="n">name</span> <span class="o">=</span> <span class="n">nameProperty</span><span class="o">.</span><span class="n">getFirstValue</span><span class="p">();</span>
+</pre></div>
+
+
+<p><a name="OpenCMISClientBindings-CustomAuthenticationProvider"></a></p>
+<h2 id="custom_authentication_provider">Custom Authentication Provider</h2>
+<p>OpenCMIS supports HTTP basic authentication for the AtomPub binding and
+WS-Security (UsernameToken) for the Web Services binding out of the box.
+Other authentication methods can be added by implementing a custom
+authentication provider.</p>
+<p>Such a provider must extend
+<code>org.apache.chemistry.opencmis.client.provider.spi.AbstractAuthenticationProvider</code>
+and overwrite the methods <code>getHTTPHeaders</code> and <code>getSOAPHeaders</code>. See
+JavaDoc for details.</p>
+<p>The session parameter <code>SessionParameter.AUTHENTICATION_PROVIDER_CLASS</code>
+must be set to the fully qualified class name in order to active the
+authentication provider before the session is created.</p>
+<div class="codehilite"><pre><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="p">,</span> <span class="n">String</span><span class="o">&gt;</span> <span class="n">parameters</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="p">,</span> <span class="n">String</span><span class="o">&gt;</span><span class="p">();</span>
+
+<span class="n">parameters</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">SessionParameter</span><span class="o">.</span><span class="n">AUTHENTICATION_PROVIDER_CLASS</span><span class="p">,</span> <span class="s">&quot;org.example.opencmis.MyAuthenticationProvider&quot;</span><span class="p">);</span>
+<span class="n">parameters</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="s">&quot;org.example.opencmis.user&quot;</span><span class="p">,</span> <span class="s">&quot;cmisuser&quot;</span><span class="p">);</span> <span class="sr">//</span> <span class="n">MyAuthenticationProvider</span> <span class="n">can</span> <span class="n">get</span> <span class="ow">and</span> <span class="n">evaluate</span> <span class="n">this</span>
+<span class="n">parameters</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="s">&quot;org.example.opencmis.secret&quot;</span><span class="p">,</span> <span class="s">&quot;b3BlbmNtaXMgdXNlcg==&quot;</span><span class="p">);</span>
+
+<span class="n">parameters</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">SessionParameter</span><span class="o">.</span><span class="n">ATOMPUB_URL</span><span class="p">,</span> <span class="n">url</span><span class="p">);</span> <span class="sr">//</span> <span class="n">service</span> <span class="n">document</span> <span class="n">URL</span>
+
+<span class="n">CmisBindingFactory</span> <span class="n">factory</span> <span class="o">=</span> <span class="n">CmisBindingFactory</span><span class="o">.</span><span class="n">newInstance</span><span class="p">();</span>
+<span class="n">CmisBinding</span> <span class="n">provider</span> <span class="o">=</span> <span class="n">factory</span><span class="o">.</span><span class="n">createCmisAtomPubBinding</span><span class="p">(</span><span class="n">parameters</span><span class="p">);</span>
+</pre></div></div>
+             <!-- Content -->
+           </td>
+          </tr>
+        </table>
+     </td>
+     <td id="cell-2-2">&nbsp;</td>
+    </tr>
+    <tr width="100%">
+      <td id="cell-3-0">&nbsp;</td>
+      <td id="cell-3-1">&nbsp;</td>
+      <td id="cell-3-2">&nbsp;</td>
+    </tr>
+    <tr width="100%">
+     <td id="cell-3-0">&nbsp;</td>
+     <td id="cell-3-1">
+       <div id="footer">
+       <!-- Footer -->
+       <div id="site-footer">
+          
+          Apache Chemistry, Apache, the Apache feather logo, and the Apache 
+          Chemistry project logo are trademarks of The Apache Software 
+          Foundation.
+          <BR />
+          Content Management Interoperability Services (CMIS) is an
+          <a href="http://www.oasis-open.org/committees/cmis/">OASIS</a>
+          specification.
+          
+       </div>
+       <!-- Footer -->
+       </div>
+     </td>
+     <td id="cell-3-2">&nbsp;</td>
+    </tr>
+    <tr width="100%">
+      <td id="cell-4-0">&nbsp;</td>
+      <td id="cell-4-1">&nbsp;</td>
+      <td id="cell-4-2">&nbsp;</td>
+    </tr>
+  </table>
+</body>
+</html>

Added: websites/staging/chemistry/trunk/content/java/opencmis-cookbook.html
==============================================================================
--- websites/staging/chemistry/trunk/content/java/opencmis-cookbook.html (added)
+++ websites/staging/chemistry/trunk/content/java/opencmis-cookbook.html Mon Feb 21 14:22:49 2011
@@ -0,0 +1,917 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!--
+
+    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.
+
+-->
+<html>
+  <head>
+    <link type="text/css" rel="stylesheet" href="/resources/site.css"></link>
+    <script src="/resources/space.js" type="text/javascript"></script>
+    <meta name="keywords" content="CMIS, Content Management Interoperability Service, ECM, Enterprise Content Management, OASIS, integration standards, Chemistry, OpenCMIS"/>
+    <meta name="description" content="Apache Chemistry, CMIS Implementation" />
+    <title>
+Apache Chemistry - OpenCMIS Cookbook
+    </title>
+  </head>
+<body onload="init()">
+  <table width="100%" cellpadding="0" cellspacing="0">
+    <tr width="100%">
+      <td id="cell-0-0">&nbsp;</td>
+      <td id="cell-0-1">&nbsp;</td>
+      <td id="cell-0-2">&nbsp;</td>
+    </tr>
+    <tr width="100%">
+      <td id="cell-1-0">&nbsp;</td>
+      <td id="cell-1-1">
+        <div style="padding: 5px;">
+          <div id="banner">
+          <!-- Banner -->
+<TABLE border="0" cellpadding="0" cellspacing="0" width="100%">
+<TR>
+<TD align="left" class="topbardiv" nowrap="">
+  <A href="http://chemistry.apache.org/" title="Apache Chemistry">
+    <IMG border="0" src="/images/chemistry_tm_logo_small.png"/>
+  </A>
+</TD>
+<TD align="right" nowrap="">
+  <A href="http://www.apache.org/" title="The Apache Software Foundation">
+    <IMG border="0" src="/images/asf-logo.png"/>
+  </A>
+</TD>
+</TR>
+</TABLE>
+          <!-- Banner -->
+          </div>
+        </div>
+        <div id="top-menu">
+          <table border="0" cellpadding="1" cellspacing="0" width="100%">
+            <tr>
+              <td>
+                <div align="left">
+                <!-- Breadcrumbs -->
+<a href="/">Home</a>&nbsp;&raquo&nbsp;<a href="/java">Java</a>&nbsp;&raquo&nbsp;<a href="/java/opencmis.html">OpenCMIS</a>&nbsp;&raquo&nbsp;<a href="/java/opencmis-cookbook.html">OpenCMIS Cookbook</a>
+                <!-- Breadcrumbs -->
+                </div>
+              </td>
+              <td>
+                <div align="right">
+                <!-- Quicklinks -->
+<P>
+<A href="http://www.apache.org/" class="external-link" rel="nofollow">Apache</A>
+|
+<A href="http://www.apache.org/licenses/LICENSE-2.0.html" class="external-link" rel="nofollow">License</A>
+|
+<A href="sitemap.html" title="SiteMap">Site Map</A>
+</P>
+                <!-- Quicklinks -->
+                </div>
+              </td>
+            </tr>
+          </table>
+        </div>
+      </td>
+      <td id="cell-1-2">&nbsp;</td>
+    </tr>
+    <tr width="100%">
+      <td id="cell-2-0">&nbsp;</td>
+      <td id="cell-2-1">
+        <table>
+          <tr height="100%" valign="top">
+            <td height="100%">
+              <div id="wrapper-menu-page-right">
+                <div id="wrapper-menu-page-top">
+                  <div id="wrapper-menu-page-bottom">
+                    <div id="menu-page">
+                    <!-- NavigationBar -->
+                    <H3><A name="Navigation-Overview"></A>Overview</H3>
+
+<UL class="alternate" type="square">
+   <LI><A href="http://www.apache.org/licenses/LICENSE-2.0.html" class="external-link" rel="nofollow">License</A></LI>
+   <LI><A href="sitemap.html" title="SiteMap">Site Map</A></LI>
+   <LI><A href="http://mail-archives.apache.org/mod_mbox/incubator-chemistry-dev/" class="external-link" rel="nofollow">Mailing List</A></LI>
+   <LI><A href="https://issues.apache.org/jira/browse/CMIS" class="external-link" rel="nofollow">Issue Tracking</A></LI>
+</UL>
+
+
+<H3><A name="Navigation-Search"></A>Search</H3>
+
+<DIV style="padding: 0px 0px 0px 20px;">
+<FORM action="http://www.google.com/search" method="get" style="font-size: 10px;">
+<INPUT name="ie" type="hidden" value="UTF-8"></INPUT>
+<INPUT name="oe" type="hidden" value="UTF-8"></INPUT>
+  <INPUT maxlength="255" name="q" size="12" type="text" value=""></INPUT>
+  <INPUT name="btnG" type="submit" value="Search"></INPUT>
+  <INPUT name="domains" type="hidden" value="incubator.apache.org/chemistry"></INPUT>
+  <INPUT name="sitesearch" type="hidden" value="incubator.apache.org/chemistry"></INPUT>
+</FORM>
+</DIV>
+
+
+<H3><A name="Navigation-CMISforJava"></A>CMIS for Java</H3>
+
+<UL class="alternate" type="square">
+   <LI><A href="opencmis.html" title="OpenCMIS">OpenCMIS</A></LI>
+   <LI><A href="opencmis-modules.html" title="OpenCMIS Modules">Overview</A></LI>
+   <LI><A href="opencmis-client-api.html" title="OpenCMIS Client API">Client API</A></LI>
+   <LI><A href="https://svn.apache.org/repos/asf/chemistry/opencmis/trunk" class="external-link" rel="nofollow">Source Code</A></LI>
+   <LI><A href="http://incubator.apache.org/chemistry/javadoc/index.html" class="external-link" rel="nofollow">JavaDoc</A></LI>
+</UL>
+
+
+<H3><A name="Navigation-CMISforPython"></A>CMIS for Python</H3>
+
+<UL class="alternate" type="square">
+   <LI><A href="cmislib.html" title="cmislib">cmislib</A></LI>
+   <LI><A href="http://incubator.apache.org/chemistry/cmislib-doc/" class="external-link" rel="nofollow">cmislib Documentation</A></LI>
+   <LI><A href="https://svn.apache.org/repos/asf/chemistry/cmislib/trunk" class="external-link" rel="nofollow">Source Code</A></LI>
+</UL>
+
+
+<H3><A name="Navigation-CMISforPHP"></A>CMIS for PHP</H3>
+
+<UL class="alternate" type="square">
+   <LI><A href="phpclient.html" title="phpclient">CMIS PHP Client</A></LI>
+   <LI><A href="https://svn.apache.org/repos/asf/chemistry/phpclient/trunk" class="external-link" rel="nofollow">Source Code</A></LI>
+</UL>
+
+
+<H3><A name="Navigation-CMISfor.NET"></A>CMIS for .NET</H3>
+
+<UL class="alternate" type="square">
+   <LI><A href="dotcmis.html" title="DotCMIS">DotCMIS</A></LI>
+   <LI><A href="https://svn.apache.org/repos/asf/chemistry/dotcmis/trunk" class="external-link" rel="nofollow">Source Code</A></LI>
+</UL>
+
+
+<H3><A name="Navigation-Sponsorship"></A>Sponsorship</H3>
+
+<UL class="alternate" type="square">
+   <LI><A href="http://www.apache.org/foundation/thanks.html" class="external-link" rel="nofollow">Thanks</A></LI>
+   <LI><A href="http://www.apache.org/foundation/sponsorship.html" class="external-link" rel="nofollow">Sponsoring Apache</A></LI>
+</UL>
+
+                    <!-- NavigationBar -->
+                    </div>
+                </div>
+              </div>
+            </div>
+           </td>
+           <td height="100%">
+             <!-- Content -->
+             <div class="wiki-content"><h1 id="opencmis_cookbook">OpenCMIS Cookbook</h1>
+<p><a name="OpenCMISCookbook-OpenCMISCookbook"></a></p>
+<p><em>Find and share OpenCMIS best practices here.</em></p>
+<ul>
+<li><a href="#OpenCMISCookbook-CMISClient">CMIS Client</a><ul>
+<li><a href="#OpenCMISCookbook-ConnectingtoaCMISrepository">Connecting to a CMIS repository</a><ul>
+<li><a href="#OpenCMISCookbook-ConnectingtoaCMISrepositorybyAtomPub">Connecting to a CMIS repository by AtomPub</a></li>
+<li><a href="#OpenCMISCookbook-ConnectingtoSharePoint2010">Connecting to SharePoint 2010</a><ul>
+<li><a href="#OpenCMISCookbook-AtomPub">AtomPub</a></li>
+<li><a href="#OpenCMISCookbook-WebServices">Web Services</a></li>
+</ul>
+</li>
+<li><a href="#OpenCMISCookbook-UsingCookies">Using Cookies</a></li>
+</ul>
+</li>
+<li><a href="#OpenCMISCookbook-Understandingtheclientsidecache">Understanding the client side cache</a></li>
+<li><a href="#OpenCMISCookbook-Gettingtheidofanobjectfromitspath">Getting the id of an object from its path</a></li>
+<li><a href="#OpenCMISCookbook-Readingafile">Reading a file</a></li>
+<li><a href="#OpenCMISCookbook-Showingafolder&apos;sitems,withresultspaging">Showing a folder's items, with results paging</a></li>
+<li><a href="#OpenCMISCookbook-RetrievingDocumentobjectsfromqueryresults">Retrieving Document objects from query results</a></li>
+<li><a href="#OpenCMISCookbook-GettingCMISextensions">Getting CMIS extensions</a></li>
+<li><a href="#OpenCMISCookbook-Connectingfroma.NetclientviatheWebServicesbinding">Connecting from a .Net client via the Web Services binding</a></li>
+<li><a href="#OpenCMISCookbook-ReadingmetadataandcontentfromaCMISrepository">Reading metadata and content from a CMIS repository</a></li>
+<li><a href="#OpenCMISCookbook-CreatingandupdatingCMISobjects">Creating and updating CMIS objects</a></li>
+<li><a href="#OpenCMISCookbook-Usingthequeryparser">Using the query parser</a></li>
+</ul>
+</li>
+<li><a href="#OpenCMISCookbook-CMISServer">CMIS Server</a><ul>
+<li><a href="#OpenCMISCookbook-AddingCMISextensions">Adding CMIS extensions</a></li>
+<li><a href="#OpenCMISCookbook-UsingtheserverframeworkwithSpring">Using the server framework with Spring</a></li>
+</ul>
+</li>
+</ul>
+<p><a name="OpenCMISCookbook-CMISClient"></a></p>
+<h2 id="cmis_client">CMIS Client</h2>
+<p><a name="OpenCMISCookbook-ConnectingtoaCMISrepository"></a></p>
+<h3 id="connecting_to_a_cmis_repository">Connecting to a CMIS repository</h3>
+<p><a name="OpenCMISCookbook-ConnectingtoaCMISrepositorybyAtomPub"></a></p>
+<h4 id="connecting_to_a_cmis_repository_by_atompub">Connecting to a CMIS repository by AtomPub</h4>
+<div class="codehilite"><pre><span class="sr">//</span> <span class="n">Default</span> <span class="n">factory</span> <span class="n">implementation</span> <span class="n">of</span> <span class="n">client</span> <span class="n">runtime</span><span class="o">.</span>
+<span class="n">SessionFactory</span> <span class="n">sessionFactory</span> <span class="o">=</span> <span class="n">SessionFactoryImpl</span><span class="o">.</span><span class="n">newInstance</span><span class="p">();</span>
+<span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="p">,</span> <span class="n">String</span><span class="o">&gt;</span> <span class="n">parameter</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="p">,</span> <span class="n">String</span><span class="o">&gt;</span><span class="p">();</span>
+
+<span class="sr">//</span> <span class="n">User</span> <span class="n">credentials</span><span class="o">.</span>
+<span class="n">parameter</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">SessionParameter</span><span class="o">.</span><span class="n">USER</span><span class="p">,</span> <span class="s">&quot;user&quot;</span><span class="p">);</span>
+<span class="n">parameter</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">SessionParameter</span><span class="o">.</span><span class="n">PASSWORD</span><span class="p">,</span> <span class="s">&quot;password&quot;</span><span class="p">);</span>
+
+<span class="sr">//</span> <span class="n">Connection</span> <span class="n">settings</span><span class="o">.</span>
+<span class="n">parameter</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">SessionParameter</span><span class="o">.</span><span class="n">ATOMPUB_URL</span><span class="p">,</span>
+    <span class="s">&quot;http://localhost:8080/alfresco/service/cmis&quot;</span><span class="p">);</span> <span class="sr">//</span> <span class="n">URL</span> <span class="n">to</span> <span class="n">your</span> <span class="n">CMIS</span> <span class="n">server</span><span class="o">.</span>
+<span class="sr">//</span> <span class="n">parameter</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">SessionParameter</span><span class="o">.</span><span class="n">REPOSITORY_ID</span><span class="p">,</span> <span class="s">&quot;myRepository&quot;</span><span class="p">);</span> <span class="sr">//</span> <span class="n">Only</span> <span class="n">necessary</span> <span class="k">if</span> <span class="n">there</span> <span class="n">is</span> <span class="n">more</span> <span class="n">than</span> <span class="n">one</span> <span class="n">repository</span><span class="o">.</span>
+<span class="n">parameter</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">SessionParameter</span><span class="o">.</span><span class="n">BINDING_TYPE</span><span class="p">,</span> <span class="n">BindingType</span><span class="o">.</span><span class="n">ATOMPUB</span><span class="o">.</span><span class="n">value</span><span class="p">());</span>
+
+<span class="sr">//</span> <span class="n">Session</span> <span class="n">locale</span><span class="o">.</span>
+<span class="n">parameter</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">SessionParameter</span><span class="o">.</span><span class="n">LOCALE_ISO3166_COUNTRY</span><span class="p">,</span> <span class="s">&quot;&quot;</span><span class="p">);</span>
+<span class="n">parameter</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">SessionParameter</span><span class="o">.</span><span class="n">LOCALE_ISO639_LANGUAGE</span><span class="p">,</span> <span class="s">&quot;en&quot;</span><span class="p">);</span>
+<span class="n">parameter</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">SessionParameter</span><span class="o">.</span><span class="n">LOCALE_VARIANT</span><span class="p">,</span> <span class="s">&quot;US&quot;</span><span class="p">);</span>
+
+<span class="sr">//</span> <span class="n">Create</span> <span class="n">session</span><span class="o">.</span>
+<span class="n">Session</span> <span class="n">session</span> <span class="o">=</span> <span class="n">null</span><span class="p">;</span>
+<span class="n">try</span> <span class="p">{</span>
+    <span class="sr">//</span> <span class="n">This</span> <span class="n">supposes</span> <span class="n">only</span> <span class="n">one</span> <span class="n">repository</span> <span class="n">is</span> <span class="n">available</span> <span class="n">at</span> <span class="n">the</span> <span class="n">URL</span><span class="o">.</span>
+    <span class="n">Repository</span> <span class="n">soleRepository</span> <span class="o">=</span>
+        <span class="n">sessionFactory</span><span class="o">.</span><span class="n">getRepositories</span><span class="p">(</span><span class="n">parameter</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
+    <span class="n">session</span> <span class="o">=</span> <span class="n">soleRepository</span><span class="o">.</span><span class="n">createSession</span><span class="p">();</span>
+<span class="p">}</span>
+<span class="n">catch</span><span class="p">(</span><span class="n">CmisConnectionException</span> <span class="n">e</span><span class="p">)</span> <span class="p">{</span> 
+    <span class="sr">//</span> <span class="n">The</span> <span class="n">server</span> <span class="n">is</span> <span class="n">unreachable</span>
+<span class="p">}</span>
+<span class="n">catch</span><span class="p">(</span><span class="n">CmisRuntimeException</span> <span class="n">e</span><span class="p">)</span> <span class="p">{</span>
+    <span class="sr">//</span> <span class="n">The</span> <span class="n">user</span><span class="o">/</span><span class="n">password</span> <span class="n">have</span> <span class="n">probably</span> <span class="n">been</span> <span class="n">rejected</span> <span class="n">by</span> <span class="n">the</span> <span class="n">server</span><span class="o">.</span>
+<span class="p">}</span>
+
+<span class="n">h4</span><span class="o">.</span> <span class="n">Connecting</span> <span class="n">to</span> <span class="n">SharePoint</span> <span class="mi">2010</span>
+
+<span class="n">While</span> <span class="n">connecting</span> <span class="n">via</span> <span class="n">AtomPub</span> <span class="n">is</span> <span class="n">straight</span> <span class="n">forward</span><span class="p">,</span> <span class="n">connecting</span> <span class="n">via</span> <span class="n">Web</span>
+</pre></div>
+
+
+<p>Services is a bit tricky.</p>
+<div class="codehilite"><pre><span class="n">h5</span><span class="o">.</span> <span class="n">AtomPub</span>
+
+<span class="n">The</span> <span class="n">service</span> <span class="n">document</span> <span class="n">URL</span> <span class="n">is</span>
+</pre></div>
+
+
+<p>http://<host>/_vti_bin/cmis/rest/<SPList>?getrepositoryinfo .
+    Since this sends the password as plain text,  HTTPS is strongly
+recommended.</p>
+<div class="codehilite"><pre><span class="n">h5</span><span class="o">.</span> <span class="n">Web</span> <span class="n">Services</span>
+
+<span class="c1"># Download the WSDL with a web browser and store it on your local disk. The</span>
+</pre></div>
+
+
+<p>WSDL URL is http://<host>/_vti_bin/cmissoapwsdl.aspx?wsdl .
+    # Provide file://... URLs to the downloaded WSDL for all OpenCMIS WSDL
+session parameters.
+    # Activate the OpenCMIS NTLM authentication provider.</p>
+<div class="codehilite"><pre><span class="n">parameters</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">SessionParameter</span><span class="o">.</span><span class="n">AUTHENTICATION_PROVIDER_CLASS</span><span class="p">,</span> <span class="n">CmisBindingFactory</span><span class="o">.</span><span class="n">NTLM_AUTHENTICATION_PROVIDER</span><span class="p">);</span>
+
+<span class="p">(</span><span class="n">The</span> <span class="n">NTLM</span>
+</pre></div>
+
+
+<p>authentication provider uses [java.net.Authenticator|http://download-llnw.oracle.com/javase/6/docs/api/java/net/Authenticator.html]
+ under the hood. If this interferes with your environment, you are on your
+own.)</p>
+<div class="codehilite"><pre><span class="n">h4</span><span class="o">.</span> <span class="n">Using</span> <span class="n">Cookies</span>
+
+<span class="n">Some</span> <span class="n">repositories</span> <span class="n">are</span> <span class="n">sending</span> <span class="n">HTTP</span> <span class="n">cookies</span> <span class="n">to</span> <span class="n">maintain</span> <span class="n">state</span> <span class="p">(</span><span class="n">although</span> <span class="n">CMIS</span>
+</pre></div>
+
+
+<p>is stateless) or accelerate authentication for subsequent calls. OpenCMIS
+ignores these cookies by default. The following code snippet activates
+cookies for your application and OpenCMIS. See [this page|http://java.sun.com/docs/books/tutorial/networking/cookies/cookiemanager.html]
+ for details.</p>
+<div class="codehilite"><pre><span class="p">{</span><span class="n">code:java</span><span class="p">}</span>
+<span class="n">CookieManager</span> <span class="n">cm</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CookieManager</span><span class="p">(</span><span class="n">null</span><span class="p">,</span> <span class="n">CookiePolicy</span><span class="o">.</span><span class="n">ACCEPT_ALL</span><span class="p">);</span>
+<span class="n">CookieHandler</span><span class="o">.</span><span class="n">setDefault</span><span class="p">(</span><span class="n">cm</span><span class="p">);</span>
+</pre></div>
+
+
+<p><a name="OpenCMISCookbook-Understandingtheclientsidecache"></a></p>
+<h3 id="understanding_the_client_side_cache">Understanding the client side cache</h3>
+<p>Client side caching is turned on by default. That is, getObject() will
+first look into the session cache if the object already exists there. If
+this is the case, it returns the object without talking to the repository.
+So it might return stale objects.<br />
+</p>
+<p>There are multiple ways to deal with that:
+* Refresh the object data that is returned from getObject().
+{code:java}
+CmisObject object = session.getObject(id);</p>
+<p>object.refresh(); // contacts the repository and refreshes the object</p>
+<p>object.refreshIfOld(60 * 1000); // ... or refreshes the object only if the
+data is older than a minute    <br />
+</p>
+<div class="codehilite"><pre><span class="o">*</span> <span class="n">Turn</span> <span class="n">off</span> <span class="n">the</span> <span class="n">session</span> <span class="n">cache</span> <span class="n">completely</span><span class="o">.</span>
+<span class="p">{</span><span class="n">code:java</span><span class="p">}</span>
+<span class="n">session</span><span class="o">.</span><span class="n">getDefaultContext</span><span class="p">()</span><span class="o">.</span><span class="n">setCacheEnabled</span><span class="p">(</span><span class="n">false</span><span class="p">);</span>
+</pre></div>
+
+
+<ul>
+<li>Turn off caching for this getObject() call.
+{code:java}
+OperationContext oc = session.createOperationContext();
+oc.setCacheEnabled(false);</li>
+</ul>
+<p>CmisObject object = session.getObject(id, oc);</p>
+<div class="codehilite"><pre><span class="o">*</span> <span class="n">Clear</span> <span class="n">the</span> <span class="n">session</span> <span class="n">cache</span> <span class="p">(</span><span class="ow">not</span> <span class="n">recommended</span><span class="p">)</span><span class="o">.</span>
+<span class="p">{</span><span class="n">code:java</span><span class="p">}</span>
+<span class="n">session</span><span class="o">.</span><span class="n">clear</span><span class="p">();</span>
+</pre></div>
+
+
+<p><a name="OpenCMISCookbook-Gettingtheidofanobjectfromitspath"></a></p>
+<h3 id="getting_the_id_of_an_object_from_its_path">Getting the id of an object from its path</h3>
+<p>{code:java}
+String path = "/User Homes/customer1/document.odt"
+CmisObject object = getSession().getObjectByPath(path);
+String id = object.getId();</p>
+<div class="codehilite"><pre><span class="n">h3</span><span class="o">.</span> <span class="n">Reading</span> <span class="n">a</span> <span class="n">file</span>
+
+<span class="p">{</span><span class="n">code:java</span><span class="p">}</span>
+<span class="n">CmisObject</span> <span class="n">object</span> <span class="o">=</span> <span class="n">getSession</span><span class="p">()</span><span class="o">.</span><span class="n">getObject</span><span class="p">(</span><span class="n">session</span><span class="o">.</span><span class="n">createObjectId</span><span class="p">(</span><span class="n">fileId</span><span class="p">));</span>
+<span class="n">Document</span> <span class="n">document</span> <span class="o">=</span> <span class="p">(</span><span class="n">Document</span><span class="p">)</span><span class="n">object</span><span class="p">;</span>
+<span class="n">String</span> <span class="n">filename</span> <span class="o">=</span> <span class="n">document</span><span class="o">.</span><span class="n">getName</span><span class="p">();</span>
+<span class="n">InputStream</span> <span class="n">stream</span> <span class="o">=</span> <span class="n">document</span><span class="o">.</span><span class="n">getContentStream</span><span class="p">()</span><span class="o">.</span><span class="n">getStream</span><span class="p">();</span>
+</pre></div>
+
+
+<p><a name="OpenCMISCookbook-Showingafolder'sitems,withresultspaging"></a></p>
+<h3 id="showing_a_folders_items_with_results_paging">Showing a folder's items, with results paging</h3>
+<p>{code:java}
+int maxItemsPerPage = 5;
+int skipCount = 10;</p>
+<p>CmisObject object = session.getObject(session.createObjectId(folderId));
+Folder folder = (Folder)object;
+OperationContext operationContext = session.createOperationContext();
+operationContext.setMaxItemsPerPage(maxItemsPerPage);</p>
+<p>ItemIterable<CmisObject> children = folder.getChildren(operationContext);
+ItemIterable<CmisObject> page = children.skipTo(skipCount).getPage();</p>
+<p>Iterator<CmisObject> pageItems = page.iterator();
+while(pageItems.hasNext()) {
+       CmisObject item = pageItems.next();
+       // Do something with the item.
+}</p>
+<div class="codehilite"><pre><span class="x">h3. Retrieving Document objects from query results</span>
+
+<span class="x">{code:java}</span>
+<span class="x">String myType = &quot;my:documentType&quot;;</span>
+<span class="x">String queryString = &quot;SELECT * FROM &quot; + myType;</span>
+
+<span class="x">// get the query name of cmis:objectId</span>
+<span class="x">ObjectType type = session.getTypeDefinition(myType);</span>
+<span class="x">PropertyDefinition</span><span class="cp">&lt;?</span><span class="o">&gt;</span> <span class="nx">objectIdPropDef</span> <span class="o">=</span>
+</pre></div>
+
+
+<p>type.getPropertyDefinitions().get(PropertyIds.OBJECT_ID);
+    String objectIdQueryName = objectIdPropDef.getQueryName();</p>
+<div class="codehilite"><pre><span class="sr">//</span> <span class="n">execute</span> <span class="n">query</span>
+<span class="n">ItemIterable</span><span class="sr">&lt;QueryResult&gt;</span> <span class="n">results</span> <span class="o">=</span> <span class="n">session</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">queryString</span><span class="p">,</span> <span class="n">false</span><span class="p">);</span>
+
+<span class="k">for</span> <span class="p">(</span><span class="n">QueryResult</span> <span class="n">qResult</span> <span class="p">:</span> <span class="n">results</span><span class="p">)</span> <span class="p">{</span>
+   <span class="n">String</span> <span class="n">objectId</span> <span class="o">=</span>
+</pre></div>
+
+
+<p>qResult.getPropertyValueByQueryName(objectIdQueryName);</p>
+<div class="codehilite"><pre>   <span class="n">Document</span> <span class="n">doc</span> <span class="o">=</span> <span class="p">(</span><span class="n">Document</span><span class="p">)</span>
+</pre></div>
+
+
+<p>session.getObject(session.createObjectId(objectId));
+    }</p>
+<p><a name="OpenCMISCookbook-GettingCMISextensions"></a></p>
+<h3 id="getting_cmis_extensions">Getting CMIS extensions</h3>
+<p><em>(since OpenCMIS 0.2.0)</em>
+The CMIS specification allows to add extensions at several points in CMIS
+data structures (object, properties, allowable actions, ACLs, policies,
+etc.).
+These extensions are XML fragments for the AtomPub and the Web Services
+binding. (It will be something simpler for the upcoming JSON binding.)
+Think of it as a tree structure with named node and leafs. Only the leafs
+can have a value.</p>
+<p>{code:java}
+// get an object from somewhere
+CmisObject object = ...</p>
+<p>// extensions can be attached to different levels
+// in this example we get the extensions on the properties level
+List<CmisExtensionElement> extensions =
+object.getExtensions(ExtensionLevel.PROPERTIES);</p>
+<p>if(extensions == null) {
+   // this object has no extensions on this level
+   return;
+}</p>
+<p>// iterate through the extensions until we find the one we are looking for
+for(CmisExtensionElement ext: extensions) {</p>
+<p>if("myExtension".equals(ext.getName()) {</p>
+<div class="codehilite"><pre> <span class="sr">//</span> <span class="n">found</span> <span class="n">it</span><span class="p">,</span> <span class="n">now</span> <span class="k">print</span> <span class="n">the</span> <span class="nb">values</span> <span class="n">of</span> <span class="n">the</span> <span class="n">children</span>     
+ <span class="k">for</span><span class="p">(</span><span class="n">CmisExtensionElement</span> <span class="n">child:</span> <span class="n">ext</span><span class="o">.</span><span class="n">getChildren</span><span class="p">())</span> <span class="p">{</span>
+<span class="n">System</span><span class="o">.</span><span class="n">out</span><span class="o">.</span><span class="n">println</span><span class="p">(</span><span class="n">child</span><span class="o">.</span><span class="n">getName</span><span class="p">()</span> <span class="o">+</span> <span class="s">&quot;: &quot;</span> <span class="o">+</span> <span class="n">child</span><span class="o">.</span><span class="n">getValue</span><span class="p">());</span>
+ <span class="p">}</span>
+</pre></div>
+
+
+<p>}</p>
+<p>}</p>
+<div class="codehilite"><pre><span class="n">h3</span><span class="o">.</span> <span class="n">Connecting</span> <span class="n">from</span> <span class="n">a</span> <span class="o">.</span><span class="n">Net</span> <span class="n">client</span> <span class="n">via</span> <span class="n">the</span> <span class="n">Web</span> <span class="n">Services</span> <span class="n">binding</span>
+
+<span class="n">This</span> <span class="n">is</span> <span class="n">a</span> <span class="n">very</span> <span class="n">simple</span> <span class="n">C</span><span class="c1"># example that demonstrates how to connect to an</span>
+</pre></div>
+
+
+<p>OpenCMIS server via the Web Services binding. Please note that .Net only
+allows UsernameTokens over HTTPS.</p>
+<p>using System;
+using System.ServiceModel;
+using OpenCMISClient.OpenCMISServer;
+using System.Net;</p>
+<p>namespace OpenCMISClient
+{
+    class CMISClientDemo
+    {
+    public void DoStuff()
+    {
+        try
+        {
+        // uncomment the next line if you are using a self signed
+SSL certificate 
+        // ServicePointManager.ServerCertificateValidationCallback
+= delegate { return true; };</p>
+<div class="codehilite"><pre>    <span class="sr">//</span> <span class="n">get</span> <span class="n">hold</span> <span class="n">of</span> <span class="n">the</span> <span class="n">services</span>
+    <span class="n">RepositoryServicePortClient</span> <span class="n">repService</span> <span class="o">=</span>
+</pre></div>
+
+
+<p>GetRepositoryService("https://localhost:8443/opencmis/services/RepositoryService?wsdl",
+"test", "test");
+        NavigationServicePortClient navService =
+GetNavigationService("https://localhost:8443/opencmis/services/NavigationService?wsdl",
+"test", "test");
+        ObjectServicePortClient objService =
+GetObjectService("https://localhost:8443/opencmis/services/ObjectService?wsdl",
+"test", "test");</p>
+<div class="codehilite"><pre>    <span class="sr">//</span> <span class="n">get</span> <span class="n">the</span> <span class="n">list</span> <span class="n">of</span> <span class="n">repositories</span>
+            <span class="n">cmisRepositoryEntryType</span><span class="o">[]</span><span class="p">(</span><span class="o">.</span><span class="n">html</span><span class="p">)</span>
+</pre></div>
+
+
+<p>repositoryEntries = repService.getRepositories(null);
+        foreach (cmisRepositoryEntryType repositoryEntry in
+repositoryEntries)
+        {
+            Console.WriteLine("Repository: " +
+repositoryEntry.repositoryName + " (" + repositoryEntry.repositoryId +
+")");</p>
+<div class="codehilite"><pre>        <span class="sr">//</span> <span class="n">get</span> <span class="n">repository</span> <span class="n">info</span>
+        <span class="n">cmisRepositoryInfoType</span> <span class="n">repositoryInfo</span> <span class="o">=</span>
+</pre></div>
+
+
+<p>repService.getRepositoryInfo(repositoryEntry.repositoryId, null);
+            Console.WriteLine("  Info:");
+            Console.WriteLine("    Description: " +
+repositoryInfo.repositoryDescription);
+            Console.WriteLine("    Product: " +
+repositoryInfo.vendorName + " / " + repositoryInfo.productName + " " +
+repositoryInfo.productVersion);</p>
+<div class="codehilite"><pre>        <span class="sr">//</span> <span class="n">get</span> <span class="n">all</span> <span class="n">base</span> <span class="n">types</span> <span class="n">of</span> <span class="n">the</span> <span class="n">repository</span>
+        <span class="n">cmisTypeDefinitionListType</span> <span class="n">typeList</span> <span class="o">=</span>
+</pre></div>
+
+
+<p>repService.getTypeChildren(repositoryInfo.repositoryId, null, true, null,
+null, null);
+            Console.WriteLine("  Types:");
+            foreach (cmisTypeDefinitionType type in typeList.types)
+            {
+            Console.WriteLine("    " + type.displayName + " ("
++ type.id + ")");
+            }</p>
+<div class="codehilite"><pre>        <span class="sr">//</span> <span class="n">get</span> <span class="n">all</span> <span class="n">root</span> <span class="n">folder</span> <span class="n">children</span>
+        <span class="n">cmisObjectInFolderListType</span> <span class="n">children</span> <span class="o">=</span>
+</pre></div>
+
+
+<p>navService.getChildren(repositoryInfo.repositoryId,
+repositoryInfo.rootFolderId, null, null, true, null, null, false, null,
+null, null);
+            Console.WriteLine("  Root folder:");
+            foreach (cmisObjectInFolderType objInFolder in
+children.objects)
+            {
+            cmisObjectType obj = objInFolder.@object;
+            String objId = GetIdPropertyValue(obj.properties,
+"cmis:objectId");
+            Console.WriteLine("    Name: " +
+GetStringPropertyValue(obj.properties, "cmis:name") + " (" + objId + ")");
+            Console.WriteLine("  Type:      " +
+GetIdPropertyValue(obj.properties, "cmis:baseTypeId"));
+            Console.WriteLine("  Created by:    " +
+GetStringPropertyValue(obj.properties, "cmis:createdBy"));
+            Console.WriteLine("  Creation date: " +
+GetDateTimePropertyValue(obj.properties, "cmis:creationDate"));</p>
+<div class="codehilite"><pre>        <span class="sr">//</span> <span class="k">if</span> <span class="n">it</span> <span class="n">is</span> <span class="n">a</span> <span class="n">document</span><span class="p">,</span> <span class="n">get</span> <span class="n">the</span> <span class="n">size</span> <span class="ow">and</span> <span class="n">the</span>
+</pre></div>
+
+
+<p>content
+            String baseType =
+GetIdPropertyValue(obj.properties, "cmis:baseTypeId");
+            if ("cmis:document".Equals(baseType))
+            {
+                // get the size
+                Int64? size =
+GetIntegerPropertyValue(obj.properties, "cmis:contentStreamLength");
+                Console.WriteLine("      Size:      " +
+size);</p>
+<div class="codehilite"><pre>            <span class="sr">//</span> <span class="n">get</span> <span class="n">the</span> <span class="n">content</span>
+            <span class="n">cmisContentStreamType</span> <span class="n">content</span> <span class="o">=</span>
+</pre></div>
+
+
+<p>objService.getContentStream(repositoryInfo.repositoryId, objId, null, null,
+null, null);
+                Console.WriteLine("      MIME type:     " +
+content.mimeType);</p>
+<div class="codehilite"><pre>            <span class="sr">//</span> <span class="n">get</span> <span class="n">the</span> <span class="s">&quot;stream&quot;</span>
+                        <span class="n">byte</span><span class="o">[]</span><span class="p">(</span><span class="o">.</span><span class="n">html</span><span class="p">)</span>
+</pre></div>
+
+
+<p>bytes = content.stream; // really streaming requires some more work
+                Console.WriteLine("      Stream:        " +
+(bytes.Length == size ? "ok" : "mismatch"));
+            }
+            }</p>
+<div class="codehilite"><pre>    <span class="p">}</span>
+    <span class="p">}</span>
+    <span class="n">catch</span> <span class="p">(</span><span class="n">FaultException</span><span class="sr">&lt;cmisFaultType&gt;</span> <span class="n">fe</span><span class="p">)</span>
+    <span class="p">{</span>
+    <span class="n">Console</span><span class="o">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">&quot;CMIS Exception: &quot;</span> <span class="o">+</span> <span class="n">fe</span><span class="o">.</span><span class="n">Detail</span><span class="o">.</span><span class="n">message</span><span class="p">);</span>
+    <span class="n">Console</span><span class="o">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">&quot;Type: &quot;</span> <span class="o">+</span> <span class="n">fe</span><span class="o">.</span><span class="n">Detail</span><span class="o">.</span><span class="n">type</span><span class="p">);</span>
+    <span class="n">Console</span><span class="o">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">&quot;Code: &quot;</span> <span class="o">+</span> <span class="n">fe</span><span class="o">.</span><span class="n">Detail</span><span class="o">.</span><span class="n">code</span><span class="p">);</span>
+    <span class="p">}</span>
+    <span class="n">catch</span> <span class="p">(</span><span class="n">Exception</span> <span class="n">e</span><span class="p">)</span>
+    <span class="p">{</span>
+    <span class="n">Console</span><span class="o">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">&quot;Exception: &quot;</span> <span class="o">+</span> <span class="n">e</span><span class="o">.</span><span class="n">Message</span><span class="p">);</span>
+    <span class="n">Console</span><span class="o">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">StackTrace</span><span class="p">);</span>
+    <span class="p">}</span>
+
+    <span class="n">Console</span><span class="o">.</span><span class="n">ReadKey</span><span class="p">();</span>
+<span class="p">}</span>
+
+<span class="n">public</span> <span class="n">RepositoryServicePortClient</span> <span class="n">GetRepositoryService</span><span class="p">(</span><span class="n">String</span>
+</pre></div>
+
+
+<p>wsdlUrl, String user, String password)
+    {
+        BasicHttpBinding binding = new BasicHttpBinding();
+        binding.MessageEncoding = WSMessageEncoding.Mtom;
+        binding.Security.Mode =
+BasicHttpSecurityMode.TransportWithMessageCredential;</p>
+<div class="codehilite"><pre>    <span class="n">RepositoryServicePortClient</span> <span class="n">service</span> <span class="o">=</span> <span class="k">new</span>
+</pre></div>
+
+
+<p>RepositoryServicePortClient(binding, new EndpointAddress(wsdlUrl));</p>
+<div class="codehilite"><pre>    <span class="n">service</span><span class="o">.</span><span class="n">ClientCredentials</span><span class="o">.</span><span class="n">UserName</span><span class="o">.</span><span class="n">UserName</span> <span class="o">=</span> <span class="n">user</span><span class="p">;</span>
+    <span class="n">service</span><span class="o">.</span><span class="n">ClientCredentials</span><span class="o">.</span><span class="n">UserName</span><span class="o">.</span><span class="n">Password</span> <span class="o">=</span> <span class="n">password</span><span class="p">;</span>
+
+    <span class="k">return</span> <span class="n">service</span><span class="p">;</span>
+<span class="p">}</span>
+
+<span class="n">public</span> <span class="n">NavigationServicePortClient</span> <span class="n">GetNavigationService</span><span class="p">(</span><span class="n">String</span>
+</pre></div>
+
+
+<p>wsdlUrl, String user, String password)
+    {
+        BasicHttpBinding binding = new BasicHttpBinding();
+        binding.MessageEncoding = WSMessageEncoding.Mtom;
+        binding.Security.Mode =
+BasicHttpSecurityMode.TransportWithMessageCredential;</p>
+<div class="codehilite"><pre>    <span class="n">NavigationServicePortClient</span> <span class="n">service</span> <span class="o">=</span> <span class="k">new</span>
+</pre></div>
+
+
+<p>NavigationServicePortClient(binding, new EndpointAddress(wsdlUrl));</p>
+<div class="codehilite"><pre>    <span class="n">service</span><span class="o">.</span><span class="n">ClientCredentials</span><span class="o">.</span><span class="n">UserName</span><span class="o">.</span><span class="n">UserName</span> <span class="o">=</span> <span class="n">user</span><span class="p">;</span>
+    <span class="n">service</span><span class="o">.</span><span class="n">ClientCredentials</span><span class="o">.</span><span class="n">UserName</span><span class="o">.</span><span class="n">Password</span> <span class="o">=</span> <span class="n">password</span><span class="p">;</span>
+
+    <span class="k">return</span> <span class="n">service</span><span class="p">;</span>
+<span class="p">}</span>
+
+<span class="n">public</span> <span class="n">ObjectServicePortClient</span> <span class="n">GetObjectService</span><span class="p">(</span><span class="n">String</span> <span class="n">wsdlUrl</span><span class="p">,</span>
+</pre></div>
+
+
+<p>String user, String password)
+    {
+        BasicHttpBinding binding = new BasicHttpBinding();
+        binding.MessageEncoding = WSMessageEncoding.Mtom;
+        binding.Security.Mode =
+BasicHttpSecurityMode.TransportWithMessageCredential;
+        binding.TransferMode = TransferMode.Streamed;</p>
+<div class="codehilite"><pre>    <span class="n">ObjectServicePortClient</span> <span class="n">service</span> <span class="o">=</span> <span class="k">new</span>
+</pre></div>
+
+
+<p>ObjectServicePortClient(binding, new EndpointAddress(wsdlUrl));</p>
+<div class="codehilite"><pre>    <span class="n">service</span><span class="o">.</span><span class="n">ClientCredentials</span><span class="o">.</span><span class="n">UserName</span><span class="o">.</span><span class="n">UserName</span> <span class="o">=</span> <span class="n">user</span><span class="p">;</span>
+    <span class="n">service</span><span class="o">.</span><span class="n">ClientCredentials</span><span class="o">.</span><span class="n">UserName</span><span class="o">.</span><span class="n">Password</span> <span class="o">=</span> <span class="n">password</span><span class="p">;</span>
+
+    <span class="k">return</span> <span class="n">service</span><span class="p">;</span>
+<span class="p">}</span>
+
+<span class="n">public</span> <span class="n">String</span> <span class="n">GetStringPropertyValue</span><span class="p">(</span><span class="n">cmisPropertiesType</span> <span class="n">properties</span><span class="p">,</span>
+</pre></div>
+
+
+<p>String id)
+    {
+        String result = null;</p>
+<div class="codehilite"><pre>    <span class="k">foreach</span> <span class="p">(</span><span class="n">cmisProperty</span> <span class="n">property</span> <span class="n">in</span> <span class="n">properties</span><span class="o">.</span><span class="n">Items</span><span class="p">)</span>
+    <span class="p">{</span>
+    <span class="k">if</span> <span class="p">(</span><span class="n">property</span><span class="o">.</span><span class="n">propertyDefinitionId</span><span class="o">.</span><span class="n">Equals</span><span class="p">(</span><span class="n">id</span><span class="p">))</span>
+    <span class="p">{</span>
+        <span class="k">if</span> <span class="p">(</span><span class="n">property</span> <span class="n">is</span> <span class="n">cmisPropertyString</span><span class="p">)</span>
+        <span class="p">{</span>
+                    <span class="n">result</span> <span class="o">=</span> <span class="p">((</span><span class="n">cmisPropertyString</span><span class="p">)</span><span class="n">property</span><span class="p">)</span><span class="o">.</span><span class="n">value</span><span class="p">[</span><span class="mi">0</span><span class="p">](</span><span class="mi">0</span><span class="o">.</span><span class="n">html</span><span class="p">)</span>
+</pre></div>
+
+
+<p>;
+            }
+            break;
+        }
+        }</p>
+<div class="codehilite"><pre>    <span class="k">return</span> <span class="n">result</span><span class="p">;</span>
+<span class="p">}</span>
+
+<span class="n">public</span> <span class="n">String</span> <span class="n">GetIdPropertyValue</span><span class="p">(</span><span class="n">cmisPropertiesType</span> <span class="n">properties</span><span class="p">,</span>
+</pre></div>
+
+
+<p>String id)
+    {
+        String result = null;</p>
+<div class="codehilite"><pre>    <span class="k">foreach</span> <span class="p">(</span><span class="n">cmisProperty</span> <span class="n">property</span> <span class="n">in</span> <span class="n">properties</span><span class="o">.</span><span class="n">Items</span><span class="p">)</span>
+    <span class="p">{</span>
+    <span class="k">if</span> <span class="p">(</span><span class="n">property</span><span class="o">.</span><span class="n">propertyDefinitionId</span><span class="o">.</span><span class="n">Equals</span><span class="p">(</span><span class="n">id</span><span class="p">))</span>
+    <span class="p">{</span>
+        <span class="k">if</span> <span class="p">(</span><span class="n">property</span> <span class="n">is</span> <span class="n">cmisPropertyId</span><span class="p">)</span>
+        <span class="p">{</span>
+                    <span class="n">result</span> <span class="o">=</span> <span class="p">((</span><span class="n">cmisPropertyId</span><span class="p">)</span><span class="n">property</span><span class="p">)</span><span class="o">.</span><span class="n">value</span><span class="p">[</span><span class="mi">0</span><span class="p">](</span><span class="mi">0</span><span class="o">.</span><span class="n">html</span><span class="p">)</span>
+</pre></div>
+
+
+<p>;
+            }
+            break;
+        }
+        }</p>
+<div class="codehilite"><pre>    <span class="k">return</span> <span class="n">result</span><span class="p">;</span>
+<span class="p">}</span>
+
+<span class="n">public</span> <span class="n">Int64</span><span class="p">?</span> <span class="n">GetIntegerPropertyValue</span><span class="p">(</span><span class="n">cmisPropertiesType</span>
+</pre></div>
+
+
+<p>properties, String id)
+    {
+        Int64? result = null;</p>
+<div class="codehilite"><pre>    <span class="k">foreach</span> <span class="p">(</span><span class="n">cmisProperty</span> <span class="n">property</span> <span class="n">in</span> <span class="n">properties</span><span class="o">.</span><span class="n">Items</span><span class="p">)</span>
+    <span class="p">{</span>
+    <span class="k">if</span> <span class="p">(</span><span class="n">property</span><span class="o">.</span><span class="n">propertyDefinitionId</span><span class="o">.</span><span class="n">Equals</span><span class="p">(</span><span class="n">id</span><span class="p">))</span>
+    <span class="p">{</span>
+        <span class="k">if</span> <span class="p">(</span><span class="n">property</span> <span class="n">is</span> <span class="n">cmisPropertyInteger</span><span class="p">)</span>
+        <span class="p">{</span>
+                    <span class="n">result</span> <span class="o">=</span> <span class="n">Int64</span><span class="o">.</span><span class="n">Parse</span><span class="p">(((</span><span class="n">cmisPropertyInteger</span><span class="p">)</span><span class="n">property</span><span class="p">)</span><span class="o">.</span><span class="n">value</span><span class="p">[</span><span class="mi">0</span><span class="p">](</span><span class="mi">0</span><span class="o">.</span><span class="n">html</span><span class="p">)</span>
+</pre></div>
+
+
+<p>);
+            }
+            break;
+        }
+        }</p>
+<div class="codehilite"><pre>    <span class="k">return</span> <span class="n">result</span><span class="p">;</span>
+<span class="p">}</span>
+
+<span class="n">public</span> <span class="n">DateTime</span><span class="p">?</span> <span class="n">GetDateTimePropertyValue</span><span class="p">(</span><span class="n">cmisPropertiesType</span>
+</pre></div>
+
+
+<p>properties, String id)
+    {
+        DateTime? result = null;</p>
+<div class="codehilite"><pre>    <span class="k">foreach</span> <span class="p">(</span><span class="n">cmisProperty</span> <span class="n">property</span> <span class="n">in</span> <span class="n">properties</span><span class="o">.</span><span class="n">Items</span><span class="p">)</span>
+    <span class="p">{</span>
+    <span class="k">if</span> <span class="p">(</span><span class="n">property</span><span class="o">.</span><span class="n">propertyDefinitionId</span><span class="o">.</span><span class="n">Equals</span><span class="p">(</span><span class="n">id</span><span class="p">))</span>
+    <span class="p">{</span>
+        <span class="k">if</span> <span class="p">(</span><span class="n">property</span> <span class="n">is</span> <span class="n">cmisPropertyDateTime</span><span class="p">)</span>
+        <span class="p">{</span>
+                    <span class="n">result</span> <span class="o">=</span> <span class="p">((</span><span class="n">cmisPropertyDateTime</span><span class="p">)</span><span class="n">property</span><span class="p">)</span><span class="o">.</span><span class="n">value</span><span class="p">[</span><span class="mi">0</span><span class="p">](</span><span class="mi">0</span><span class="o">.</span><span class="n">html</span><span class="p">)</span>
+</pre></div>
+
+
+<p>;
+            }
+            break;
+        }
+        }</p>
+<div class="codehilite"><pre>    <span class="k">return</span> <span class="n">result</span><span class="p">;</span>
+<span class="p">}</span>
+<span class="p">}</span>
+</pre></div>
+
+
+<p>}</p>
+<div class="codehilite"><pre><span class="n">h3</span><span class="o">.</span> <span class="n">Reading</span> <span class="n">metadata</span> <span class="ow">and</span> <span class="n">content</span> <span class="n">from</span> <span class="n">a</span> <span class="n">CMIS</span> <span class="n">repository</span>
+
+<span class="n">TODO</span>
+
+<span class="n">h3</span><span class="o">.</span> <span class="n">Creating</span> <span class="ow">and</span> <span class="n">updating</span> <span class="n">CMIS</span> <span class="n">objects</span>
+
+<span class="n">TODO</span>
+
+<span class="n">h3</span><span class="o">.</span> <span class="n">Using</span> <span class="n">the</span> <span class="n">query</span> <span class="n">parser</span>
+
+<span class="n">TODO</span>
+
+<span class="n">h2</span><span class="o">.</span> <span class="n">CMIS</span> <span class="n">Server</span>
+
+<span class="n">h3</span><span class="o">.</span> <span class="n">Adding</span> <span class="n">CMIS</span> <span class="n">extensions</span>
+
+<span class="n">_</span><span class="p">(</span><span class="n">since</span> <span class="n">OpenCMIS</span> <span class="mf">0.2.0</span><span class="p">)</span><span class="n">_</span>
+<span class="p">{</span><span class="n">code:java</span><span class="p">}</span>
+<span class="sr">//</span> <span class="n">we</span> <span class="n">want</span> <span class="n">to</span> <span class="n">attach</span> <span class="n">an</span> <span class="n">extension</span> <span class="n">to</span> <span class="n">an</span> <span class="n">object</span>
+<span class="n">ObjectData</span> <span class="n">object</span> <span class="o">=</span> <span class="o">...</span>
+
+<span class="sr">//</span> <span class="n">some</span> <span class="n">dummy</span> <span class="n">data</span>
+<span class="n">String</span> <span class="n">typeId</span> <span class="o">=</span> <span class="s">&quot;MyType&quot;</span><span class="p">;</span>
+<span class="n">String</span> <span class="n">objectId</span> <span class="o">=</span> <span class="s">&quot;1111-2222-3333&quot;</span><span class="p">;</span>
+<span class="n">String</span> <span class="n">name</span> <span class="o">=</span> <span class="s">&quot;MyDocument&quot;</span><span class="p">;</span>
+
+<span class="sr">//</span> <span class="n">find</span> <span class="n">a</span> <span class="n">namespace</span> <span class="k">for</span> <span class="n">the</span> <span class="n">extensions</span> <span class="n">that</span> <span class="n">is</span> <span class="n">different</span> <span class="n">from</span> <span class="n">the</span> <span class="n">CMIS</span>
+</pre></div>
+
+
+<p>namespaces
+    String ns = "http://apache.org/opencmis/example";</p>
+<div class="codehilite"><pre><span class="sr">//</span> <span class="n">create</span> <span class="n">a</span> <span class="n">list</span> <span class="k">for</span> <span class="n">the</span> <span class="n">first</span> <span class="n">level</span> <span class="n">of</span> <span class="k">our</span> <span class="n">extension</span>
+<span class="n">List</span><span class="sr">&lt;CmisExtensionElement&gt;</span> <span class="n">extElements</span> <span class="o">=</span> <span class="k">new</span>
+</pre></div>
+
+
+<p>ArrayList<CmisExtensionElement>();</p>
+<div class="codehilite"><pre><span class="sr">//</span> <span class="n">set</span> <span class="n">up</span> <span class="n">an</span> <span class="n">attribute</span> <span class="p">(</span><span class="n">Avoid</span> <span class="n">attributes</span><span class="o">!</span> <span class="n">They</span> <span class="n">will</span> <span class="ow">not</span> <span class="n">work</span> <span class="n">with</span> <span class="n">the</span> <span class="n">JSON</span>
+</pre></div>
+
+
+<p>binding!)
+    Map<String, String> attr = new HashMap<String, String>();
+    attr.put("type", typeId);</p>
+<div class="codehilite"><pre><span class="sr">//</span> <span class="n">add</span> <span class="n">two</span> <span class="n">leafs</span> <span class="n">to</span> <span class="n">the</span> <span class="n">extension</span>
+<span class="n">extElements</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="k">new</span> <span class="n">CmisExtensionElementImpl</span><span class="p">(</span><span class="n">ns</span><span class="p">,</span> <span class="s">&quot;objectId&quot;</span><span class="p">,</span> <span class="n">attr</span><span class="p">,</span>
+</pre></div>
+
+
+<p>objectId));
+    extElements.add(new CmisExtensionElementImpl(ns, "name", null, name));</p>
+<div class="codehilite"><pre><span class="sr">//</span> <span class="n">set</span> <span class="n">the</span> <span class="n">extension</span> <span class="n">list</span>
+<span class="n">List</span><span class="sr">&lt;CmisExtensionElement&gt;</span> <span class="n">extensions</span> <span class="o">=</span> <span class="k">new</span>
+</pre></div>
+
+
+<p>ArrayList<CmisExtensionElement>();
+    extensions.add(new CmisExtensionElementImpl(ns, "exampleExtension", null,
+extElements));
+    object.setExtensions(extensions);</p>
+<p>This should create something like that:</p>
+<div class="codehilite"><pre><span class="o">&lt;</span><span class="n">exampleExtension:exampleExtension</span>
+</pre></div>
+
+
+<p>xmlns="http://apache.org/opencmis/example"
+xmlns:exampleExtension="http://apache.org/opencmis/example"&gt;
+        <objectId type="MyType">1111-2222-3333</objectId>
+        <name>MyDocument</name>
+    </exampleExtension:exampleExtension></p>
+<p><a name="OpenCMISCookbook-UsingtheserverframeworkwithSpring"></a></p>
+<h3 id="using_the_server_framework_with_spring">Using the server framework with Spring</h3>
+<p>By default, the OpenCMIS services factory is set up by a context listner
+configured in the web.xml. If you want or need Spring to set up the
+services factory, remove the context listner from the web.xml and use a
+bean like this instead:</p>
+<p>{code:java}
+public class CmisLifecycleBean implements ServletContextAware,
+InitializingBean, DisposableBean
+{
+    private ServletContext servletContext;
+    private CmisServiceFactory factory;</p>
+<div class="codehilite"><pre><span class="nv">@Override</span>
+<span class="n">public</span> <span class="n">void</span> <span class="n">setServletContext</span><span class="p">(</span><span class="n">ServletContext</span> <span class="n">servletContext</span><span class="p">)</span>
+<span class="p">{</span>
+<span class="n">this</span><span class="o">.</span><span class="n">servletContext</span> <span class="o">=</span> <span class="n">servletContext</span><span class="p">;</span>
+<span class="p">}</span>
+
+<span class="n">public</span> <span class="n">void</span> <span class="n">setCmisServiceFactory</span><span class="p">(</span><span class="n">CmisServiceFactory</span> <span class="n">factory</span><span class="p">)</span>
+<span class="p">{</span>
+<span class="n">this</span><span class="o">.</span><span class="n">factory</span> <span class="o">=</span> <span class="n">factory</span><span class="p">;</span>
+<span class="p">}</span>
+
+<span class="nv">@Override</span>
+<span class="n">public</span> <span class="n">void</span> <span class="n">afterPropertiesSet</span><span class="p">()</span> <span class="n">throws</span> <span class="n">Exception</span>
+<span class="p">{</span>
+<span class="k">if</span> <span class="p">(</span><span class="n">factory</span> <span class="o">!=</span> <span class="n">null</span><span class="p">)</span>
+<span class="p">{</span>
+    <span class="n">factory</span><span class="o">.</span><span class="n">init</span><span class="p">(</span><span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="p">,</span> <span class="n">String</span><span class="o">&gt;</span><span class="p">());</span>
+</pre></div>
+
+
+<p>servletContext.setAttribute(CmisRepositoryContextListener.SERVICES_FACTORY,
+factory);
+    }
+    }</p>
+<div class="codehilite"><pre><span class="nv">@Override</span>
+<span class="n">public</span> <span class="n">void</span> <span class="n">destroy</span><span class="p">()</span> <span class="n">throws</span> <span class="n">Exception</span>
+<span class="p">{</span>
+<span class="k">if</span> <span class="p">(</span><span class="n">factory</span> <span class="o">!=</span> <span class="n">null</span><span class="p">)</span>
+<span class="p">{</span>
+    <span class="n">factory</span><span class="o">.</span><span class="n">destroy</span><span class="p">();</span>
+<span class="p">}</span>
+<span class="p">}</span>
+</pre></div>
+
+
+<p>}</p>
+<div class="codehilite"><pre><span class="n">The</span> <span class="n">Spring</span> <span class="n">configuration</span> <span class="n">could</span> <span class="n">look</span> <span class="n">like</span> <span class="n">this:</span>
+
+<span class="p">{</span><span class="n">code:xml</span><span class="p">}</span>
+<span class="o">&lt;</span><span class="n">bean</span> <span class="n">id</span><span class="o">=</span><span class="s">&quot;CmisLifecycleBean&quot;</span>
+</pre></div>
+
+
+<p>class="org.example.mycmisservice.CmisLifecycleBean"&gt;
+        <property name="cmisServiceFactory" ref="CmisServiceFactory" />
+    </bean></p>
+<div class="codehilite"><pre><span class="o">&lt;</span><span class="n">bean</span> <span class="n">id</span><span class="o">=</span><span class="s">&quot;CmisServiceFactory&quot;</span>
+</pre></div>
+
+
+<p>class="org.example.mycmisservice.MyCmisServiceFactory"&gt;
+    </bean></p></div>
+             <!-- Content -->
+           </td>
+          </tr>
+        </table>
+     </td>
+     <td id="cell-2-2">&nbsp;</td>
+    </tr>
+    <tr width="100%">
+      <td id="cell-3-0">&nbsp;</td>
+      <td id="cell-3-1">&nbsp;</td>
+      <td id="cell-3-2">&nbsp;</td>
+    </tr>
+    <tr width="100%">
+     <td id="cell-3-0">&nbsp;</td>
+     <td id="cell-3-1">
+       <div id="footer">
+       <!-- Footer -->
+       <div id="site-footer">
+          
+          Apache Chemistry, Apache, the Apache feather logo, and the Apache 
+          Chemistry project logo are trademarks of The Apache Software 
+          Foundation.
+          <BR />
+          Content Management Interoperability Services (CMIS) is an
+          <a href="http://www.oasis-open.org/committees/cmis/">OASIS</a>
+          specification.
+          
+       </div>
+       <!-- Footer -->
+       </div>
+     </td>
+     <td id="cell-3-2">&nbsp;</td>
+    </tr>
+    <tr width="100%">
+      <td id="cell-4-0">&nbsp;</td>
+      <td id="cell-4-1">&nbsp;</td>
+      <td id="cell-4-2">&nbsp;</td>
+    </tr>
+  </table>
+</body>
+</html>



Mime
View raw message