Return-Path: X-Original-To: apmail-chemistry-commits-archive@www.apache.org Delivered-To: apmail-chemistry-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3F2484D2D for ; Tue, 5 Jul 2011 09:41:14 +0000 (UTC) Received: (qmail 72305 invoked by uid 500); 5 Jul 2011 09:41:13 -0000 Delivered-To: apmail-chemistry-commits-archive@chemistry.apache.org Received: (qmail 72248 invoked by uid 500); 5 Jul 2011 09:41:09 -0000 Mailing-List: contact commits-help@chemistry.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@chemistry.apache.org Delivered-To: mailing list commits@chemistry.apache.org Received: (qmail 72230 invoked by uid 99); 5 Jul 2011 09:41:08 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Jul 2011 09:41:08 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Jul 2011 09:41:06 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 4BB2323889BF; Tue, 5 Jul 2011 09:40:46 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1142946 - /chemistry/site/trunk/content/java/developing/guide.mdtext Date: Tue, 05 Jul 2011 09:40:46 -0000 To: commits@chemistry.apache.org From: fmui@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110705094046.4BB2323889BF@eris.apache.org> Author: fmui Date: Tue Jul 5 09:40:45 2011 New Revision: 1142946 URL: http://svn.apache.org/viewvc?rev=1142946&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=1142946&r1=1142945&r2=1142946&view=diff ============================================================================== --- chemistry/site/trunk/content/java/developing/guide.mdtext (original) +++ chemistry/site/trunk/content/java/developing/guide.mdtext Tue Jul 5 09:40:45 2011 @@ -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://www.eclipse.org/downloads.html). +* You can download and install Eclipse [here](http://www.eclipse.org/downloads/). * 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). @@ -51,7 +51,7 @@ OpenCMIS is a collection of Java librari It is available under the open source [Apache License](http://www.apache.org/licenses/) from the [Apache Chemistry project](http://chemistry.apache.org/). The OpenCMIS Client API is a Java client-side library that implements the CMIS specification. You can see the Javadoc for the -OpenCMIS Client API [here](http://incubator.apache.org/chemistry/javadoc/org/apache/chemistry/opencmis/client/api/package-summary.html). +OpenCMIS Client API [here](http://chemistry.apache.org/java/0.4.0/maven/apidocs/org/apache/chemistry/opencmis/client/api/package-summary.html). CMIS defines a domain model that describes a vendor-neutral ECM repository and its contents, a set of services to work with the repository and its content, and a set of bindings which a client uses to access the services. ####The CMIS Domain Model @@ -102,7 +102,7 @@ The CMIS services are:- 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 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 [`SessionFactory`](http://chemistry.apache.org/java/0.4.0/maven/apidocs/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 @@ -205,7 +205,7 @@ Note that:- parameter.put(SessionParameter.USER, "admin"); parameter.put(SessionParameter.PASSWORD, "admin"); parameter.put(SessionParameter.ATOMPUB_URL, - "http://opencmis.cloudapp.net/inmemory/atom/"); + "http://repo.opencmis.org/inmemory/atom/"); parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value()); ####Connecting to a repository by id @@ -377,9 +377,9 @@ The following code snippet retrieves the Note the following points :- * All paths start with the root folder `/`. -* The [`Document`](http://incubator.apache.org/chemistry/javadoc/org/apache/chemistry/opencmis/client/api/Document.html) +* The [`Document`](http://chemistry.apache.org/java/0.4.0/maven/apidocs/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. +`getPaths()` method from the [`FileableCmisObject`](http://chemistry.apache.org/java/0.4.0/maven/apidocs/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. @@ -395,33 +395,42 @@ The following code snippet updates the n id2 = doc2.updateProperties(properties); System.out.println("renamed to " + doc2.getName()); -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) +You can update the contents of a document by setting a new [ContentStream](http://chemistry.apache.org/java/0.4.0/maven/apidocs/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:- :::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(); - properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document"); - properties.put(PropertyIds.NAME, "test3.txt"); - doc2.setContentStream(contentStream, true); + if (!session.getRepositoryInfo().getCapabilities().getContentStreamUpdatesCapability() + .equals(CapabilityContentStreamUpdates.ANYTIME)) { + System.out.println("update without checkout not supported in this repository"); + } else { + System.out.println("updating content stream"); + 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(); + 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(); + // did it work? + try { + content = getContentAsString(doc2.getContentStream()); + } catch (IOException e) { + e.printStackTrace(); + } + System.out.println("Contents of " + doc2.getName() + " are: " + content); } - System.out.println("Contents of " + doc2.getName() + " are: " + content); + +Note that this code snippet will not work for repositories that require a checkout to set a content stream. +For more information on checkout see the versioning section in this guide. ####Deleting a document You can delete any CMIS object using the `delete` method. The following code snippet lists the @@ -519,7 +528,7 @@ This code snippet uses a recursive metho Note the following points:- -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 children of a [`Tree`](http://chemistry.apache.org/java/0.4.0/maven/apidocs/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. @@ -645,7 +654,7 @@ you are running this code against, there ###CMIS Properties ####Displaying the properties of an Object -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 +All objects of the CMIS base types implement the interface [`CmisObjectProperties`](http://chemistry.apache.org/java/0.4.0/maven/apidocs/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. @@ -686,7 +695,7 @@ 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`](http://incubator.apache.org/chemistry/javadoc/org/apache/chemistry/opencmis/client/api/DocumentProperties.html) interface, +For example, the document type has a set of properties described by the [`DocumentProperties`](http://chemistry.apache.org/java/0.4.0/maven/apidocs/org/apache/chemistry/opencmis/client/api/DocumentProperties.html) interface, and you can use the methods on this interface to retrieve the value a property:- @@ -789,10 +798,10 @@ 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://chemistry.apache.org/java/0.4.0/maven/apidocs/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`](http://incubator.apache.org/chemistry/javadoc/org/apache/chemistry/opencmis/commons/exceptions/CmisInvalidArgumentException.html) +[`CmisInvalidArgumentException`](http://chemistry.apache.org/java/0.4.0/maven/apidocs/org/apache/chemistry/opencmis/commons/exceptions/CmisInvalidArgumentException.html) by supplying a null content stream. :::java @@ -806,7 +815,7 @@ by supplying a null content stream. ###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://chemistry.apache.org/java/0.4.0/maven/apidocs/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 @@ -816,7 +825,7 @@ Caching of objects is turned on by defau or `getObjectByPath()` will not return stale objects, you can turn it off using an `OperationContext`:- :::java - OperationContext oc = session.createOperationContext(); + OperationContext operationContext = session.createOperationContext(); oc.setCacheEnabled(false); CmisObject object = session.getObject(id, oc); @@ -834,7 +843,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(); + OperationContext operationContext = session.createOperationContext(); context.setRenditionFilterString("cmis:thumbnail"); CmisObject oo = session.getObject(o.getId(), context); List rl = oo.getRenditions(); @@ -1012,7 +1021,8 @@ 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.