- made tracing configurable 
- optimized link cache
- cleaned up code
- updated README

git-svn-id: https://svn.apache.org/repos/asf/chemistry/dotcmis/trunk@1084737 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/DotCMIS/binding/atompub/atompub-linkcache.cs b/DotCMIS/binding/atompub/atompub-linkcache.cs
index 6296b8c..53b803c 100644
--- a/DotCMIS/binding/atompub/atompub-linkcache.cs
+++ b/DotCMIS/binding/atompub/atompub-linkcache.cs
@@ -18,15 +18,31 @@
  */

 using System;

 using System.Collections.Generic;

-using System.Linq;

 using System.Text;

-using DotCMIS.Binding.Impl;

 using System.Web;

+using DotCMIS.Binding.Impl;

 

 namespace DotCMIS.Binding.AtomPub

 {

     internal class LinkCache

     {

+        private static HashSet<string> KnownLinks = new HashSet<string>();

+

+        static LinkCache()

+        {

+            KnownLinks.Add(AtomPubConstants.RelACL);

+            KnownLinks.Add(AtomPubConstants.RelDown);

+            KnownLinks.Add(AtomPubConstants.RelUp);

+            KnownLinks.Add(AtomPubConstants.RelFolderTree);

+            KnownLinks.Add(AtomPubConstants.RelRelationships);

+            KnownLinks.Add(AtomPubConstants.RelSelf);

+            KnownLinks.Add(AtomPubConstants.RelAllowableActions);

+            KnownLinks.Add(AtomPubConstants.RelEditMedia);

+            KnownLinks.Add(AtomPubConstants.RelPolicies);

+            KnownLinks.Add(AtomPubConstants.RelVersionHistory);

+            KnownLinks.Add(AtomPubConstants.LinkRelContent);

+        }

+

         private const int CacheSizeRepositories = 10;

         private const int CacheSizeTypes = 100;

         private const int CacheSizeLinks = 400;

@@ -98,7 +114,10 @@
 

         public void AddLink(string repositoryId, string id, string rel, string type, string link)

         {

-            linkCache.Put(new string[] { repositoryId, id, rel, type }, link);

+            if (KnownLinks.Contains(rel))

+            {

+                linkCache.Put(new string[] { repositoryId, id, rel, type }, link);

+            }

         }

 

         public void RemoveLinks(string repositoryId, string id)

@@ -135,7 +154,10 @@
 

         public void AddTypeLink(string repositoryId, string id, string rel, string type, string link)

         {

-            typeLinkCache.Put(new string[] { repositoryId, id, rel, type }, link);

+            if (KnownLinks.Contains(rel))

+            {

+                typeLinkCache.Put(new string[] { repositoryId, id, rel, type }, link);

+            }

         }

 

         public void RemoveTypeLinks(string repositoryId, string id)

diff --git a/DotCMIS/binding/atompub/atompub-parser.cs b/DotCMIS/binding/atompub/atompub-parser.cs
index 060f464..37c2845 100644
--- a/DotCMIS/binding/atompub/atompub-parser.cs
+++ b/DotCMIS/binding/atompub/atompub-parser.cs
@@ -22,8 +22,6 @@
 using System.Xml;

 using System.Xml.Serialization;

 using DotCMIS.CMISWebServicesReference;

-using DotCMIS.Exceptions;

-using System.Globalization;

 

 namespace DotCMIS.Binding.AtomPub

 {

diff --git a/DotCMIS/binding/atompub/atompub-writer.cs b/DotCMIS/binding/atompub/atompub-writer.cs
index dfc449b..05b99d7 100644
--- a/DotCMIS/binding/atompub/atompub-writer.cs
+++ b/DotCMIS/binding/atompub/atompub-writer.cs
@@ -17,16 +17,14 @@
  * under the License.

  */

 using System;

-using System.Collections.Generic;

-using System.Linq;

-using System.Text;

-using DotCMIS.CMISWebServicesReference;

-using System.IO;

-using DotCMIS.Exceptions;

-using System.Xml;

 using System.Globalization;

+using System.IO;

+using System.Text;

+using System.Xml;

 using System.Xml.Serialization;

+using DotCMIS.CMISWebServicesReference;

 using DotCMIS.Enums;

+using DotCMIS.Exceptions;

 

 namespace DotCMIS.Binding.AtomPub

 {

diff --git a/DotCMIS/binding/binding-caches.cs b/DotCMIS/binding/binding-caches.cs
index 91de73d..5e69e3f 100644
--- a/DotCMIS/binding/binding-caches.cs
+++ b/DotCMIS/binding/binding-caches.cs
@@ -63,7 +63,7 @@
         private IBindingCacheLevel root;

         private string name;

         private object cacheLock = new object();

- 

+

         public Cache()

             : this("Cache")

         {

@@ -146,7 +146,10 @@
 

                 cacheLevel[keys[keys.Length - 1]] = value;

 

-                Trace.WriteLine(name + ": put [" + GetFormattedKeys(keys) + "] = " + value);

+                if (DotCMISDebug.DotCMISSwitch.TraceVerbose)

+                {

+                    Trace.WriteLine(name + ": put [" + GetFormattedKeys(keys) + "] = " + value);

+                }

             }

             finally

             {

@@ -216,7 +219,10 @@
 

                 cacheLevel.Remove(keys[keys.Length - 1]);

 

-                Trace.WriteLine(name + ": removed [" + GetFormattedKeys(keys) + "]");

+                if (DotCMISDebug.DotCMISSwitch.TraceVerbose)

+                {

+                    Trace.WriteLine(name + ": removed [" + GetFormattedKeys(keys) + "]");

+                }

             }

             finally

             {

diff --git a/DotCMIS/binding/binding-intf.cs b/DotCMIS/binding/binding-intf.cs
index 6073a5f..945fa98 100644
--- a/DotCMIS/binding/binding-intf.cs
+++ b/DotCMIS/binding/binding-intf.cs
@@ -19,11 +19,11 @@
 using System;

 using System.Collections.Generic;

 using System.Net;

+using System.ServiceModel.Channels;

+using System.ServiceModel.Description;

 using DotCMIS.Binding.Impl;

 using DotCMIS.Binding.Services;

 using DotCMIS.CMISWebServicesReference;

-using System.ServiceModel.Description;

-using System.ServiceModel.Channels;

 

 namespace DotCMIS.Binding

 {

diff --git a/DotCMIS/binding/http.cs b/DotCMIS/binding/http.cs
index 68baaa4..dc3379e 100644
--- a/DotCMIS/binding/http.cs
+++ b/DotCMIS/binding/http.cs
@@ -17,14 +17,15 @@
  * under the License.

  */

 using System;

-using System.Diagnostics;

 using System.Collections.Generic;

+using System.Diagnostics;

 using System.IO;

 using System.Net;

 using System.Text;

 using System.Web;

 using DotCMIS.Enums;

 using DotCMIS.Exceptions;

+using DotCMIS.Util;

 

 namespace DotCMIS.Binding.Impl

 {

@@ -63,7 +64,10 @@
             try

             {

                 // log before connect

-                Trace.WriteLine(method + " " + url);

+                if (DotCMISDebug.DotCMISSwitch.TraceInfo)

+                {

+                    Trace.WriteLine(method + " " + url);

+                }

 

                 // create connection           

                 HttpWebRequest conn = (HttpWebRequest)WebRequest.Create(url.Url);

diff --git a/DotCMIS/binding/services.cs b/DotCMIS/binding/services.cs
index ff0446a..4b0c742 100644
--- a/DotCMIS/binding/services.cs
+++ b/DotCMIS/binding/services.cs
@@ -16,7 +16,6 @@
  * specific language governing permissions and limitations

  * under the License.

  */

-using System;

 using System.Collections.Generic;

 using DotCMIS.Data;

 using DotCMIS.Data.Extensions;

diff --git a/DotCMIS/binding/webservices/webservices.cs b/DotCMIS/binding/webservices/webservices.cs
index e7df3b9..a6186af 100644
--- a/DotCMIS/binding/webservices/webservices.cs
+++ b/DotCMIS/binding/webservices/webservices.cs
@@ -18,16 +18,16 @@
  */

 using System;

 using System.Collections.Generic;

+using System.Reflection;

 using System.ServiceModel;

+using System.ServiceModel.Channels;

 using DotCMIS.Binding.Impl;

 using DotCMIS.Binding.Services;

 using DotCMIS.CMISWebServicesReference;

 using DotCMIS.Data;

 using DotCMIS.Data.Extensions;

-using DotCMIS.Exceptions;

 using DotCMIS.Enums;

-using System.ServiceModel.Channels;

-using System.Reflection;

+using DotCMIS.Exceptions;

 

 namespace DotCMIS.Binding.WebServices

 {

diff --git a/DotCMIS/client/client-caches.cs b/DotCMIS/client/client-caches.cs
index b5121a7..c059bf5 100644
--- a/DotCMIS/client/client-caches.cs
+++ b/DotCMIS/client/client-caches.cs
@@ -18,8 +18,6 @@
  */

 using System;

 using System.Collections.Generic;

-using System.Linq;

-using System.Text;

 using System.Threading;

 using DotCMIS.Util;

 

diff --git a/DotCMIS/client/client-intf.cs b/DotCMIS/client/client-intf.cs
index 31e935f..a4db8f7 100644
--- a/DotCMIS/client/client-intf.cs
+++ b/DotCMIS/client/client-intf.cs
@@ -18,11 +18,11 @@
  */

 using System;

 using System.Collections.Generic;

+using System.IO;

 using DotCMIS.Binding;

 using DotCMIS.Data;

 using DotCMIS.Data.Extensions;

 using DotCMIS.Enums;

-using System.IO;

 

 namespace DotCMIS.Client

 {

diff --git a/DotCMIS/client/client-types.cs b/DotCMIS/client/client-types.cs
index 39cae18..e45adc1 100644
--- a/DotCMIS/client/client-types.cs
+++ b/DotCMIS/client/client-types.cs
@@ -18,11 +18,9 @@
  */

 using System;

 using System.Collections.Generic;

-using System.Linq;

-using System.Text;

-using DotCMIS.Enums;

 using DotCMIS.Data;

 using DotCMIS.Data.Impl;

+using DotCMIS.Enums;

 

 namespace DotCMIS.Client.Impl

 {

diff --git a/DotCMIS/client/client-utils.cs b/DotCMIS/client/client-utils.cs
index ed14b20..c116c64 100644
--- a/DotCMIS/client/client-utils.cs
+++ b/DotCMIS/client/client-utils.cs
@@ -17,11 +17,10 @@
  * under the License.

  */

 using System;

+using System.Collections;

 using System.Collections.Generic;

-using System.Linq;

 using System.Text;

 using DotCMIS.Enums;

-using System.Collections;

 

 namespace DotCMIS.Client.Impl

 {

diff --git a/DotCMIS/const.cs b/DotCMIS/const.cs
index 7ee2a2e..93626ee 100644
--- a/DotCMIS/const.cs
+++ b/DotCMIS/const.cs
@@ -16,10 +16,6 @@
  * specific language governing permissions and limitations

  * under the License.

  */

-using System;

-using System.Collections.Generic;

-using System.Linq;

-using System.Text;

 

 namespace DotCMIS

 {

diff --git a/DotCMIS/data/data-intf.cs b/DotCMIS/data/data-intf.cs
index bdef85d..b37d979 100644
--- a/DotCMIS/data/data-intf.cs
+++ b/DotCMIS/data/data-intf.cs
@@ -1,4 +1,5 @@
-/*

+using System;

+/*

  * Licensed to the Apache Software Foundation (ASF) under one

  * or more contributor license agreements.  See the NOTICE file

  * distributed with this work for additional information

@@ -17,11 +18,9 @@
  * under the License.

  */

 using System.Collections.Generic;

+using System.IO;

 using DotCMIS.Data.Extensions;

 using DotCMIS.Enums;

-using System.IO;

-using System;

-using System.Collections;

 

 namespace DotCMIS.Data

 {

diff --git a/DotCMIS/data/extensions.cs b/DotCMIS/data/extensions.cs
index 81ecc1a..b0f28d7 100644
--- a/DotCMIS/data/extensions.cs
+++ b/DotCMIS/data/extensions.cs
@@ -16,10 +16,7 @@
  * specific language governing permissions and limitations

  * under the License.

  */

-using System;

 using System.Collections.Generic;

-using System.Linq;

-using System.Text;

 

 namespace DotCMIS.Data.Extensions

 {

diff --git a/DotCMIS/enums.cs b/DotCMIS/enums.cs
index 1a87f25..02a1467 100644
--- a/DotCMIS/enums.cs
+++ b/DotCMIS/enums.cs
@@ -18,11 +18,9 @@
  */

 using System;

 using System.Collections.Generic;

-using System.Linq;

-using System.Text;

 using System.Reflection;

-using DotCMIS.CMISWebServicesReference;

 using System.Xml.Serialization;

+using DotCMIS.CMISWebServicesReference;

 

 namespace DotCMIS.Enums

 {

diff --git a/DotCMIS/exceptions.cs b/DotCMIS/exceptions.cs
index c3c3b68..6ef8388 100644
--- a/DotCMIS/exceptions.cs
+++ b/DotCMIS/exceptions.cs
@@ -17,9 +17,6 @@
  * under the License.

  */

 using System;

-using System.Collections.Generic;

-using System.Linq;

-using System.Text;

 

 namespace DotCMIS.Exceptions

 {

diff --git a/DotCMIS/util.cs b/DotCMIS/util.cs
index 6264482..99e5d2d 100644
--- a/DotCMIS/util.cs
+++ b/DotCMIS/util.cs
@@ -18,11 +18,16 @@
  */

 using System;

 using System.Collections.Generic;

+using System.Diagnostics;

 using System.Linq;

-using System.Text;

 

 namespace DotCMIS.Util

 {

+    internal class DotCMISDebug

+    {

+        public static TraceSwitch DotCMISSwitch = new TraceSwitch("DotCMIS", "DotCMIS");

+    }

+

     /// <summary>

     /// LRU cache implementation. Not thread safe!

     /// </summary>

diff --git a/DotCMISUnitTest/SmokeTest.cs b/DotCMISUnitTest/SmokeTest.cs
index e91761a..0d3a161 100644
--- a/DotCMISUnitTest/SmokeTest.cs
+++ b/DotCMISUnitTest/SmokeTest.cs
@@ -171,6 +171,12 @@
                 Assert.NotNull(hit);

                 Assert.NotNull(hit["cmis:objectId"]);

                 Console.WriteLine(hit.GetPropertyValueById(PropertyIds.Name) + " (" + hit.GetPropertyValueById(PropertyIds.ObjectId) + ")");

+

+                foreach (IPropertyData prop in hit.Properties)

+                {

+                    string name = prop.QueryName;

+                    object value = prop.FirstValue;

+                }

             }

         }

 

@@ -199,6 +205,12 @@
             Assert.True(doc.AllowableActions.Actions.Contains(Actions.CanGetProperties));

             Assert.False(doc.AllowableActions.Actions.Contains(Actions.CanGetChildren));

 

+            // check type

+            IObjectType type = doc.ObjectType;

+            Assert.NotNull(type);

+            Assert.NotNull(type.Id);

+            Assert.AreEqual(properties[PropertyIds.ObjectTypeId], type.Id);

+

             // check versions

             IList<IDocument> versions = doc.GetAllVersions();

             Assert.NotNull(versions);

diff --git a/README b/README
index d160cc6..87b2507 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-Apache Chemistry DotCMIS 0.1

+Apache Chemistry DotCMIS 0.2

 ============================

 

 Apache Chemistry DotCMIS is a Content Management Interoperability Services (CMIS)

@@ -10,7 +10,7 @@
 and DotCMISDoc.chm for the API documentation.

 

 

-This is the very first release of DotCMIS. All CMIS operations and both bindings have 

+This is the second release of DotCMIS. All CMIS operations and both bindings have 

 been implemented. The API is complete and is not supposed to change in following releases. 

 The most frequently used operations have been successfully tested against a small number 

 of repositories from different vendors.

@@ -20,15 +20,36 @@
 If you find a problem, please let us know: https://issues.apache.org/jira/browse/CMIS

 

 

+Change log 

+----------

+

+DotCMIS 0.2:

+

+- Web Services compatibility has been improved. 

+- AtomPub content encoding and link cache have been improved.

+- Content-Disposition header has been added to the AtomPub setContentStream operation.

+- Compression option has been added to the AtomPub binding.

+- Another GetObject() convenience method has been added to ISession.

+- Several bug fixes.

+

+

 Known stumbling blocks

 ----------------------

 

-- The Web Services binding only works with HTTPS. The .NET framework does not allow calls

-  with UsernameTokens over plain HTTP.

+- The Web Services binding only works with HTTPS. 

+  The .NET framework does not allow calls with UsernameTokens over plain HTTP.

 

-- Not all CMIS Web Services endpoints are compatible with the .NET framework for a number

-  of reasons. Use the AtomPub binding if available. It's also faster.

+- Not all CMIS Web Services endpoints are compatible with the .NET framework for 

+  a number of reasons.

+  

+- Content is buffered in main memory when the Web Services binding is used. 

+  That can cause problems with huge documents. 

+  The maxium document size can be controlled with the SessionParameter.MessageSize 

+  parameter. The default is 4 MB. The absolute maximum is 2 GB.

 

+=> Use the AtomPub binding whenever possible! 

+   It causes less trouble, is faster, streams and can deal with documents of any size.

+  

   

 Strong-Name signing

 -------------------