You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2016/06/10 18:36:07 UTC

svn commit: r1747768 [8/8] - in /chemistry/docs: ./ cmis-samples/ cmis-samples/branches/ cmis-samples/tags/ cmis-samples/trunk/ cmis-samples/trunk/cinder-chemistry/ cmis-samples/trunk/cinder-chemistry/css/ cmis-samples/trunk/cinder-chemistry/fonts/ cmi...

Added: chemistry/docs/cmis-samples/trunk/docs/samples/retrieving-objects.md
URL: http://svn.apache.org/viewvc/chemistry/docs/cmis-samples/trunk/docs/samples/retrieving-objects.md?rev=1747768&view=auto
==============================================================================
--- chemistry/docs/cmis-samples/trunk/docs/samples/retrieving-objects.md (added)
+++ chemistry/docs/cmis-samples/trunk/docs/samples/retrieving-objects.md Fri Jun 10 18:36:06 2016
@@ -0,0 +1,205 @@
+# Retrieving Objects 
+
+
+## Getting the Root Folder
+
+All repositories have to provide a root folder. It's the entry point for [browsing](#getting-folder-children) the repository content. The root folder might be completely empty and useless for repositories that only support unfiled objects.
+    
+OpenCMIS (Java)
+{: .opencmis }
+```java
+Folder rootFolder = session.getRootFolder();
+```
+
+PortCMIS (C#)
+{: .portcmis }
+```csharp
+IFolder rootFolder = Session.GetRootFolder();
+```
+
+
+## Getting Objects by ID
+
+All objects in a repository must have a unique object ID and can be retrieved by this ID. If the user has no permissions to see the object, a [objectNotFound](exceptions/index.html) exception is thrown.
+
+
+OpenCMIS (Java)
+{: .opencmis }
+```java
+CmisObject cmisObject = session.getObject(id);
+
+if (cmisObject instanceof Document) {
+    Document document = (Document) cmisObject;
+} else if (cmisObject instanceof Folder) {
+    Folder folder = (Folder) cmisDocument;
+} else {
+    ...
+}
+```
+
+PortCMIS (C#)
+{: .portcmis }
+```csharp
+ICmisObject cmisObject = Session.GetObject(id);
+
+if (cmisObject is IDocument) {
+    IDocument document = cmisObject as IDocument;
+} else if (cmisObject is IFolder) {
+    IFolder folder = cmisDocument as IFolder;
+} else {
+    ...
+}
+```
+
+## Getting Objects by Path
+
+ A filed object has one or more paths and can be retrieved by this path. If the user has no permissions to see the object, a [objectNotFound](exceptions/index.html) exception is thrown.
+
+Most repositories use the **cmis:name** property of the folders and the object to assemble the path. But it is possible that the path segments don’t match the names. 
+
+
+OpenCMIS (Java)
+{: .opencmis }
+```java
+String path = "/User Homes/customer1/document.odt";
+CmisObject cmisObject = session.getObjectByPath(path);
+
+// get the object ID
+String id = cmisObject.getId();
+
+// we know it is a filable object, we just retrieved it by path
+FileableCmisObject fileableCmisObject = (FileableCmisObject) cmisObject;
+
+// get all paths, there must be at least one
+List<String> paths = fileableCmisObject.getPaths();
+
+// get all parent folders, there must be at least one
+List<Folder> parents = fileableCmisObject.getParents();
+```
+
+PortCMIS (C#)
+{: .portcmis }
+```csharp
+string path = "/User Homes/customer1/document.odt";
+ICmisObject cmisObject = Session.GetObjectByPath(path);
+
+// get the object ID
+string id = cmisObject.Id;
+
+// we know it is a filable object, we just retrieved it by path
+IFileableCmisObject fileableCmisObject = cmisObject as IFileableCmisObject;
+
+// get all paths, there must be at least one
+IList<string> paths = fileableCmisObject.Paths;
+
+// get all parent folders, there must be at least one
+IList<IFolder> parents = fileableCmisObject.Parents;
+```
+
+
+## Getting Folder Children
+
+The page about [lists](lists/index.html) explains how paging works.
+
+OpenCMIS (Java)
+{: .opencmis }
+```java
+Folder folder = ...
+
+for (CmisObject child: folder.getChildren()) {
+    System.out.println(child.getName());
+}
+```
+
+PortCMIS (C#)
+{: .portcmis }
+```csharp
+IFolder folder = ...
+
+foreach (ICmisObject child in folder.GetChildren()) {
+    Console.WriteLine(child.Name);
+}
+```
+
+
+## Understanding the Object Cache
+
+By default, OpenCMIS and PortCMIS cache objects. That is, the object returned by `getObject()` or `getObjectbyPath()`
+can be stale. There are multiple ways to deal with that.
+
+### Refresh the object data that is returned from `getObject()`
+
+OpenCMIS (Java)
+{: .opencmis }
+```java
+CmisObject cmisObject = session.getObject(id);
+cmisObject.refresh(); // contacts the repository and refreshes the object
+cmisObject.refreshIfOld(60 * 1000); // ... or refreshes the object only if the data is older than a minute
+```
+
+PortCMIS (C#)
+{: .portcmis }
+```csharp
+ICmisObject cmisObject = Session.GetObject(id);
+cmisObject.Refresh(); // contacts the repository and refreshes the object
+cmisObject.RefreshIfOld(60 * 1000); // ... or refreshes the object only if the data is older than a minute
+```
+
+
+### Turn off the session cache completely
+
+OpenCMIS (Java)
+{: .opencmis }
+```java
+session.getDefaultContext().setCacheEnabled(false);
+```
+
+PortCMIS (C#)
+{: .portcmis }
+```csharp
+Session.DefaultContext.CacheEnabled = false;
+```
+
+
+### Turn off caching for this `getObject()` call
+
+See also the page about the [Operation Context](operation-context/index.html).
+
+OpenCMIS (Java)
+{: .opencmis }
+```java
+OperationContext oc = session.createOperationContext();
+oc.setCacheEnabled(false);
+
+CmisObject cmisObject = session.getObject(id, oc);
+```
+
+PortCMIS (C#)
+{: .portcmis }
+```csharp
+IOperationContext oc = session.CreateOperationContext();
+oc.CacheEnabled = false;
+
+ICmisObject cmisObject = Session.GetObject(id, oc);
+```
+
+
+### Clear the session cache
+
+This is not recommended!
+
+OpenCMIS (Java)
+{: .opencmis }
+```java
+session.clear();
+```
+
+PortCMIS (C#)
+{: .portcmis }
+```csharp
+Session.Clear();
+```
+
+
+*[unfiled]: An object is called "unfiled" if it doesn't reside in a folder. Folders cannot be unfiled.
+*[filed]: An object is called "filed" if it resides in one or more folders. 
\ No newline at end of file

Added: chemistry/docs/cmis-samples/trunk/docs/samples/types.md
URL: http://svn.apache.org/viewvc/chemistry/docs/cmis-samples/trunk/docs/samples/types.md?rev=1747768&view=auto
==============================================================================
--- chemistry/docs/cmis-samples/trunk/docs/samples/types.md (added)
+++ chemistry/docs/cmis-samples/trunk/docs/samples/types.md Fri Jun 10 18:36:06 2016
@@ -0,0 +1,40 @@
+# Working with Types
+
+## Getting Type Definitions
+
+<span class="cmis">CMIS 1.0</span>
+<span class="cmis">CMIS 1.1</span>
+
+OpenCMIS (Java)
+{: .opencmis }
+```java
+ObjectType type = session.getTypeDefinition("cmis:document");
+
+if (type instanceof DocumentType) {
+    DocumentType docType = (DocumentType) type;
+    boolean isVersionable = docType.isVersionable();
+} else if (type instanceof RelationshipType) {
+    RelationshipType relType = (RelationshipType) type;
+} else {
+    ...
+}
+```
+
+PortCMIS (C#)
+{: .portcmis }
+```csharp
+IObjectType type = Session.GetTypeDefinition("cmis:document");
+
+if (type is IDocumentType) {
+    IDocumentType docType = type as IDocumentType;
+    bool isVersionable = docType.Versionable;
+} else if (type is IRelationshipType) {
+    IRelationshipType relType = type as IRelationshipType;
+} else {
+    ...
+}
+```
+
+## Creating, Updating, and Deleting Types
+
+<span class="cmis">CMIS 1.1</span>
\ No newline at end of file

Added: chemistry/docs/cmis-samples/trunk/docs/samples/update-objects.md
URL: http://svn.apache.org/viewvc/chemistry/docs/cmis-samples/trunk/docs/samples/update-objects.md?rev=1747768&view=auto
==============================================================================
--- chemistry/docs/cmis-samples/trunk/docs/samples/update-objects.md (added)
+++ chemistry/docs/cmis-samples/trunk/docs/samples/update-objects.md Fri Jun 10 18:36:06 2016
@@ -0,0 +1,72 @@
+# Updating Objects
+
+## Updating Properties
+
+The page about [properties](properties/index.html) explains how Java and C# data types are map to CMIS data types.
+
+OpenCMIS (Java)
+{: .opencmis }
+```Java
+CmisObject cmisObject = ...
+
+Map<String, Object> properties = new HashMap<String, Object>();
+
+properties.put("my:property", "new value"); // single-value property
+properties.put("my:int.property", 42);
+properties.put("my:date.property", new GregorianCalendar());
+properties.put("my:bool.property", true);
+
+List<String> shoppingList = new ArrayList<String>();
+shoppingList.add("milk");
+shoppingList.add("bread");
+shoppingList.add("cheese");
+properties.put("my:shopping.list", shoppingList); // multi-value property
+
+cmisObject.updateProperties(properties);
+```
+
+PortCMIS (C#)
+{: .portcmis }
+```csharp
+ICmisObject cmisObject = ...
+
+IDictonary<string, object> properties = new Dictonary<string, object>();
+
+properties.Add("my:property", "new value"); // single-value property
+properties.Add("my:int.property", 42);
+properties.Add("my:date.property", DateTime.Now);
+properties.Add("my:bool.property", true);
+
+IList<string> shoppingList = new List<string>();
+shoppingList.Add("milk");
+shoppingList.Add("bread");
+shoppingList.Add("cheese");
+properties.Add("my:shopping.list", shoppingList); // multi-value property
+
+cmisObject.UpdateProperties(properties);
+```
+
+### Renaming an Object
+
+If you just want to change the **cmis:name** property, there is a shortcut.
+
+OpenCMIS (Java)
+{: .opencmis }
+```Java
+CmisObject cmisObject = ....
+cmisObject.rename("new name");
+```
+
+PortCMIS (C#)
+{: .portcmis }
+```csharp
+ICmisObject cmisObject = ....
+cmisObject.Rename("new name");
+```
+
+## Bulk Update
+
+
+## Updating Content
+
+See [Working with Content](content/index.html).

Added: chemistry/docs/cmis-samples/trunk/docs/samples/versions.md
URL: http://svn.apache.org/viewvc/chemistry/docs/cmis-samples/trunk/docs/samples/versions.md?rev=1747768&view=auto
==============================================================================
--- chemistry/docs/cmis-samples/trunk/docs/samples/versions.md (added)
+++ chemistry/docs/cmis-samples/trunk/docs/samples/versions.md Fri Jun 10 18:36:06 2016
@@ -0,0 +1,187 @@
+# Working with Versions
+
+<span class="cmis">CMIS 1.0</span>
+<span class="cmis">CMIS 1.1</span>
+
+Only documents can be versioned and only if the type of the document is marked as versionable.
+
+To check whether a document type is verionable or not, use the following code.
+
+OpenCMIS (Java)
+{: .opencmis }
+```java
+DocumentType documentType = (DocumentType) session.getTypeDefinition("my:documentType");
+boolean isVersionable = Boolean.TRUE.equals(documentType.isVersionable());
+```
+
+PortCMIS (C#)
+{: .portcmis }
+```csharp
+IDocumentType documentType = session.GetTypeDefinition("my:documentType") as IDocumentType;
+bool isVersionable = documentType.Versionable == true;
+```
+
+## Retrieving the Version History
+
+The code snippets below show how to retrieve the version history of a document.
+The returned list is ordered by creation date (**cmis:creationDate**). The newest version is on the top of the list, the first version on the bottom.
+If the version series is checked-out, a PWC exists and the user is allowed to see the PWC, then this PWC is the first entry in the list. 
+
+OpenCMIS (Java)
+{: .opencmis }
+```java
+Document document = ...
+
+for (Document version: document.getAllVersions())
+{
+    System.out.println(child.getVersionLabel());
+}
+```
+
+PortCMIS (C#)
+{: .portcmis }
+```csharp
+IDocument document = ...
+
+foreach (IDocument version in document.GetAllVersions())
+{
+    Console.WriteLine(child.VersionLabel);
+}
+```
+
+## Getting the Latest Version
+
+The version that has the most recent last modification date (**cmis:lastModificationDate**) is called the latest version of the version series.
+
+If you already have a version document object from a version series, you can test if it is the latest version and if not, get the latest version.
+
+!!! note 
+    The test if the document is the latest verion depends on the property **cmis:isLatestVersion**.
+    The property has to loaded with document object to make this check work. See the page about the [Operation Context](operation-context/index.html) how to accomplish that.
+
+
+OpenCMIS (Java)
+{: .opencmis }
+```java
+Document document = ...
+Document latest;
+
+if (Boolean.TRUE.equals(document.isLatestVersion())) {
+	latest = document;
+} else {
+	latest = document.getObjectOfLatestVersion(false); // major = false
+}
+```
+
+PortCMIS (C#)
+{: .portcmis }
+```csharp
+IDocument document = ...
+IDocument latest;
+
+if (document.LatestVersion == true) {
+	latest = document;
+} else {
+	latest = document.GetObjectOfLatestVersion(false); // major = false
+}
+```
+
+If you only have a document ID, you can use the following code to get latest version.
+
+OpenCMIS (Java)
+{: .opencmis }
+```java
+Document latest = session.getLatestDocumentVersion(docId);
+```
+
+PortCMIS (C#)
+{: .portcmis }
+```csharp
+IDocument latest = Session.GetLatestDocumentVersion(docId);
+```
+
+## Creating Versions
+
+To create a new version, the version series has to be checked out, updated and checked in.
+Many repositories allow a check out only on the latest version.
+
+The check-out creates a PWC (Private Working Copy). The PWC can (usually) only be seen and updated by the user who checked out the version series. There can be only one PWC per version series, which means that version series is locked while it checked out.
+
+To check if a version series is already checked out, use this snippet.
+
+OpenCMIS (Java)
+{: .opencmis }
+```java
+Document document = ...
+
+boolean isCheckedOut = Boolean.TRUE.equals(document.isVersionSeriesCheckedOut());
+String checkedOutBy = document.getVersionSeriesCheckedOutBy(); // not all repositories provide this
+```
+
+PortCMIS (C#)
+{: .portcmis }
+```csharp
+IDocument document = ...
+
+bool isCheckedOut = document.IsVersionSeriesCheckedOut == true;
+string checkedOutBy = document.VersionSeriesCheckedOutBy; // not all repositories provide this
+```
+
+### Check-out
+
+OpenCMIS (Java)
+{: .opencmis }
+```java
+Document document = ...
+
+ObjectId pwcId = document.checkOut();
+Document pwc = session.getObject(pwcId); // get PWC document
+```
+
+PortCMIS (C#)
+{: .portcmis }
+```csharp
+IDocument document = ...
+
+IObjectId pwcId = document.CheckOut();
+IDocument pwc = session.GetObject(pwcId); // get PWC document
+```
+
+### Cancel Check-out
+
+OpenCMIS (Java)
+{: .opencmis }
+```java
+Document pwc = ...
+
+pwc.cancelCheckOut();
+```
+
+PortCMIS (C#)
+{: .portcmis }
+```csharp
+IDocument pwc = ...
+
+pwc.CancelCheckOut();
+```
+
+
+### Check-in
+
+OpenCMIS (Java)
+{: .opencmis }
+```java
+Document pwc = ...
+
+ObjectId newVersionId = pwc.checkIn(true, null, null, "new version");
+```
+
+PortCMIS (C#)
+{: .portcmis }
+```csharp
+IDocument pwc = ...
+
+IObjectId newVersionId = pwc.CheckIn(true, null, null, "new version");
+```
+
+*[PWC]: Private Working Copy
\ No newline at end of file

Added: chemistry/docs/cmis-samples/trunk/mkdocs.yml
URL: http://svn.apache.org/viewvc/chemistry/docs/cmis-samples/trunk/mkdocs.yml?rev=1747768&view=auto
==============================================================================
--- chemistry/docs/cmis-samples/trunk/mkdocs.yml (added)
+++ chemistry/docs/cmis-samples/trunk/mkdocs.yml Fri Jun 10 18:36:06 2016
@@ -0,0 +1,33 @@
+site_name: 'Apache Chemistry Samples'
+site_author: 'Apache Chemistry'
+theme_dir: 'cinder-chemistry'
+use_directory_urls: false
+markdown_extensions:
+    - extra
+    - smarty
+    - admonition
+    - meta
+    - sane_lists
+extra_css:
+    - css/chemistry.css
+pages:
+    - Home: 'index.md'
+    - Samples:
+        - 'Creating a Session': 'samples/create-session.md'
+        - 'Retrieving Objects': 'samples/retrieving-objects.md'
+        - 'Creating Objects': 'samples/create-objects.md'
+        - 'Updating Objects': 'samples/update-objects.md'
+        - 'Deleting Objects': 'samples/delete-objects.md'
+        - 'Working with Content': 'samples/content.md'
+        - 'Working with Versions': 'samples/versions.md'
+        - 'Executing Queries': 'samples/queries.md'
+        - 'Understanding the Operation Context': 'samples/operation-context.md'
+        - 'Working with Lists, Paging and Skipping': 'samples/lists.md'
+        - 'Checking Allowable Actions': 'samples/allowable-actions.md'
+        - 'Managing Access Control': 'samples/access-control.md'
+        - 'Working with Properties and Secondary Types': 'samples/properties.md'
+        - 'Getting Extensions': 'samples/extensions.md'
+        - 'Retrieving the Change Log': 'samples/changelog.md'
+        - 'Working with Types': 'samples/types.md'
+        - 'CMIS Exceptions': 'samples/exceptions.md'
+    - About: 'about.md'
\ No newline at end of file