chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1576756 - /chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub.cs
Date Wed, 12 Mar 2014 14:40:50 GMT
Author: fmui
Date: Wed Mar 12 14:40:49 2014
New Revision: 1576756

URL: http://svn.apache.org/r1576756
Log:
fixed AtomPub change token handling (similar to CMIS-674)

Modified:
    chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub.cs

Modified: chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub.cs
URL: http://svn.apache.org/viewvc/chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub.cs?rev=1576756&r1=1576755&r2=1576756&view=diff
==============================================================================
--- chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub.cs (original)
+++ chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub.cs Wed Mar 12 14:40:49 2014
@@ -495,6 +495,37 @@ namespace DotCMIS.Binding.AtomPub
 
         // ---- common methods ----
 
+        protected cmisObjectType CreateObject(IProperties properties, string changeToken,
IList<string> policies)
+        {
+            cmisObjectType cmisObject = new cmisObjectType();
+            IProperties newProps = properties;
+
+            if (changeToken != null)
+            {
+                newProps = new Properties();
+                if (properties != null)
+                {
+                    foreach (IPropertyData prop in properties.PropertyList)
+                    {
+                        ((Properties)newProps).AddProperty(prop);
+                    }
+                }
+
+                if (newProps[PropertyIds.ChangeToken] == null)
+                {
+                    PropertyData changeTokenProperty = new PropertyData(PropertyType.String);
+                    changeTokenProperty.Id = PropertyIds.ChangeToken;
+                    changeTokenProperty.AddValue(changeToken);
+                    ((Properties)newProps).AddProperty(changeTokenProperty);
+                }
+            }
+
+            cmisObject.properties = Converter.Convert(newProps);
+            cmisObject.policyIds = Converter.ConvertPolicies(policies);
+
+            return cmisObject;
+        }
+
         protected cmisObjectType CreateIdObject(string objectId)
         {
             cmisObjectType cmisObject = new cmisObjectType();
@@ -1546,9 +1577,7 @@ namespace DotCMIS.Binding.AtomPub
             url.AddParameter(AtomPubConstants.ParamVersioningState, versioningState);
 
             // set up object and writer
-            cmisObjectType cmisObject = new cmisObjectType();
-            cmisObject.properties = Converter.Convert(properties);
-            cmisObject.policyIds = Converter.ConvertPolicies(policies);
+            cmisObjectType cmisObject = CreateObject(properties, null, policies);
 
             string mediaType = null;
             Stream stream = null;
@@ -1598,9 +1627,7 @@ namespace DotCMIS.Binding.AtomPub
 
 
             // set up object and writer
-            cmisObjectType cmisObject = new cmisObjectType();
-            cmisObject.properties = Converter.Convert(properties);
-            cmisObject.policyIds = Converter.ConvertPolicies(policies);
+            cmisObjectType cmisObject = CreateObject(properties, null, policies);
 
             AtomEntryWriter entryWriter = new AtomEntryWriter(cmisObject);
 
@@ -1645,9 +1672,7 @@ namespace DotCMIS.Binding.AtomPub
             UrlBuilder url = new UrlBuilder(link);
 
             // set up object and writer
-            cmisObjectType cmisObject = new cmisObjectType();
-            cmisObject.properties = Converter.Convert(properties);
-            cmisObject.policyIds = Converter.ConvertPolicies(policies);
+            cmisObjectType cmisObject = CreateObject(properties, null, policies);
 
             AtomEntryWriter entryWriter = new AtomEntryWriter(cmisObject);
 
@@ -1694,9 +1719,7 @@ namespace DotCMIS.Binding.AtomPub
 
 
             // set up object and writer
-            cmisObjectType cmisObject = new cmisObjectType();
-            cmisObject.properties = Converter.Convert(properties);
-            cmisObject.policyIds = Converter.ConvertPolicies(policies);
+            cmisObjectType cmisObject = CreateObject(properties, null, policies);
 
             AtomEntryWriter entryWriter = new AtomEntryWriter(cmisObject);
 
@@ -1832,9 +1855,7 @@ namespace DotCMIS.Binding.AtomPub
             url.AddParameter(AtomPubConstants.ParamChangeToken, changeToken);
 
             // set up object and writer
-            cmisObjectType cmisObject = new cmisObjectType();
-            cmisObject.properties = Converter.Convert(properties);
-
+            cmisObjectType cmisObject = CreateObject(properties, changeToken, null);
             AtomEntryWriter entryWriter = new AtomEntryWriter(cmisObject);
 
             // update
@@ -2283,9 +2304,7 @@ namespace DotCMIS.Binding.AtomPub
             url.AddParameter(AtomPubConstants.ParamCheckIn, "true");
 
             // set up object and writer
-            cmisObjectType cmisObject = new cmisObjectType();
-            cmisObject.properties = Converter.Convert(properties);
-            cmisObject.policyIds = Converter.ConvertPolicies(policies);
+            cmisObjectType cmisObject = CreateObject(properties, null, policies);
 
             if (cmisObject.properties == null)
             {



Mime
View raw message