chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1138920 - /chemistry/site/trunk/content/java/developing/guide.mdtext
Date Thu, 23 Jun 2011 15:12:48 GMT
Author: fmui
Date: Thu Jun 23 15:12:48 2011
New Revision: 1138920

URL: http://svn.apache.org/viewvc?rev=1138920&view=rev
Log:
OpenCMIS guide update

Modified:
    chemistry/site/trunk/content/java/developing/guide.mdtext

Modified: chemistry/site/trunk/content/java/developing/guide.mdtext
URL: http://svn.apache.org/viewvc/chemistry/site/trunk/content/java/developing/guide.mdtext?rev=1138920&r1=1138919&r2=1138920&view=diff
==============================================================================
--- chemistry/site/trunk/content/java/developing/guide.mdtext (original)
+++ chemistry/site/trunk/content/java/developing/guide.mdtext Thu Jun 23 15:12:48 2011
@@ -18,7 +18,7 @@ Notice:    Licensed to the Apache Softwa
 
 #OpenCMIS Client API Developer's Guide
 ##Audience
-This guide is for software engineers who want to use the Apache Chemistry OpenCMIS client
to access CMIS-complaint
+This guide is for software engineers who want to use the Apache Chemistry OpenCMIS client
to access CMIS-compliant
 content repositories from java code. The examples included in the guide assume the code is
running in
 a standalone Java application, but the OpenCMIS client can be used by on any Java platform,

 such as Web applications and phone apps.
@@ -34,7 +34,7 @@ The guide is divided into 5 parts :-
 ###Assumptions
 The guide assumes you are using the Eclipse IDE for code development, and have Maven and
SVN installed.
 
