PortCMIS: a bunch of small corrections and improvements
git-svn-id: https://svn.apache.org/repos/asf/chemistry/portcmis/trunk@1799023 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/PortCMIS/binding/BindingCaches.cs b/PortCMIS/binding/BindingCaches.cs
index 757e56a..3ecb920 100644
--- a/PortCMIS/binding/BindingCaches.cs
+++ b/PortCMIS/binding/BindingCaches.cs
@@ -22,11 +22,9 @@
using PortCMIS.Utils;
using System;
using System.Collections.Generic;
-using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
-using System.Threading.Tasks;
namespace PortCMIS.Binding
{
@@ -79,7 +77,7 @@
if (cacheLevelConfig == null || cacheLevelConfig.Length == 0)
{
- throw new ArgumentException("Cache config must not be empty!", "cacheLevelConfig");
+ throw new ArgumentException("Cache config must not be empty!", nameof(cacheLevelConfig));
}
cacheLevels = new List<Type>();
cacheLevelParameters = new List<IDictionary<string, string>>();
@@ -108,7 +106,7 @@
if (keys.Length != cacheLevels.Count)
{
- throw new ArgumentException("Wrong number of keys!", "keys");
+ throw new ArgumentException("Wrong number of keys!", nameof(keys));
}
lock (cacheLock)
@@ -146,7 +144,7 @@
if (keys.Length != cacheLevels.Count)
{
- throw new ArgumentException("Wrong number of keys!", "keys");
+ throw new ArgumentException("Wrong number of keys!", nameof(keys));
}
object result = null;
@@ -249,7 +247,7 @@
}
catch (Exception e)
{
- throw new ArgumentException("Class '" + typeName + "' not found!", "typeName", e);
+ throw new ArgumentException("Class '" + typeName + "' not found!", nameof(typeName), e);
}
cacheLevels.Add(levelType);
@@ -283,7 +281,7 @@
{
if ((level < 0) || (level >= cacheLevels.Count))
{
- throw new ArgumentException("Cache level doesn't fit the configuration!", "level");
+ throw new ArgumentException("Cache level doesn't fit the configuration!", nameof(level));
}
// get the class and create an instance
@@ -334,7 +332,7 @@
{
get
{
- object value = GetValue(key == null ? NullKey : key);
+ object value = GetValue(key ?? NullKey);
if (value != null)
{
return value;
@@ -364,7 +362,7 @@
{
if (value != null)
{
- AddValue(key == null ? NullKey : key, value);
+ AddValue(key ?? NullKey, value);
}
}
}
@@ -588,7 +586,7 @@
private const int CacheSizeRepositories = 10;
private const int CacheSizeTypes = 100;
- private IBindingCache cache;
+ private readonly IBindingCache cache;
public TypeDefinitionCache(IBindingSession session)
{
diff --git a/PortCMIS/binding/BindingImpl.cs b/PortCMIS/binding/BindingImpl.cs
index 3265af7..f65ddfa 100644
--- a/PortCMIS/binding/BindingImpl.cs
+++ b/PortCMIS/binding/BindingImpl.cs
@@ -25,10 +25,7 @@
using PortCMIS.Exceptions;
using System;
using System.Collections.Generic;
-using System.Linq;
using System.Numerics;
-using System.Text;
-using System.Threading.Tasks;
namespace PortCMIS.Binding.Impl
{
@@ -51,7 +48,7 @@
{
if (sessionParameters == null)
{
- throw new ArgumentNullException("sessionParameters");
+ throw new ArgumentNullException(nameof(sessionParameters));
}
if (!sessionParameters.ContainsKey(SessionParameter.BindingSpiClass))
@@ -258,7 +255,7 @@
public const string SpiObject = "org.apache.chemistry.portcmis.bindings.spi.object";
public const string HttpInvokerObject = "org.apache.chemistry.portcmis.binding.httpinvoker.object";
- private Dictionary<string, object> data;
+ private readonly Dictionary<string, object> data;
private object sessionLock = new object();
public BindingSession()
@@ -303,7 +300,7 @@
return (int)value;
}
}
- catch (Exception)
+ catch
{
}
@@ -325,7 +322,7 @@
return (bool)value;
}
}
- catch (Exception)
+ catch
{
}
@@ -471,7 +468,7 @@
/// </summary>
internal class BindingRepositoryService : IRepositoryService
{
- private BindingSession session;
+ private readonly BindingSession session;
public BindingRepositoryService(BindingSession session)
{
diff --git a/PortCMIS/binding/BindingIntf.cs b/PortCMIS/binding/BindingIntf.cs
index 92e1024..61568b7 100644
--- a/PortCMIS/binding/BindingIntf.cs
+++ b/PortCMIS/binding/BindingIntf.cs
@@ -633,7 +633,7 @@
// don't accept null
if (sessionParameters == null)
{
- throw new ArgumentNullException("sessionParameters");
+ throw new ArgumentNullException(nameof(sessionParameters));
}
// check binding entry
@@ -653,7 +653,7 @@
}
}
- private void Check(IDictionary<string, string> sessionParameters, String parameter)
+ private void Check(IDictionary<string, string> sessionParameters, string parameter)
{
if (!sessionParameters.ContainsKey(parameter))
{
diff --git a/PortCMIS/binding/BindingsConstants.cs b/PortCMIS/binding/BindingsConstants.cs
index f76273f..30c5987 100644
--- a/PortCMIS/binding/BindingsConstants.cs
+++ b/PortCMIS/binding/BindingsConstants.cs
@@ -17,15 +17,10 @@
* under the License.
*/
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace PortCMIS.Binding
{
- internal class BindingConstants
+ internal static class BindingConstants
{
// media types
public const string MediaTypeService = "application/atomsvc+xml";
diff --git a/PortCMIS/binding/DateTimeHelper.cs b/PortCMIS/binding/DateTimeHelper.cs
index 56d5ac9..8af9573 100644
--- a/PortCMIS/binding/DateTimeHelper.cs
+++ b/PortCMIS/binding/DateTimeHelper.cs
@@ -18,16 +18,11 @@
*/
using System;
-using System.Collections.Generic;
using System.Globalization;
-using System.Linq;
-using System.Numerics;
-using System.Text;
-using System.Threading.Tasks;
namespace PortCMIS.Binding
{
- internal class DateTimeHelper
+ internal static class DateTimeHelper
{
private static readonly DateTime Jan1st1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
@@ -41,8 +36,9 @@
return (datetime.Ticks - Jan1st1970.Ticks) / TimeSpan.TicksPerMillisecond;
}
- public static DateTime ParseISO8601(string s) {
- return DateTime.Parse(s, null, DateTimeStyles.RoundtripKind);
+ public static DateTime ParseISO8601(string s)
+ {
+ return DateTime.Parse(s, null, DateTimeStyles.RoundtripKind);
}
public static string FormatISO8601(DateTime dt)
diff --git a/PortCMIS/binding/Http.cs b/PortCMIS/binding/Http.cs
index b8c2e10..5e87d9d 100644
--- a/PortCMIS/binding/Http.cs
+++ b/PortCMIS/binding/Http.cs
@@ -17,17 +17,9 @@
* under the License.
*/
-using PortCMIS.Client;
-using PortCMIS.Exceptions;
-using PortCMIS.Utils;
-using System;
using System.Collections.Generic;
using System.IO;
-using System.Linq;
-using System.Net;
using System.Net.Http;
-using System.Net.Http.Headers;
-using System.Threading.Tasks;
namespace PortCMIS.Binding.Http
{
diff --git a/PortCMIS/binding/HttpPortable.cs b/PortCMIS/binding/HttpPortable.cs
index b3ab7c3..5f51c3b 100644
--- a/PortCMIS/binding/HttpPortable.cs
+++ b/PortCMIS/binding/HttpPortable.cs
@@ -281,10 +281,10 @@
if (httpResponse.StatusCode != HttpStatusCode.NoContent)
{
if (ContentType != null &&
- (ContentType.ToLowerInvariant().StartsWith("text/") ||
- ContentType.ToLowerInvariant().EndsWith("+xml") ||
- ContentType.ToLowerInvariant().StartsWith("application/xml") ||
- ContentType.ToLowerInvariant().StartsWith("application/json")))
+ (ContentType.ToLowerInvariant().StartsWith("text/", StringComparison.Ordinal) ||
+ ContentType.ToLowerInvariant().EndsWith("+xml", StringComparison.Ordinal) ||
+ ContentType.ToLowerInvariant().StartsWith("application/xml", StringComparison.Ordinal) ||
+ ContentType.ToLowerInvariant().StartsWith("application/json", StringComparison.Ordinal)))
{
ErrorContent = GetContentString().Result;
}
@@ -295,7 +295,7 @@
response.Dispose();
response = null;
}
- catch (Exception) { }
+ catch { }
}
}
@@ -314,7 +314,7 @@
response.Dispose();
response = null;
}
- catch (Exception) { }
+ catch { }
}
}
diff --git a/PortCMIS/binding/Url.cs b/PortCMIS/binding/Url.cs
index 1acdc74..79d375c 100644
--- a/PortCMIS/binding/Url.cs
+++ b/PortCMIS/binding/Url.cs
@@ -48,7 +48,7 @@
{
if (url == null)
{
- throw new ArgumentNullException("url");
+ throw new ArgumentNullException(nameof(url));
}
uri = new UriBuilder(url);
@@ -186,7 +186,7 @@
private const string MIMESpecials = "()<>@,;:\\\"/[]?=" + "\t ";
private const string RFC2231Specials = "*'%" + MIMESpecials;
- private static 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 = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
public static string EncodeContentDisposition(string disposition, string filename)
{
@@ -218,7 +218,7 @@
byte[] bytes;
try
{
- bytes = UTF8Encoding.UTF8.GetBytes(value);
+ bytes = Encoding.UTF8.GetBytes(value);
}
catch (Exception)
{
diff --git a/PortCMIS/binding/atompub/AtomPubBinding.cs b/PortCMIS/binding/atompub/AtomPubBinding.cs
index 41f6de8..93bb7c5 100644
--- a/PortCMIS/binding/atompub/AtomPubBinding.cs
+++ b/PortCMIS/binding/atompub/AtomPubBinding.cs
@@ -17,12 +17,10 @@
* under the License.
*/
-using PortCMIS.Binding;
using PortCMIS.Binding.Http;
using PortCMIS.Binding.Impl;
using PortCMIS.Binding.Services;
using PortCMIS.Client;
-using PortCMIS.Client.Impl;
using PortCMIS.Data;
using PortCMIS.Data.Extensions;
using PortCMIS.Enums;
@@ -2462,7 +2460,7 @@
IExtensionsData extension)
{
// we need an object id
- if (objectId == null || objectId.Length == 0)
+ if (string.IsNullOrEmpty(objectId))
{
throw new CmisInvalidArgumentException("Object ID must be set!");
}
@@ -2615,12 +2613,12 @@
public void MoveObject(string repositoryId, ref string objectId, string targetFolderId, string sourceFolderId,
IExtensionsData extension)
{
- if (objectId == null || objectId.Length == 0)
+ if (string.IsNullOrEmpty(objectId))
{
throw new CmisInvalidArgumentException("Object ID must be set!");
}
- if (targetFolderId == null || targetFolderId.Length == 0 || sourceFolderId == null || sourceFolderId.Length == 0)
+ if (string.IsNullOrEmpty(targetFolderId) || string.IsNullOrEmpty(sourceFolderId))
{
throw new CmisInvalidArgumentException("Source and target folder must be set!");
}
@@ -2907,7 +2905,7 @@
public void CheckOut(string repositoryId, ref string objectId, IExtensionsData extension, out bool? contentCopied)
{
- if (objectId == null || objectId.Length == 0)
+ if (string.IsNullOrEmpty(objectId))
{
throw new CmisInvalidArgumentException("Object ID must be set!");
}
@@ -2991,7 +2989,7 @@
IExtensionsData extension)
{
// we need an object id
- if (objectId == null || objectId.Length == 0)
+ if (string.IsNullOrEmpty(objectId))
{
throw new CmisInvalidArgumentException("Object ID must be set!");
}
diff --git a/PortCMIS/binding/atompub/AtomPubUtils.cs b/PortCMIS/binding/atompub/AtomPubUtils.cs
index 7349094..6b16dc6 100644
--- a/PortCMIS/binding/atompub/AtomPubUtils.cs
+++ b/PortCMIS/binding/atompub/AtomPubUtils.cs
@@ -17,7 +17,6 @@
* under the License.
*/
-using PortCMIS.Binding;
using PortCMIS.Binding.Impl;
using PortCMIS.Client;
using PortCMIS.Data;
@@ -31,7 +30,6 @@
using System.Net.Http;
using System.Net.Http.Headers;
using System.Numerics;
-using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
@@ -50,7 +48,7 @@
{
if (stream == null)
{
- throw new ArgumentNullException("stream");
+ throw new ArgumentNullException(nameof(stream));
}
this.stream = stream;
@@ -512,9 +510,10 @@
{
string uri = parser.NamespaceURI;
string local = parser.LocalName;
- Dictionary<string, string> result = new Dictionary<string, string>();
-
- result["href"] = parser.GetAttribute("href");
+ Dictionary<string, string> result = new Dictionary<string, string>()
+ {
+ ["href"] = parser.GetAttribute("href")
+ };
XmlUtils.Next(parser);
@@ -657,8 +656,10 @@
string uri = parser.NamespaceURI;
string local = parser.LocalName;
- AtomLink result = new AtomLink();
- result.Rel = LinkRelContent;
+ AtomLink result = new AtomLink()
+ {
+ Rel = LinkRelContent
+ };
// save attributes
if (parser.HasAttributes)
@@ -719,7 +720,7 @@
internal abstract class AtomBase
{
- private IList<AtomElement> elements = new List<AtomElement>();
+ private readonly IList<AtomElement> elements = new List<AtomElement>();
public abstract string Type { get; }
@@ -747,7 +748,7 @@
internal class ServiceDoc : AtomBase
{
- private IList<RepositoryWorkspace> workspaces = new List<RepositoryWorkspace>();
+ private readonly IList<RepositoryWorkspace> workspaces = new List<RepositoryWorkspace>();
public override string Type { get { return "Service Document"; } }
public IList<RepositoryWorkspace> Workspaces { get { return workspaces; } }
@@ -824,29 +825,31 @@
internal class LinkCache
{
- private static readonly HashSet<string> KnownLinks = new HashSet<string>();
+ private static readonly HashSet<string> KnownLinks = new HashSet<string>()
+ {
+ BindingConstants.RelAcl,
+ BindingConstants.RelDown,
+ BindingConstants.RelUp,
+ BindingConstants.RelFolderTree,
+ BindingConstants.RelRelationships,
+ BindingConstants.RelSelf,
+ BindingConstants.RelAllowableActions,
+ BindingConstants.RelEditMedia,
+ BindingConstants.RelPolicies,
+ BindingConstants.RelVersionHistory,
+ BindingConstants.RelWorkingCopy,
+ AtomPubParser.LinkRelContent
+ };
static LinkCache()
{
- KnownLinks.Add(BindingConstants.RelAcl);
- KnownLinks.Add(BindingConstants.RelDown);
- KnownLinks.Add(BindingConstants.RelUp);
- KnownLinks.Add(BindingConstants.RelFolderTree);
- KnownLinks.Add(BindingConstants.RelRelationships);
- KnownLinks.Add(BindingConstants.RelSelf);
- KnownLinks.Add(BindingConstants.RelAllowableActions);
- KnownLinks.Add(BindingConstants.RelEditMedia);
- KnownLinks.Add(BindingConstants.RelPolicies);
- KnownLinks.Add(BindingConstants.RelVersionHistory);
- KnownLinks.Add(BindingConstants.RelWorkingCopy);
- KnownLinks.Add(AtomPubParser.LinkRelContent);
}
- private IBindingCache linkCache;
- private IBindingCache typeLinkCache;
- private IBindingCache collectionLinkCache;
- private IBindingCache templateCache;
- private IBindingCache repositoryLinkCache;
+ private readonly IBindingCache linkCache;
+ private readonly IBindingCache typeLinkCache;
+ private readonly IBindingCache collectionLinkCache;
+ private readonly IBindingCache templateCache;
+ private readonly IBindingCache repositoryLinkCache;
/// <summary>
/// Constructor.
@@ -1175,7 +1178,7 @@
private CmisVersion cmisVersion;
private IObjectData objectData;
private IContentStream contentStream;
- private Stream stream;
+ private readonly Stream stream;
private ITypeDefinition typeDef;
private BulkUpdate bulkUpdate;
diff --git a/PortCMIS/binding/atompub/XmlConstants.cs b/PortCMIS/binding/atompub/XmlConstants.cs
index f546ea4..d46f45e 100644
--- a/PortCMIS/binding/atompub/XmlConstants.cs
+++ b/PortCMIS/binding/atompub/XmlConstants.cs
@@ -17,15 +17,10 @@
* under the License.
*/
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace PortCMIS.Binding.AtomPub
{
- class XmlConstants
+ internal static class XmlConstants
{
// namespaces
public const string NamespaceCmis = "http://docs.oasis-open.org/ns/cmis/core/200908/";
diff --git a/PortCMIS/binding/atompub/XmlConverter.cs b/PortCMIS/binding/atompub/XmlConverter.cs
index 8bf276f..413ccd3 100644
--- a/PortCMIS/binding/atompub/XmlConverter.cs
+++ b/PortCMIS/binding/atompub/XmlConverter.cs
@@ -17,8 +17,6 @@
* under the License.
*/
-using PortCMIS.Binding.AtomPub;
-using PortCMIS.Client.Impl;
using PortCMIS.Data;
using PortCMIS.Data.Extensions;
using PortCMIS.Enums;
@@ -28,8 +26,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
-using System.Text;
-using System.Threading.Tasks;
using System.Xml;
namespace PortCMIS.Binding.AtomPub
@@ -358,19 +354,19 @@
}
}
- if (source is DocumentTypeDefinition)
+ if (source is IDocumentTypeDefinition)
{
- DocumentTypeDefinition docDef = (DocumentTypeDefinition)source;
+ IDocumentTypeDefinition docDef = (IDocumentTypeDefinition)source;
XmlUtils.Write(writer, XmlConstants.PrefixCmis, XmlConstants.NamespaceCmis, XmlConstants.TAG_TYPE_VERSIONABLE, docDef.IsVersionable);
XmlUtils.Write(writer, XmlConstants.PrefixCmis, XmlConstants.NamespaceCmis, XmlConstants.TAG_TYPE_CONTENTSTREAM_ALLOWED, docDef.ContentStreamAllowed);
}
- if (source is RelationshipTypeDefinition)
+ if (source is IRelationshipTypeDefinition)
{
- RelationshipTypeDefinition relDef = (RelationshipTypeDefinition)source;
+ IRelationshipTypeDefinition relDef = (IRelationshipTypeDefinition)source;
if (relDef.AllowedSourceTypeIds != null)
{
- foreach (String id in relDef.AllowedSourceTypeIds)
+ foreach (string id in relDef.AllowedSourceTypeIds)
{
if (id != null)
{
@@ -380,7 +376,7 @@
}
if (relDef.AllowedTargetTypeIds != null)
{
- foreach (String id in relDef.AllowedTargetTypeIds)
+ foreach (string id in relDef.AllowedTargetTypeIds)
{
if (id != null)
{
@@ -544,7 +540,7 @@
}
}
}
- else if (source is PropertyDateTimeDefinition)
+ else if (source is IPropertyDateTimeDefinition)
{
IPropertyDateTimeDefinition def = (IPropertyDateTimeDefinition)source;
@@ -1080,7 +1076,7 @@
// --- bulk update ---
// -------------------
- public static void WriteBulkUpdate(XmlWriter writer, String ns, BulkUpdate bulkUpdate)
+ public static void WriteBulkUpdate(XmlWriter writer, string ns, BulkUpdate bulkUpdate)
{
if (bulkUpdate == null || bulkUpdate.ObjectIdAndChangeToken == null)
{
@@ -1852,29 +1848,29 @@
string typeAttr = parser.GetAttribute("type", XmlConstants.NamespaceXsi);
if (typeAttr != null)
{
- if (typeAttr.EndsWith(XmlConstants.ATTR_DOCUMENT_TYPE))
+ if (typeAttr.EndsWith(XmlConstants.ATTR_DOCUMENT_TYPE, StringComparison.Ordinal))
{
result = new DocumentTypeDefinition();
}
- else if (typeAttr.EndsWith(XmlConstants.ATTR_FOLDER_TYPE))
+ else if (typeAttr.EndsWith(XmlConstants.ATTR_FOLDER_TYPE, StringComparison.Ordinal))
{
result = new FolderTypeDefinition();
}
- else if (typeAttr.EndsWith(XmlConstants.ATTR_RELATIONSHIP_TYPE))
+ else if (typeAttr.EndsWith(XmlConstants.ATTR_RELATIONSHIP_TYPE, StringComparison.Ordinal))
{
result = new RelationshipTypeDefinition();
((RelationshipTypeDefinition)result).AllowedSourceTypeIds = new List<string>();
((RelationshipTypeDefinition)result).AllowedTargetTypeIds = new List<string>();
}
- else if (typeAttr.EndsWith(XmlConstants.ATTR_POLICY_TYPE))
+ else if (typeAttr.EndsWith(XmlConstants.ATTR_POLICY_TYPE, StringComparison.Ordinal))
{
result = new PolicyTypeDefinition();
}
- else if (typeAttr.EndsWith(XmlConstants.ATTR_ITEM_TYPE))
+ else if (typeAttr.EndsWith(XmlConstants.ATTR_ITEM_TYPE, StringComparison.Ordinal))
{
result = new ItemTypeDefinition();
}
- else if (typeAttr.EndsWith(XmlConstants.ATTR_SECONDARY_TYPE))
+ else if (typeAttr.EndsWith(XmlConstants.ATTR_SECONDARY_TYPE, StringComparison.Ordinal))
{
result = new SecondaryTypeDefinition();
}
@@ -2425,7 +2421,7 @@
private static readonly ChoiceStringParser CHOICE_STRING_PARSER = new ChoiceStringParser();
private class ChoiceStringParser : ChoiceXmlWalker<string>
{
- protected override Choice<string> createTarget(XmlReader parser, string localname, string ns)
+ protected override Choice<string> CreateTarget(XmlReader parser, string localname, string ns)
{
return new Choice<string>();
}
@@ -2468,7 +2464,7 @@
private static readonly ChoiceBooleanParser CHOICE_BOOLEAN_PARSER = new ChoiceBooleanParser();
private class ChoiceBooleanParser : ChoiceXmlWalker<bool?>
{
- protected override Choice<bool?> createTarget(XmlReader parser, string localname, string ns)
+ protected override Choice<bool?> CreateTarget(XmlReader parser, string localname, string ns)
{
return new Choice<bool?>();
}
@@ -2492,7 +2488,7 @@
private static readonly ChoiceIntegerParser CHOICE_INTEGER_PARSER = new ChoiceIntegerParser();
private class ChoiceIntegerParser : ChoiceXmlWalker<BigInteger?>
{
- protected override Choice<BigInteger?> createTarget(XmlReader parser, string localname, string ns)
+ protected override Choice<BigInteger?> CreateTarget(XmlReader parser, string localname, string ns)
{
return new Choice<BigInteger?>();
}
@@ -2516,7 +2512,7 @@
private static readonly ChoiceDateTimeParser CHOICE_DATETIME_PARSER = new ChoiceDateTimeParser();
private class ChoiceDateTimeParser : ChoiceXmlWalker<DateTime?>
{
- protected override Choice<DateTime?> createTarget(XmlReader parser, string localname, string ns)
+ protected override Choice<DateTime?> CreateTarget(XmlReader parser, string localname, string ns)
{
return new Choice<DateTime?>();
}
@@ -2540,7 +2536,7 @@
private static readonly ChoiceDecimalParser CHOICE_DECIMAL_PARSER = new ChoiceDecimalParser();
private class ChoiceDecimalParser : ChoiceXmlWalker<decimal?>
{
- protected override Choice<decimal?> createTarget(XmlReader parser, string localname, string ns)
+ protected override Choice<decimal?> CreateTarget(XmlReader parser, string localname, string ns)
{
return new Choice<decimal?>();
}
@@ -2563,11 +2559,11 @@
private abstract class ChoiceXmlWalker<T> : XmlWalker<Choice<T>>
{
- protected abstract Choice<T> createTarget(XmlReader parser, string localname, string ns);
+ protected abstract Choice<T> CreateTarget(XmlReader parser, string localname, string ns);
protected override Choice<T> PrepareTarget(XmlReader parser, string localname, string ns)
{
- Choice<T> result = createTarget(parser, localname, ns);
+ Choice<T> result = CreateTarget(parser, localname, ns);
if (parser.HasAttributes)
{
diff --git a/PortCMIS/binding/atompub/XmlUtils.cs b/PortCMIS/binding/atompub/XmlUtils.cs
index 178037c..3910543 100644
--- a/PortCMIS/binding/atompub/XmlUtils.cs
+++ b/PortCMIS/binding/atompub/XmlUtils.cs
@@ -31,7 +31,7 @@
namespace PortCMIS.Binding.AtomPub
{
- internal class XmlUtils
+ internal static class XmlUtils
{
// --------------
@@ -43,8 +43,11 @@
/// </summary>
public static XmlWriter CreateWriter(Stream stream)
{
- XmlWriterSettings settings = new XmlWriterSettings();
- settings.Encoding = Encoding.UTF8;
+ XmlWriterSettings settings = new XmlWriterSettings()
+ {
+ Encoding = Encoding.UTF8
+ };
+
return XmlWriter.Create(stream, settings);
}
@@ -184,9 +187,12 @@
/// </summary>
public static XmlReader CreateParser(Stream stream)
{
- XmlReaderSettings settings = new XmlReaderSettings();
- settings.MaxCharactersInDocument = 0;
- settings.CloseInput = true;
+ XmlReaderSettings settings = new XmlReaderSettings()
+ {
+ MaxCharactersInDocument = 0,
+ CloseInput = true
+ };
+
return XmlReader.Create(stream, settings);
}
diff --git a/PortCMIS/binding/atompub/XmlWalker.cs b/PortCMIS/binding/atompub/XmlWalker.cs
index a32b927..d6c1e56 100644
--- a/PortCMIS/binding/atompub/XmlWalker.cs
+++ b/PortCMIS/binding/atompub/XmlWalker.cs
@@ -17,18 +17,15 @@
* under the License.
*/
-using PortCMIS.Binding.AtomPub;
using PortCMIS.Data.Extensions;
+using PortCMIS.Enums;
using PortCMIS.Exceptions;
using System;
using System.Collections.Generic;
-using System.Linq;
+using System.Globalization;
using System.Numerics;
using System.Text;
-using System.Threading.Tasks;
using System.Xml;
-using PortCMIS.Enums;
-using System.Globalization;
namespace PortCMIS.Binding.AtomPub
{
@@ -272,13 +269,14 @@
{
string value = ReadText(parser);
- DateTime result = DateTimeHelper.ParseISO8601(value);
- if (result == null)
+ try
{
- throw new CmisInvalidArgumentException("Invalid datetime value!");
+ return DateTimeHelper.ParseISO8601(value);
}
-
- return result;
+ catch (Exception e)
+ {
+ throw new CmisInvalidArgumentException("Invalid datetime value!", e);
+ }
}
protected E ReadEnum<E>(XmlReader parser)
@@ -292,7 +290,7 @@
}
- internal class XmlConstraints
+ internal static class XmlConstraints
{
public const int MaxStringLength = 100 * 1024;
diff --git a/PortCMIS/binding/browser/BrowserBinding.cs b/PortCMIS/binding/browser/BrowserBinding.cs
index 6414e2f..7d38fcd 100644
--- a/PortCMIS/binding/browser/BrowserBinding.cs
+++ b/PortCMIS/binding/browser/BrowserBinding.cs
@@ -17,7 +17,6 @@
* under the License.
*/
-using PortCMIS.Binding;
using PortCMIS.Binding.Browser.Json;
using PortCMIS.Binding.Http;
using PortCMIS.Binding.Impl;
@@ -31,13 +30,10 @@
using System.Collections.Generic;
using System.Globalization;
using System.IO;
-using System.Linq;
-using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Numerics;
using System.Text;
-using System.Threading.Tasks;
namespace PortCMIS.Binding.Browser
{
@@ -459,7 +455,7 @@
int idx = 0;
foreach (string typeId in secondaryTypeIds)
{
- if (typeId == null || typeId.Length == 0)
+ if (string.IsNullOrEmpty(typeId))
{
continue;
}
@@ -1654,7 +1650,7 @@
IExtensionsData extension)
{
// we need an object ID
- if (objectId == null || objectId.Length == 0)
+ if (string.IsNullOrEmpty(objectId))
{
throw new CmisInvalidArgumentException("Object ID must be set!");
}
@@ -1718,7 +1714,7 @@
IExtensionsData extension)
{
// we need an object id
- if (objectId == null || objectId.Length == 0)
+ if (string.IsNullOrEmpty(objectId))
{
throw new CmisInvalidArgumentException("Object ID must be set!");
}
@@ -1793,7 +1789,7 @@
IContentStream contentStream, IExtensionsData extension)
{
// we need an object id
- if (objectId == null || objectId.Length == 0)
+ if (string.IsNullOrEmpty(objectId))
{
throw new CmisInvalidArgumentException("Object ID must be set!");
}
@@ -1828,7 +1824,7 @@
IContentStream contentStream, IExtensionsData extension)
{
// we need an object id
- if (objectId == null || objectId.Length == 0)
+ if (string.IsNullOrEmpty(objectId))
{
throw new CmisInvalidArgumentException("Object ID must be set!");
}
@@ -1861,7 +1857,7 @@
public void DeleteContentStream(string repositoryId, ref string objectId, ref string changeToken, IExtensionsData extension)
{
// we need an object id
- if (objectId == null || objectId.Length == 0)
+ if (string.IsNullOrEmpty(objectId))
{
throw new CmisInvalidArgumentException("Object ID must be set!");
}
@@ -1900,7 +1896,7 @@
public void CheckOut(string repositoryId, ref string objectId, IExtensionsData extension, out bool? contentCopied)
{
// we need an object id
- if (objectId == null || objectId.Length == 0)
+ if (string.IsNullOrEmpty(objectId))
{
throw new CmisInvalidArgumentException("Object ID must be set!");
}
@@ -1943,7 +1939,7 @@
IExtensionsData extension)
{
// we need an object id
- if (objectId == null || objectId.Length == 0)
+ if (string.IsNullOrEmpty(objectId))
{
throw new CmisInvalidArgumentException("Object ID must be set!");
}
diff --git a/PortCMIS/binding/browser/BrowserConstants.cs b/PortCMIS/binding/browser/BrowserConstants.cs
index 6ebd851..3186263 100644
--- a/PortCMIS/binding/browser/BrowserConstants.cs
+++ b/PortCMIS/binding/browser/BrowserConstants.cs
@@ -17,12 +17,9 @@
* under the License.
*/
+using PortCMIS.Enums;
using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using PortCMIS.Enums;
namespace PortCMIS.Binding.Browser
{
diff --git a/PortCMIS/binding/browser/BrowserConverter.cs b/PortCMIS/binding/browser/BrowserConverter.cs
index 5adaa0b..cf808cf 100644
--- a/PortCMIS/binding/browser/BrowserConverter.cs
+++ b/PortCMIS/binding/browser/BrowserConverter.cs
@@ -17,19 +17,15 @@
* under the License.
*/
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using PortCMIS.Binding.Browser.Json;
+using PortCMIS.Const;
using PortCMIS.Data;
+using PortCMIS.Data.Extensions;
using PortCMIS.Enums;
using PortCMIS.Exceptions;
-using PortCMIS.Data.Extensions;
-using System.Collections;
+using System;
+using System.Collections.Generic;
using System.Numerics;
-using PortCMIS.Const;
namespace PortCMIS.Binding.Browser
{
@@ -3443,7 +3439,14 @@
}
else if (value is string)
{
- return DateTimeHelper.ParseISO8601((string)value);
+ try
+ {
+ return DateTimeHelper.ParseISO8601((string)value);
+ }
+ catch
+ {
+ return null;
+ }
}
}
diff --git a/PortCMIS/binding/browser/BrowserUtils.cs b/PortCMIS/binding/browser/BrowserUtils.cs
index 9ffb272..b414400 100644
--- a/PortCMIS/binding/browser/BrowserUtils.cs
+++ b/PortCMIS/binding/browser/BrowserUtils.cs
@@ -20,9 +20,6 @@
using PortCMIS.Data;
using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace PortCMIS.Binding.Browser
{
diff --git a/PortCMIS/binding/browser/json/Json.cs b/PortCMIS/binding/browser/json/Json.cs
index 3f68689..c8f57f3 100644
--- a/PortCMIS/binding/browser/json/Json.cs
+++ b/PortCMIS/binding/browser/json/Json.cs
@@ -27,10 +27,8 @@
using System.Collections.Generic;
using System.Globalization;
using System.IO;
-using System.Linq;
using System.Numerics;
using System.Text;
-using System.Threading.Tasks;
namespace PortCMIS.Binding.Browser.Json
@@ -202,7 +200,7 @@
{
if (key == null)
{
- throw new ArgumentNullException("key");
+ throw new ArgumentNullException(nameof(key));
}
return dict[key].Value;
@@ -212,7 +210,7 @@
{
if (key == null)
{
- throw new ArgumentNullException("key");
+ throw new ArgumentNullException(nameof(key));
}
KeyValuePair<string, object> kv = new KeyValuePair<string, object>(key, value);
@@ -270,12 +268,12 @@
{
if (key == null)
{
- throw new ArgumentNullException("key");
+ throw new ArgumentNullException(nameof(key));
}
if (dict.ContainsKey(key))
{
- throw new ArgumentException("Key already exists!", key);
+ throw new ArgumentException("Key already exists!", nameof(key));
}
this[key] = value;
@@ -285,7 +283,7 @@
{
if (key == null)
{
- throw new ArgumentNullException("key");
+ throw new ArgumentNullException(nameof(key));
}
if (dict.Remove(key))
diff --git a/PortCMIS/client/ClientCaches.cs b/PortCMIS/client/ClientCaches.cs
index 9494ba4..719e863 100644
--- a/PortCMIS/client/ClientCaches.cs
+++ b/PortCMIS/client/ClientCaches.cs
@@ -193,7 +193,7 @@
}
}
}
- catch (Exception) { }
+ catch { }
// cache time-to-live
cacheTtl = 2 * 60 * 60 * 1000;
@@ -209,7 +209,7 @@
}
}
}
- catch (Exception) { }
+ catch { }
// path-to-id size
pathToIdSize = 1000;
diff --git a/PortCMIS/client/ClientImpl.cs b/PortCMIS/client/ClientImpl.cs
index 34570f4..997b6f2 100644
--- a/PortCMIS/client/ClientImpl.cs
+++ b/PortCMIS/client/ClientImpl.cs
@@ -111,7 +111,7 @@
{
if (parameters == null)
{
- throw new ArgumentNullException("parameters");
+ throw new ArgumentNullException(nameof(parameters));
}
if (!parameters.ContainsKey(SessionParameter.BindingType))
@@ -283,7 +283,7 @@
{
lock (sessionLock)
{
- context = (value == null ? FallbackContext : value);
+ context = value ?? FallbackContext;
}
}
}
@@ -299,14 +299,14 @@
{
if (parameters == null)
{
- throw new ArgumentNullException("parameters");
+ throw new ArgumentNullException(nameof(parameters));
}
this.parameters = parameters;
- ObjectFactory = (objectFactory == null ? CreateObjectFactory() : objectFactory);
+ ObjectFactory = objectFactory ?? CreateObjectFactory();
AuthenticationProvider = authenticationProvider;
- Cache = (cache == null ? CreateCache() : cache);
+ Cache = cache ?? CreateCache();
string cachePathOmitStr;
if (parameters.TryGetValue(SessionParameter.CachePathOmit, out cachePathOmitStr))
@@ -457,7 +457,7 @@
{
IRepositoryService service = Binding.GetRepositoryService();
- PageFetcher<IObjectType>.FetchPage fetchPageDelegate = delegate(BigInteger maxNumItems, BigInteger skipCount)
+ PageFetcher<IObjectType>.FetchPage fetchPageDelegate = delegate (BigInteger maxNumItems, BigInteger skipCount)
{
// fetch the data
ITypeDefinitionList tdl = service.GetTypeChildren(RepositoryId, typeId, includePropertyDefinitions, maxNumItems, skipCount, null);
@@ -499,9 +499,11 @@
foreach (ITypeDefinitionContainer container in descendantsList)
{
- Tree<IObjectType> tree = new Tree<IObjectType>();
- tree.Item = ObjectFactory.ConvertTypeDefinition(container.TypeDefinition);
- tree.Children = ConvertTypeDescendants(container.Children);
+ Tree<IObjectType> tree = new Tree<IObjectType>()
+ {
+ Item = ObjectFactory.ConvertTypeDefinition(container.TypeDefinition),
+ Children = ConvertTypeDescendants(container.Children)
+ };
result.Add(tree);
}
@@ -568,7 +570,7 @@
INavigationService service = Binding.GetNavigationService();
IOperationContext ctxt = new OperationContext(context);
- PageFetcher<IDocument>.FetchPage fetchPageDelegate = delegate(BigInteger maxNumItems, BigInteger skipCount)
+ PageFetcher<IDocument>.FetchPage fetchPageDelegate = delegate (BigInteger maxNumItems, BigInteger skipCount)
{
// get all checked out documents
IObjectList checkedOutDocs = service.GetCheckedOutDocs(RepositoryId, null, ctxt.FilterString, ctxt.OrderBy,
@@ -608,7 +610,7 @@
{
if (objectId == null || objectId.Id == null)
{
- throw new ArgumentException("Object Id must be set!", "objectId");
+ throw new ArgumentException("Object Id must be set!", nameof(objectId));
}
return GetObject(objectId.Id, context);
@@ -625,11 +627,11 @@
{
if (objectId == null)
{
- throw new ArgumentException("Object Id must be set!", "objectId");
+ throw new ArgumentException("Object Id must be set!", nameof(objectId));
}
if (context == null)
{
- throw new ArgumentException("Operation context must be set!", "context");
+ throw new ArgumentException("Operation context must be set!", nameof(context));
}
ICmisObject result = null;
@@ -673,7 +675,7 @@
if (context == null)
{
- throw new ArgumentNullException("context");
+ throw new ArgumentNullException(nameof(context));
}
ICmisObject result = null;
@@ -713,22 +715,22 @@
/// <inheritdoc/>
public ICmisObject GetObjectByPath(string parentPath, string name, IOperationContext context)
{
- if (parentPath == null || parentPath.Length < 1)
+ if (string.IsNullOrEmpty(parentPath))
{
- throw new ArgumentException("Parent path must be set!", "parentPath");
+ throw new ArgumentException("Parent path must be set!", nameof(parentPath));
}
if (parentPath[0] != '/')
{
- throw new ArgumentException("Parent path must start with a '/'!", "parentPath");
+ throw new ArgumentException("Parent path must start with a '/'!", nameof(parentPath));
}
- if (name == null || name.Length < 1)
+ if (string.IsNullOrEmpty(name))
{
- throw new ArgumentException("Name must be set!", "name");
+ throw new ArgumentException("Name must be set!", nameof(name));
}
StringBuilder path = new StringBuilder();
path.Append(parentPath);
- if (!parentPath.EndsWith("/"))
+ if (!parentPath.EndsWith("/", StringComparison.Ordinal))
{
path.Append('/');
}
@@ -748,7 +750,7 @@
{
if (objectId == null)
{
- throw new ArgumentNullException("objectId");
+ throw new ArgumentNullException(nameof(objectId));
}
return GetLatestDocumentVersion(CreateObjectId(objectId), false, context);
@@ -771,12 +773,12 @@
{
if (objectId == null || objectId.Id == null)
{
- throw new ArgumentNullException("objectId");
+ throw new ArgumentNullException(nameof(objectId));
}
if (context == null)
{
- throw new ArgumentNullException("context");
+ throw new ArgumentNullException(nameof(context));
}
ICmisObject result = null;
@@ -864,7 +866,7 @@
{
if (objectId == null)
{
- throw new ArgumentNullException("objectId");
+ throw new ArgumentNullException(nameof(objectId));
}
return Exists(objectId.Id);
}
@@ -874,7 +876,7 @@
{
if (objectId == null)
{
- throw new ArgumentNullException(objectId);
+ throw new ArgumentNullException(nameof(objectId));
}
try
@@ -918,22 +920,22 @@
/// <inheritdoc/>
public bool ExistsPath(string parentPath, string name)
{
- if (parentPath == null || parentPath.Length < 1)
+ if (string.IsNullOrEmpty(parentPath))
{
- throw new ArgumentException("Parent path must be set!", "parentPath");
+ throw new ArgumentException("Parent path must be set!", nameof(parentPath));
}
if (parentPath[0] != '/')
{
- throw new ArgumentException("Parent path must start with a '/'!", "parentPath");
+ throw new ArgumentException("Parent path must start with a '/'!", nameof(parentPath));
}
- if (name == null || name.Length < 1)
+ if (string.IsNullOrEmpty(name))
{
- throw new ArgumentException("Name must be set!", "name");
+ throw new ArgumentException("Name must be set!", nameof(name));
}
StringBuilder path = new StringBuilder(parentPath.Length + name.Length + 2);
path.Append(parentPath);
- if (!parentPath.EndsWith("/"))
+ if (!parentPath.EndsWith("/", StringComparison.Ordinal))
{
path.Append('/');
}
@@ -973,7 +975,7 @@
IDiscoveryService service = Binding.GetDiscoveryService();
IOperationContext ctxt = new OperationContext(context);
- PageFetcher<IQueryResult>.FetchPage fetchPageDelegate = delegate(BigInteger maxNumItems, BigInteger skipCount)
+ PageFetcher<IQueryResult>.FetchPage fetchPageDelegate = delegate (BigInteger maxNumItems, BigInteger skipCount)
{
// fetch the data
IObjectList resultList = service.Query(RepositoryId, statement, searchAllVersions, ctxt.IncludeAllowableActions,
@@ -1005,12 +1007,12 @@
{
if (typeId == null || typeId.Trim().Length == 0)
{
- throw new ArgumentException("Type ID must be set!", "typeId");
+ throw new ArgumentException("Type ID must be set!", nameof(typeId));
}
if (context == null)
{
- throw new ArgumentException("Operation context must be set!", "context");
+ throw new ArgumentException("Operation context must be set!", nameof(context));
}
IDiscoveryService discoveryService = Binding.GetDiscoveryService();
@@ -1045,7 +1047,7 @@
statement.Append(orderBy);
}
- PageFetcher<ICmisObject>.FetchPage fetchPageDelegate = delegate(BigInteger maxNumItems, BigInteger skipCount)
+ PageFetcher<ICmisObject>.FetchPage fetchPageDelegate = delegate (BigInteger maxNumItems, BigInteger skipCount)
{
// fetch the data
IObjectList resultList = discoveryService.Query(RepositoryId, statement.ToString(),
@@ -1266,7 +1268,7 @@
IRelationshipService service = Binding.GetRelationshipService();
IOperationContext ctxt = new OperationContext(context);
- PageFetcher<IRelationship>.FetchPage fetchPageDelegate = delegate(BigInteger maxNumItems, BigInteger skipCount)
+ PageFetcher<IRelationship>.FetchPage fetchPageDelegate = delegate (BigInteger maxNumItems, BigInteger skipCount)
{
// fetch the relationships
IObjectList relList = service.GetObjectRelationships(RepositoryId, id, includeSubRelationshipTypes, relationshipDirection,
@@ -1314,7 +1316,7 @@
if (!(secondaryType is ISecondaryType))
{
throw new ArgumentException("Secondary types contains a type that is not a secondary type: "
- + secondaryType.Id, "addSecondaryTypeIds");
+ + secondaryType.Id, nameof(addSecondaryTypeIds));
}
secondaryTypes[secondaryType.Id] = (ISecondaryType)secondaryType;
@@ -1367,7 +1369,7 @@
{
if (objectId == null || objectId.Id == null)
{
- throw new ArgumentException("Invalid object ID!", "objectId");
+ throw new ArgumentException("Invalid object ID!", nameof(objectId));
}
Binding.GetObjectService().DeleteObject(RepositoryId, objectId.Id, allVersions, null);
@@ -1379,7 +1381,7 @@
{
if (folderId == null || folderId.Id == null)
{
- throw new ArgumentException("Invalid object ID!", "folderId");
+ throw new ArgumentException("Invalid object ID!", nameof(folderId));
}
IFailedToDeleteData failed = Binding.GetObjectService().DeleteTree(RepositoryId, folderId.Id, allVersions, unfile, continueOnFailure, null);
@@ -1405,7 +1407,7 @@
{
if (docId == null || docId.Id == null)
{
- throw new ArgumentException("Invalid document ID!", "objectId");
+ throw new ArgumentException("Invalid document ID!", nameof(docId));
}
// get the content stream
@@ -1430,7 +1432,7 @@
{
if (objectId == null || objectId.Id == null)
{
- throw new ArgumentException("Invalid object ID!", "objectId");
+ throw new ArgumentException("Invalid object ID!", nameof(objectId));
}
return Binding.GetAclService().GetAcl(RepositoryId, objectId.Id, onlyBasicPermissions, null);
@@ -1441,7 +1443,7 @@
{
if (objectId == null || objectId.Id == null)
{
- throw new ArgumentException("Invalid object ID!", "objectId");
+ throw new ArgumentException("Invalid object ID!", nameof(objectId));
}
return Binding.GetAclService().ApplyAcl(RepositoryId, objectId.Id, ObjectFactory.ConvertAces(addAces),
@@ -1453,9 +1455,9 @@
{
if (objectId == null || objectId.Id == null)
{
- throw new ArgumentException("Invalid object ID!", "objectId");
+ throw new ArgumentException("Invalid object ID!", nameof(objectId));
}
- if (policyIds == null || (policyIds.Length == 0))
+ if (policyIds == null || policyIds.Length == 0)
{
throw new ArgumentException("No Policies provided!");
}
@@ -1465,7 +1467,7 @@
{
if (policyIds[i] == null || policyIds[i].Id == null)
{
- throw new ArgumentException("A Policy ID is not set!", "policyIds");
+ throw new ArgumentException("A Policy ID is not set!", nameof(policyIds));
}
ids[i] = policyIds[i].Id;
@@ -1482,11 +1484,11 @@
{
if (objectId == null || objectId.Id == null)
{
- throw new ArgumentException("Invalid object ID!", "objectId");
+ throw new ArgumentException("Invalid object ID!", nameof(objectId));
}
if (policyIds == null || policyIds.Length == 0)
{
- throw new ArgumentException("No Policies provided!", "policyIds");
+ throw new ArgumentException("No Policies provided!", nameof(policyIds));
}
string[] ids = new string[policyIds.Length];
@@ -1511,7 +1513,7 @@
/// </summary>
protected void CheckPath(string path)
{
- if (path == null || path.Length < 1)
+ if (string.IsNullOrEmpty(path))
{
throw new ArgumentException("Invalid path!");
}
@@ -1554,12 +1556,12 @@
{
if (session == null)
{
- throw new ArgumentNullException("session");
+ throw new ArgumentNullException(nameof(session));
}
if (statement == null)
{
- throw new ArgumentNullException("statement");
+ throw new ArgumentNullException(nameof(statement));
}
this.session = session;
@@ -1577,7 +1579,7 @@
{
if (type == null)
{
- throw new ArgumentException("Type must be set!");
+ throw new ArgumentNullException(nameof(type));
}
if (type.QueryName == null)
@@ -1703,7 +1705,7 @@
}
/// <inheritdoc/>
- public void SetId(int parameterIndex, params IObjectId[] id)
+ public void SetId(int parameterIndex, params IObjectId[] id)
{
if (id == null || id.Length == 0)
{
diff --git a/PortCMIS/client/ClientIntf.cs b/PortCMIS/client/ClientIntf.cs
index 4ab089a..e208856 100644
--- a/PortCMIS/client/ClientIntf.cs
+++ b/PortCMIS/client/ClientIntf.cs
@@ -2290,14 +2290,14 @@
/// <summary>
/// Item properties.
/// </summary>
- public interface ItemProperties
+ public interface IItemProperties
{
}
/// <summary>
/// Item interface.
/// </summary>
- public interface IItem : IFileableCmisObject, ItemProperties
+ public interface IItem : IFileableCmisObject, IItemProperties
{
/// <summary>
/// Returns the object type as an item type.
diff --git a/PortCMIS/client/ClientObjectFactory.cs b/PortCMIS/client/ClientObjectFactory.cs
index 6ac4703..a25ec94 100644
--- a/PortCMIS/client/ClientObjectFactory.cs
+++ b/PortCMIS/client/ClientObjectFactory.cs
@@ -47,8 +47,10 @@
{
if (aces == null) { return null; }
- Acl result = new Acl();
- result.Aces = new List<IAce>();
+ Acl result = new Acl()
+ {
+ Aces = new List<IAce>()
+ };
foreach (IAce ace in aces)
{
@@ -61,8 +63,10 @@
/// <inheritdoc/>
public virtual IAcl CreateAcl(IList<IAce> aces)
{
- Acl acl = new Acl();
- acl.Aces = aces;
+ Acl acl = new Acl()
+ {
+ Aces = aces
+ };
return acl;
}
@@ -106,7 +110,7 @@
{
if (rendition == null)
{
- throw new ArgumentException("rendition");
+ throw new ArgumentNullException(nameof(rendition));
}
return new Rendition(this.session, objectId, rendition.StreamId, rendition.MimeType, rendition.Length, rendition.Kind,
@@ -118,11 +122,13 @@
/// <inheritdoc/>
public virtual IContentStream CreateContentStream(string filename, long length, string mimetype, Stream stream)
{
- ContentStream result = new ContentStream();
- result.FileName = filename;
- result.Length = length;
- result.MimeType = mimetype;
- result.Stream = stream;
+ ContentStream result = new ContentStream()
+ {
+ FileName = filename,
+ Length = length,
+ MimeType = mimetype,
+ Stream = stream
+ };
return result;
}
@@ -219,7 +225,7 @@
{
if (objectType == null)
{
- throw new ArgumentNullException("objectType");
+ throw new ArgumentNullException(nameof(objectType));
}
if (objectType.PropertyDefinitions == null)
@@ -418,7 +424,7 @@
{
if (objectData == null)
{
- throw new ArgumentNullException("objectData");
+ throw new ArgumentNullException(nameof(objectData));
}
if (objectData.Id == null)
@@ -455,7 +461,7 @@
{
if (objectData == null)
{
- throw new ArgumentException("Object data is null!");
+ throw new ArgumentNullException(nameof(objectData));
}
return new QueryResult(session, objectData);
diff --git a/PortCMIS/client/ClientObjects.cs b/PortCMIS/client/ClientObjects.cs
index cc5ba4c..53e15a4 100644
--- a/PortCMIS/client/ClientObjects.cs
+++ b/PortCMIS/client/ClientObjects.cs
@@ -123,12 +123,12 @@
{
if (session == null)
{
- throw new ArgumentNullException("session");
+ throw new ArgumentNullException(nameof(session));
}
if (objectType == null)
{
- throw new ArgumentNullException("objectType");
+ throw new ArgumentNullException(nameof(objectType));
}
if (objectType.PropertyDefinitions == null || objectType.PropertyDefinitions.Count < 9)
@@ -139,7 +139,7 @@
if (objectData == null)
{
- throw new ArgumentNullException("objectData");
+ throw new ArgumentNullException(nameof(objectData));
}
if (objectData.Properties == null)
@@ -340,8 +340,10 @@
string objectId = ObjectId;
string changeToken = ChangeToken;
- HashSet<Updatability> updatebility = new HashSet<Updatability>();
- updatebility.Add(Updatability.ReadWrite);
+ HashSet<Updatability> updatebility = new HashSet<Updatability>()
+ {
+ Updatability.ReadWrite
+ };
// check if checked out
bool? isCheckedOut = GetPropertyValue(PropertyIds.IsVersionSeriesCheckedOut) as bool?;
@@ -373,9 +375,9 @@
/// <inheritdoc/>
public virtual ICmisObject Rename(string newName)
{
- if (newName == null || newName.Length == 0)
+ if (string.IsNullOrEmpty(newName))
{
- throw new ArgumentException("New name must not be empty!", "newName");
+ throw new ArgumentException("New name must not be empty!", nameof(newName));
}
IDictionary<string, object> prop = new Dictionary<string, object>();
@@ -450,7 +452,7 @@
{
if (propertyId == null)
{
- throw new ArgumentNullException("propertyId");
+ throw new ArgumentNullException(nameof(propertyId));
}
lock (objectLock)
@@ -774,12 +776,12 @@
if (sourceFolderId == null || sourceFolderId.Id == null)
{
- throw new ArgumentException("Source folder ID must be set!", "sourceFolderId");
+ throw new ArgumentException("Source folder ID must be set!", nameof(sourceFolderId));
}
if (targetFolderId == null || targetFolderId.Id == null)
{
- throw new ArgumentException("Target folder ID must be set!", "targetFolderId");
+ throw new ArgumentException("Target folder ID must be set!", nameof(targetFolderId));
}
Binding.GetObjectService().MoveObject(RepositoryId, ref objectId, targetFolderId.Id, sourceFolderId.Id, null);
@@ -881,7 +883,7 @@
// the repository sent a folder without a valid path...
throw new CmisInvalidServerData("Repository sent invalid data! No path property value!");
}
- paths.Add(folderPath + (folderPath.EndsWith("/") ? "" : "/") + p.RelativePathSegment);
+ paths.Add(folderPath + (folderPath.EndsWith("/", StringComparison.Ordinal) ? "" : "/") + p.RelativePathSegment);
}
return paths;
@@ -934,7 +936,7 @@
}
else
{
- throw new InvalidCastException("Object type is not a document type.");
+ throw new CmisInvalidServerData("Object type is not a document type.");
}
}
}
@@ -1192,9 +1194,11 @@
IObjectFactory of = Session.ObjectFactory;
- HashSet<Updatability> updatebility = new HashSet<Updatability>();
- updatebility.Add(Updatability.ReadWrite);
- updatebility.Add(Updatability.WhenCheckedOut);
+ HashSet<Updatability> updatebility = new HashSet<Updatability>()
+ {
+ Updatability.ReadWrite,
+ Updatability.WhenCheckedOut
+ };
Binding.GetVersioningService().CheckIn(RepositoryId, ref objectId, major, of.ConvertProperties(properties, ObjectType, SecondaryTypes, updatebility),
contentStream, checkinComment, of.ConvertPolicies(policies), of.ConvertAces(addAces), of.ConvertAces(removeAces), null);
@@ -1292,12 +1296,14 @@
// -> get the file name from properties, if present
if (contentStream.FileName == null && ContentStreamFileName != null)
{
- ContentStream newContentStream = new ContentStream();
- newContentStream.FileName = ContentStreamFileName;
- newContentStream.Length = contentStream.Length;
- newContentStream.MimeType = contentStream.MimeType;
- newContentStream.Stream = contentStream.Stream;
- newContentStream.Extensions = contentStream.Extensions;
+ ContentStream newContentStream = new ContentStream()
+ {
+ FileName = ContentStreamFileName,
+ Length = contentStream.Length,
+ MimeType = contentStream.MimeType,
+ Stream = contentStream.Stream,
+ Extensions = contentStream.Extensions
+ };
contentStream = newContentStream;
}
@@ -1475,7 +1481,7 @@
}
else
{
- throw new InvalidCastException("Object type is not a folder type.");
+ throw new CmisInvalidServerData("Object type is not a folder type.");
}
}
}
@@ -1907,7 +1913,7 @@
}
else
{
- throw new InvalidCastException("Object type is not a policy type.");
+ throw new CmisInvalidServerData("Object type is not a policy type.");
}
}
}
@@ -1944,7 +1950,7 @@
}
else
{
- throw new InvalidCastException("Object type is not a relationship type.");
+ throw new CmisInvalidServerData("Object type is not a relationship type.");
}
}
}
@@ -1976,7 +1982,7 @@
get
{
string sourceId = GetPropertyAsStringValue(PropertyIds.SourceId);
- if (sourceId == null || sourceId.Length == 0)
+ if (string.IsNullOrEmpty(sourceId))
{
return null;
}
@@ -2012,7 +2018,7 @@
get
{
string targetId = GetPropertyAsStringValue(PropertyIds.TargetId);
- if (targetId == null || targetId.Length == 0)
+ if (string.IsNullOrEmpty(targetId))
{
return null;
}
@@ -2050,7 +2056,7 @@
}
else
{
- throw new InvalidCastException("Object type is not an item type.");
+ throw new CmisInvalidServerData("Object type is not an item type.");
}
}
}
@@ -2169,8 +2175,8 @@
/// </summary>
public class Rendition : RenditionData, IRendition
{
- private ISession session;
- private string objectId;
+ private readonly ISession session;
+ private readonly string objectId;
/// <summary>
/// Constructor.
@@ -2298,12 +2304,12 @@
{
if (algorithm == null || algorithm.Trim().Length == 0)
{
- throw new ArgumentException("Algorithm must be set!", "algorithm");
+ throw new ArgumentException("Algorithm must be set!", nameof(algorithm));
}
if (hashStr == null || hashStr.Trim().Length == 0)
{
- throw new ArgumentException("Hash must be set!", "hashStr");
+ throw new ArgumentException("Hash must be set!", nameof(hashStr));
}
Algorithm = algorithm.ToLowerInvariant();
diff --git a/PortCMIS/client/ClientTypes.cs b/PortCMIS/client/ClientTypes.cs
index 718941a..8bb4fb2 100644
--- a/PortCMIS/client/ClientTypes.cs
+++ b/PortCMIS/client/ClientTypes.cs
@@ -29,8 +29,8 @@
/// </summary>
internal class ObjectTypeHelper
{
- private ISession session;
- private IObjectType objectType;
+ private readonly ISession session;
+ private readonly IObjectType objectType;
private IObjectType baseType;
private IObjectType parentType;
@@ -86,7 +86,7 @@
/// </summary>
public class DocumentType : DocumentTypeDefinition, IDocumentType
{
- private ObjectTypeHelper helper;
+ private readonly ObjectTypeHelper helper;
/// <summary>
/// Constructor.
@@ -122,7 +122,7 @@
/// </summary>
public class FolderType : FolderTypeDefinition, IFolderType
{
- private ObjectTypeHelper helper;
+ private readonly ObjectTypeHelper helper;
/// <summary>
/// Constructor.
@@ -156,7 +156,7 @@
/// </summary>
public class RelationshipType : RelationshipTypeDefinition, IRelationshipType
{
- private ObjectTypeHelper helper;
+ private readonly ObjectTypeHelper helper;
private IList<IObjectType> allowedSourceTypes;
private IList<IObjectType> allowedTargetTypes;
@@ -219,7 +219,7 @@
IList<IObjectType> types = new List<IObjectType>(ids == null ? 0 : ids.Count);
if (ids != null)
{
- foreach (String id in ids)
+ foreach (string id in ids)
{
types.Add(helper.Session.GetTypeDefinition(id));
}
@@ -236,7 +236,7 @@
/// </summary>
public class PolicyType : PolicyTypeDefinition, IPolicyType
{
- private ObjectTypeHelper helper;
+ private readonly ObjectTypeHelper helper;
/// <summary>
/// Constructor.
@@ -270,7 +270,7 @@
/// </summary>
public class ItemType : ItemTypeDefinition, IItemType
{
- private ObjectTypeHelper helper;
+ private readonly ObjectTypeHelper helper;
/// <summary>
/// Constructor.
@@ -304,7 +304,7 @@
/// </summary>
public class SecondaryType : SecondaryTypeDefinition, ISecondaryType
{
- private ObjectTypeHelper helper;
+ private readonly ObjectTypeHelper helper;
/// <summary>
/// Constructor.
diff --git a/PortCMIS/client/ClientUtils.cs b/PortCMIS/client/ClientUtils.cs
index 5c23c77..1c07c56 100644
--- a/PortCMIS/client/ClientUtils.cs
+++ b/PortCMIS/client/ClientUtils.cs
@@ -125,8 +125,10 @@
if (toid.Length == 0) { continue; }
if (toid == PropertiesStar)
{
- tempSet = new HashSet<string>();
- tempSet.Add(PropertiesStar);
+ tempSet = new HashSet<string>()
+ {
+ PropertiesStar
+ };
break;
}
if (toid.IndexOf(',') > -1)
@@ -342,28 +344,40 @@
/// <summary>
/// Generates a cache key from the current state of the operation context.
/// </summary>
+ ///
protected virtual void GenerateCacheKey()
{
if (!cacheEnabled)
{
cacheKey = null;
}
- else
+
+ StringBuilder sb = new StringBuilder(128);
+
+ int bits = 0;
+ if (includeAcls)
{
- StringBuilder sb = new StringBuilder();
-
- sb.Append(includeAcls ? "1" : "0");
- sb.Append(includeAllowableActions ? "1" : "0");
- sb.Append(includePolicies ? "1" : "0");
- sb.Append("|");
- sb.Append(filter == null ? "" : FilterString);
- sb.Append("|");
- sb.Append(includeRelationships == null ? "" : includeRelationships.GetCmisValue());
- sb.Append("|");
- sb.Append(renditionFilter == null ? "" : RenditionFilterString);
-
- cacheKey = sb.ToString();
+ bits += 1;
}
+ if (includeAllowableActions)
+ {
+ bits += 2;
+ }
+ if (includePolicies)
+ {
+ bits += 4;
+ }
+
+ sb.Append((char)('0' + bits));
+ sb.Append(includeRelationships == null ? '-' : (char)('a' + (int)includeRelationships));
+ sb.Append(filter == null ? "" : FilterString);
+ if (renditionFilter != null && renditionFilter.Count > 0)
+ {
+ sb.Append('\\');
+ sb.Append(RenditionFilterString);
+ }
+
+ cacheKey = sb.ToString();
}
}
@@ -426,10 +440,12 @@
/// </remarks>
public static IOperationContext CreateMinimumOperationContext(params string[] property)
{
- ISet<string> filter = new HashSet<string>();
- filter.Add(PropertyIds.ObjectId);
- filter.Add(PropertyIds.ObjectTypeId);
- filter.Add(PropertyIds.BaseTypeId);
+ ISet<string> filter = new HashSet<string>()
+ {
+ PropertyIds.ObjectId,
+ PropertyIds.ObjectTypeId,
+ PropertyIds.BaseTypeId
+ };
if (property != null)
{
@@ -555,7 +571,7 @@
get { return id; }
set
{
- if (value == null || value.Length == 0)
+ if (string.IsNullOrEmpty(value))
{
throw new ArgumentException("ID must be set!");
}
@@ -683,7 +699,8 @@
/// </summary>
/// <param name="pageFetcher">>the delegate that fetches a page</param>
public AbstractEnumerable(PageFetcher<T> pageFetcher) :
- this(0, pageFetcher) { }
+ this(0, pageFetcher)
+ { }
/// <summary>
/// Constructor.
@@ -753,7 +770,7 @@
/// </summary>
internal abstract class AbstractEnumerator<T> : IEnumerator<T>
{
- private PageFetcher<T> pageFetcher;
+ private readonly PageFetcher<T> pageFetcher;
private PageFetcher<T>.Page<T> page = null;
private BigInteger? totalNumItems = null;
private bool? hasMoreItems = null;
@@ -768,7 +785,7 @@
/// </summary>
/// <param name="skipCount">the skip count</param>
/// <param name="pageFetcher">the delegate that fetches a page</param>
- public AbstractEnumerator(BigInteger skipCount, PageFetcher<T> pageFetcher)
+ protected AbstractEnumerator(BigInteger skipCount, PageFetcher<T> pageFetcher)
{
this.SkipCount = skipCount;
this.pageFetcher = pageFetcher;
@@ -1007,7 +1024,8 @@
/// </summary>
/// <param name="pageFetcher">the delegate that fetches a page</param>
public CollectionEnumerable(PageFetcher<T> pageFetcher) :
- this(0, pageFetcher) { }
+ this(0, pageFetcher)
+ { }
/// <summary>
/// Constructor.
@@ -1015,7 +1033,8 @@
/// <param name="position">the position</param>
/// <param name="pageFetcher">the delegate that fetches a page</param>
public CollectionEnumerable(BigInteger position, PageFetcher<T> pageFetcher) :
- base(position, pageFetcher) { }
+ base(position, pageFetcher)
+ { }
/// <inheritdoc/>
protected override AbstractEnumerator<T> CreateEnumerator()
@@ -1035,7 +1054,8 @@
/// <param name="skipCount">the skip count</param>
/// <param name="pageFetcher">the delegate that fetches a page</param>
public CollectionEnumerator(BigInteger skipCount, PageFetcher<T> pageFetcher) :
- base(skipCount, pageFetcher) { }
+ base(skipCount, pageFetcher)
+ { }
/// <summary>
/// Move to the next items.
@@ -1063,7 +1083,7 @@
}
page = IncrementPage();
- items = page == null ? null : page.Items;
+ items = page?.Items;
}
if (items == null || items.Count == 0 || SkipOffset == items.Count)
@@ -1087,7 +1107,8 @@
/// </summary>
/// <param name="pageFetcher">the delegate that fetches a page</param>
public CollectionPageEnumerable(PageFetcher<T> pageFetcher) :
- this(0, pageFetcher) { }
+ this(0, pageFetcher)
+ { }
/// <summary>
/// Constructor.
@@ -1095,7 +1116,8 @@
/// <param name="position">the position</param>
/// <param name="pageFetcher">the delegate that fetches a page</param>
public CollectionPageEnumerable(BigInteger position, PageFetcher<T> pageFetcher) :
- base(position, pageFetcher) { }
+ base(position, pageFetcher)
+ { }
/// <inheritdoc/>
protected override AbstractEnumerator<T> CreateEnumerator()
@@ -1115,7 +1137,8 @@
/// <param name="skipCount">the skip count</param>
/// <param name="pageFetcher">the delegate that fetches a page</param>
public CollectionPageEnumerator(BigInteger skipCount, PageFetcher<T> pageFetcher) :
- base(skipCount, pageFetcher) { }
+ base(skipCount, pageFetcher)
+ { }
/// <summary>
/// Move to the next items.
@@ -1249,7 +1272,7 @@
private static string CheckFilename(string filename)
{
- if (filename == null || filename.Length == 0)
+ if (string.IsNullOrEmpty(filename))
{
return "content";
}
diff --git a/PortCMIS/const/ExtensionFeatures.cs b/PortCMIS/const/ExtensionFeatures.cs
index 651ec3d..d275be0 100644
--- a/PortCMIS/const/ExtensionFeatures.cs
+++ b/PortCMIS/const/ExtensionFeatures.cs
@@ -17,11 +17,6 @@
* under the License.
*/
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using PortCMIS.Data;
namespace PortCMIS.Const
diff --git a/PortCMIS/data/DataImpl.cs b/PortCMIS/data/DataImpl.cs
index 319b4f8..7bcf95b 100644
--- a/PortCMIS/data/DataImpl.cs
+++ b/PortCMIS/data/DataImpl.cs
@@ -342,7 +342,7 @@
public string ParentTypeId
{
get { return parentTypeId; }
- set { parentTypeId = (value == null || value.Length == 0 ? null : value); }
+ set { parentTypeId = string.IsNullOrEmpty(value) ? null : value; }
}
/// <inheritdoc/>
@@ -877,7 +877,7 @@
{
if (properties == null)
{
- throw new ArgumentNullException("properties");
+ throw new ArgumentNullException(nameof(properties));
}
AddProperties(properties.PropertyList);
@@ -1137,7 +1137,7 @@
public IPrincipal Principal { get; set; }
/// <inheritdoc/>
- public string PrincipalId { get { return Principal == null ? null : Principal.Id; } }
+ public string PrincipalId { get { return Principal?.Id; } }
/// <inheritdoc/>
public IList<string> Permissions { get; set; }
diff --git a/PortCMIS/data/Extensions.cs b/PortCMIS/data/Extensions.cs
index bca80a5..031cb08 100644
--- a/PortCMIS/data/Extensions.cs
+++ b/PortCMIS/data/Extensions.cs
@@ -17,11 +17,8 @@
* under the License.
*/
-using System;
using System.Collections.Generic;
-using System.Linq;
using System.Text;
-using System.Threading.Tasks;
namespace PortCMIS.Data.Extensions
{
diff --git a/PortCMIS/enum/Enums.cs b/PortCMIS/enum/Enums.cs
index 668db4c..d8e2f85 100644
--- a/PortCMIS/enum/Enums.cs
+++ b/PortCMIS/enum/Enums.cs
@@ -18,7 +18,6 @@
*/
using System;
-using System.Collections.Generic;
using System.Reflection;
namespace PortCMIS.Enums
diff --git a/PortCMIS/utils/Cache.cs b/PortCMIS/utils/Cache.cs
index d098008..06a6d52 100644
--- a/PortCMIS/utils/Cache.cs
+++ b/PortCMIS/utils/Cache.cs
@@ -20,8 +20,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace PortCMIS.Utils
{
diff --git a/PortCMIS/utils/Logger.cs b/PortCMIS/utils/Logger.cs
index 18af3ae..e1f0976 100644
--- a/PortCMIS/utils/Logger.cs
+++ b/PortCMIS/utils/Logger.cs
@@ -26,7 +26,7 @@
/// <summary>
/// Simplistic logging.
/// </summary>
- public class Logger
+ public static class Logger
{
/// <summary>
diff --git a/PortCMISTests/SimpleCmisTest.cs b/PortCMISTests/SimpleCmisTest.cs
index fa43b59..61dceed 100644
--- a/PortCMISTests/SimpleCmisTest.cs
+++ b/PortCMISTests/SimpleCmisTest.cs
@@ -20,7 +20,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using PortCMIS;
using PortCMIS.Client;
-using PortCMIS.Client.Impl;
using PortCMIS.Data;
using PortCMIS.Enums;
using PortCMIS.Exceptions;
@@ -155,6 +154,14 @@
Assert.AreEqual(newDoc.Name, newDoc2.Name);
Assert.AreEqual(Encoding.UTF8.GetBytes(contentString).Length, newDoc2.ContentStreamLength);
+ // fetch it again
+ newObj = Session.GetLatestDocumentVersion(newDoc, ctxt);
+ Assert.IsTrue(newObj is IDocument);
+ IDocument newDoc3 = (IDocument)newObj;
+
+ Assert.AreEqual(newDoc.Id, newDoc3.Id);
+ Assert.AreEqual(newDoc.Name, newDoc3.Name);
+
// delete document
newDoc.Delete();
@@ -168,8 +175,27 @@
// expected
}
+ Assert.IsFalse(Session.Exists(newDoc.Id));
+
+
+ // try an item
+ IList<IObjectType> types = Session.GetTypeChildren(null, false).ToList();
+ Assert.IsNotNull(types);
+ Assert.IsTrue(types.Count >= 2);
+ if (types.Any(type => type.Id == "cmis:item"))
+ {
+ IItem newItem = CreateItem(newFolder, "testItem");
+
+ newItem.Delete();
+
+ Assert.IsFalse(Session.Exists(newItem.Id));
+ }
+
+
// delete folder
+ Assert.IsTrue(Session.ExistsPath(newFolder.Path));
+
newFolder.Delete();
Assert.IsFalse(Session.Exists(newFolder));
diff --git a/PortCMISTests/framework/DefaultTestValues.cs b/PortCMISTests/framework/DefaultTestValues.cs
index 14a3476..57a539b 100644
--- a/PortCMISTests/framework/DefaultTestValues.cs
+++ b/PortCMISTests/framework/DefaultTestValues.cs
@@ -31,7 +31,7 @@
public static IDictionary<string, string> SessionParameters = new Dictionary<string, string>()
{
- {SessionParameter.BindingType , BindingType.Browser},
+ {SessionParameter.BindingType , BindingType.AtomPub},
{SessionParameter.BrowserUrl , "http://localhost:8080/inmemory/browser"},
{SessionParameter.AtomPubUrl , "http://localhost:8080/inmemory/atom11"},
{SessionParameter.RepositoryId , "A1"},
diff --git a/PortCMISTests/framework/TestFramework.cs b/PortCMISTests/framework/TestFramework.cs
index 66e9652..5cacf27 100644
--- a/PortCMISTests/framework/TestFramework.cs
+++ b/PortCMISTests/framework/TestFramework.cs
@@ -94,7 +94,20 @@
props[PropertyIds.Name] = name;
props[PropertyIds.ObjectTypeId] = "cmis:folder";
- return parent.CreateFolder(props);
+ IFolder newFolder = parent.CreateFolder(props);
+
+ Assert.IsNotNull(newFolder);
+ Assert.AreEqual(BaseTypeId.CmisFolder, newFolder.BaseTypeId);
+ Assert.AreEqual("cmis:folder", newFolder.FolderType.Id);
+ Assert.AreEqual(name, newFolder.Name);
+ Assert.AreEqual(parent.Id, newFolder.ParentId);
+ Assert.IsFalse(newFolder.IsRootFolder);
+ Assert.IsNotNull(newFolder.CreationDate);
+ Assert.IsNotNull(newFolder.CreatedBy);
+ Assert.IsNotNull(newFolder.LastModificationDate);
+ Assert.IsNotNull(newFolder.LastModifiedBy);
+
+ return newFolder;
}
public IDocument CreateTextDocument(IFolder parent, string name, string content)
@@ -105,7 +118,40 @@
IContentStream contentStream = ContentStreamUtils.CreateTextContentStream(name, content);
- return parent.CreateDocument(props, contentStream, VersioningState.None);
+ IDocument newDoc = parent.CreateDocument(props, contentStream, VersioningState.None);
+
+
+ Assert.IsNotNull(newDoc);
+ Assert.AreEqual(BaseTypeId.CmisDocument, newDoc.BaseTypeId);
+ Assert.AreEqual("cmis:document", newDoc.DocumentType.Id);
+ Assert.AreEqual(name, newDoc.Name);
+ Assert.AreEqual(parent.Id, newDoc.Parents[0].Id);
+ Assert.IsNotNull(newDoc.CreationDate);
+ Assert.IsNotNull(newDoc.CreatedBy);
+ Assert.IsNotNull(newDoc.LastModificationDate);
+ Assert.IsNotNull(newDoc.LastModifiedBy);
+
+ return newDoc;
+ }
+
+ public IItem CreateItem(IFolder parent, string name)
+ {
+ IDictionary<string, object> props = new Dictionary<string, object>();
+ props[PropertyIds.Name] = name;
+ props[PropertyIds.ObjectTypeId] = "cmis:item";
+
+ IItem newItem = parent.CreateItem(props);
+
+ Assert.IsNotNull(newItem);
+ Assert.AreEqual(BaseTypeId.CmisItem, newItem.BaseTypeId);
+ Assert.AreEqual("cmis:item", newItem.ItemType.Id);
+ Assert.AreEqual(name, newItem.Name);
+ Assert.IsNotNull(newItem.CreationDate);
+ Assert.IsNotNull(newItem.CreatedBy);
+ Assert.IsNotNull(newItem.LastModificationDate);
+ Assert.IsNotNull(newItem.LastModifiedBy);
+
+ return newItem;
}
public byte[] ConvertStreamToByteArray(Stream stream)
diff --git a/PortCMISWin/binding/WindowsHttp.cs b/PortCMISWin/binding/WindowsHttp.cs
index 11be947..1bc7cc8 100644
--- a/PortCMISWin/binding/WindowsHttp.cs
+++ b/PortCMISWin/binding/WindowsHttp.cs
@@ -351,10 +351,10 @@
if (httpResponse.StatusCode != HttpStatusCode.NoContent)
{
if (ContentType != null &&
- (ContentType.ToLowerInvariant().StartsWith("text/") ||
- ContentType.ToLowerInvariant().EndsWith("+xml") ||
- ContentType.ToLowerInvariant().StartsWith("application/xml") ||
- ContentType.ToLowerInvariant().StartsWith("application/json")))
+ (ContentType.ToLowerInvariant().StartsWith("text/", StringComparison.Ordinal) ||
+ ContentType.ToLowerInvariant().EndsWith("+xml", StringComparison.Ordinal) ||
+ ContentType.ToLowerInvariant().StartsWith("application/xml", StringComparison.Ordinal) ||
+ ContentType.ToLowerInvariant().StartsWith("application/json", StringComparison.Ordinal)))
{
ErrorContent = GetContentString().Result;
@@ -366,7 +366,7 @@
response.Dispose();
response = null;
}
- catch (Exception) { }
+ catch { }
}
}
@@ -385,7 +385,7 @@
response.Dispose();
response = null;
}
- catch (Exception) { }
+ catch { }
}
}