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/17 21:43:34 UTC
svn commit: r1799023 [2/2] - in /chemistry/portcmis/trunk: PortCMIS/binding/
PortCMIS/binding/atompub/ PortCMIS/binding/browser/
PortCMIS/binding/browser/json/ PortCMIS/client/ PortCMIS/const/
PortCMIS/data/ PortCMIS/enum/ PortCMIS/utils/ PortCMISTests...
Modified: chemistry/portcmis/trunk/PortCMIS/client/ClientUtils.cs
URL: http://svn.apache.org/viewvc/chemistry/portcmis/trunk/PortCMIS/client/ClientUtils.cs?rev=1799023&r1=1799022&r2=1799023&view=diff
==============================================================================
--- chemistry/portcmis/trunk/PortCMIS/client/ClientUtils.cs (original)
+++ chemistry/portcmis/trunk/PortCMIS/client/ClientUtils.cs Sat Jun 17 21:43:33 2017
@@ -125,8 +125,10 @@ namespace PortCMIS.Client
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 @@ namespace PortCMIS.Client
/// <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();
- 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);
+ StringBuilder sb = new StringBuilder(128);
- cacheKey = sb.ToString();
+ int bits = 0;
+ if (includeAcls)
+ {
+ 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 @@ namespace PortCMIS.Client
/// </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 @@ namespace PortCMIS.Client
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 @@ namespace PortCMIS.Client
/// </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 @@ namespace PortCMIS.Client
/// </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 @@ namespace PortCMIS.Client
/// </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 @@ namespace PortCMIS.Client
/// </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 @@ namespace PortCMIS.Client
/// <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 @@ namespace PortCMIS.Client
/// <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 @@ namespace PortCMIS.Client
}
page = IncrementPage();
- items = page == null ? null : page.Items;
+ items = page?.Items;
}
if (items == null || items.Count == 0 || SkipOffset == items.Count)
@@ -1087,7 +1107,8 @@ namespace PortCMIS.Client
/// </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 @@ namespace PortCMIS.Client
/// <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 @@ namespace PortCMIS.Client
/// <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 @@ namespace PortCMIS.Client
private static string CheckFilename(string filename)
{
- if (filename == null || filename.Length == 0)
+ if (string.IsNullOrEmpty(filename))
{
return "content";
}
Modified: chemistry/portcmis/trunk/PortCMIS/const/ExtensionFeatures.cs
URL: http://svn.apache.org/viewvc/chemistry/portcmis/trunk/PortCMIS/const/ExtensionFeatures.cs?rev=1799023&r1=1799022&r2=1799023&view=diff
==============================================================================
--- chemistry/portcmis/trunk/PortCMIS/const/ExtensionFeatures.cs (original)
+++ chemistry/portcmis/trunk/PortCMIS/const/ExtensionFeatures.cs Sat Jun 17 21:43:33 2017
@@ -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
Modified: chemistry/portcmis/trunk/PortCMIS/data/DataImpl.cs
URL: http://svn.apache.org/viewvc/chemistry/portcmis/trunk/PortCMIS/data/DataImpl.cs?rev=1799023&r1=1799022&r2=1799023&view=diff
==============================================================================
--- chemistry/portcmis/trunk/PortCMIS/data/DataImpl.cs (original)
+++ chemistry/portcmis/trunk/PortCMIS/data/DataImpl.cs Sat Jun 17 21:43:33 2017
@@ -342,7 +342,7 @@ namespace PortCMIS.Data
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 @@ namespace PortCMIS.Data
{
if (properties == null)
{
- throw new ArgumentNullException("properties");
+ throw new ArgumentNullException(nameof(properties));
}
AddProperties(properties.PropertyList);
@@ -1137,7 +1137,7 @@ namespace PortCMIS.Data
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; }
Modified: chemistry/portcmis/trunk/PortCMIS/data/Extensions.cs
URL: http://svn.apache.org/viewvc/chemistry/portcmis/trunk/PortCMIS/data/Extensions.cs?rev=1799023&r1=1799022&r2=1799023&view=diff
==============================================================================
--- chemistry/portcmis/trunk/PortCMIS/data/Extensions.cs (original)
+++ chemistry/portcmis/trunk/PortCMIS/data/Extensions.cs Sat Jun 17 21:43:33 2017
@@ -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
{
Modified: chemistry/portcmis/trunk/PortCMIS/enum/Enums.cs
URL: http://svn.apache.org/viewvc/chemistry/portcmis/trunk/PortCMIS/enum/Enums.cs?rev=1799023&r1=1799022&r2=1799023&view=diff
==============================================================================
--- chemistry/portcmis/trunk/PortCMIS/enum/Enums.cs (original)
+++ chemistry/portcmis/trunk/PortCMIS/enum/Enums.cs Sat Jun 17 21:43:33 2017
@@ -18,7 +18,6 @@
*/
using System;
-using System.Collections.Generic;
using System.Reflection;
namespace PortCMIS.Enums
Modified: chemistry/portcmis/trunk/PortCMIS/utils/Cache.cs
URL: http://svn.apache.org/viewvc/chemistry/portcmis/trunk/PortCMIS/utils/Cache.cs?rev=1799023&r1=1799022&r2=1799023&view=diff
==============================================================================
--- chemistry/portcmis/trunk/PortCMIS/utils/Cache.cs (original)
+++ chemistry/portcmis/trunk/PortCMIS/utils/Cache.cs Sat Jun 17 21:43:33 2017
@@ -20,8 +20,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace PortCMIS.Utils
{
Modified: chemistry/portcmis/trunk/PortCMIS/utils/Logger.cs
URL: http://svn.apache.org/viewvc/chemistry/portcmis/trunk/PortCMIS/utils/Logger.cs?rev=1799023&r1=1799022&r2=1799023&view=diff
==============================================================================
--- chemistry/portcmis/trunk/PortCMIS/utils/Logger.cs (original)
+++ chemistry/portcmis/trunk/PortCMIS/utils/Logger.cs Sat Jun 17 21:43:33 2017
@@ -26,7 +26,7 @@ namespace PortCMIS.Utils
/// <summary>
/// Simplistic logging.
/// </summary>
- public class Logger
+ public static class Logger
{
/// <summary>
Modified: chemistry/portcmis/trunk/PortCMISTests/SimpleCmisTest.cs
URL: http://svn.apache.org/viewvc/chemistry/portcmis/trunk/PortCMISTests/SimpleCmisTest.cs?rev=1799023&r1=1799022&r2=1799023&view=diff
==============================================================================
--- chemistry/portcmis/trunk/PortCMISTests/SimpleCmisTest.cs (original)
+++ chemistry/portcmis/trunk/PortCMISTests/SimpleCmisTest.cs Sat Jun 17 21:43:33 2017
@@ -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 @@ namespace PortCMISTests
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 @@ namespace PortCMISTests
// 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));
Modified: chemistry/portcmis/trunk/PortCMISTests/framework/DefaultTestValues.cs
URL: http://svn.apache.org/viewvc/chemistry/portcmis/trunk/PortCMISTests/framework/DefaultTestValues.cs?rev=1799023&r1=1799022&r2=1799023&view=diff
==============================================================================
--- chemistry/portcmis/trunk/PortCMISTests/framework/DefaultTestValues.cs (original)
+++ chemistry/portcmis/trunk/PortCMISTests/framework/DefaultTestValues.cs Sat Jun 17 21:43:33 2017
@@ -31,7 +31,7 @@ namespace PortCMISTests.Framework
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"},
Modified: chemistry/portcmis/trunk/PortCMISTests/framework/TestFramework.cs
URL: http://svn.apache.org/viewvc/chemistry/portcmis/trunk/PortCMISTests/framework/TestFramework.cs?rev=1799023&r1=1799022&r2=1799023&view=diff
==============================================================================
--- chemistry/portcmis/trunk/PortCMISTests/framework/TestFramework.cs (original)
+++ chemistry/portcmis/trunk/PortCMISTests/framework/TestFramework.cs Sat Jun 17 21:43:33 2017
@@ -94,7 +94,20 @@ namespace PortCMISTests.Framework
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 @@ namespace PortCMISTests.Framework
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)
Modified: chemistry/portcmis/trunk/PortCMISWin/binding/WindowsHttp.cs
URL: http://svn.apache.org/viewvc/chemistry/portcmis/trunk/PortCMISWin/binding/WindowsHttp.cs?rev=1799023&r1=1799022&r2=1799023&view=diff
==============================================================================
--- chemistry/portcmis/trunk/PortCMISWin/binding/WindowsHttp.cs (original)
+++ chemistry/portcmis/trunk/PortCMISWin/binding/WindowsHttp.cs Sat Jun 17 21:43:33 2017
@@ -351,10 +351,10 @@ namespace PortCMIS.Binding.Http
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 @@ namespace PortCMIS.Binding.Http
response.Dispose();
response = null;
}
- catch (Exception) { }
+ catch { }
}
}
@@ -385,7 +385,7 @@ namespace PortCMIS.Binding.Http
response.Dispose();
response = null;
}
- catch (Exception) { }
+ catch { }
}
}