Author: fmui
Date: Fri Aug 5 12:35:06 2016
New Revision: 1755309
URL: http://svn.apache.org/viewvc?rev=1755309&view=rev
Log:
Samples: more properties documentation
Modified:
chemistry/docs/cmis-samples/trunk/docs/css/chemistry.css
chemistry/docs/cmis-samples/trunk/docs/samples/content.md
chemistry/docs/cmis-samples/trunk/docs/samples/properties.md
Modified: chemistry/docs/cmis-samples/trunk/docs/css/chemistry.css
URL:
http://svn.apache.org/viewvc/chemistry/docs/cmis-samples/trunk/docs/css/chemistry.css?rev=1755309&r1=1755308&r2=1755309&view=diff
==============================================================================
--- chemistry/docs/cmis-samples/trunk/docs/css/chemistry.css (original)
+++ chemistry/docs/cmis-samples/trunk/docs/css/chemistry.css Fri Aug 5
12:35:06 2016
@@ -18,7 +18,7 @@
.cmis {
- color: white;
+ color: white;
background-color: #c17702;
border-color: #935b01;
font-size: 0.8em;
@@ -26,11 +26,12 @@
padding-right: 10px;
border-style: solid;
border-width: 1px;
- border-radius: 5px;
+ border-radius: 5px;
+ white-space: nowrap;
}
.spec {
- color: white;
+ color: white;
background-color: #008cba;
border-color: #0079a1;
font-size: 0.8em;
@@ -38,7 +39,8 @@
padding-right: 10px;
border-style: solid;
border-width: 1px;
- border-radius: 5px;
+ border-radius: 5px;
+ white-space: nowrap;
}
.admonition {
Modified: chemistry/docs/cmis-samples/trunk/docs/samples/content.md
URL:
http://svn.apache.org/viewvc/chemistry/docs/cmis-samples/trunk/docs/samples/content.md?rev=1755309&r1=1755308&r2=1755309&view=diff
==============================================================================
--- chemistry/docs/cmis-samples/trunk/docs/samples/content.md (original)
+++ chemistry/docs/cmis-samples/trunk/docs/samples/content.md Fri Aug 5
12:35:06 2016
@@ -134,6 +134,18 @@ IContentStream contentStream = document.
Stream stream = contentStream.Stream;
```
+### Getting a Content URL
+
+The AtomPub Binding and the Browser Binding can provide a URL to the content
of a document. Depending on the repository and the binding, the server might
not return the content but an error message because this URL does not include
authentication data. A user may have to re-authenticate to get the content.
+
+OpenCMIS (Java)
+{: .opencmis }
+```java
+Document document = ...
+
+String link = document.getContentUrl();
+```
+
## Updating Content
Modified: chemistry/docs/cmis-samples/trunk/docs/samples/properties.md
URL:
http://svn.apache.org/viewvc/chemistry/docs/cmis-samples/trunk/docs/samples/properties.md?rev=1755309&r1=1755308&r2=1755309&view=diff
==============================================================================
--- chemistry/docs/cmis-samples/trunk/docs/samples/properties.md (original)
+++ chemistry/docs/cmis-samples/trunk/docs/samples/properties.md Fri Aug 5
12:35:06 2016
@@ -6,11 +6,13 @@
<span class="cmis">CMIS 1.1</span>
The table below shows how the CMIS data types are mapped to Java and C# data
types.
+Multi-value property values are set and returned as lists of these data types.
+
CMIS Data Type | OpenCMIS (Java) | PortCMIS (C#)
---------------|--------------------------------|--------------
**string** | **String** | **string**
-**boolean** | **boolean** | **bool**
+**boolean** | **Boolean** | **bool**
**decimal** | **BigDecimal**, float, double, byte, short, int, long |
**decimal**, float, double
**integer** | **BigInteger**, byte, short, int, long | **BigInteger**,
sbyte, byte, short, ushort, int, uint, long
**datetime** | **GregorianCalendar**, Date | **DateTime**
@@ -19,7 +21,302 @@ CMIS Data Type | OpenCMIS (Java)
**html** | **String** | **string**
+## Properties
+
+### Retrieving Properties
+
+!!! note
+ Only the properties that have been requested are available. Use an
[Operation Context](operation-context/index.html#property-filter) to define,
which properties should be provided by the repository.
+
+The value of a property that is not set, has not been provided by the
repository, or of a property that does not exits is `null`.
+
+OpenCMIS (Java)
+{: .opencmis }
+```java
+Document doc = ...
+
+// properties defined in the CMIS specification have getters (here are just a
few examples)
+String id = doc.getId();
+String name = doc.getName();
+String creator = doc.getCreatedBy();
+GregorianCalendar lastModification = doc.getLastModificationDate();
+
+
+// all property values can be accessed by their property ID
+String name2 = doc.getPropertyValue("cmis:name");
+BigInteger projectNumber = doc.getPropertyValue("project:number");
+
+// multi value property values are always returned as lists
+List<String> colors = doc.getPropertyValue("project:colors");
+
+
+// there is detailed information about a property available for generic clients
+Property<String> nameProp = doc.getProperty("cmis:name");
+PropertyType namePropType = nameProp.getType();
+boolean nameMultiValued = nameProp.isMultiValued();
+String name3 = nameProp.getValue();
+
+Property<Boolean> lightsProp = doc.getProperty("lights:on");
+PropertyType lightsPropType = lightsProp.getType();
+boolean lightsMultiValued = lightsProp.isMultiValued();
+Boolean lightsValue = lightsProp.getValue();
+```
+
+PortCMIS (C#)
+{: .portcmis }
+```csharp
+IDocument doc = ...
+
+// properties defined in the CMIS specification have getters (here are just a
few examples)
+string id = doc.Id;
+string name = doc.Name;
+string creator = doc.CreatedBy;
+DateTime? lastModification = doc.LastModificationDate;
+
+// all property values can be accessed by their property ID
+string name2 = doc.GetPropertyAsStringValue("cmis:name");
+BigInteger projectNumber = (BigInteger)doc.GetPropertyValue("project:number");
+
+// multi value property values are always returned as lists
+IList<string> colors = (IList<string>)doc.GetPropertyValue("project:colors");
+
+// there is detailed information about a property available for generic clients
+IProperty nameProp = doc["cmis:name"];
+PropertyType? namePropType = nameProp.PropertyType;
+bool nameMultiValued = nameProp.IsMultiValued;
+string name3 = (string)nameProp.Value;
+
+IProperty lightsProp = doc["lights:on"];
+PropertyType? lightsPropType = lightsProp.PropertyType;
+bool lightsMultiValued = lightsProp.IsMultiValued;
+bool? lightsValue = (bool?)lightsProp.Value;
+
+```
+
+
+### Setting Properties
+
+Before OpenCMIS or PortCMIS sends properties to a repository, it checks the
type definition whether the properties exist or not, if the data types match,
and if multi-value properties contain `null` values. If it detects a problem,
it throws an exception before it sends anything to the repository.
+
+If a property cannot be set, for example because it is a read-only property,
OpenCMIS or PortCMIS silently filters out the property. The value is not sent
to the repository.
+
+
+OpenCMIS (Java)
+{: .opencmis }
+```java
+Map<String, Object> properties = new HashMap<String, Object>();
+
+// adding single value properties
+properties.put(PropertyIds.NAME, "the-tower");
+properties.put("project:number", 1234);
+properties.put("project:now", new GregorianCalendar());
+properties.put("project:onTime", true);
+properties.put("project:budget", new BigDecimal("654321.98"));
+
+// adding a multi value property
+List<String> colors = new ArrayList<String>();
+colors.add("red");
+colors.add("green");
+colors.add("blue");
+
+properties.put("project:colors", colors);
+
+// unsetting a property
+properties.put("project:something", null);
+
+// call create... or update...
+```
+
+PortCMIS (C#)
+{: .portcmis }
+```csharp
+IDictionary<string, object> properties = new Dictionary<string, object>();
+
+// adding single value properties
+properties[PropertyIds.Name] = "the-tower";
+properties["project:number"] = 1234;
+properties["project:now"] = DateTime.Now;
+properties["project:onTime"] = true;
+properties["project:budget"] = 654321.98M;
+
+// adding a multi value property
+IList<string> colors = new List<string>();
+colors.Add("red");
+colors.Add("green");
+colors.Add("blue");
+
+properties["project:colors"] = colors;
+
+// unsetting a property
+properties["project:something"] = null;
+
+// call Create... or Update...
+```
+
## Secondary Types
<span class="cmis">CMIS 1.1</span>
-<span class="spec">Spec 2.1.19</span>
\ No newline at end of file
+<span class="spec">Spec 2.1.19</span>
+
+Secondary types can be added during creation of an object and later added and
removed by updating its properties.
+
+In general, secondary types can be added and removed at any time.
+But a repository may have rules and constraints that prevents a client from
making those changes.
+
+
+### Setting Secondary Types
+
+OpenCMIS (Java)
+{: .opencmis }
+```java
+Folder parent = ...
+
+Map<String, Object> properties = new HashMap<String, Object>();
+
+// set standard CMIS properties
+properties.put(PropertyIds.NAME, "MyNewDocument");
+properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
+
+// add two secondary types
+List<String> secondaryTypes = new ArrayList<String>();
+secondaryTypes.add("custom:classifictaion");
+secondaryTypes.add("custom:draft");
+
+properties.put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, secondaryTypes);
+
+// set secondary type properties
+properties.put("classifictaion", "confidential");
+properties.put("draftState", "early");
+
+ContentStream contentStream = ...
+
+// create the document
+Document newDoc = parent.createDocument(properties, contentStream,
VersioningState.NONE);
+```
+
+PortCMIS (C#)
+{: .portcmis }
+```csharp
+IFolder parent = ...
+
+IDictionary<string, object> properties = new Dictionary<string, object>();
+
+// set standard CMIS properties
+properties[PropertyIds.Name] = "MyNewDocument";
+properties[PropertyIds.ObjectTypeId] = "cmis:document";
+
+// add two secondary types
+IList<string> secondaryTypes = new List<string>();
+secondaryTypes.Add("custom:classifictaion");
+secondaryTypes.Add("custom:draft");
+
+properties[PropertyIds.SecondaryObjectTypeIds] = secondaryTypes;
+
+// set secondary type properties
+properties["classifictaion"] = "confidential";
+properties["draftState"] = "early";
+
+ContentStream contentStream = ...
+
+// create the document
+IDocument newDoc = parent.CreateDocument(properties, contentStream,
VersioningState.None);
+```
+
+
+### Adding Secondary Types
+
+OpenCMIS (Java)
+{: .opencmis }
+```java
+CmisObject cmisObject = ...
+
+// get current list of secondary types
+List<String> secondaryTypes =
doc.getPropertyValue(PropertyIds.SECONDARY_OBJECT_TYPE_IDS);
+if (secondaryTypes == null) {
+ secondaryTypes = new ArrayList<String>();
+}
+
+Map<String, Object> properties = new HashMap<String, Object>();
+
+// add the new secondary type
+secondaryTypes.add("custom:classifictaion");
+properties.put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, secondaryTypes);
+
+// set secondary type property
+properties.put("classifictaion", "public");
+
+// update
+cmisObject.updateProperties(properties);
+
+```
+
+PortCMIS (C#)
+{: .portcmis }
+```csharp
+ICmisObject cmisObject = ...
+
+// get current list of secondary types
+IList<string> secondaryTypes =
(IList<string>)doc.GetPropertyValue(PropertyIds.SecondaryObjectTypeIds);
+if (secondaryTypes == null) {
+ secondaryTypes = new List<string>();
+}
+
+IDictonary<string, object> properties = new Dictonary<string, object>();
+
+// add the new secondary type
+secondaryTypes.Add("custom:classifictaion");
+properties[PropertyIds.SecondaryObjectTypeIds] = secondaryTypes;
+
+// set secondary type property
+properties["classifictaion"] = "public";
+
+// update
+cmisObject.UpdateProperties(properties);
+```
+
+
+### Removing Secondary Types
+
+OpenCMIS (Java)
+{: .opencmis }
+```java
+CmisObject cmisObject = ...
+
+// get the current list of secondary types
+List<String> secondaryTypes =
doc.getPropertyValue(PropertyIds.SECONDARY_OBJECT_TYPE_IDS);
+if (secondaryTypes == null ||
!secondaryTypes.contains("custom:classifictaion")) {
+ // there is nothing to remove
+ return;
+}
+
+Map<String, Object> properties = new HashMap<String, Object>();
+
+// remove the new secondary type
+secondaryTypes.remove("custom:classifictaion");
+properties.put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, secondaryTypes);
+
+// update
+cmisObject.updateProperties(properties);
+```
+
+PortCMIS (C#)
+{: .portcmis }
+```csharp
+ICmisObject cmisObject = ...
+
+// get current list of secondary types
+IList<string> secondaryTypes =
(IList<string>)doc.GetPropertyValue(PropertyIds.SecondaryObjectTypeIds);
+if (secondaryTypes == null ||
!secondaryTypes.Contains("custom:classifictaion")) {
+ // there is nothing to remove
+ return;
+}
+
+IDictionary<string, object> properties = new Dictionary<string, object>();
+
+// remove the secondary type
+secondaryTypes.Remove("custom:classifictaion");
+properties[PropertyIds.SecondaryObjectTypeIds] = secondaryTypes;
+
+// update
+cmisObject.UpdateProperties(properties);
+```