-* You can download and install Eclipse [here](http://eclipse.org/downloads.html).
+* You can download and install Eclipse [here](http://www.eclipse.org/downloads.html).
 * You can download and install Maven [here](http://maven.apache.org/download.html).
 * You can download and install SVN for your platform [here](http://subversion.apache.org/packages.html).
 
@@ -42,7 +42,7 @@ The guide assumes you are using the Ecli
 This section gives a high-level overview of the OpenCMIS library, and introduces a supplied
"Hello World" sample to
 get an OpenCMIS client up and running against a repository and accessing CMIS objects.
 ###What is OpenCMIS?
-CMIS (Content Management Interoperability Services) is vendor-neutral [OASIS Web services
interface specification](http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=cmis)

+CMIS (Content Management Interoperability Services) is a vendor-neutral [OASIS Web services
interface specification](http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=cmis)

 that enables interoperability between Enterprise Content Management (ECM) systems. 
 CMIS allows rich information to be shared across Internet protocols in vendor-neutral formats,

 among document systems, publishers and repositories, in a single enterprise and between companies.
@@ -83,7 +83,7 @@ CMIS services are provided for the disco
 folders and documents are the main objects you will be concerned with for the first 2 parts
of this document.
 ####CMIS Services
 The CMIS specification describes a set of services that act on repositories. The OpenCMIS
client API uses these services, but by using a client binding,
-presents the user of the API simple set of classes rather than the services described by
CMIS. If you want to access a CMIS repository at the service level, you can do that
+presents the user of the API a simple set of classes rather than the services described by
CMIS. If you want to access a CMIS repository at the service level, you can do that
 by using the [OpenCMIS client bindings layer](http://chemistry.apache.org/java/developing/client/dev-client-bindings.html)
directly.
 The CMIS services are:-
 
@@ -100,26 +100,28 @@ The CMIS services are:-
 
 ####CMIS Bindings
 How does an OpenCMIS client communicate over the wire with a CMIS service endpoint? A CMIS
repository can communicate over two protocols,
-SOAP and [AtomPub](http://tools.ietf.org/html/rfc5023), and provide  tow corresponding bindings,
a web services binding, and an AtomPub binding. A CMIS service endpoint will 
-provide a URL for both types of binding, and in an OpenCMIS you specify the binding type
when calling the `getRepositories()` method on 
-the `SessionFactory` object.
+SOAP and [AtomPub](http://tools.ietf.org/html/rfc5023), and provide two corresponding bindings,
a web services binding, and an AtomPub binding. A CMIS service endpoint will 
+provide a URL for both types of binding, and in OpenCMIS you specify the binding type when
calling the `getRepositories()` method on 
+the [`SessionFactory`](http://incubator.apache.org/chemistry/javadoc/org/apache/chemistry/opencmis/client/api/SessionFactory.html)
object.
 ####The OpenCMIS Workbench
 The workbench is a GUI repository browser that lets you quickly view the contents of a repository,
create documents and folders, look at metadata, and 
 perform queries. It's really useful for debugging your applications, and for quickly testing
out queries before you commit them to code. You can
-download the latest version [here](http://incubator.apache.org/chemistry/cmis-workbench.html).
The workbench is a Java Swing application, and comes 
+download the latest version [here](http://chemistry.apache.org/java/developing/tools/dev-tools-workbench.html).
The workbench is a Java Swing application, and comes 
 with both Windows and UNIX starter scripts.
 ###Hello World
 You can download, install, and test the Apache Chemistry client code using the `Hello World`
sample. On a command line, type the following command :-
-<p class="todo"> Need a full URL here</p>
 
+    :::text
     svn co https://svn.apache.org/repos/asf/chemistry/opencmis/trunk/chemistry-opencmis-samples/chemistry-opencmis-hello
 
 You can then build the sample and run the `org.apache.chemistry.opencmis.doc.Hello` sample
using maven, by typing the following command
 
+    :::text
     mvn clean install
 
 You will see some output towards the end of the build that looks similar to the following
lines:-
 
+    :::text
     org.apache.chemistry.opencmis.doc.Hello started
     Found repository: InMemory Repository
     Got a connection to repository: InMemory Repository, with id: A1
@@ -137,18 +139,20 @@ The simplest way to view the sample code
 
 1. Add the maven repository to your eclipse workspace classpath with the following command.
You only need to perform this step once.
 
-    `mvn eclipse:configure-workspace -Declipse.workspace=<path-to-your-eclipse-workspace>`
+        :::text
+        mvn eclipse:configure-workspace -Declipse.workspace=<path-to-your-eclipse-workspace>
     
 1. Create a an eclipse project from the code, and import it into your eclipse.
 Type the following command :-
 
-    `mvn eclipse:eclipse`
+        :::text
+        mvn eclipse:eclipse
 
 1. Import the project into eclipse:-
  
     1. click `File->Import` and choose `General->Existing projects into workspace`
in the 
     Import wizard.
-    1. Click `Next` and  browse to the folder you extracted the project to.
+    1. Click `Next` and  browse to the folder you checked out the project to.
     1. Click the checkbox next to `chemistry-opencmis-hello` project. The project will be
imported into your workspace.
 
 You can run the `main` method in the `Hello` class as a Java application.
@@ -159,12 +163,13 @@ OpenCMIS API in the next section.
 This section introduces the most commonly used parts of the OpenCMIS client API. The code
snippets are taken from the GettingStarted sample class supplied with Apache chemistry.
 ###Installing the getting started sample
 On a command line, type the following command :-
-<p class="todo"> Need a full URL here</p>
 
+    :::text
     svn co https://svn.apache.org/repos/asf/chemistry/opencmis/trunk/chemistry-opencmis-samples/chemistry-opencmis-getting-started
 
 You can then build the sample and run the `org.apache.chemistry.opencmis.doc.GettingStarted`
sample using maven, by typing the following command
 
+    :::text
     mvn clean install
     
 This will pull in any dependencies for the sample, build it, and run it against a public
repository.
@@ -172,13 +177,14 @@ This will pull in any dependencies for t
 The simplest way to work with the getting started sample is to use Maven to create an eclipse
project from the code, and import it into your eclipse.
 To create the eclipse project type the following command :-
 
+    :::text
     mvn eclipse:eclipse
 
 To import the project into eclipse:-
  
 1. click `File->Import` and choose `General->Existing projects into workspace` in the

 Import wizard.
-1. Click `Next` and  browse to the folder you extracted the project to.
+1. Click `Next` and  browse to the folder you checked out the project to.
 1. Click the checkbox next to `chemistry-opencmis-gettingstarted` project. The project will
be imported into your workspace.
 
 You can run the `main` method in the `GettingStarted` class as a Java application.
@@ -193,6 +199,7 @@ Note that:-
 1. This repository does not require credentials, but the code snippet sets a user id and
password to show how this is done
 1. The code uses the `ATOMPUB` binding for connection. 
 
+        :::java
         SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
         Map<String, String> parameter = new HashMap<String, String>();
         parameter.put(SessionParameter.USER, "admin");
@@ -202,9 +209,10 @@ Note that:-
         parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
         
 ####Connecting to a repository by id
-In a production environment, the client code will probably know the ID of the repository
that it wants to connnect to.
+In a production environment, the client code will probably know the ID of the repository
that it wants to connect to.
 The following code snippet shows how to connect to a repository using its ID.
 
+        :::java
         parameter.put(SessionParameter.REPOSITORY_ID, "A1");
         Session session = sessionFactory.createSession(parameter);
         
@@ -214,6 +222,7 @@ That's it. Any work you want to do again
 The CMIS specification allows a CMIS service endpoint to advertise one or more repositories,
so this code snippet retrieves a list of repositories. In this 
 case there the code chooses the first repository in list:-
 
+        :::java
         List<Repository> repositories = new ArrayList<Repository>();
         repositories = sessionFactory.getRepositories(parameter);
         for (Repository r : repositories) {
@@ -222,6 +231,7 @@ case there the code chooses the first re
         
 Now you can create your session with the first and only repository:-
 
+        :::java
         Repository repository = repositories.get(0);
         parameter.put(SessionParameter.REPOSITORY_ID, repository.getId());
         Session session = sessionFactory.createSession(parameter);
@@ -233,7 +243,7 @@ Now you can create your session with the
 That's it. Any work you want to do against the repository uses this session.
 
 ###Working with Folders and Documents
-Of the  for base objects described by the CMIS domain model, the most commonly used are the
folder and the document.
+Of the four base objects described by the CMIS domain model, the most commonly used are the
folder and the document.
 
 A folder is a container for other objects. Folders exist in a  hierarchical structure as
you would expect, but 
 a CMIS repository can optionally store objects in multiple folders, and an object can exist
but not be contained in a folder. 
@@ -242,9 +252,10 @@ capabilities.
 
 The Document is the only object that can have content, described by a content stream, and
has properties such as the author and modification date. 
 ####Finding the contents of the root folder
-Now you have a session you can start examining the repository. All CMIS repositories have
a root folder, which is the single top level folder in the heirarchy.
+Now you have a session you can start examining the repository. All CMIS repositories have
a root folder, which is the single top level folder in the hierarchy.
 To list the objects in the root folder of your repository you use the `getRootFolder()` method
on the session.
 
+        :::java
         Folder root = session.getRootFolder();
         ItemIterable<CmisObject> children = root.getChildren();
         System.out.println("Found the following objects in the root folder:-");
@@ -257,6 +268,7 @@ To create a folder, you use the  `create
 As with most CMIS methods, it takes a map of properties which define the Object to be created.
 In this code snippet a folder with the name `ADGNewFolder` is created in the root folder:-
 
+        :::java
         System.out.println("Creating 'ADGNewFolder' in the root folder");
         Map<String, String> newFolderProps = new HashMap<String, String>();
         newFolderProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
@@ -275,8 +287,10 @@ There are many other properties you can 
         
 ####Creating a a simple document object
 Document objects describe entities in the CMIS repository. A document object with content
-contains a content stream that is the actual file contents, and a mimetype for the content
stream. So, to create Document Object, first you need a content stream
+contains a content stream that is the actual file contents, and a mimetype for the content
stream. 
+So, to create a document Object, first you need a content stream
 
+         :::java
          final String textFileName = "test.txt";
          System.out.println("creating a simple text file, " + textFileName);
          String mimetype = "text/plain; charset=UTF-8";
@@ -296,6 +310,7 @@ contains a content stream that is the ac
 To add a document with some content to the repository, you use the `createDocument()` method
on the parent folder, and provide the content stream
 and a map of properties which define the object to be created.
 
+        :::java
         Map<String, Object> properties = new HashMap<String, Object>();
         properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
         properties.put(PropertyIds.NAME, filename);
@@ -305,28 +320,29 @@ Note the following points :-
          
 * The `createDocument()` method returns the Object ID of the newly created document object.

 * Each version of a document object has its own object ID.
-* You can create a document without an associated content stream.
+* You can create a document without an associated content stream, by passing null as the
contentStream Parameter.
 
 ####Reading the contents of a document object
 You can retrieve a CMIS object by path, or by using the object ID.
 
 The following code snippet retrieves the newly created object using the object ID:-
 
-        // Get the contents of the file
-        doc = (Document) session.getObject(id);
-        try {
-            content = getContentAsString(doc.getContentStream());
-        } catch (IOException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        }
+    :::java
+    // Get the contents of the file
+    doc = (Document) session.getObject(id);
+    try {
+        content = getContentAsString(doc.getContentStream());
+    } catch (IOException e) {
+        e.printStackTrace();
+    }
 
-        System.out.println("Contents of " + filename + " are: " + content);
-        
-        ...
+    System.out.println("Contents of " + filename + " are: " + content);
+    
+    ...
         
-     /**
-     * Helper method to get the 
+    /**
+     * Helper method to get the contents of a stream
+     * 
      * @param stream
      * @return
      * @throws IOException
@@ -348,64 +364,71 @@ The following code snippet retrieves the
 
 The following code snippet retrieves the newly created object using a path:-
 
-        String path = newFolder.getPath() + "/" + textFileName;
-        System.out.println("Getting object by path " + path);
-        doc = (Document) session.getObjectByPath(path);
-        try {
-            content = getContentAsString(doc.getContentStream());
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
+    :::java
+    String path = newFolder.getPath() + "/" + textFileName;
+    System.out.println("Getting object by path " + path);
+    doc = (Document) session.getObjectByPath(path);
+    try {
+        content = getContentAsString(doc.getContentStream());
+    } catch (IOException e) {
+        e.printStackTrace();
+    }
         
 Note the following points :-
 
 * All paths start with the root folder `/`. 
-* The `Document` class does not have a `getPath()` method, since multifiling means a document
can have more than one parent folder. It does implement the 
-`getPaths()` method from the `FileableCmisObject` interface. This returns a list of the current
paths to the document object. 
+* The [`Document`](http://incubator.apache.org/chemistry/javadoc/org/apache/chemistry/opencmis/client/api/Document.html)

+class does not have a `getPath()` method, since multifiling means a document can have more
than one parent folder. It does implement the 
+`getPaths()` method from the [`FileableCmisObject`](http://incubator.apache.org/chemistry/javadoc/org/apache/chemistry/opencmis/client/api/FileableCmisObject.html)
interface. 
+This returns a list of the current paths to the document object. 
 ####Updating a document.
-You can update the properties of a Document object, and you update the contents of the document
by overwriting the document's content stream with a new content stream.
+You can update the properties of a document object, and you update the contents of the document
by overwriting the document's content stream with a new content stream.
 Note that the object ID returned when updating a document is not guaranteed to remain the
same, some repository implementations return the same object ID, and some may not.
 
 The following code snippet updates the name property of the `test2.txt` document:-
 
-        Document doc2 = (Document) session.getObject(id2);        
-        System.out.println("renaming " + doc2.getName() + " to test3.txt");
-        properties = new HashMap<String, Object>();
-        properties.put(PropertyIds.NAME, "test3.txt");
-        id2 = doc2.updateProperties(properties);
-        System.out.println("renamed to " + doc2.getName());
+    :::java
+    Document doc2 = (Document) session.getObject(id2);        
+    System.out.println("renaming " + doc2.getName() + " to test3.txt");
+    properties = new HashMap<String, Object>();
+    properties.put(PropertyIds.NAME, "test3.txt");
+    id2 = doc2.updateProperties(properties);
+    System.out.println("renamed to " + doc2.getName());
 
-You can update the contents of a document by setting a new content stream using the `setContentStream()`
method.
+You can update the contents of a document by setting a new [ContentStream](http://incubator.apache.org/chemistry/javadoc/org/apache/chemistry/opencmis/commons/data/ContentStream.html)

+using the `setContentStream()` method.
 You must set the overwrite flag if the document has existing content, otherwise an exception
will be thrown. The following code snippet updated the content of the `test3.txt` document:-
 
-        content = "This is some updated test content for our renamed second document.";
-        buf = null;
-        try {
-            buf = content.getBytes("UTF-8");
-        } catch (UnsupportedEncodingException e) {
-            e.printStackTrace();
-        }
-        input = new ByteArrayInputStream(buf);
-        contentStream = session.getObjectFactory().createContentStream("test3.txt", buf.length,
-                mimetype, input);
-        properties = new HashMap<String, Object>();
-        properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
-        properties.put(PropertyIds.NAME, "test3.txt");
-        doc2.setContentStream(contentStream, true);
-
-        // did it work?
-        try {
-            content = getContentAsString(doc2.getContentStream());
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-        System.out.println("Contents of " + doc2.getName() + " are: " + content);
+    :::java
+    content = "This is some updated test content for our renamed second document.";
+    buf = null;
+    try {
+        buf = content.getBytes("UTF-8");
+    } catch (UnsupportedEncodingException e) {
+        e.printStackTrace();
+    }
+    input = new ByteArrayInputStream(buf);
+    contentStream = session.getObjectFactory().createContentStream("test3.txt", buf.length,
+            mimetype, input);
+    properties = new HashMap<String, Object>();
+    properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
+    properties.put(PropertyIds.NAME, "test3.txt");
+    doc2.setContentStream(contentStream, true);
+
+    // did it work?
+    try {
+        content = getContentAsString(doc2.getContentStream());
+    } catch (IOException e) {
+        e.printStackTrace();
+    }
+    System.out.println("Contents of " + doc2.getName() + " are: " + content);
         
 ####Deleting a document
 You can delete any CMIS object using the `delete` method. The following code snippet lists
the 
 contents of the test folder before and after a delete of one of the two documents
 in the folder.
 
+        :::java
         children = newFolder.getChildren();
         System.out.println("Now finding the following objects in our folder:-");
         for (CmisObject o : children) {
@@ -418,7 +441,7 @@ in the folder.
             System.out.println(o.getName());
         }
         
-Note that the `allVersions` flag is set o `true`. If you set it to false then the delete
will
+Note that the `allVersions` flag is set to `true`. If you set it to false then the delete
will
 be of this version only.
 
 ####Deleting a folder tree
@@ -426,6 +449,7 @@ You can delete a folder and all its cont
 creates a new folder tree and then deletes it, ignoring any failures to delete individual
objects, and deleting
 all versions of any documents in the tree.
 
+        :::java
         System.out.println("Creating 'ADGFolder1' in the root folder");
         newFolderProps = new HashMap<String, String>();
         newFolderProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
@@ -451,11 +475,11 @@ no objects are deleted. In other reposit
 CMIS provides several concepts for navigating through the tree of objects in the repository.
For any folder, 
 you can get its children, get its descendants, and get the folder tree. The getting started
sample application sets
 up a tree in the repository that looks like this:-
-
 <img src="images/FileTree.png" />
 
 The following snippet from the getting started sample will print out the children of a folder
:-
 
+        :::java
         children = folder1.getChildren();
         System.out.println("Children of " + folder1.getName() + ":-");
         for (CmisObject o : children) {
@@ -465,6 +489,7 @@ The following snippet from the getting s
 Note that the children of a Folder object can be of any type supported by the repository.

 Running the sample produces the following output :-
 
+    :::text
     Children of ADGFolder1:-
     ADGFolder11
     ADGFolder12
@@ -473,6 +498,7 @@ Running the sample produces the followin
 If your repository supports `getDescendants`, you can navigate the whole subtree of descendants
of any folder. 
 This code snippet uses a recursive method to print out the entire folder subtree:-
 
+    :::java
     if (!session.getRepositoryInfo().getCapabilities().isGetDescendantsSupported()) {
         System.out.println("getDescendants not supported in this repository");
     } else {
@@ -493,12 +519,13 @@ This code snippet uses a recursive metho
     
 Note the following points:-
 
-1. The children of a `Tree` are themselves of type `Tree`. 
+1. The children of a [`Tree`](http://incubator.apache.org/chemistry/javadoc/org/apache/chemistry/opencmis/client/api/Tree.html)
are themselves of type `Tree`. 
 1. The single argument of `getDescendants` is the depth or level of the tree that you want
to go to. A depth of 1 will give you just the root of the tree. 
 A depth of -1 will return the full tree.
 
 Running the sample produces the following output :-
 
+    :::text
     Descendants of ADGFolder1:-
     Descendant ADGFolder11
     Descendant ADGFolder111
@@ -514,6 +541,7 @@ Running the sample produces the followin
 If your repository supports `getFolderTree`, you can navigate the whole subtree of folders
from any folder in the repository.
 This code snippet uses a recursive method to print out the entire folder subtree:-
 
+    :::java
     if (!session.getRepositoryInfo().getCapabilities().isGetFolderTreeSupported()) {
         System.out.println("getFolderTree not supported in this repository");
     } else {
@@ -534,6 +562,7 @@ This code snippet uses a recursive metho
     
 Running the sample produces the following output :-
 
+    :::text
     Foldertree for ADGFolder1:-
     Folder ADGFolder11
     Folder ADGFolder111
@@ -566,6 +595,7 @@ CMIS 1.0 does not allow you to create ty
 
 So, we can retrieve information in the type definition for our `doc` object :-
 
+        :::java
         System.out.println("Getting type definition for doc type");
         ObjectType objectType = session.getTypeDefinition(doc.getType().getId());
         System.out.println("isBaseType() returns " + (objectType.isBaseType() ? "true" :
"false"));
@@ -590,15 +620,36 @@ So, we can retrieve information in the t
             System.out.println("\t" + o.getItem().getDisplayName());
         }
         
+The following lines are typical output from this code:-
+
+    :::text
+    Getting type definition for doc type
+    isBaseType() returns true
+    getBaseType() returns null
+    getParentType() returns null
+    Listing child types of CMIS Document
+        My Type 1 Level 1
+        My Type 2 Level 1
+        Complex type with properties, Level 1
+        Document type with properties, Level 1
+        VersionedType
+    Getting immediate descendant types of CMIS Document
+        My Type 1 Level 1
+        My Type 2 Level 1
+        Complex type with properties, Level 1
+        Document type with properties, Level 1
+        VersionedType
+        
 You will see that, not surprisingly, doc has a type of `Document`, which is a base type,
so has no parent. Depending on the repository
 you are running this code against, there may be a number of children of the `Document` type,
which are types derived from this base type.
 
 ###CMIS Properties
 ####Displaying the properties of an Object
-All objects of the CMIS base types implement the interface `CmisObjectProperties` which provides

+All objects of the CMIS base types implement the interface [`CmisObjectProperties`](http://incubator.apache.org/chemistry/javadoc/org/apache/chemistry/opencmis/client/api/CmisObjectProperties.html)
which provides 
 accessors to CMIS object properties. The following code snippet uses the `getProperties()`
method
 to print out all the available properties on a newly created Document object, doc.
 
+         :::java
          List<Property<?>> props = doc.getProperties();
          for (Property<?> p : props) {
              System.out.println(p.getDefinition().getDisplayName() + "=" +
@@ -608,6 +659,7 @@ to print out all the available propertie
          
 The output should look something like this :-
 
+    :::text
     Is Latest Major Version=[false]
     Content Stream Length=[26]
     Content Stream Id=[store://2011/5/20/12/54/0d69ee48-ef03-4715-ae23-b84b4342315c.bin]
@@ -634,9 +686,11 @@ The output should look something like th
     
 ####Getting a property explicitly
 Each object type has a known set of properties, and you can retrieve these explicitly. 
-For example, the document type has a set of properties described by the `DocumentProperties`
interface, and you can use the methods on this interface to retrieve 
+For example, the document type has a set of properties described by the [`DocumentProperties`](http://incubator.apache.org/chemistry/javadoc/org/apache/chemistry/opencmis/client/api/DocumentProperties.html)
interface, 
+and you can use the methods on this interface to retrieve 
 the value a property:-
 
+        :::java
         System.out.println("VersionLabel property on " + doc.getName() + " is "
                 + doc.getVersionLabel());
         System.out.println("Is this the latest version of " + doc.getName() + " ?:  "
@@ -645,6 +699,7 @@ the value a property:-
 Note that properties can be of simple types, `Boolean`, String, long, or more complex types,
 such as `GregorianCalendar`. The following code snippet prints out the `CreationDate` property:-
 
+        :::java
         GregorianCalendar calendar = doc.getCreationDate();
         String DATE_FORMAT = "yyyyMMdd";
         SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
@@ -652,20 +707,32 @@ such as `GregorianCalendar`. The followi
                 + sdf.format(calendar.getTime())
                 );
                 
-####Getting a property value
+####Getting a property value by Id
 You can get the value of any property using the `getPropertyValue()` method. 
-This is particularly useful for retrieving properties that are not part of the CMIS specification.
You should 
-always use the `queryName` to get a property value. Given a property, you can always get
its `queryName` from the 
-property definition.
-The following code snippet takes a property, finds the `queryName` from the property definition,
and gets the 
+This is particularly useful for retrieving properties that are not part of the CMIS specification.

+The following code snippet takes a property, finds the Id from the property definition, and
gets the 
 property's value using the `queryName`:-
 
-        Property<?> someProperty = props.get(0);
-        System.out
-                .println(someProperty.getDisplayName() + " property on " + doc.getName()
-                        + " (by getPropertValue()) is "
-                        + doc.getPropertyValue(someProperty.getQueryName())); 
-               
+    :::java
+    List<Property<?>> props = doc.getProperties();
+    Property<?> someProperty = props.get(0);
+    System.out
+            .println(someProperty.getDisplayName() + " property on " + doc.getName()
+                    + " (by getPropertValue()) is "
+                    + doc.getPropertyValue(someProperty.getId())); 
+
+####Getting a property value by query name
+Given a query result, you can always use the `queryName` to get a property value. 
+The following code snippet performs a query and gets a property's value using the `queryName`:-
+
+    :::java
+    String query = "SELECT * FROM cmis:document WHERE cmis:name = 'test.txt'";
+    ItemIterable<QueryResult> queryResult = session.query(query, false);
+    for (QueryResult item : queryResult) {
+        System.out.println("property cmis:createdBy on test.txt is "
+                + item.getPropertyByQueryName("cmis:createdBy").getFirstValue());
+    } 
+                                       
 ###Working with CMIS Queries
 CMIS provides a type-based query service for discovering objects that match specified criteria.
To allow this, CMIS provides 
 a relational view of the CMIS data model. Through this relational view, queries may be performed
using a simplified SQL SELECT 
@@ -675,6 +742,7 @@ capability for the CMIS data model. You 
 #####A Simple Query
 Let's look at a query that will find all document objects that have a name that starts with
the string `test`:-
 
+    :::sql
     SELECT * FROM cmis:document WHERE cmis:name LIKE 'test%'
 
 This query specifies the virtual table `cmis:document` in the FROM clause. In the CMIS relational
view, a virtual table 
@@ -694,6 +762,7 @@ You can run the query against any reposi
 
 Let's look at the code required for this query when using the OpenCMIS client library:-
 
+            :::java
             String query = "SELECT * FROM cmis:document WHERE cmis:name LIKE 'test%'";
             ItemIterable<QueryResult> q = session.query(query, false);
 
@@ -720,10 +789,13 @@ in this particular query. This code snip
 ###Exceptions
 If something goes wrong in an OpenCMIS method, an exception will be thrown. 
 All OpenCMIS exceptions extend 
-[CmisBaseException](http://incubator.apache.org/chemistry/javadoc/org/apache/chemistry/opencmis/commons/exceptions/package-tree.html)
+[`CmisBaseException`](http://incubator.apache.org/chemistry/javadoc/org/apache/chemistry/opencmis/commons/exceptions/package-tree.html)
 which is a Java runtime exception. Because all exceptions are runtime, you do not have to
catch or specify the exceptions in your own code. 
-It does make sense to explicitly catch them in robust code. This code snippet forces an `CmisInvalidArgumentException`
by supplying a null content stream.
+It does make sense to explicitly catch them in robust code. This code snippet forces an 
+[`CmisInvalidArgumentException`](http://incubator.apache.org/chemistry/javadoc/org/apache/chemistry/opencmis/commons/exceptions/CmisInvalidArgumentException.html)

+by supplying a null content stream.
 
+        :::java
         try {
             doc2.setContentStream(null, false);
         } catch (CmisInvalidArgumentException e1) {
@@ -734,7 +806,7 @@ It does make sense to explicitly catch t
 ###Operation Context
 The amount of metadata and associated information retrieved during an OpenCMIS operation
could be large, 
 so certain OpenCMIS methods return a sensible subset of the information by default, 
-and provide additional methods that take an [OperationContext](http://incubator.apache.org/chemistry/javadoc/org/apache/chemistry/opencmis/client/api/OperationContext.html).
+and provide additional methods that take an [`OperationContext`](http://incubator.apache.org/chemistry/javadoc/org/apache/chemistry/opencmis/client/api/OperationContext.html).
 An OperationContext allows you to tune the amount of information returned by setting property
filters, renditions filters, or by setting what. It is also used to control 
 paging and caching in an operation. 
 ####Setting 
@@ -743,6 +815,7 @@ paging and caching in an operation. 
 Caching of objects is turned on by default in OpenCMIS, but if you want to guarantee that
`getObject()`
 or `getObjectByPath()` will not return stale objects, you can turn it off using an `OperationContext`:-
 
+    :::java
     OperationContext oc = session.createOperationContext();
     oc.setCacheEnabled(false);
     CmisObject object = session.getObject(id, oc);
@@ -750,6 +823,7 @@ or `getObjectByPath()` will not return s
 ####Rendition Filter
 For example the following code snippet looks like it retrieves a list of renditions for a
document object.
 
+        :::java
         CmisObject oo = session.getObject(o.getId());
         List<Rendition> rl = oo.getRenditions();   
          
@@ -759,6 +833,7 @@ This is because renditions are not inclu
 
 You can use an `OperationContext` with a rendition filter to extend the information retrieved:-
 
+        :::java
         OperationContext context = session.createOperationContext();
         context.setRenditionFilterString("cmis:thumbnail");
         CmisObject oo = session.getObject(o.getId(), context);
@@ -770,11 +845,12 @@ This code will retrieve any renditions o
 When you retrieve the children of a CMIS object, the result set returned is of an arbitrary
size. 
 Retrieving a large result set synchronously could increase response times. 
 To improve performance, you can use OpenCMIS's paging support to control the size of the
result set retrieved from the repository. 
-To use paging, you must specify an `OperationContext` in the `getChildren` method call on
the parent object. 
+To use paging, you must specify an `OperationContext` in the `getChildren()` method call
on the parent object. 
 The `OperationContext` specifies the maximum number of items to retrieve in a page. 
 
 The following code snippet retrieves a page of three objects from the result set, starting
at the fifth item.
 
+        :::java
         OperationContext operationContext = new OperationContextImpl();
         operationContext.setMaxItemsPerPage(3);
         ItemIterable<CmisObject> children1 = folderPaging.getChildren(operationContext);
@@ -785,10 +861,11 @@ The following code snippet retrieves a p
             count++;
         }
         
-Note that `skipTo()` method returns a  an iterable over the complete collection. The getPage()
method is then be used to create an iterable over the page.
+Note that `skipTo()` method returns a  an iterable over the complete collection. The `getPage()`
method is then be used to create an iterable over the page.
 
 The following code snippet retrieves all objects in the result set, using the `getHasMoreItems()`
method to end the `getPage()` loop.
 
+        :::java
         operationContext = new OperationContextImpl();
         operationContext.setMaxItemsPerPage(3);
         children1 = folderPaging.getChildren(operationContext);
@@ -809,7 +886,7 @@ The following code snippet retrieves all
         }
         
 ###Query - prepared statments
-<p class="todo"> todo</p> 
+<img src="images/todo.gif" title="todo">
         
 ##Advanced CMIS features
 ###Capabilities
@@ -818,6 +895,7 @@ that are not needed for that domain. Thi
 To allow this, some capabilities can be optionally supported by a CMIS repository. 
 You can discover which optional capabilities your repository supports using the getRepositoryInfo
service:-
 
+         :::java
          System.out.println("Printing repository capabilities...");
          final RepositoryInfo repInfo = session.getRepositoryInfo();
          RepositoryCapabilities cap = repInfo.getCapabilities();
@@ -838,7 +916,7 @@ You can discover which optional capabili
          System.out.println("\nVersioning Capabilities");
          System.out.println("-----------------------");        
          System.out.println("PWC searchable: " + (cap.isPwcSearchableSupported()?"true":"false"));
-         System.out.println("PWC searchable: " + (cap.isPwcUpdatableSupported()?"true":"false"));
+         System.out.println("PWC updatable: " + (cap.isPwcUpdatableSupported()?"true":"false"));
          System.out.println("All versions searchable: " + (cap.isAllVersionsSearchableSupported()?"true":"false"));
          System.out.println("\nQuery Capabilities");
          System.out.println("-----------------------");        
@@ -854,10 +932,11 @@ shown in the CMIS specification, which h
 capability in the section on [optional capabilities](http://docs.oasis-open.org/cmis/CMIS/v1.0/cd04/cmis-spec-v1.0.html#_Toc243712491).
 ###Allowable Actions
 The CMIS specification allows an application to discover the set of operations that can currently
be performed on a particular object, 
-without having to actually having to perform the action itself. The set of allowable actions
for a particular object are not fixed, but are 
+without having to perform the action itself. The set of allowable actions for a particular
object are not fixed, but are 
 influenced by ACLs, constraints on the object's base type, and policies or other mechanisms
not specified by CMIS. The following code snippet 
 gets the current allowable actions for the test.txt document object:-
 
+        :::java
         System.out.println("Getting the current allowable actions for the " + doc.getName()
+ " document object...");
         for (Action a: doc.getAllowableActions().getAllowableActions()) {
             System.out.println("\t" + a.value());
@@ -866,6 +945,7 @@ gets the current allowable actions for t
 In practice, you would check a single allowable action before executing that action. So,
the following code snippet shows how to check if 
 your application is currently allowed to check out the document `test.txt`
 
+        :::java
         if (doc.getAllowableActions().getAllowableActions().contains(Action.CAN_CHECK_OUT))
{
             System.out.println("can check out " + doc.getName());
         } else {
@@ -875,7 +955,7 @@ your application is currently allowed to
   
 ###Multi-filing and Unfiling
 Multi-filing allows you to file a document object in more than one folder.
-Unfiling allows you to leave a document without  parent folder. Both this capabilities are

+Unfiling allows you to leave a document without  parent folder. Both these capabilities are

 optional, and your repository may not support them. 
 
 The following code snippet checks if multi-filing is supported by this repository. If it
is, 
@@ -883,6 +963,7 @@ The following code snippet checks if mul
 folder. Since multi-filing is supported, the document should be seen in both folders, 
 and the code checks for this.
 
+        :::java
         if (!(cap.isMultifilingSupported())) {
             System.out.println("Multifiling not supported by this repository");
         } else {
@@ -915,6 +996,7 @@ If it is, it removes our document from b
 Since unfiling is supported, the document should still be accessible by its ID, 
 and the code checks for this.
 
+        :::java
         if (!(cap.isUnfilingSupported())) {
             System.out.println("Unfiling not supported by this repository");
         } else {
@@ -933,9 +1015,9 @@ and the code checks for this.
       
 ###Versioning
 Only document objects can be versioned.  
-Whether or not a Document object is versionable is specified by the `versionable` attribute
on its Object-type.
-A version is copy of the object, preserving its state at a certain point in time. 
-Each version is itself a Document object, with its own ObjectId.
+Whether or not a document object is versionable is specified by the `versionable` attribute
on its Object-type.
+A version is a copy of the object, preserving its state at a certain point in time. 
+Each version is itself a document object, with its own ObjectId.
 
 The CMIS specification uses the following terminology when discussing versioning:
 
@@ -948,6 +1030,7 @@ Version Series need not have a Latest Ma
 
 The following code snippet checks if the test.txt document object is versionable.
 
+        :::java
         if (((DocumentType)(doc.getType())).isVersionable()) {
             System.out.println(doc.getName() + " is versionable");
         } else {
@@ -960,6 +1043,7 @@ Repositories may allow any version of a 
 The following code snippet checks out the latest version of the test.txt document, updates
the content stream, and checks in the new version of the 
 document as a minor version. 
 
+        :::java
         if (versionable) {
             Document pwc = (Document) session.getObject(doc.checkOut());
             try {
@@ -1011,6 +1095,7 @@ document as a minor version. 
 The code snippet uses the `getAllVersions()` method to retrieve all the versions in the version
series. 
 The output from this code snippet will look something like this:-
 
+    :::text
     Document version history
     name: test.txt
     version label: 1.0
@@ -1050,6 +1135,7 @@ It then scans the object tree starting f
 document object that has renditions associated with it. It then gets the document again using
an `OperationContext`
 to retrieve all renditions of a particular type.
 
+        :::java
         if (session.getRepositoryInfo().getCapabilities().getRenditionsCapability()
                 .equals(CapabilityRenditions.NONE)) {
             System.out.println("Repository does not support renditions");
@@ -1097,15 +1183,14 @@ to retrieve all renditions of a particul
         }
         
 ###Relationships
-<p class="todo">todo</p>
+<img src="images/todo.gif" title="todo">
 ###Permissions
-<p class="todo">todo</p>
-###Advance uses of types
-<p class="todo">todo</p>
+<img src="images/todo.gif" title="todo">
 ###Change logs
-<p class="todo">todo</p>
+<img src="images/todo.gif" title="todo">
 ##OpenCMIS bindings
+<img src="images/todo.gif" title="todo">
 ##Performance
-<p class="todo"> todo</p> 
+<img src="images/todo.gif" title="todo">
 ##Troubleshooting
-<p class="todo">Common pitfalls</p>
+<img src="images/todo.gif" title="todo">Common pitfalls
\ No newline at end of file



Mime
View raw message