chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1142946 - /chemistry/site/trunk/content/java/developing/guide.mdtext
Date Tue, 05 Jul 2011 09:40:46 GMT
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<String, Object>();
-    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<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();
+        // 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 <a href="#Versioning">versioning</a>
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<Rendition> rl = oo.getRenditions();
@@ -1012,7 +1021,8 @@ and the code checks for this.
             }
 
         }
-      
+
+<a name="Versioning"></a>       
 ###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.



Mime
View raw message