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 2017/06/22 19:44:33 UTC
svn commit: r1799607 [1/2] - in /chemistry/portcmis/trunk/PortCMIS: binding/
binding/atompub/ binding/browser/ binding/browser/json/ client/ const/
data/ enum/ exceptions/ utils/
Author: fmui
Date: Thu Jun 22 19:44:32 2017
New Revision: 1799607
URL: http://svn.apache.org/viewvc?rev=1799607&view=rev
Log:
PortCMIS: another bunch of small corrections and improvements
Modified:
chemistry/portcmis/trunk/PortCMIS/binding/BindingCaches.cs
chemistry/portcmis/trunk/PortCMIS/binding/BindingImpl.cs
chemistry/portcmis/trunk/PortCMIS/binding/BindingIntf.cs
chemistry/portcmis/trunk/PortCMIS/binding/DateTimeHelper.cs
chemistry/portcmis/trunk/PortCMIS/binding/HttpPortable.cs
chemistry/portcmis/trunk/PortCMIS/binding/Url.cs
chemistry/portcmis/trunk/PortCMIS/binding/atompub/AtomPubBinding.cs
chemistry/portcmis/trunk/PortCMIS/binding/atompub/AtomPubUtils.cs
chemistry/portcmis/trunk/PortCMIS/binding/atompub/XmlConverter.cs
chemistry/portcmis/trunk/PortCMIS/binding/atompub/XmlWalker.cs
chemistry/portcmis/trunk/PortCMIS/binding/browser/BrowserBinding.cs
chemistry/portcmis/trunk/PortCMIS/binding/browser/BrowserConverter.cs
chemistry/portcmis/trunk/PortCMIS/binding/browser/json/Json.cs
chemistry/portcmis/trunk/PortCMIS/client/ClientCaches.cs
chemistry/portcmis/trunk/PortCMIS/client/ClientImpl.cs
chemistry/portcmis/trunk/PortCMIS/client/ClientIntf.cs
chemistry/portcmis/trunk/PortCMIS/client/ClientObjects.cs
chemistry/portcmis/trunk/PortCMIS/client/ClientUtils.cs
chemistry/portcmis/trunk/PortCMIS/const/ClientVersion.cs
chemistry/portcmis/trunk/PortCMIS/const/ExtensionFeatures.cs
chemistry/portcmis/trunk/PortCMIS/data/DataImpl.cs
chemistry/portcmis/trunk/PortCMIS/enum/Enums.cs
chemistry/portcmis/trunk/PortCMIS/exceptions/Exceptions.cs
chemistry/portcmis/trunk/PortCMIS/utils/Cache.cs
chemistry/portcmis/trunk/PortCMIS/utils/Logger.cs
Modified: chemistry/portcmis/trunk/PortCMIS/binding/BindingCaches.cs
URL: http://svn.apache.org/viewvc/chemistry/portcmis/trunk/PortCMIS/binding/BindingCaches.cs?rev=1799607&r1=1799606&r2=1799607&view=diff
==============================================================================
--- chemistry/portcmis/trunk/PortCMIS/binding/BindingCaches.cs (original)
+++ chemistry/portcmis/trunk/PortCMIS/binding/BindingCaches.cs Thu Jun 22 19:44:32 2017
@@ -22,6 +22,7 @@ using PortCMIS.Data;
using PortCMIS.Utils;
using System;
using System.Collections.Generic;
+using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading;
@@ -411,9 +412,9 @@ namespace PortCMIS.Binding
try
{
- return Int32.Parse(value);
+ return Int32.Parse(value, CultureInfo.InvariantCulture);
}
- catch (Exception)
+ catch
{
return defValue;
}
@@ -436,7 +437,7 @@ namespace PortCMIS.Binding
{
return Boolean.Parse(value);
}
- catch (Exception)
+ catch
{
return defValue;
}
@@ -542,7 +543,7 @@ namespace PortCMIS.Binding
{
private const int CacheSizeRepositories = 10;
- private IBindingCache cache;
+ private readonly IBindingCache cache;
public RepositoryInfoCache(IBindingSession session)
{
@@ -554,7 +555,7 @@ namespace PortCMIS.Binding
cache = new Cache("Repository Info Cache");
cache.Initialize(new string[] {
- typeof(DictionaryCacheLevel).FullName + " " + DictionaryCacheLevel.Capacity + "=" + repCount.ToString() });
+ typeof(DictionaryCacheLevel).FullName + " " + DictionaryCacheLevel.Capacity + "=" + repCount.ToString(CultureInfo.InvariantCulture) });
}
public void Put(IRepositoryInfo repositoryInfo)
@@ -604,8 +605,8 @@ namespace PortCMIS.Binding
cache = new Cache("Type Definition Cache");
cache.Initialize(new string[] {
- typeof(DictionaryCacheLevel).FullName + " " + DictionaryCacheLevel.Capacity + "=" + repCount.ToString(), // repository
- typeof(LruCacheLevel).FullName + " " + LruCacheLevel.MaxEntries + "=" + typeCount.ToString() // type
+ typeof(DictionaryCacheLevel).FullName + " " + DictionaryCacheLevel.Capacity + "=" + repCount.ToString(CultureInfo.InvariantCulture), // repository
+ typeof(LruCacheLevel).FullName + " " + LruCacheLevel.MaxEntries + "=" + typeCount.ToString(CultureInfo.InvariantCulture) // type
});
}
Modified: chemistry/portcmis/trunk/PortCMIS/binding/BindingImpl.cs
URL: http://svn.apache.org/viewvc/chemistry/portcmis/trunk/PortCMIS/binding/BindingImpl.cs?rev=1799607&r1=1799606&r2=1799607&view=diff
==============================================================================
--- chemistry/portcmis/trunk/PortCMIS/binding/BindingImpl.cs (original)
+++ chemistry/portcmis/trunk/PortCMIS/binding/BindingImpl.cs Thu Jun 22 19:44:32 2017
@@ -25,6 +25,7 @@ using PortCMIS.Data.Extensions;
using PortCMIS.Exceptions;
using System;
using System.Collections.Generic;
+using System.Globalization;
using System.Numerics;
namespace PortCMIS.Binding.Impl
@@ -293,7 +294,7 @@ namespace PortCMIS.Binding.Impl
{
if (value is string)
{
- return Int32.Parse((string)value);
+ return Int32.Parse((string)value, CultureInfo.InvariantCulture);
}
else if (value is int)
{
@@ -315,7 +316,7 @@ namespace PortCMIS.Binding.Impl
{
if (value is string)
{
- return Convert.ToBoolean((string)value);
+ return Convert.ToBoolean((string)value, CultureInfo.InvariantCulture);
}
else if (value is bool)
{
Modified: chemistry/portcmis/trunk/PortCMIS/binding/BindingIntf.cs
URL: http://svn.apache.org/viewvc/chemistry/portcmis/trunk/PortCMIS/binding/BindingIntf.cs?rev=1799607&r1=1799606&r2=1799607&view=diff
==============================================================================
--- chemistry/portcmis/trunk/PortCMIS/binding/BindingIntf.cs (original)
+++ chemistry/portcmis/trunk/PortCMIS/binding/BindingIntf.cs Thu Jun 22 19:44:32 2017
@@ -23,6 +23,7 @@ using PortCMIS.Binding.Services;
using PortCMIS.Client;
using System;
using System.Collections.Generic;
+using System.Globalization;
using System.Linq;
using System.Net;
using System.Net.Http;
@@ -676,9 +677,9 @@ namespace PortCMIS.Binding
{
IDictionary<string, string> result = new Dictionary<string, string>();
- result[SessionParameter.CacheSizeRepositories] = SessionParameterDefaults.CacheSizeRepositories.ToString();
- result[SessionParameter.CacheSizeTypes] = SessionParameterDefaults.CacheSizeTypes.ToString();
- result[SessionParameter.CacheSizeLinks] = SessionParameterDefaults.CacheSizeLinks.ToString();
+ result[SessionParameter.CacheSizeRepositories] = SessionParameterDefaults.CacheSizeRepositories.ToString(CultureInfo.InvariantCulture);
+ result[SessionParameter.CacheSizeTypes] = SessionParameterDefaults.CacheSizeTypes.ToString(CultureInfo.InvariantCulture);
+ result[SessionParameter.CacheSizeLinks] = SessionParameterDefaults.CacheSizeLinks.ToString(CultureInfo.InvariantCulture);
return result;
}
Modified: chemistry/portcmis/trunk/PortCMIS/binding/DateTimeHelper.cs
URL: http://svn.apache.org/viewvc/chemistry/portcmis/trunk/PortCMIS/binding/DateTimeHelper.cs?rev=1799607&r1=1799606&r2=1799607&view=diff
==============================================================================
--- chemistry/portcmis/trunk/PortCMIS/binding/DateTimeHelper.cs (original)
+++ chemistry/portcmis/trunk/PortCMIS/binding/DateTimeHelper.cs Thu Jun 22 19:44:32 2017
@@ -43,7 +43,7 @@ namespace PortCMIS.Binding
public static string FormatISO8601(DateTime dt)
{
- return dt.ToString("o");
+ return dt.ToString("o", CultureInfo.InvariantCulture);
}
}
}
Modified: chemistry/portcmis/trunk/PortCMIS/binding/HttpPortable.cs
URL: http://svn.apache.org/viewvc/chemistry/portcmis/trunk/PortCMIS/binding/HttpPortable.cs?rev=1799607&r1=1799606&r2=1799607&view=diff
==============================================================================
--- chemistry/portcmis/trunk/PortCMIS/binding/HttpPortable.cs (original)
+++ chemistry/portcmis/trunk/PortCMIS/binding/HttpPortable.cs Thu Jun 22 19:44:32 2017
@@ -143,76 +143,81 @@ namespace PortCMIS.Binding.Http
HttpRequestMessage request = new HttpRequestMessage(method, url.ToString());
- // set additional headers
-
- string userAgent = session.GetValue(SessionParameter.UserAgent) as string;
- request.Headers.UserAgent.Add(ProductInfoHeaderValue.Parse(userAgent ?? ClientVersion.UserAgent));
-
- if (headers != null)
+ try
{
- foreach (KeyValuePair<string, string> header in headers)
+ // set additional headers
+ string userAgent = session.GetValue(SessionParameter.UserAgent) as string;
+ request.Headers.UserAgent.Add(ProductInfoHeaderValue.Parse(userAgent ?? ClientVersion.UserAgent));
+
+ if (headers != null)
{
- request.Headers.TryAddWithoutValidation(header.Key, header.Value);
+ foreach (KeyValuePair<string, string> header in headers)
+ {
+ request.Headers.TryAddWithoutValidation(header.Key, header.Value);
+ }
}
- }
- // range
- if (offset != null && length != null)
- {
- long longOffset = offset.Value < 0 ? 0 : offset.Value;
- if (length.Value > 0)
+ // range
+ if (offset != null && length != null)
{
- request.Headers.Range = new RangeHeaderValue(longOffset, longOffset + length.Value - 1);
+ long longOffset = offset.Value < 0 ? 0 : offset.Value;
+ if (length.Value > 0)
+ {
+ request.Headers.Range = new RangeHeaderValue(longOffset, longOffset + length.Value - 1);
+ }
+ else
+ {
+ request.Headers.Range = new RangeHeaderValue(longOffset, null);
+ }
}
- else
+ else if (offset != null && offset.Value > 0)
{
- request.Headers.Range = new RangeHeaderValue(longOffset, null);
+ request.Headers.Range = new RangeHeaderValue(offset, null);
}
- }
- else if (offset != null && offset.Value > 0)
- {
- request.Headers.Range = new RangeHeaderValue(offset, null);
- }
-
- // content
- if (content != null)
- {
- request.Headers.TransferEncodingChunked = true;
- request.Content = content;
- }
- // authentication provider
- if (authProvider != null)
- {
- authProvider.PrepareHttpRequestMessage(request);
- }
-
- Response response;
- try
- {
- Task<HttpResponseMessage> task = Send(httpClient, request);
- if (task.IsFaulted)
+ // content
+ if (content != null)
{
- throw task.Exception;
+ request.Headers.TransferEncodingChunked = true;
+ request.Content = content;
}
- else
+
+ // authentication provider
+ if (authProvider != null)
{
- HttpResponseMessage httpResponseMessage = task.Result;
+ authProvider.PrepareHttpRequestMessage(request);
+ }
- if (authProvider != null)
+ Response response;
+ try
+ {
+ Task<HttpResponseMessage> task = Send(httpClient, request);
+ if (task.IsFaulted)
+ {
+ throw task.Exception;
+ }
+ else
{
- authProvider.HandleResponse(httpResponseMessage);
+ HttpResponseMessage httpResponseMessage = task.Result;
+
+ if (authProvider != null)
+ {
+ authProvider.HandleResponse(httpResponseMessage);
+ }
+ response = new Response(httpResponseMessage);
}
- response = new Response(httpResponseMessage);
}
- }
- catch (Exception e)
- {
- throw new CmisConnectionException("Cannot access " + url + ": " + e.Message, e);
- }
+ catch (Exception e)
+ {
+ throw new CmisConnectionException("Cannot access " + url + ": " + e.Message, e);
+ }
- return response;
+ return response;
+ } finally
+ {
+ request.Dispose();
+ }
}
private async Task<HttpResponseMessage> Send(HttpClient httpClient, HttpRequestMessage request)
Modified: chemistry/portcmis/trunk/PortCMIS/binding/Url.cs
URL: http://svn.apache.org/viewvc/chemistry/portcmis/trunk/PortCMIS/binding/Url.cs?rev=1799607&r1=1799606&r2=1799607&view=diff
==============================================================================
--- chemistry/portcmis/trunk/PortCMIS/binding/Url.cs (original)
+++ chemistry/portcmis/trunk/PortCMIS/binding/Url.cs Thu Jun 22 19:44:32 2017
@@ -55,6 +55,20 @@ namespace PortCMIS.Binding
}
/// <summary>
+ /// Creates a new instance with a given URL.
+ /// </summary>
+ /// <param name="url">the URL</param>
+ public UrlBuilder(Uri url)
+ {
+ if (url == null)
+ {
+ throw new ArgumentNullException(nameof(url));
+ }
+
+ uri = new UriBuilder(url);
+ }
+
+ /// <summary>
/// Adds a parameter.
/// </summary>
/// <param name="name">the parameter name</param>
@@ -130,7 +144,7 @@ namespace PortCMIS.Binding
foreach (char c in RFC7232Reserved)
{
- result.Replace(c.ToString(), "%" + Convert.ToByte(c).ToString("X"));
+ result.Replace(c.ToString(), "%" + Convert.ToByte(c, CultureInfo.InvariantCulture).ToString("X", CultureInfo.InvariantCulture));
}
if (quoteSlash)
@@ -186,7 +200,7 @@ namespace PortCMIS.Binding
private const string MIMESpecials = "()<>@,;:\\\"/[]?=" + "\t ";
private const string RFC2231Specials = "*'%" + MIMESpecials;
- private static readonly char[] HexDigits = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
+ private static readonly char[] HexDigits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
public static string EncodeContentDisposition(string disposition, string filename)
{
@@ -220,7 +234,7 @@ namespace PortCMIS.Binding
{
bytes = Encoding.UTF8.GetBytes(value);
}
- catch (Exception)
+ catch
{
return true;
}
Modified: chemistry/portcmis/trunk/PortCMIS/binding/atompub/AtomPubBinding.cs
URL: http://svn.apache.org/viewvc/chemistry/portcmis/trunk/PortCMIS/binding/atompub/AtomPubBinding.cs?rev=1799607&r1=1799606&r2=1799607&view=diff
==============================================================================
--- chemistry/portcmis/trunk/PortCMIS/binding/atompub/AtomPubBinding.cs (original)
+++ chemistry/portcmis/trunk/PortCMIS/binding/atompub/AtomPubBinding.cs Thu Jun 22 19:44:32 2017
@@ -611,8 +611,8 @@ namespace PortCMIS.Binding.AtomPub
return null;
}
- int begin = errorContent.IndexOf("<!--exception-->");
- int end = errorContent.IndexOf("<!--/exception-->");
+ int begin = errorContent.IndexOf("<!--exception-->", StringComparison.Ordinal);
+ int end = errorContent.IndexOf("<!--/exception-->", StringComparison.Ordinal);
if (begin == -1 || end == -1 || begin > end)
{
@@ -630,8 +630,8 @@ namespace PortCMIS.Binding.AtomPub
return message;
}
- int begin = errorContent.IndexOf("<!--message-->");
- int end = errorContent.IndexOf("<!--/message-->");
+ int begin = errorContent.IndexOf("<!--message-->", StringComparison.Ordinal);
+ int end = errorContent.IndexOf("<!--/message-->", StringComparison.Ordinal);
if (begin == -1 || end == -1 || begin > end)
{
@@ -794,16 +794,23 @@ namespace PortCMIS.Binding.AtomPub
/// </summary>
protected IResponse Post(UrlBuilder url, HttpContent content)
{
- // make the call
- IResponse resp = Session.GetHttpInvoker().InvokePOST(url, content, session);
+ try
+ {
+ // make the call
+ IResponse resp = Session.GetHttpInvoker().InvokePOST(url, content, session);
- // check response code
- if (resp.StatusCode != 201)
+ // check response code
+ if (resp.StatusCode != 201)
+ {
+ throw ConvertStatusCode(resp.StatusCode, resp.Message, resp.ErrorContent, null);
+ }
+
+ return resp;
+ }
+ finally
{
- throw ConvertStatusCode(resp.StatusCode, resp.Message, resp.ErrorContent, null);
+ content.Dispose();
}
-
- return resp;
}
/// <summary>
@@ -831,16 +838,23 @@ namespace PortCMIS.Binding.AtomPub
/// </summary>
protected IResponse Put(UrlBuilder url, IDictionary<string, string> headers, HttpContent content)
{
- // make the call
- IResponse resp = Session.GetHttpInvoker().InvokePUT(url, headers, content, session);
+ try
+ {
+ // make the call
+ IResponse resp = Session.GetHttpInvoker().InvokePUT(url, headers, content, session);
- // check response code
- if (resp.StatusCode < 200 || resp.StatusCode > 299)
+ // check response code
+ if (resp.StatusCode < 200 || resp.StatusCode > 299)
+ {
+ throw ConvertStatusCode(resp.StatusCode, resp.Message, resp.ErrorContent, null);
+ }
+
+ return resp;
+ }
+ finally
{
- throw ConvertStatusCode(resp.StatusCode, resp.Message, resp.ErrorContent, null);
+ content.Dispose();
}
-
- return resp;
}
/// <summary>
Modified: chemistry/portcmis/trunk/PortCMIS/binding/atompub/AtomPubUtils.cs
URL: http://svn.apache.org/viewvc/chemistry/portcmis/trunk/PortCMIS/binding/atompub/AtomPubUtils.cs?rev=1799607&r1=1799606&r2=1799607&view=diff
==============================================================================
--- chemistry/portcmis/trunk/PortCMIS/binding/atompub/AtomPubUtils.cs (original)
+++ chemistry/portcmis/trunk/PortCMIS/binding/atompub/AtomPubUtils.cs Thu Jun 22 19:44:32 2017
@@ -841,10 +841,6 @@ namespace PortCMIS.Binding.AtomPub
AtomPubParser.LinkRelContent
};
- static LinkCache()
- {
- }
-
private readonly IBindingCache linkCache;
private readonly IBindingCache typeLinkCache;
private readonly IBindingCache collectionLinkCache;
@@ -881,8 +877,8 @@ namespace PortCMIS.Binding.AtomPub
linkCache = new Cache("Link Cache");
linkCache.Initialize(new string[] {
- dictionaryLevelName + " " + DictionaryCacheLevel.Capacity + "=" + repCount.ToString(), // repository
- lruLevelName + " " + LruCacheLevel.MaxEntries + "=" + objCount.ToString(), // id
+ dictionaryLevelName + " " + DictionaryCacheLevel.Capacity + "=" + repCount.ToString(CultureInfo.InvariantCulture), // repository
+ lruLevelName + " " + LruCacheLevel.MaxEntries + "=" + objCount.ToString(CultureInfo.InvariantCulture), // id
dictionaryLevelName + " " + DictionaryCacheLevel.Capacity + "=16", // rel
contentTypeLevelName + " " + DictionaryCacheLevel.Capacity + "=3,"
+ DictionaryCacheLevel.SingleValue + "=true" // type
@@ -890,8 +886,8 @@ namespace PortCMIS.Binding.AtomPub
typeLinkCache = new Cache("Type Link Cache");
typeLinkCache.Initialize(new string[] {
- dictionaryLevelName + " " + DictionaryCacheLevel.Capacity + "=" + repCount.ToString(), // repository
- lruLevelName + " " + LruCacheLevel.MaxEntries + "=" + typeCount.ToString(), // id
+ dictionaryLevelName + " " + DictionaryCacheLevel.Capacity + "=" + repCount.ToString(CultureInfo.InvariantCulture), // repository
+ lruLevelName + " " + LruCacheLevel.MaxEntries + "=" + typeCount.ToString(CultureInfo.InvariantCulture), // id
dictionaryLevelName + " " + DictionaryCacheLevel.Capacity + "=16", // rel
contentTypeLevelName + " " + DictionaryCacheLevel.Capacity + "=3,"
+ DictionaryCacheLevel.SingleValue + "=true"// type
@@ -899,19 +895,19 @@ namespace PortCMIS.Binding.AtomPub
collectionLinkCache = new Cache("Collection Link Cache");
collectionLinkCache.Initialize(new string[] {
- dictionaryLevelName + " " + DictionaryCacheLevel.Capacity + "=" + repCount.ToString(), // repository
+ dictionaryLevelName + " " + DictionaryCacheLevel.Capacity + "=" + repCount.ToString(CultureInfo.InvariantCulture), // repository
dictionaryLevelName + " " + DictionaryCacheLevel.Capacity + "=8" // collection
});
templateCache = new Cache("URI Template Cache");
templateCache.Initialize(new string[] {
- dictionaryLevelName + " " + DictionaryCacheLevel.Capacity + "=" + repCount.ToString(), // repository
+ dictionaryLevelName + " " + DictionaryCacheLevel.Capacity + "=" + repCount.ToString(CultureInfo.InvariantCulture), // repository
dictionaryLevelName + " " + DictionaryCacheLevel.Capacity + "=6" // type
});
repositoryLinkCache = new Cache("Repository Link Cache");
repositoryLinkCache.Initialize(new string[] {
- dictionaryLevelName + " " + DictionaryCacheLevel.Capacity + "=" + repCount.ToString(), // repository
+ dictionaryLevelName + " " + DictionaryCacheLevel.Capacity + "=" + repCount.ToString(CultureInfo.InvariantCulture), // repository
dictionaryLevelName + " " + DictionaryCacheLevel.Capacity + "=6" // rel
});
}
Modified: chemistry/portcmis/trunk/PortCMIS/binding/atompub/XmlConverter.cs
URL: http://svn.apache.org/viewvc/chemistry/portcmis/trunk/PortCMIS/binding/atompub/XmlConverter.cs?rev=1799607&r1=1799606&r2=1799607&view=diff
==============================================================================
--- chemistry/portcmis/trunk/PortCMIS/binding/atompub/XmlConverter.cs (original)
+++ chemistry/portcmis/trunk/PortCMIS/binding/atompub/XmlConverter.cs Thu Jun 22 19:44:32 2017
@@ -30,7 +30,7 @@ using System.Xml;
namespace PortCMIS.Binding.AtomPub
{
- class XmlConverter
+ internal class XmlConverter
{
// ---------------
// --- writers ---
Modified: chemistry/portcmis/trunk/PortCMIS/binding/atompub/XmlWalker.cs
URL: http://svn.apache.org/viewvc/chemistry/portcmis/trunk/PortCMIS/binding/atompub/XmlWalker.cs?rev=1799607&r1=1799606&r2=1799607&view=diff
==============================================================================
--- chemistry/portcmis/trunk/PortCMIS/binding/atompub/XmlWalker.cs (original)
+++ chemistry/portcmis/trunk/PortCMIS/binding/atompub/XmlWalker.cs Thu Jun 22 19:44:32 2017
@@ -257,7 +257,7 @@ namespace PortCMIS.Binding.AtomPub
try
{
- return Decimal.Parse(value);
+ return Decimal.Parse(value, CultureInfo.InvariantCulture);
}
catch (Exception e)
{
Modified: chemistry/portcmis/trunk/PortCMIS/binding/browser/BrowserBinding.cs
URL: http://svn.apache.org/viewvc/chemistry/portcmis/trunk/PortCMIS/binding/browser/BrowserBinding.cs?rev=1799607&r1=1799606&r2=1799607&view=diff
==============================================================================
--- chemistry/portcmis/trunk/PortCMIS/binding/browser/BrowserBinding.cs (original)
+++ chemistry/portcmis/trunk/PortCMIS/binding/browser/BrowserBinding.cs Thu Jun 22 19:44:32 2017
@@ -282,21 +282,28 @@ namespace PortCMIS.Binding.Browser
{
MultipartFormDataContent content = new MultipartFormDataContent();
- IList<KeyValuePair<string, string>> parameters = CreateContent();
- foreach (KeyValuePair<string, string> p in parameters)
+ try
{
- content.Add(new StringContent(p.Value, Encoding.UTF8), p.Key);
- }
+ IList<KeyValuePair<string, string>> mpfParameters = CreateContent();
+ foreach (KeyValuePair<string, string> p in mpfParameters)
+ {
+ content.Add(new StringContent(p.Value, Encoding.UTF8), p.Key);
+ }
- if (Stream.Stream != null)
- {
- StreamContent streamContent = new StreamContent(Stream.Stream);
- streamContent.Headers.ContentType = MediaTypeHeaderValue.Parse(Stream.MimeType ?? "application/octet-stream");
+ if (Stream.Stream != null)
+ {
+ StreamContent streamContent = new StreamContent(Stream.Stream);
+ streamContent.Headers.ContentType = MediaTypeHeaderValue.Parse(Stream.MimeType ?? "application/octet-stream");
- content.Add(streamContent, "content", Stream.FileName ?? "content");
- }
+ content.Add(streamContent, "content", Stream.FileName ?? "content");
+ }
- return content;
+ return content;
+ } catch
+ {
+ content.Dispose();
+ throw;
+ }
}
protected IList<KeyValuePair<string, string>> CreateContent()
@@ -508,7 +515,7 @@ namespace PortCMIS.Binding.Browser
}
else
{
- return DateTimeHelper.ConvertDateTimeToMillis((DateTime)value).ToString();
+ return DateTimeHelper.ConvertDateTimeToMillis((DateTime)value).ToString(CultureInfo.InvariantCulture);
}
}
else if (value is decimal)
@@ -549,9 +556,9 @@ namespace PortCMIS.Binding.Browser
{
try
{
- return Convert.ToInt64(value).ToString("0", CultureInfo.InvariantCulture);
+ return Convert.ToInt64(value, CultureInfo.InvariantCulture).ToString("0", CultureInfo.InvariantCulture);
}
- catch (Exception)
+ catch
{
return value.ToString();
}
@@ -581,7 +588,7 @@ namespace PortCMIS.Binding.Browser
object succintObj = session.GetValue(SessionParameter.BrowserSuccinct);
if (succintObj is string)
{
- Succinct = Convert.ToBoolean((string)succintObj);
+ Succinct = Convert.ToBoolean((string)succintObj, CultureInfo.InvariantCulture);
}
DateTimeFormat = DateTimeFormat.Simple;
@@ -741,7 +748,15 @@ namespace PortCMIS.Binding.Browser
if (errorContent != null)
{
JsonParser parser = new JsonParser();
- obj = parser.Parse(new StringReader(errorContent));
+ StringReader sr = new StringReader(errorContent);
+ try
+ {
+ obj = parser.Parse(sr);
+ }
+ finally
+ {
+ sr.Dispose();
+ }
}
}
catch (JsonParseException)
@@ -1141,10 +1156,16 @@ namespace PortCMIS.Binding.Browser
FormDataComposer composer = new FormDataComposer(BindingConstants.CmisActionCreateType);
if (type != null)
{
- StringWriter sw = new StringWriter();
- JsonConverter.Convert(type, DateTimeFormat).WriteJsonString(sw);
-
- composer.Parameters[BindingConstants.ControlType] = sw.ToString();
+ StringWriter sw = new StringWriter(CultureInfo.InvariantCulture);
+ try
+ {
+ JsonConverter.Convert(type, DateTimeFormat).WriteJsonString(sw);
+ composer.Parameters[BindingConstants.ControlType] = sw.ToString();
+ }
+ finally
+ {
+ sw.Dispose();
+ }
}
// send and parse
@@ -1164,10 +1185,16 @@ namespace PortCMIS.Binding.Browser
FormDataComposer composer = new FormDataComposer(BindingConstants.CmisActionUpdateType);
if (type != null)
{
- StringWriter sw = new StringWriter();
- JsonConverter.Convert(type, DateTimeFormat).WriteJsonString(sw);
-
- composer.Parameters[BindingConstants.ControlType] = sw.ToString();
+ StringWriter sw = new StringWriter(CultureInfo.InvariantCulture);
+ try
+ {
+ JsonConverter.Convert(type, DateTimeFormat).WriteJsonString(sw);
+ composer.Parameters[BindingConstants.ControlType] = sw.ToString();
+ }
+ finally
+ {
+ sw.Dispose();
+ }
}
// send and parse
@@ -1372,7 +1399,7 @@ namespace PortCMIS.Binding.Browser
IObjectData newObj = JsonConverter.ConvertObject(json, typeCache);
- return (newObj == null ? null : newObj.Id);
+ return newObj?.Id;
}
public string CreateDocumentFromSource(string repositoryId, string sourceId, IProperties properties, string folderId,
@@ -1401,7 +1428,7 @@ namespace PortCMIS.Binding.Browser
IObjectData newObj = JsonConverter.ConvertObject(json, typeCache);
- return (newObj == null ? null : newObj.Id);
+ return newObj?.Id;
}
public string CreateFolder(string repositoryId, IProperties properties, string folderId, IList<string> policies,
@@ -1428,7 +1455,7 @@ namespace PortCMIS.Binding.Browser
IObjectData newObj = JsonConverter.ConvertObject(json, typeCache);
- return (newObj == null ? null : newObj.Id);
+ return newObj?.Id;
}
public string CreateRelationship(string repositoryId, IProperties properties, IList<string> policies, IAcl addAces,
@@ -1455,7 +1482,7 @@ namespace PortCMIS.Binding.Browser
IObjectData newObj = JsonConverter.ConvertObject(json, typeCache);
- return (newObj == null ? null : newObj.Id);
+ return newObj?.Id;
}
public string CreatePolicy(string repositoryId, IProperties properties, string folderId, IList<string> policies,
@@ -1482,7 +1509,7 @@ namespace PortCMIS.Binding.Browser
IObjectData newObj = JsonConverter.ConvertObject(json, typeCache);
- return (newObj == null ? null : newObj.Id);
+ return newObj?.Id;
}
public string CreateItem(string repositoryId, IProperties properties, string folderId, IList<string> policies,
@@ -1509,7 +1536,7 @@ namespace PortCMIS.Binding.Browser
IObjectData newObj = JsonConverter.ConvertObject(json, typeCache);
- return (newObj == null ? null : newObj.Id);
+ return newObj?.Id;
}
public IAllowableActions GetAllowableActions(string repositoryId, string objectId, IExtensionsData extension)
@@ -1675,7 +1702,7 @@ namespace PortCMIS.Binding.Browser
IObjectData newObj = JsonConverter.ConvertObject(json, typeCache);
- objectId = (newObj == null ? null : newObj.Id);
+ objectId = newObj?.Id;
SetChangeToken(ref changeToken, newObj);
}
@@ -1738,7 +1765,7 @@ namespace PortCMIS.Binding.Browser
IObjectData newObj = JsonConverter.ConvertObject(json, typeCache);
- objectId = (newObj == null ? null : newObj.Id);
+ objectId = newObj?.Id;
}
public void DeleteObject(string repositoryId, string objectId, bool? allVersions, IExtensionsData extension)
@@ -1815,7 +1842,7 @@ namespace PortCMIS.Binding.Browser
IObjectData newObj = JsonConverter.ConvertObject(json, typeCache);
- objectId = (newObj == null ? null : newObj.Id);
+ objectId = newObj?.Id;
SetChangeToken(ref changeToken, newObj);
}
@@ -1849,7 +1876,7 @@ namespace PortCMIS.Binding.Browser
IObjectData newObj = JsonConverter.ConvertObject(json, typeCache);
- objectId = (newObj == null ? null : newObj.Id);
+ objectId = newObj?.Id;
SetChangeToken(ref changeToken, newObj);
}
@@ -1880,7 +1907,7 @@ namespace PortCMIS.Binding.Browser
IObjectData newObj = JsonConverter.ConvertObject(json, typeCache);
- objectId = (newObj == null ? null : newObj.Id);
+ objectId = newObj?.Id;
SetChangeToken(ref changeToken, newObj);
}
@@ -1917,7 +1944,7 @@ namespace PortCMIS.Binding.Browser
IObjectData newObj = JsonConverter.ConvertObject(json, typeCache);
- objectId = (newObj == null ? null : newObj.Id);
+ objectId = newObj?.Id;
contentCopied = null;
}
@@ -1968,7 +1995,7 @@ namespace PortCMIS.Binding.Browser
IObjectData newObj = JsonConverter.ConvertObject(json, typeCache);
- objectId = (newObj == null ? null : newObj.Id);
+ objectId = newObj?.Id;
}
public IObjectData GetObjectOfLatestVersion(string repositoryId, string objectId, string versionSeriesId, bool? major,
Modified: chemistry/portcmis/trunk/PortCMIS/binding/browser/BrowserConverter.cs
URL: http://svn.apache.org/viewvc/chemistry/portcmis/trunk/PortCMIS/binding/browser/BrowserConverter.cs?rev=1799607&r1=1799606&r2=1799607&view=diff
==============================================================================
--- chemistry/portcmis/trunk/PortCMIS/binding/browser/BrowserConverter.cs (original)
+++ chemistry/portcmis/trunk/PortCMIS/binding/browser/BrowserConverter.cs Thu Jun 22 19:44:32 2017
@@ -18,7 +18,7 @@
*/
using PortCMIS.Binding.Browser.Json;
-using PortCMIS.Const;
+using PortCMIS.Constants;
using PortCMIS.Data;
using PortCMIS.Data.Extensions;
using PortCMIS.Enums;
@@ -29,7 +29,7 @@ using System.Numerics;
namespace PortCMIS.Binding.Browser
{
- internal class JsonConverter
+ internal static class JsonConverter
{
public enum PropertyMode
{
@@ -434,7 +434,7 @@ namespace PortCMIS.Binding.Browser
canCreate.Add(o.ToString().GetCmisEnum<PropertyType>());
}
}
- catch (Exception)
+ catch
{
// ignore
}
Modified: chemistry/portcmis/trunk/PortCMIS/binding/browser/json/Json.cs
URL: http://svn.apache.org/viewvc/chemistry/portcmis/trunk/PortCMIS/binding/browser/json/Json.cs?rev=1799607&r1=1799606&r2=1799607&view=diff
==============================================================================
--- chemistry/portcmis/trunk/PortCMIS/binding/browser/json/Json.cs (original)
+++ chemistry/portcmis/trunk/PortCMIS/binding/browser/json/Json.cs Thu Jun 22 19:44:32 2017
@@ -44,7 +44,7 @@ namespace PortCMIS.Binding.Browser.Json
/// <summary>
/// JSON Value helpers.
/// </summary>
- internal class JsonValue
+ internal static class JsonValue
{
public static void WriteJsonString(object value, TextWriter writer)
{
@@ -114,10 +114,10 @@ namespace PortCMIS.Binding.Browser.Json
try
{
- long longValue = Convert.ToInt64(value);
+ long longValue = Convert.ToInt64(value, CultureInfo.InvariantCulture);
writer.Write(longValue.ToString("0", CultureInfo.InvariantCulture));
}
- catch (Exception)
+ catch
{
writer.Write(value.ToString());
}
@@ -363,9 +363,16 @@ namespace PortCMIS.Binding.Browser.Json
public override string ToString()
{
- StringWriter sw = new StringWriter();
- WriteJsonString(sw);
- return sw.ToString();
+ StringWriter sw = new StringWriter(CultureInfo.InvariantCulture);
+ try
+ {
+ WriteJsonString(sw);
+ return sw.ToString();
+ }
+ finally
+ {
+ sw.Dispose();
+ }
}
}
@@ -403,9 +410,16 @@ namespace PortCMIS.Binding.Browser.Json
public override string ToString()
{
- StringWriter sw = new StringWriter();
- WriteJsonString(sw);
- return sw.ToString();
+ StringWriter sw = new StringWriter(CultureInfo.InvariantCulture);
+ try
+ {
+ WriteJsonString(sw);
+ return sw.ToString();
+ }
+ finally
+ {
+ sw.Dispose();
+ }
}
}
@@ -423,7 +437,7 @@ namespace PortCMIS.Binding.Browser.Json
public const int StatusEnd = 6;
public const int StatusInError = -1;
- private Yylex lexer = new Yylex(null);
+ private readonly Yylex lexer = new Yylex(null);
private Yytoken token = null;
private int status = StatusInit;
@@ -927,7 +941,7 @@ namespace PortCMIS.Binding.Browser.Json
private bool zzAtEOF;
// user code:
- private StringBuilder sb = new StringBuilder();
+ private readonly StringBuilder sb = new StringBuilder();
public Yylex(TextReader input)
{
Modified: chemistry/portcmis/trunk/PortCMIS/client/ClientCaches.cs
URL: http://svn.apache.org/viewvc/chemistry/portcmis/trunk/PortCMIS/client/ClientCaches.cs?rev=1799607&r1=1799606&r2=1799607&view=diff
==============================================================================
--- chemistry/portcmis/trunk/PortCMIS/client/ClientCaches.cs (original)
+++ chemistry/portcmis/trunk/PortCMIS/client/ClientCaches.cs Thu Jun 22 19:44:32 2017
@@ -20,6 +20,7 @@
using PortCMIS.Utils;
using System;
using System.Collections.Generic;
+using System.Globalization;
namespace PortCMIS.Client
{
@@ -186,7 +187,7 @@ namespace PortCMIS.Client
string cacheSizeStr;
if (parameters.TryGetValue(SessionParameter.CacheSizeObjects, out cacheSizeStr))
{
- cacheSize = Int32.Parse(cacheSizeStr);
+ cacheSize = Int32.Parse(cacheSizeStr, CultureInfo.InvariantCulture);
if (cacheSize < 0)
{
cacheSize = 0;
@@ -202,7 +203,7 @@ namespace PortCMIS.Client
string cacheTtlStr;
if (parameters.TryGetValue(SessionParameter.CacheTTLObjects, out cacheTtlStr))
{
- cacheTtl = Int32.Parse(cacheTtlStr);
+ cacheTtl = Int32.Parse(cacheTtlStr, CultureInfo.InvariantCulture);
if (cacheTtl < 0)
{
cacheTtl = 2 * 60 * 60 * 1000;
@@ -218,14 +219,14 @@ namespace PortCMIS.Client
string pathToIdSizeStr;
if (parameters.TryGetValue(SessionParameter.CacheSizePathToId, out pathToIdSizeStr))
{
- pathToIdSize = Int32.Parse(pathToIdSizeStr);
+ pathToIdSize = Int32.Parse(pathToIdSizeStr, CultureInfo.InvariantCulture);
if (pathToIdSize < 0)
{
pathToIdSize = 0;
}
}
}
- catch (Exception) { }
+ catch { }
// path-to-id time-to-live
pathToIdTtl = 30 * 60 * 1000;
@@ -234,14 +235,14 @@ namespace PortCMIS.Client
string pathToIdTtlStr;
if (parameters.TryGetValue(SessionParameter.CacheTTLPathToId, out pathToIdTtlStr))
{
- pathToIdTtl = Int32.Parse(pathToIdTtlStr);
+ pathToIdTtl = Int32.Parse(pathToIdTtlStr, CultureInfo.InvariantCulture);
if (pathToIdTtl < 0)
{
pathToIdTtl = 30 * 60 * 1000;
}
}
}
- catch (Exception) { }
+ catch { }
InitializeInternals();
}
Modified: chemistry/portcmis/trunk/PortCMIS/client/ClientImpl.cs
URL: http://svn.apache.org/viewvc/chemistry/portcmis/trunk/PortCMIS/client/ClientImpl.cs?rev=1799607&r1=1799606&r2=1799607&view=diff
==============================================================================
--- chemistry/portcmis/trunk/PortCMIS/client/ClientImpl.cs (original)
+++ chemistry/portcmis/trunk/PortCMIS/client/ClientImpl.cs Thu Jun 22 19:44:32 2017
@@ -85,15 +85,21 @@ namespace PortCMIS.Client.Impl
{
ICmisBinding binding = CmisBindingHelper.CreateBinding(parameters);
- IList<IRepositoryInfo> repositoryInfos = binding.GetRepositoryService().GetRepositoryInfos(null);
+ try
+ {
+ IList<IRepositoryInfo> repositoryInfos = binding.GetRepositoryService().GetRepositoryInfos(null);
+
+ IList<IRepository> result = new List<IRepository>();
+ foreach (IRepositoryInfo data in repositoryInfos)
+ {
+ result.Add(new Repository(data, parameters, this, objectFactory, binding.GetAuthenticationProvider(), cache));
+ }
- IList<IRepository> result = new List<IRepository>();
- foreach (IRepositoryInfo data in repositoryInfos)
+ return result;
+ } finally
{
- result.Add(new Repository(data, parameters, this, objectFactory, binding.GetAuthenticationProvider(), cache));
+ binding.Dispose();
}
-
- return result;
}
}
@@ -212,19 +218,21 @@ namespace PortCMIS.Client.Impl
/// </summary>
public class Session : ISession
{
- private static HashSet<Updatability> CreateUpdatability = new HashSet<Updatability>();
- private static HashSet<Updatability> CreateAndCheckoutUpdatability = new HashSet<Updatability>();
- static Session()
- {
- CreateUpdatability.Add(Updatability.OnCreate);
- CreateUpdatability.Add(Updatability.ReadWrite);
- CreateAndCheckoutUpdatability.Add(Updatability.OnCreate);
- CreateAndCheckoutUpdatability.Add(Updatability.ReadWrite);
- CreateAndCheckoutUpdatability.Add(Updatability.WhenCheckedOut);
- }
+ private static HashSet<Updatability> CreateUpdatability = new HashSet<Updatability>()
+ {
+ Updatability.OnCreate,
+ Updatability.ReadWrite
+ };
+
+ private static HashSet<Updatability> CreateAndCheckoutUpdatability = new HashSet<Updatability>()
+ {
+ Updatability.OnCreate,
+ Updatability.ReadWrite,
+ Updatability.WhenCheckedOut
+ };
/// <summary>
- /// Initial default operation context.
+ /// Initial default operation defaultContext.
/// </summary>
protected static IOperationContext FallbackContext = new OperationContext(null, false, true, false, IncludeRelationships.None, null, true, null, true, 100);
@@ -267,7 +275,7 @@ namespace PortCMIS.Client.Impl
/// </summary>
protected bool cachePathOmit;
- private IOperationContext context = FallbackContext;
+ private IOperationContext defaultContext = FallbackContext;
/// <inheritdoc/>
public IOperationContext DefaultContext
@@ -276,14 +284,14 @@ namespace PortCMIS.Client.Impl
{
lock (sessionLock)
{
- return context;
+ return defaultContext;
}
}
set
{
lock (sessionLock)
{
- context = value ?? FallbackContext;
+ defaultContext = value ?? FallbackContext;
}
}
}
@@ -420,7 +428,7 @@ namespace PortCMIS.Client.Impl
}
}
- // session context
+ // session defaultContext
/// <inheritdoc/>
public IOperationContext CreateOperationContext()
@@ -1116,7 +1124,7 @@ namespace PortCMIS.Client.Impl
string newId = Binding.GetObjectService().CreateDocument(RepositoryId, ObjectFactory.ConvertProperties(properties, null, null,
(versioningState == VersioningState.CheckedOut ? CreateAndCheckoutUpdatability : CreateUpdatability)),
- (folderId == null ? null : folderId.Id), contentStream, versioningState, ObjectFactory.ConvertPolicies(policies),
+ folderId?.Id, contentStream, versioningState, ObjectFactory.ConvertPolicies(policies),
ObjectFactory.ConvertAces(addAces), ObjectFactory.ConvertAces(removeAces), null);
return newId == null ? null : CreateObjectId(newId);
@@ -1161,7 +1169,7 @@ namespace PortCMIS.Client.Impl
string newId = Binding.GetObjectService().CreateDocumentFromSource(RepositoryId, source.Id,
ObjectFactory.ConvertProperties(properties, type, secondaryTypes,
(versioningState == VersioningState.CheckedOut ? CreateAndCheckoutUpdatability : CreateUpdatability)),
- (folderId == null ? null : folderId.Id),
+ folderId?.Id,
versioningState, ObjectFactory.ConvertPolicies(policies), ObjectFactory.ConvertAces(addAces),
ObjectFactory.ConvertAces(removeAces), null);
@@ -1186,7 +1194,7 @@ namespace PortCMIS.Client.Impl
CheckProperties(properties);
string newId = Binding.GetObjectService().CreateFolder(RepositoryId, ObjectFactory.ConvertProperties(properties, null, null, CreateUpdatability),
- (folderId == null ? null : folderId.Id), ObjectFactory.ConvertPolicies(policies), ObjectFactory.ConvertAces(addAces),
+ folderId?.Id, ObjectFactory.ConvertPolicies(policies), ObjectFactory.ConvertAces(addAces),
ObjectFactory.ConvertAces(removeAces), null);
return newId == null ? null : CreateObjectId(newId);
@@ -1205,7 +1213,7 @@ namespace PortCMIS.Client.Impl
CheckProperties(properties);
string newId = Binding.GetObjectService().CreatePolicy(RepositoryId, ObjectFactory.ConvertProperties(properties, null, null, CreateUpdatability),
- (folderId == null ? null : folderId.Id), ObjectFactory.ConvertPolicies(policies), ObjectFactory.ConvertAces(addAces),
+ folderId?.Id, ObjectFactory.ConvertPolicies(policies), ObjectFactory.ConvertAces(addAces),
ObjectFactory.ConvertAces(removeAces), null);
return newId == null ? null : CreateObjectId(newId);
@@ -1224,7 +1232,7 @@ namespace PortCMIS.Client.Impl
CheckProperties(properties);
string newId = Binding.GetObjectService().CreateItem(RepositoryId, ObjectFactory.ConvertProperties(properties, null, null, CreateUpdatability),
- (folderId == null ? null : folderId.Id), ObjectFactory.ConvertPolicies(policies), ObjectFactory.ConvertAces(addAces),
+ folderId?.Id, ObjectFactory.ConvertPolicies(policies), ObjectFactory.ConvertAces(addAces),
ObjectFactory.ConvertAces(removeAces), null);
return newId == null ? null : CreateObjectId(newId);
@@ -1264,7 +1272,7 @@ namespace PortCMIS.Client.Impl
}
string id = objectId.Id;
- string typeId = (type == null ? null : type.Id);
+ string typeId = type?.Id;
IRelationshipService service = Binding.GetRelationshipService();
IOperationContext ctxt = new OperationContext(context);
Modified: chemistry/portcmis/trunk/PortCMIS/client/ClientIntf.cs
URL: http://svn.apache.org/viewvc/chemistry/portcmis/trunk/PortCMIS/client/ClientIntf.cs?rev=1799607&r1=1799606&r2=1799607&view=diff
==============================================================================
--- chemistry/portcmis/trunk/PortCMIS/client/ClientIntf.cs (original)
+++ chemistry/portcmis/trunk/PortCMIS/client/ClientIntf.cs Thu Jun 22 19:44:32 2017
@@ -143,17 +143,17 @@ namespace PortCMIS.Client
ICmisBinding Binding { get; }
/// <value>
- /// Gets and sets the default operation context.
+ /// Gets and sets the default operation defaultContext.
/// </value>
IOperationContext DefaultContext { get; set; }
/// <summary>
- /// Creates a new operation context object.
+ /// Creates a new operation defaultContext object.
/// </summary>
IOperationContext CreateOperationContext();
/// <summary>
- /// Creates a new operation context object with the given parameters.
+ /// Creates a new operation defaultContext object with the given parameters.
/// </summary>
IOperationContext CreateOperationContext(HashSet<string> filter, bool includeAcls, bool includeAllowableActions, bool includePolicies,
IncludeRelationships includeRelationships, HashSet<string> renditionFilter, bool includePathSegments, string orderBy,
@@ -235,7 +235,7 @@ namespace PortCMIS.Client
/// <summary>
/// Gets the root folder of the repository with the given <see cref="PortCMIS.Client.IOperationContext"/>.
/// </summary>
- /// <param name="context">the operation context</param>
+ /// <param name="context">the operation defaultContext</param>
/// <returns>the root folder object, not <c>null</c></returns>
/// <cmis>1.0</cmis>
IFolder GetRootFolder(IOperationContext context);
@@ -248,7 +248,7 @@ namespace PortCMIS.Client
IItemEnumerable<IDocument> GetCheckedOutDocs();
/// <summary>
- /// Returns all checked out documents with the given operation context.
+ /// Returns all checked out documents with the given operation defaultContext.
/// </summary>
/// <returns></returns>
/// <cmis>1.0</cmis>
@@ -256,7 +256,7 @@ namespace PortCMIS.Client
/// <summary>
/// Gets a CMIS object from the session cache. If the object is not in the cache or the cache is
- /// turned off per default operation context, it will load the object from the repository and puts
+ /// turned off per default operation defaultContext, it will load the object from the repository and puts
/// it into the cache.
/// <para>
/// This method might return a stale object if the object has been found in the cache and has
@@ -271,7 +271,7 @@ namespace PortCMIS.Client
/// <summary>
/// Gets a CMIS object from the session cache. If the object is not in the cache or the cache is
- /// turned off or the given operation context has caching turned off, it will load the object
+ /// turned off or the given operation defaultContext has caching turned off, it will load the object
/// from the repository and puts it into the cache.
/// <para>
/// This method might return a stale object if the object has been found in the cache and has
@@ -281,13 +281,13 @@ namespace PortCMIS.Client
/// </para>
/// </summary>
/// <param name="objectId">the object ID</param>
- /// <param name="context">the operation context</param>
+ /// <param name="context">the operation defaultContext</param>
/// <cmis>1.0</cmis>
ICmisObject GetObject(IObjectId objectId, IOperationContext context);
/// <summary>
/// Gets a CMIS object from the session cache. If the object is not in the cache or the cache is
- /// turned off per default operation context, it will load the object from the repository and puts
+ /// turned off per default operation defaultContext, it will load the object from the repository and puts
/// it into the cache.
/// <para>
/// This method might return a stale object if the object has been found in the cache and has
@@ -302,7 +302,7 @@ namespace PortCMIS.Client
/// <summary>
/// Gets a CMIS object from the session cache. If the object is not in the cache or the cache is
- /// turned off or the given operation context has caching turned off, it will load the object
+ /// turned off or the given operation defaultContext has caching turned off, it will load the object
/// from the repository and puts it into the cache.
/// <para>
/// This method might return a stale object if the object has been found in the cache and has
@@ -312,13 +312,13 @@ namespace PortCMIS.Client
/// </para>
/// </summary>
/// <param name="objectId">the object ID</param>
- /// <param name="context">the operation context</param>
+ /// <param name="context">the operation defaultContext</param>
/// <cmis>1.0</cmis>
ICmisObject GetObject(string objectId, IOperationContext context);
/// <summary>
/// Gets a CMIS object from the session cache. If the object is not in the cache or the cache is
- /// turned off per default operation context, it will load the object
+ /// turned off per default operation defaultContext, it will load the object
/// from the repository and puts it into the cache.
/// <para>
/// This method might return a stale object if the object has been found in the cache and has
@@ -333,7 +333,7 @@ namespace PortCMIS.Client
/// <summary>
/// Gets a CMIS object from the session cache. If the object is not in the cache or the cache is
- /// turned off or the given operation context has caching turned off, it will load the object
+ /// turned off or the given operation defaultContext has caching turned off, it will load the object
/// from the repository and puts it into the cache.
/// <para>
/// This method might return a stale object if the object has been found in the cache and has
@@ -343,13 +343,13 @@ namespace PortCMIS.Client
/// </para>
/// </summary>
/// <param name="path">the path to the object</param>
- /// <param name="context">the operation context</param>
+ /// <param name="context">the operation defaultContext</param>
/// <cmis>1.0</cmis>
ICmisObject GetObjectByPath(string path, IOperationContext context);
/// <summary>
/// Gets a CMIS object from the session cache. If the object is not in the cache or the cache is
- /// turned off per default operation context, it will load the object
+ /// turned off per default operation defaultContext, it will load the object
/// from the repository and puts it into the cache.
/// <para>
/// This method might return a stale object if the object has been found in the cache and has
@@ -365,7 +365,7 @@ namespace PortCMIS.Client
/// <summary>
/// Gets a CMIS object from the session cache. If the object is not in the cache or the cache is
- /// turned off or the given operation context has caching turned off, it will load the object
+ /// turned off or the given operation defaultContext has caching turned off, it will load the object
/// from the repository and puts it into the cache.
/// <para>
/// This method might return a stale object if the object has been found in the cache and has
@@ -376,7 +376,7 @@ namespace PortCMIS.Client
/// </summary>
/// <param name="parentPath">the path of the parent folder</param>
/// <param name="name">name of the object</param>
- /// <param name="context">the operation context</param>
+ /// <param name="context">the operation defaultContext</param>
/// <cmis>1.0</cmis>
ICmisObject GetObjectByPath(string parentPath, string name, IOperationContext context);
@@ -388,10 +388,10 @@ namespace PortCMIS.Client
IDocument GetLatestDocumentVersion(string objectId);
/// <summary>
- /// Gets the latest version in a version series with the given operation context.
+ /// Gets the latest version in a version series with the given operation defaultContext.
/// </summary>
/// <param name="objectId">the document ID of an arbitrary version in the version series</param>
- /// <param name="context">the operation context</param>
+ /// <param name="context">the operation defaultContext</param>
/// <cmis>1.0</cmis>
IDocument GetLatestDocumentVersion(string objectId, IOperationContext context);
@@ -403,19 +403,19 @@ namespace PortCMIS.Client
IDocument GetLatestDocumentVersion(IObjectId objectId);
/// <summary>
- /// Gets the latest version in a version series with the given operation context.
+ /// Gets the latest version in a version series with the given operation defaultContext.
/// </summary>
/// <param name="objectId">the document ID of an arbitrary version in the version series</param>
- /// <param name="context">the operation context</param>
+ /// <param name="context">the operation defaultContext</param>
/// <cmis>1.0</cmis>
IDocument GetLatestDocumentVersion(IObjectId objectId, IOperationContext context);
/// <summary>
- /// Gets the latest version in a version series with the given operation context.
+ /// Gets the latest version in a version series with the given operation defaultContext.
/// </summary>
/// <param name="objectId">the document ID of an arbitrary version in the version series</param>
/// <param name="major">defines if the latest major or the latest minor version should be returned</param>
- /// <param name="context">the operation context</param>
+ /// <param name="context">the operation defaultContext</param>
/// <cmis>1.0</cmis>
IDocument GetLatestDocumentVersion(IObjectId objectId, bool major, IOperationContext context);
@@ -485,7 +485,7 @@ namespace PortCMIS.Client
/// <param name="typeId">a type ID</param>
/// <param name="where">WHERE part of the query, may be <c>null</c></param>
/// <param name="searchAllVersions">indicates whether all versions should searched or not</param>
- /// <param name="context">the operation context</param>
+ /// <param name="context">the operation defaultContext</param>
/// <returns>query results</returns>
/// <cmis>1.0</cmis>
IItemEnumerable<ICmisObject> QueryObjects(string typeId, string where, bool searchAllVersions, IOperationContext context);
@@ -532,7 +532,7 @@ namespace PortCMIS.Client
/// <param name="changeLogToken">the change log token, may be <c>null</c></param>
/// <param name="includeProperties">indicates whether properties should be included or</param>
/// <param name="maxNumItems">max number of changes</param>
- /// <param name="context">the operation context</param>
+ /// <param name="context">the operation defaultContext</param>
/// <returns>the change events</returns>
/// <cmis>1.0</cmis>
IChangeEvents GetContentChanges(string changeLogToken, bool includeProperties, long maxNumItems, IOperationContext context);
@@ -842,7 +842,7 @@ namespace PortCMIS.Client
}
/// <summary>
- /// Operation context interface.
+ /// Operation defaultContext interface.
/// </summary>
public interface IOperationContext
{
@@ -1181,7 +1181,7 @@ namespace PortCMIS.Client
/// true if all document versions should be included in
/// the search results, false if only the latest document
/// versions should be included in the search results</param>
- /// <param name='context'>the operation context to use</param>
+ /// <param name='context'>the operation defaultContext to use</param>
IItemEnumerable<IQueryResult> Query(bool searchAllVersions, IOperationContext context);
}
@@ -1349,9 +1349,9 @@ namespace PortCMIS.Client
IDocument GetRenditionDocument();
/// <summary>
- /// Returns the rendition document using the provided operation context if the rendition is a stand-alone document.
+ /// Returns the rendition document using the provided operation defaultContext if the rendition is a stand-alone document.
/// </summary>
- /// <param name="context">the operation context</param>
+ /// <param name="context">the operation defaultContext</param>
/// <returns>the rendition document or <c>null</c> if there is no rendition document</returns>
IDocument GetRenditionDocument(IOperationContext context);
@@ -1986,10 +1986,10 @@ namespace PortCMIS.Client
IDocument GetObjectOfLatestVersion(bool major);
/// <summary>
- /// Fetches the latest major or minor version of this document with the given operation context.
+ /// Fetches the latest major or minor version of this document with the given operation defaultContext.
/// </summary>
/// <param name="major">indicates if the latest major or the very last version should be returned</param>
- /// <param name="context">the operation context</param>
+ /// <param name="context">the operation defaultContext</param>
/// <returns>the latest document object</returns>
IDocument GetObjectOfLatestVersion(bool major, IOperationContext context);
@@ -1999,7 +1999,7 @@ namespace PortCMIS.Client
IList<IDocument> GetAllVersions();
/// <summary>
- /// Gets a list of all versions in this version series using the given operation context.
+ /// Gets a list of all versions in this version series using the given operation defaultContext.
/// </summary>
IList<IDocument> GetAllVersions(IOperationContext context);
@@ -2199,9 +2199,9 @@ namespace PortCMIS.Client
IItemEnumerable<IDocument> GetCheckedOutDocs();
/// <summary>
- /// Returns all checked out documents in this folder using the given operation context.
+ /// Returns all checked out documents in this folder using the given operation defaultContext.
/// </summary>
- /// <param name="context">the operation context</param>
+ /// <param name="context">the operation defaultContext</param>
/// <returns>the checked out documents</returns>
IItemEnumerable<IDocument> GetCheckedOutDocs(IOperationContext context);
}
Modified: chemistry/portcmis/trunk/PortCMIS/client/ClientObjects.cs
URL: http://svn.apache.org/viewvc/chemistry/portcmis/trunk/PortCMIS/client/ClientObjects.cs?rev=1799607&r1=1799606&r2=1799607&view=diff
==============================================================================
--- chemistry/portcmis/trunk/PortCMIS/client/ClientObjects.cs (original)
+++ chemistry/portcmis/trunk/PortCMIS/client/ClientObjects.cs Thu Jun 22 19:44:32 2017
@@ -25,6 +25,7 @@ using PortCMIS.Enums;
using PortCMIS.Exceptions;
using System;
using System.Collections.Generic;
+using System.Globalization;
using System.IO;
using System.Numerics;
using System.Text;
@@ -93,7 +94,7 @@ namespace PortCMIS.Client.Impl
}
/// <summary>
- /// Gets the operation context that was used to fetch this object.
+ /// Gets the operation defaultContext that was used to fetch this object.
/// </summary>
protected virtual IOperationContext CreationContext { get; private set; }
@@ -118,7 +119,7 @@ namespace PortCMIS.Client.Impl
/// <param name="session">the current session</param>
/// <param name="objectType">the object type</param>
/// <param name="objectData">the low-level object data</param>
- /// <param name="context">the operation context that was used to fetch this object</param>
+ /// <param name="context">the operation defaultContext that was used to fetch this object</param>
protected void Initialize(ISession session, IObjectType objectType, IObjectData objectData, IOperationContext context)
{
if (session == null)
@@ -485,7 +486,7 @@ namespace PortCMIS.Client.Impl
return null;
}
- return Convert.ToString(value);
+ return Convert.ToString(value, CultureInfo.InvariantCulture);
}
/// <inheritdoc/>
@@ -502,7 +503,7 @@ namespace PortCMIS.Client.Impl
return (long)((BigInteger)value);
}
- return Convert.ToInt64(value);
+ return Convert.ToInt64(value, CultureInfo.InvariantCulture);
}
/// <inheritdoc/>
@@ -519,7 +520,7 @@ namespace PortCMIS.Client.Impl
return Convert.ToBoolean((long)((BigInteger)value));
}
- return Convert.ToBoolean(value);
+ return Convert.ToBoolean(value, CultureInfo.InvariantCulture);
}
/// <inheritdoc/>
@@ -531,7 +532,7 @@ namespace PortCMIS.Client.Impl
return null;
}
- return Convert.ToDateTime(value);
+ return Convert.ToDateTime(value, CultureInfo.InvariantCulture);
}
// --- allowable actions ---
@@ -816,7 +817,7 @@ namespace PortCMIS.Client.Impl
if (p == null || p.Object == null || p.Object.Properties == null)
{
// should not happen...
- throw new CmisInvalidServerData("Repository sent invalid data!");
+ throw new CmisInvalidServerDataException("Repository sent invalid data!");
}
// get id property
@@ -824,7 +825,7 @@ namespace PortCMIS.Client.Impl
if (idProperty == null || idProperty.PropertyType != PropertyType.Id)
{
// the repository sent an object without a valid object id...
- throw new CmisInvalidServerData("Repository sent invalid data! No object ID!");
+ throw new CmisInvalidServerDataException("Repository sent invalid data! No object ID!");
}
// fetch the object and make sure it is a folder
@@ -833,7 +834,7 @@ namespace PortCMIS.Client.Impl
if (parentFolder == null)
{
// the repository sent an object that is not a folder...
- throw new CmisInvalidServerData("Repository sent invalid data! Object is not a folder!");
+ throw new CmisInvalidServerDataException("Repository sent invalid data! Object is not a folder!");
}
parents.Add(parentFolder);
@@ -860,7 +861,7 @@ namespace PortCMIS.Client.Impl
if (p == null || p.Object == null || p.Object.Properties == null)
{
// should not happen...
- throw new CmisInvalidServerData("Repository sent invalid data!");
+ throw new CmisInvalidServerDataException("Repository sent invalid data!");
}
// get path property
@@ -868,20 +869,20 @@ namespace PortCMIS.Client.Impl
if (pathProperty == null || pathProperty.PropertyType != PropertyType.String)
{
// the repository sent a folder without a valid path...
- throw new CmisInvalidServerData("Repository sent invalid data! No path property!");
+ throw new CmisInvalidServerDataException("Repository sent invalid data! No path property!");
}
if (p.RelativePathSegment == null)
{
// the repository didn't send a relative path segment
- throw new CmisInvalidServerData("Repository sent invalid data! No relative path segment!");
+ throw new CmisInvalidServerDataException("Repository sent invalid data! No relative path segment!");
}
string folderPath = pathProperty.FirstValue as string;
if (folderPath == null)
{
// the repository sent a folder without a valid path...
- throw new CmisInvalidServerData("Repository sent invalid data! No path property value!");
+ throw new CmisInvalidServerDataException("Repository sent invalid data! No path property value!");
}
paths.Add(folderPath + (folderPath.EndsWith("/", StringComparison.Ordinal) ? "" : "/") + p.RelativePathSegment);
}
@@ -919,7 +920,7 @@ namespace PortCMIS.Client.Impl
/// <param name="session">the session object</param>
/// <param name="objectType">the object type</param>
/// <param name="objectData">the low-level data object</param>
- /// <param name="context">the operation context used to fetch this object</param>
+ /// <param name="context">the operation defaultContext used to fetch this object</param>
public Document(ISession session, IObjectType objectType, IObjectData objectData, IOperationContext context)
{
Initialize(session, objectType, objectData, context);
@@ -936,7 +937,7 @@ namespace PortCMIS.Client.Impl
}
else
{
- throw new CmisInvalidServerData("Object type is not a document type.");
+ throw new CmisInvalidServerDataException("Object type is not a document type.");
}
}
}
@@ -1047,7 +1048,7 @@ namespace PortCMIS.Client.Impl
IList<IContentStreamHash> result = new List<IContentStreamHash>();
foreach (object hash in hashes.Values)
{
- result.Add(new ContentStreamHash(Convert.ToString(hash)));
+ result.Add(new ContentStreamHash(Convert.ToString(hash, CultureInfo.InvariantCulture)));
}
return result;
@@ -1070,7 +1071,7 @@ namespace PortCMIS.Client.Impl
newId = CopyViaClient(targetFolderId, properties, versioningState, policies, addAces, removeAces);
}
- // if no context is provided the object will not be fetched
+ // if no defaultContext is provided the object will not be fetched
if (context == null || newId == null)
{
return null;
@@ -1223,6 +1224,11 @@ namespace PortCMIS.Client.Impl
/// <inheritdoc/>
public virtual IList<IDocument> GetAllVersions(IOperationContext context)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
string objectId;
string versionSeriesId;
@@ -1464,7 +1470,7 @@ namespace PortCMIS.Client.Impl
/// <param name="session">the session object</param>
/// <param name="objectType">the object type</param>
/// <param name="objectData">the low-level data object</param>
- /// <param name="context">the operation context used to fetch this object</param>
+ /// <param name="context">the operation defaultContext used to fetch this object</param>
public Folder(ISession session, IObjectType objectType, IObjectData objectData, IOperationContext context)
{
Initialize(session, objectType, objectData, context);
@@ -1481,7 +1487,7 @@ namespace PortCMIS.Client.Impl
}
else
{
- throw new CmisInvalidServerData("Object type is not a folder type.");
+ throw new CmisInvalidServerDataException("Object type is not a folder type.");
}
}
}
@@ -1492,7 +1498,7 @@ namespace PortCMIS.Client.Impl
{
IObjectId newId = Session.CreateDocument(properties, this, contentStream, versioningState, policies, addAces, removeAces);
- // if no context is provided the object will not be fetched
+ // if no defaultContext is provided the object will not be fetched
if (context == null || newId == null)
{
return null;
@@ -1514,7 +1520,7 @@ namespace PortCMIS.Client.Impl
{
IObjectId newId = Session.CreateDocumentFromSource(source, properties, this, versioningState, policies, addAces, removeAces);
- // if no context is provided the object will not be fetched
+ // if no defaultContext is provided the object will not be fetched
if (context == null || newId == null)
{
return null;
@@ -1535,7 +1541,7 @@ namespace PortCMIS.Client.Impl
{
IObjectId newId = Session.CreateFolder(properties, this, policies, addAces, removeAces);
- // if no context is provided the object will not be fetched
+ // if no defaultContext is provided the object will not be fetched
if (context == null || newId == null)
{
return null;
@@ -1556,7 +1562,7 @@ namespace PortCMIS.Client.Impl
{
IObjectId newId = Session.CreatePolicy(properties, this, policies, addAces, removeAces);
- // if no context is provided the object will not be fetched
+ // if no defaultContext is provided the object will not be fetched
if (context == null || newId == null)
{
return null;
@@ -1577,7 +1583,7 @@ namespace PortCMIS.Client.Impl
{
IObjectId newId = Session.CreateItem(properties, this, policies, addAces, removeAces);
- // if no context is provided the object will not be fetched
+ // if no defaultContext is provided the object will not be fetched
if (context == null || newId == null)
{
return null;
@@ -1636,6 +1642,11 @@ namespace PortCMIS.Client.Impl
/// <inheritdoc/>
public virtual IItemEnumerable<IDocument> GetCheckedOutDocs(IOperationContext context)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
string objectId = ObjectId;
INavigationService service = Binding.GetNavigationService();
IObjectFactory of = Session.ObjectFactory;
@@ -1679,6 +1690,11 @@ namespace PortCMIS.Client.Impl
/// <inheritdoc/>
public virtual IItemEnumerable<ICmisObject> GetChildren(IOperationContext context)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
string objectId = ObjectId;
INavigationService service = Binding.GetNavigationService();
IObjectFactory of = Session.ObjectFactory;
@@ -1718,6 +1734,11 @@ namespace PortCMIS.Client.Impl
/// <inheritdoc/>
public virtual IList<ITree<IFileableCmisObject>> GetDescendants(int depth, IOperationContext context)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
IList<IObjectInFolderContainer> bindingContainerList = Binding.GetNavigationService().GetDescendants(RepositoryId, ObjectId, depth,
context.FilterString, context.IncludeAllowableActions, context.IncludeRelationships, context.RenditionFilterString,
context.IncludePathSegments, null);
@@ -1734,6 +1755,11 @@ namespace PortCMIS.Client.Impl
/// <inheritdoc/>
public virtual IList<ITree<IFileableCmisObject>> GetFolderTree(int depth, IOperationContext context)
{
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
IList<IObjectInFolderContainer> bindingContainerList = Binding.GetNavigationService().GetFolderTree(RepositoryId, ObjectId, depth,
context.FilterString, context.IncludeAllowableActions, context.IncludeRelationships, context.RenditionFilterString,
context.IncludePathSegments, null);
@@ -1835,7 +1861,7 @@ namespace PortCMIS.Client.Impl
// we still don't know the path ... it's not a CMIS compliant repository
if (path == null)
{
- throw new CmisInvalidServerData("Repository didn't return " + PropertyIds.Path + "!");
+ throw new CmisInvalidServerDataException("Repository didn't return " + PropertyIds.Path + "!");
}
return path;
@@ -1896,7 +1922,7 @@ namespace PortCMIS.Client.Impl
/// <param name="session">the session object</param>
/// <param name="objectType">the object type</param>
/// <param name="objectData">the low-level data object</param>
- /// <param name="context">the operation context used to fetch this object</param>
+ /// <param name="context">the operation defaultContext used to fetch this object</param>
public Policy(ISession session, IObjectType objectType, IObjectData objectData, IOperationContext context)
{
Initialize(session, objectType, objectData, context);
@@ -1913,7 +1939,7 @@ namespace PortCMIS.Client.Impl
}
else
{
- throw new CmisInvalidServerData("Object type is not a policy type.");
+ throw new CmisInvalidServerDataException("Object type is not a policy type.");
}
}
}
@@ -1933,7 +1959,7 @@ namespace PortCMIS.Client.Impl
/// <param name="session">the session object</param>
/// <param name="objectType">the object type</param>
/// <param name="objectData">the low-level data object</param>
- /// <param name="context">the operation context used to fetch this object</param>
+ /// <param name="context">the operation defaultContext used to fetch this object</param>
public Relationship(ISession session, IObjectType objectType, IObjectData objectData, IOperationContext context)
{
Initialize(session, objectType, objectData, context);
@@ -1950,7 +1976,7 @@ namespace PortCMIS.Client.Impl
}
else
{
- throw new CmisInvalidServerData("Object type is not a relationship type.");
+ throw new CmisInvalidServerDataException("Object type is not a relationship type.");
}
}
}
@@ -2039,7 +2065,7 @@ namespace PortCMIS.Client.Impl
/// <param name="session">the session object</param>
/// <param name="objectType">the object type</param>
/// <param name="objectData">the low-level data object</param>
- /// <param name="context">the operation context used to fetch this object</param>
+ /// <param name="context">the operation defaultContext used to fetch this object</param>
public Item(ISession session, IObjectType objectType, IObjectData objectData, IOperationContext context)
{
Initialize(session, objectType, objectData, context);
@@ -2056,7 +2082,7 @@ namespace PortCMIS.Client.Impl
}
else
{
- throw new CmisInvalidServerData("Object type is not an item type.");
+ throw new CmisInvalidServerDataException("Object type is not an item type.");
}
}
}