Added: chemistry/portcmis/PortCMIS/client/ClientUtils.cs URL: http://svn.apache.org/viewvc/chemistry/portcmis/PortCMIS/client/ClientUtils.cs?rev=1691890&view=auto ============================================================================== --- chemistry/portcmis/PortCMIS/client/ClientUtils.cs (added) +++ chemistry/portcmis/PortCMIS/client/ClientUtils.cs Mon Jul 20 08:48:57 2015 @@ -0,0 +1,742 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* Kind, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +using PortCMIS.Enums; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Numerics; +using System.Text; + +namespace PortCMIS.Client.Impl +{ + /// <summary> + /// Operation context implementation. + /// </summary> + public class OperationContext : IOperationContext + { + public const string PropertiesStar = "*"; + public const string RenditionNone = "cmis:none"; + + private HashSet<string> filter; + private bool includeAllowableActions; + private bool includeAcls; + private IncludeRelationships? includeRelationships; + private bool includePolicies; + private HashSet<string> renditionFilter; + private bool includePathSegments; + private string orderBy; + private bool cacheEnabled; + private string cacheKey; + private int maxItemsPerPage; + + public OperationContext() + { + filter = null; + includeAcls = false; + includeAllowableActions = true; + includePolicies = false; + includeRelationships = PortCMIS.Enums.IncludeRelationships.None; + renditionFilter = null; + includePathSegments = true; + orderBy = null; + cacheEnabled = false; + maxItemsPerPage = 100; + + GenerateCacheKey(); + } + + public OperationContext(IOperationContext source) + { + filter = (source.Filter == null ? null : new HashSet<string>(source.Filter)); + includeAcls = source.IncludeAcls; + includeAllowableActions = source.IncludeAllowableActions; + includePolicies = source.IncludePolicies; + includeRelationships = source.IncludeRelationships; + renditionFilter = (source.RenditionFilter == null ? null : new HashSet<string>(source.RenditionFilter)); + includePathSegments = source.IncludePathSegments; + orderBy = source.OrderBy; + cacheEnabled = source.CacheEnabled; + maxItemsPerPage = source.MaxItemsPerPage; + + GenerateCacheKey(); + } + + public OperationContext(HashSet<string> filter, bool includeAcls, bool includeAllowableActions, + bool includePolicies, IncludeRelationships includeRelationships, HashSet<string> renditionFilter, + bool includePathSegments, String orderBy, bool cacheEnabled, int maxItemsPerPage) + { + this.filter = filter; + this.includeAcls = includeAcls; + this.includeAllowableActions = includeAllowableActions; + this.includePolicies = includePolicies; + this.includeRelationships = includeRelationships; + this.renditionFilter = renditionFilter; + this.includePathSegments = includePathSegments; + this.orderBy = orderBy; + this.cacheEnabled = cacheEnabled; + this.maxItemsPerPage = maxItemsPerPage; + + GenerateCacheKey(); + } + + public HashSet<string> Filter + { + get { return filter == null ? null : new HashSet<string>(filter); } + set + { + if (value != null) + { + HashSet<string> tempSet = new HashSet<string>(); + foreach (string oid in value) + { + if (oid == null) { continue; } + + string toid = oid.Trim(); + if (toid.Length == 0) { continue; } + if (toid == PropertiesStar) + { + tempSet = new HashSet<string>(); + tempSet.Add(PropertiesStar); + break; + } + if (toid.IndexOf(',') > -1) + { + throw new ArgumentException("Query ID must not contain a comma!"); + } + + tempSet.Add(toid); + } + + if (tempSet.Count == 0) { filter = null; } + else { filter = tempSet; } + } + else + { + filter = null; + } + + GenerateCacheKey(); + } + } + + public string FilterString + { + get + { + if (filter == null) { return null; } + + if (filter.Contains(PropertiesStar)) + { + return PropertiesStar; + } + + this.filter.Add(PropertyIds.ObjectId); + this.filter.Add(PropertyIds.BaseTypeId); + this.filter.Add(PropertyIds.ObjectTypeId); + + StringBuilder sb = new StringBuilder(); + + foreach (String oid in filter) + { + if (sb.Length > 0) { sb.Append(','); } + sb.Append(oid); + } + + return sb.ToString(); + } + + set + { + if (value == null || value.Trim().Length == 0) + { + Filter = null; + return; + } + + string[] ids = value.Split(','); + HashSet<string> tempSet = new HashSet<string>(); + foreach (string qid in ids) + { + tempSet.Add(qid); + } + + Filter = tempSet; + } + } + + public bool IncludeAllowableActions + { + get { return includeAllowableActions; } + set { includeAllowableActions = value; GenerateCacheKey(); } + } + + public bool IncludeAcls + { + get { return includeAcls; } + set { includeAcls = value; GenerateCacheKey(); } + } + + public IncludeRelationships? IncludeRelationships + { + get { return includeRelationships; } + set { includeRelationships = value; GenerateCacheKey(); } + } + + public bool IncludePolicies + { + get { return includePolicies; } + set { includePolicies = value; GenerateCacheKey(); } + } + + public HashSet<string> RenditionFilter + { + get { return renditionFilter == null ? null : new HashSet<string>(renditionFilter); } + set + { + HashSet<string> tempSet = new HashSet<string>(); + if (value != null) + { + foreach (String rf in value) + { + if (rf == null) { continue; } + + String trf = rf.Trim(); + if (trf.Length == 0) { continue; } + if (trf.IndexOf(',') > -1) + { + throw new ArgumentException("Rendition must not contain a comma!"); + } + + tempSet.Add(trf); + } + + if (tempSet.Count == 0) + { + tempSet.Add(RenditionNone); + } + } + else + { + tempSet.Add(RenditionNone); + } + + renditionFilter = tempSet; + + GenerateCacheKey(); + } + } + + public string RenditionFilterString + { + get + { + if (renditionFilter == null) { return null; } + + StringBuilder sb = new StringBuilder(); + foreach (string rf in renditionFilter) + { + if (sb.Length > 0) { sb.Append(','); } + sb.Append(rf); + } + + return sb.ToString(); + } + + set + { + if (value == null || value.Trim().Length == 0) + { + RenditionFilter = null; + return; + } + + string[] renditions = value.Split(','); + HashSet<string> tempSet = new HashSet<string>(); + foreach (string rend in renditions) + { + tempSet.Add(rend); + } + + RenditionFilter = tempSet; + } + } + + public bool IncludePathSegments + { + get { return includePathSegments; } + set { includePathSegments = value; GenerateCacheKey(); } + } + + public string OrderBy + { + get { return orderBy; } + set { orderBy = value; GenerateCacheKey(); } + } + + public bool CacheEnabled + { + get { return cacheEnabled; } + set { cacheEnabled = value; GenerateCacheKey(); } + } + + public string CacheKey + { + get { return cacheKey; } + } + + public int MaxItemsPerPage + { + get { return maxItemsPerPage; } + set { maxItemsPerPage = value; } + } + + protected 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); + + cacheKey = sb.ToString(); + } + } + } + + /// <summary> + /// Object ID implementation. + /// </summary> + public class ObjectId : IObjectId + { + private string id; + public string Id + { + get { return id; } + set + { + if (value == null || value.Length == 0) + { + throw new ArgumentException("ID must be set!"); + } + + id = value; + } + } + + public ObjectId(string id) + { + Id = id; + } + } + + /// <summary> + /// Tree implementation. + /// </summary> + public class Tree<T> : ITree<T> + { + public T Item { get; set; } + public IList<ITree<T>> Children { get; set; } + } + + /// <summary> + /// Base class for IItemEnumerable's. + /// </summary> + public abstract class AbstractEnumerable<T> : IItemEnumerable<T> + { + private AbstractEnumerator<T> enumerator; + protected AbstractEnumerator<T> Enumerator + { + get + { + if (enumerator == null) { enumerator = CreateEnumerator(); } + return enumerator; + } + } + + protected PageFetcher<T> PageFetcher { get; set; } + protected BigInteger SkipCount { get; private set; } + + public AbstractEnumerable(PageFetcher<T> pageFetcher) : + this(0, pageFetcher) { } + + protected AbstractEnumerable(BigInteger position, PageFetcher<T> pageFetcher) + { + this.PageFetcher = pageFetcher; + this.SkipCount = position; + } + + protected abstract AbstractEnumerator<T> CreateEnumerator(); + + IEnumerator<T> IEnumerable<T>.GetEnumerator() + { + return GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public IEnumerator<T> GetEnumerator() + { + return Enumerator; + } + + public IItemEnumerable<T> SkipTo(BigInteger position) + { + return new CollectionEnumerable<T>(position, PageFetcher); + } + + public IItemEnumerable<T> GetPage() + { + return new CollectionPageEnumerable<T>(SkipCount, PageFetcher); + } + + public IItemEnumerable<T> GetPage(int maxNumItems) + { + PageFetcher.MaxNumItems = maxNumItems; + return new CollectionPageEnumerable<T>(SkipCount, PageFetcher); + } + + public BigInteger PageNumItems { get { return Enumerator.PageNumItems; } } + + public bool HasMoreItems { get { return Enumerator.HasMoreItems; } } + + public BigInteger TotalNumItems { get { return Enumerator.TotalNumItems; } } + } + + /// <summary> + /// Abstract Enumerator implementation. + /// </summary> + public abstract class AbstractEnumerator<T> : IEnumerator<T> + { + private PageFetcher<T> pageFetcher; + private PageFetcher<T>.Page<T> page = null; + private BigInteger? totalNumItems = null; + private bool? hasMoreItems = null; + + protected T current; + + public AbstractEnumerator(BigInteger skipCount, PageFetcher<T> pageFetcher) + { + this.SkipCount = skipCount; + this.pageFetcher = pageFetcher; + } + + T IEnumerator<T>.Current { get { return Current; } } + object IEnumerator.Current { get { return Current; } } + public T Current { get { return current; } } + + public void Reset() + { + throw new NotSupportedException(); + } + + public abstract bool MoveNext(); + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + } + + public BigInteger SkipCount { get; protected set; } + + public int SkipOffset { get; protected set; } + + public BigInteger Position { get { return SkipCount + SkipOffset; } } + + public BigInteger PageNumItems + { + get + { + PageFetcher<T>.Page<T> page = GetCurrentPage(); + if (page != null) + { + IList<T> items = page.Items; + if (items != null) + { + return items.Count; + } + } + return 0; + } + } + + public BigInteger TotalNumItems + { + get + { + if (totalNumItems == null) + { + totalNumItems = -1; + PageFetcher<T>.Page<T> page = GetCurrentPage(); + if (page != null) + { + totalNumItems = page.TotalNumItems; + } + } + return (BigInteger)totalNumItems; + } + } + + public bool HasMoreItems + { + get + { + if (hasMoreItems == null) + { + hasMoreItems = false; + PageFetcher<T>.Page<T> page = GetCurrentPage(); + if (page != null) + { + if (page.HasMoreItems.HasValue) + { + hasMoreItems = page.HasMoreItems; + } + } + } + return (bool)hasMoreItems; + } + } + + protected int IncrementSkipOffset() + { + return SkipOffset++; + } + + protected PageFetcher<T>.Page<T> GetCurrentPage() + { + if (page == null) + { + page = pageFetcher.FetchNextPage(SkipCount); + } + return page; + } + + protected PageFetcher<T>.Page<T> IncrementPage() + { + SkipCount += SkipOffset; + SkipOffset = 0; + totalNumItems = null; + hasMoreItems = null; + page = pageFetcher.FetchNextPage(SkipCount); + return page; + } + } + + /// <summary> + /// Page fetcher. + /// </summary> + public class PageFetcher<T> + { + public delegate Page<T> FetchPage(BigInteger maxNumItems, BigInteger skipCount); + + private FetchPage fetchPageDelegate; + + public PageFetcher(BigInteger maxNumItems, FetchPage fetchPageDelegate) + { + MaxNumItems = maxNumItems; + this.fetchPageDelegate = fetchPageDelegate; + } + + public BigInteger MaxNumItems { get; set; } + + public Page<T> FetchNextPage(BigInteger skipCount) + { + return fetchPageDelegate(MaxNumItems, skipCount); + } + + public class Page<P> + { + public Page(IList<P> items, BigInteger? totalNumItems, bool? hasMoreItems) + { + Items = items; + TotalNumItems = totalNumItems; + HasMoreItems = hasMoreItems; + } + + public IList<P> Items { get; private set; } + public BigInteger? TotalNumItems { get; private set; } + public bool? HasMoreItems { get; private set; } + } + } + + /// <summary> + /// CMIS Collection Enumerable. + /// </summary> + public class CollectionEnumerable<T> : AbstractEnumerable<T> + { + public CollectionEnumerable(PageFetcher<T> pageFetcher) : + this(0, pageFetcher) { } + + public CollectionEnumerable(BigInteger position, PageFetcher<T> pageFetcher) : + base(position, pageFetcher) { } + + protected override AbstractEnumerator<T> CreateEnumerator() + { + return new CollectionEnumerator<T>(SkipCount, PageFetcher); + } + } + + /// <summary> + /// Enumerator for iterating over all items in a CMIS Collection. + /// </summary> + public class CollectionEnumerator<T> : AbstractEnumerator<T> + { + public CollectionEnumerator(BigInteger skipCount, PageFetcher<T> pageFetcher) : + base(skipCount, pageFetcher) { } + + public override bool MoveNext() + { + PageFetcher<T>.Page<T> page = GetCurrentPage(); + if (page == null) + { + return false; + } + + IList<T> items = page.Items; + if (items == null || items.Count == 0) + { + return false; + } + + if (SkipOffset == items.Count) + { + if (!HasMoreItems) + { + return false; + } + + page = IncrementPage(); + items = page == null ? null : page.Items; + } + + if (items == null || items.Count == 0 || SkipOffset == items.Count) + { + return false; + } + + current = items[IncrementSkipOffset()]; + + return true; + } + } + + /// <summary> + /// Enumerable for a CMIS Collection Page. + /// </summary> + public class CollectionPageEnumerable<T> : AbstractEnumerable<T> + { + public CollectionPageEnumerable(PageFetcher<T> pageFetcher) : + this(0, pageFetcher) { } + + public CollectionPageEnumerable(BigInteger position, PageFetcher<T> pageFetcher) : + base(position, pageFetcher) { } + + protected override AbstractEnumerator<T> CreateEnumerator() + { + return new CollectionPageEnumerator<T>(SkipCount, PageFetcher); + } + } + + /// <summary> + /// Enumerator for iterating over a page of items in a CMIS Collection. + /// </summary> + public class CollectionPageEnumerator<T> : AbstractEnumerator<T> + { + public CollectionPageEnumerator(BigInteger skipCount, PageFetcher<T> pageFetcher) : + base(skipCount, pageFetcher) { } + + public override bool MoveNext() + { + PageFetcher<T>.Page<T> page = GetCurrentPage(); + if (page == null) + { + return false; + } + + IList<T> items = page.Items; + if (items == null || items.Count == 0 || SkipOffset == items.Count) + { + return false; + } + + current = items[IncrementSkipOffset()]; + + return true; + } + } + + internal class StringListBuilder + { + private string seperator; + private bool first; + public StringBuilder StringBuilder { get; private set; } + + public StringListBuilder() : this(",", new StringBuilder()) { } + + public StringListBuilder(StringBuilder stringBuilder) : this(",", stringBuilder) { } + + public StringListBuilder(string seperator) : this(seperator, new StringBuilder()) { } + + public StringListBuilder(string seperator, StringBuilder stringBuilder) + { + this.seperator = seperator; + StringBuilder = stringBuilder; + first = true; + } + + public void Add(string s) + { + if (!first) + { + StringBuilder.Append(seperator); + } + else + { + first = false; + } + + StringBuilder.Append(s); + } + + override public string ToString() + { + return StringBuilder.ToString(); + } + } +}
Added: chemistry/portcmis/PortCMIS/client/SessionParameter.cs URL: http://svn.apache.org/viewvc/chemistry/portcmis/PortCMIS/client/SessionParameter.cs?rev=1691890&view=auto ============================================================================== --- chemistry/portcmis/PortCMIS/client/SessionParameter.cs (added) +++ chemistry/portcmis/PortCMIS/client/SessionParameter.cs Mon Jul 20 08:48:57 2015 @@ -0,0 +1,68 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* Kind, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +namespace PortCMIS.Client +{ + public static class SessionParameter + { + // ---- general parameter ---- + public const string User = "org.apache.chemistry.portcmis.user"; + public const string Password = "org.apache.chemistry.portcmis.password"; + // ---- provider parameter ---- + // Predefined binding types + public const string BindingType = "org.apache.chemistry.portcmis.binding.spi.type"; + // Class name of the binding class. + public const string BindingSpiClass = "org.apache.chemistry.portcmis.binding.spi.classname"; + // URL of the AtomPub service document. + public const string AtomPubUrl = "org.apache.chemistry.portcmis.binding.atompub.url"; + // URL of the Browser service + public const string BrowserUrl = "org.apache.chemistry.portcmis.binding.browser.url"; + // succinct flag + public const string BrowserSuccinct = "org.apache.chemistry.portcmis.binding.browser.succinct"; + // date time format + public const string BrowserDateTimeFormat = "org.apache.chemistry.portcmis.binding.browser.datetimeformat"; + // authentication provider + public const string AuthenticationProviderClass = "org.apache.chemistry.portcmis.binding.auth.classname"; + // HTTP invoker + public const string HttpInvokerClass = "org.apache.chemistry.portcmis.binding.httpinvoker.classname"; + // compression flag + public const string Compression = "org.apache.chemistry.portcmis.binding.compression"; + // timeouts + public const string ConnectTimeout = "org.apache.chemistry.portcmis.binding.connecttimeout"; + public const string ReadTimeout = "org.apache.chemistry.portcmis.binding.readtimeout"; + // binding caches + public const string CacheSizeRepositories = "org.apache.chemistry.portcmis.binding.cache.repositories.size"; + public const string CacheSizeTypes = "org.apache.chemistry.portcmis.binding.cache.types.size"; + public const string CacheSizeLinks = "org.apache.chemistry.portcmis.binding.cache.links.size"; + // session parameter + public const string ObjectFactoryClass = "org.apache.chemistry.portcmis.objectfactory.classname"; + public const string CacheClass = "org.apache.chemistry.portcmis.cache.classname"; + public const string RepositoryId = "org.apache.chemistry.portcmis.session.repository.id"; + public const string CacheSizeObjects = "org.apache.chemistry.portcmis.cache.objects.size"; + public const string CacheTTLObjects = "org.apache.chemistry.portcmis.cache.objects.ttl"; + public const string CacheSizePathToId = "org.apache.chemistry.portcmis.cache.pathtoid.size"; + public const string CacheTTLPathToId = "org.apache.chemistry.portcmis.cache.pathtoid.ttl"; + public const string CachePathOmit = "org.apache.chemistry.portcmis.cache.path.omit"; + + // workarounds + public const string IncludeObjectIdUrlParamOnCheckout = "org.apache.chemistry.portcmis.workaround.includeObjectIdOnCheckout"; + public const string IncludeObjectIdUrlParamOnMove = "org.apache.chemistry.portcmis.workaround.includeObjectIdOnMove"; + public const string OmitChangeTokens = "org.apache.chemistry.opencmis.portcmis.omitChangeTokens"; + } +} Added: chemistry/portcmis/PortCMIS/client/SessionParameterDefaults.cs URL: http://svn.apache.org/viewvc/chemistry/portcmis/PortCMIS/client/SessionParameterDefaults.cs?rev=1691890&view=auto ============================================================================== --- chemistry/portcmis/PortCMIS/client/SessionParameterDefaults.cs (added) +++ chemistry/portcmis/PortCMIS/client/SessionParameterDefaults.cs Mon Jul 20 08:48:57 2015 @@ -0,0 +1,38 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* Kind, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PortCMIS.Client +{ + public static class SessionParameterDefaults + { + public const int CacheSizeRepositories = 10; + public const int CacheSizeTypes = 100; + public const int CacheSizeLinks = 400; + public const int CacheSizeObjects = 100; + public const int CacheTTLObjects = 2 * 60 * 60 * 1000; + public const int CacheSizePathToId = 100; + public const int CacheTTLPathToId = 30 * 60 * 1000; + } +} Added: chemistry/portcmis/PortCMIS/const/BasicPermissions.cs URL: http://svn.apache.org/viewvc/chemistry/portcmis/PortCMIS/const/BasicPermissions.cs?rev=1691890&view=auto ============================================================================== --- chemistry/portcmis/PortCMIS/const/BasicPermissions.cs (added) +++ chemistry/portcmis/PortCMIS/const/BasicPermissions.cs Mon Jul 20 08:48:57 2015 @@ -0,0 +1,31 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* Kind, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +namespace PortCMIS +{ + /// <summary> + /// Basic permission constants.S + /// </summary> + public static class BasicPermissions + { + public const string Read = "cmis:read"; + public const string Write = "cmis:write"; + public const string All = "cmis:all"; + } +} Added: chemistry/portcmis/PortCMIS/const/BindingType.cs URL: http://svn.apache.org/viewvc/chemistry/portcmis/PortCMIS/const/BindingType.cs?rev=1691890&view=auto ============================================================================== --- chemistry/portcmis/PortCMIS/const/BindingType.cs (added) +++ chemistry/portcmis/PortCMIS/const/BindingType.cs Mon Jul 20 08:48:57 2015 @@ -0,0 +1,29 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* Kind, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +namespace PortCMIS +{ + public static class BindingType + { + public const string AtomPub = "atompub"; + public const string WebServices = "webservices"; + public const string Browser = "browser"; + public const string Custom = "custom"; + } +} Added: chemistry/portcmis/PortCMIS/const/ExtensionFeatures.cs URL: http://svn.apache.org/viewvc/chemistry/portcmis/PortCMIS/const/ExtensionFeatures.cs?rev=1691890&view=auto ============================================================================== --- chemistry/portcmis/PortCMIS/const/ExtensionFeatures.cs (added) +++ chemistry/portcmis/PortCMIS/const/ExtensionFeatures.cs Mon Jul 20 08:48:57 2015 @@ -0,0 +1,49 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* Kind, either express or implied. See the License for the +* specific language governing permissions and limitations +* 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 +{ + public class ExtensionFeatures + { + public readonly static IExtensionFeature ExtendedDatetimeFormat = new ExtensionFeature() + { + Id = "http://docs.oasis-open.org/ns/cmis/extension/datetimeformat", + Url = "https://www.oasis-open.org/committees/tc_home.php?wg_abbrev=cmis", + CommonName = "Browser Binding DateTime Format", + VersionLabel = "1.0", + Description = "Adds an additional DateTime format for the Browser Binding." + }; + + public readonly static IExtensionFeature ContentStreamHash = new ExtensionFeature() + { + Id = "http://docs.oasis-open.org/ns/cmis/extension/contentstreamhash", + Url = "https://www.oasis-open.org/committees/tc_home.php?wg_abbrev=cmis", + CommonName = "Content Stream Hash", + VersionLabel = "1.0", + Description = "Adds the property cmis:contentStreamHash, which represents the hash of the document content." + }; + } +} Added: chemistry/portcmis/PortCMIS/const/PermissionMappingKeys.cs URL: http://svn.apache.org/viewvc/chemistry/portcmis/PortCMIS/const/PermissionMappingKeys.cs?rev=1691890&view=auto ============================================================================== --- chemistry/portcmis/PortCMIS/const/PermissionMappingKeys.cs (added) +++ chemistry/portcmis/PortCMIS/const/PermissionMappingKeys.cs Mon Jul 20 08:48:57 2015 @@ -0,0 +1,59 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* Kind, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +namespace PortCMIS +{ + public static class PermissionMappingKeys + { + public const string CanGetDescendentsFolder = "canGetDescendents.Folder"; + public const string CanGetChildrenFolder = "canGetChildren.Folder"; + public const string CanGetParentsFolder = "canGetParents.Folder"; + public const string CanGetFolderParentObject = "canGetFolderParent.Object"; + public const string CanCreateDocumentFolder = "canCreateDocument.Folder"; + public const string CanCreateFolderFolder = "canCreateFolder.Folder"; + public const string CanCreateRelationshipSource = "canCreateRelationship.Source"; + public const string CanCreateRelationshipTarget = "canCreateRelationship.Target"; + public const string CanGetPropertiesObject = "canGetProperties.Object"; + public const string CanViewContentObject = "canViewContent.Object"; + public const string CanUpdatePropertiesObject = "canUpdateProperties.Object"; + public const string CanMoveObject = "canMove.Object"; + public const string CanMoveTarget = "canMove.Target"; + public const string CanMoveSource = "canMove.Source"; + public const string CanDeleteObject = "canDelete.Object"; + public const string CanDeleteTreeFolder = "canDeleteTree.Folder"; + public const string CanSetContentDocument = "canSetContent.Document"; + public const string CanDeleteContentDocument = "canDeleteContent.Document"; + public const string CanAddToFolderObject = "canAddToFolder.Object"; + public const string CanAddToFolderFolder = "canAddToFolder.Folder"; + public const string CanRemoveFromFolderObject = "canRemoveFromFolder.Object"; + public const string CanRemoveFromFolderFolder = "canRemoveFromFolder.Folder"; + public const string CanCheckoutDocument = "canCheckout.Document"; + public const string CanCancelCheckoutDocument = "canCancelCheckout.Document"; + public const string CanCheckinDocument = "canCheckin.Document"; + public const string CanGetAllVersionsVersionSeries = "canGetAllVersions.VersionSeries"; + public const string CanGetObjectRelationshipSObject = "canGetObjectRelationships.Object"; + public const string CanAddPolicyObject = "canAddPolicy.Object"; + public const string CanAddPolicyPolicy = "canAddPolicy.Policy"; + public const string CanRemovePolicyObject = "canRemovePolicy.Object"; + public const string CanRemovePolicyPolicy = "canRemovePolicy.Policy"; + public const string CanGetAppliesPoliciesObject = "canGetAppliedPolicies.Object"; + public const string CanGetAclObject = "canGetAcl.Object"; + public const string CanApplyAclObject = "canApplyAcl.Object"; + } +} Added: chemistry/portcmis/PortCMIS/const/PropertyIds.cs URL: http://svn.apache.org/viewvc/chemistry/portcmis/PortCMIS/const/PropertyIds.cs?rev=1691890&view=auto ============================================================================== --- chemistry/portcmis/PortCMIS/const/PropertyIds.cs (added) +++ chemistry/portcmis/PortCMIS/const/PropertyIds.cs Mon Jul 20 08:48:57 2015 @@ -0,0 +1,75 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* Kind, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +namespace PortCMIS +{ + public static class PropertyIds + { + // ---- base ---- + public const string Name = "cmis:name"; + public const string ObjectId = "cmis:objectId"; + public const string ObjectTypeId = "cmis:objectTypeId"; + public const string BaseTypeId = "cmis:baseTypeId"; + public const string CreatedBy = "cmis:createdBy"; + public const string CreationDate = "cmis:creationDate"; + public const string LastModifiedBy = "cmis:lastModifiedBy"; + public const string LastModificationDate = "cmis:lastModificationDate"; + public const string ChangeToken = "cmis:changeToken"; + public const string Description = "cmis:description"; + public const string SecondaryObjectTypeIds = "cmis:secondaryObjectTypeIds"; + + // ---- document ---- + public const string IsImmutable = "cmis:isImmutable"; + public const string IsLatestVersion = "cmis:isLatestVersion"; + public const string IsMajorVersion = "cmis:isMajorVersion"; + public const string IsLatestMajorVersion = "cmis:isLatestMajorVersion"; + public const string VersionLabel = "cmis:versionLabel"; + public const string VersionSeriesId = "cmis:versionSeriesId"; + public const string IsVersionSeriesCheckedOut = "cmis:isVersionSeriesCheckedOut"; + public const string VersionSeriesCheckedOutBy = "cmis:versionSeriesCheckedOutBy"; + public const string VersionSeriesCheckedOutId = "cmis:versionSeriesCheckedOutId"; + public const string CheckinComment = "cmis:checkinComment"; + public const string IsPrivateWorkingCopy = "cmis:isPrivateWorkingCopy"; + public const string ContentStreamLength = "cmis:contentStreamLength"; + public const string ContentStreamMimeType = "cmis:contentStreamMimeType"; + public const string ContentStreamFileName = "cmis:contentStreamFileName"; + public const string ContentStreamId = "cmis:contentStreamId"; + + // ---- folder ---- + public const string ParentId = "cmis:parentId"; + public const string AllowedChildObjectTypeIds = "cmis:allowedChildObjectTypeIds"; + public const string Path = "cmis:path"; + + // ---- relationship ---- + public const string SourceId = "cmis:sourceId"; + public const string TargetId = "cmis:targetId"; + + // ---- policy ---- + public const string PolicyText = "cmis:policyText"; + + // ---- retention ---- + public const string ExpirationDate = "cmis:rm_expirationDate"; + public const string StartOfRetention = "cmis:rm_startOfRetention"; + public const string DestructionDate = "cmis:rm_destructionDate"; + public const string HoldIds = "cmis:rm_holdIds"; + + // ---- extensions ---- + public const string ContentStreamHash = "cmis:contentStreamHash"; + } +} Added: chemistry/portcmis/PortCMIS/data/DataImpl.cs URL: http://svn.apache.org/viewvc/chemistry/portcmis/PortCMIS/data/DataImpl.cs?rev=1691890&view=auto ============================================================================== --- chemistry/portcmis/PortCMIS/data/DataImpl.cs (added) +++ chemistry/portcmis/PortCMIS/data/DataImpl.cs Mon Jul 20 08:48:57 2015 @@ -0,0 +1,686 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* Kind, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +using PortCMIS.Data.Extensions; +using PortCMIS.Enums; +using System; +using System.Collections.Generic; +using System.IO; +using System.Numerics; +using System.Text; + +namespace PortCMIS.Data +{ + public class RepositoryInfo : ExtensionsData, IRepositoryInfo + { + public RepositoryInfo() + { + } + public RepositoryInfo(IRepositoryInfo source) + { + Id = source.Id; + Name = source.Name; + Description = source.Description; + VendorName = source.VendorName; + ProductName = source.ProductName; + ProductVersion = source.ProductVersion; + RootFolderId = source.RootFolderId; + Capabilities = source.Capabilities; + AclCapabilities = source.AclCapabilities; + LatestChangeLogToken = source.LatestChangeLogToken; + CmisVersionSupported = source.CmisVersionSupported; + ThinClientUri = source.ThinClientUri; + ChangesIncomplete = source.ChangesIncomplete; + ChangesOnType = source.ChangesOnType; + PrincipalIdAnonymous = source.PrincipalIdAnonymous; + PrincipalIdAnyone = source.PrincipalIdAnyone; + ExtensionFeatures = source.ExtensionFeatures; + Extensions = source.Extensions; + } + + public string Id { get; set; } + public string Name { get; set; } + public string Description { get; set; } + public string VendorName { get; set; } + public string ProductName { get; set; } + public string ProductVersion { get; set; } + public string RootFolderId { get; set; } + public IRepositoryCapabilities Capabilities { get; set; } + public IAclCapabilities AclCapabilities { get; set; } + public string LatestChangeLogToken { get; set; } + public string CmisVersionSupported { get; set; } + public string ThinClientUri { get; set; } + public bool? ChangesIncomplete { get; set; } + public IList<BaseTypeId?> ChangesOnType { get; set; } + public string PrincipalIdAnonymous { get; set; } + public string PrincipalIdAnyone { get; set; } + public IList<IExtensionFeature> ExtensionFeatures { get; set; } + + public override string ToString() + { + return "RepositoryInfo: " + Id; + } + } + + public class RepositoryCapabilities : ExtensionsData, IRepositoryCapabilities + { + public CapabilityContentStreamUpdates? ContentStreamUpdatesCapability { get; set; } + public CapabilityChanges? ChangesCapability { get; set; } + public CapabilityRenditions? RenditionsCapability { get; set; } + public bool? IsGetDescendantsSupported { get; set; } + public bool? IsGetFolderTreeSupported { get; set; } + public CapabilityOrderBy? OrderByCapability { get; set; } + public bool? IsMultifilingSupported { get; set; } + public bool? IsUnfilingSupported { get; set; } + public bool? IsVersionSpecificFilingSupported { get; set; } + public bool? IsPwcSearchableSupported { get; set; } + public bool? IsPwcUpdatableSupported { get; set; } + public bool? IsAllVersionsSearchableSupported { get; set; } + public CapabilityQuery? QueryCapability { get; set; } + public CapabilityJoin? JoinCapability { get; set; } + public CapabilityAcl? AclCapability { get; set; } + public ICreatablePropertyTypes CreatablePropertyTypes { get; set; } + public INewTypeSettableAttributes NewTypeSettableAttributes { get; set; } + } + + public class CreatablePropertyTypes : ExtensionsData, ICreatablePropertyTypes + { + public ISet<PropertyType> CanCreate { get; set; } + } + + public class NewTypeSettableAttributes : ExtensionsData, INewTypeSettableAttributes + { + public bool? CanSetId { get; set; } + public bool? CanSetLocalName { get; set; } + public bool? CanSetLocalNamespace { get; set; } + public bool? CanSetDisplayName { get; set; } + public bool? CanSetQueryName { get; set; } + public bool? CanSetDescription { get; set; } + public bool? CanSetCreatable { get; set; } + public bool? CanSetFileable { get; set; } + public bool? CanSetQueryable { get; set; } + public bool? CanSetFulltextIndexed { get; set; } + public bool? CanSetIncludedInSupertypeQuery { get; set; } + public bool? CanSetControllablePolicy { get; set; } + public bool? CanSetControllableAcl { get; set; } + } + + public class AclCapabilities : ExtensionsData, IAclCapabilities + { + public SupportedPermissions? SupportedPermissions { get; set; } + public AclPropagation? AclPropagation { get; set; } + public IList<IPermissionDefinition> Permissions { get; set; } + public IDictionary<string, IPermissionMapping> PermissionMapping { get; set; } + } + + public class PermissionDefinition : ExtensionsData, IPermissionDefinition + { + public string Id { get; set; } + public string Description { get; set; } + } + + public class PermissionMapping : ExtensionsData, IPermissionMapping + { + public string Key { get; set; } + public IList<string> Permissions { get; set; } + } + + public class ExtensionFeature : ExtensionsData, IExtensionFeature + { + public string Id { get; set; } + public string Url { get; set; } + public string CommonName { get; set; } + public string VersionLabel { get; set; } + public string Description { get; set; } + public IDictionary<string, string> FeatureData { get; set; } + } + + public abstract class AbstractTypeDefinition : ExtensionsData, ITypeDefinition + { + private List<IPropertyDefinition> propertyDefintionList = new List<IPropertyDefinition>(); + private Dictionary<string, IPropertyDefinition> propertyDefintionDict = new Dictionary<string, IPropertyDefinition>(); + private string parentTypeId; + public string Id { get; set; } + public string LocalName { get; set; } + public string LocalNamespace { get; set; } + public string DisplayName { get; set; } + public string QueryName { get; set; } + public string Description { get; set; } + public BaseTypeId BaseTypeId { get; set; } + public string ParentTypeId + { + get { return parentTypeId; } + set { parentTypeId = (value == null || value.Length == 0 ? null : value); } + } + public bool? IsCreatable { get; set; } + public bool? IsFileable { get; set; } + public bool? IsQueryable { get; set; } + public bool? IsFulltextIndexed { get; set; } + public bool? IsIncludedInSupertypeQuery { get; set; } + public bool? IsControllablePolicy { get; set; } + public bool? IsControllableAcl { get; set; } + public IPropertyDefinition this[string propertyId] + { + get + { + IPropertyDefinition propertyDefinition = null; + propertyDefintionDict.TryGetValue(propertyId, out propertyDefinition); + return propertyDefinition; + } + } + public IList<IPropertyDefinition> PropertyDefinitions + { + get + { + return propertyDefintionList; + } + } + public ITypeMutability TypeMutability { get; set; } + + public void Initialize(ITypeDefinition typeDefinition) + { + Id = typeDefinition.Id; + LocalName = typeDefinition.LocalName; + LocalNamespace = typeDefinition.LocalNamespace; + DisplayName = typeDefinition.DisplayName; + QueryName = typeDefinition.QueryName; + Description = typeDefinition.Description; + BaseTypeId = typeDefinition.BaseTypeId; + ParentTypeId = typeDefinition.ParentTypeId; + IsCreatable = typeDefinition.IsCreatable; + IsFileable = typeDefinition.IsFileable; + IsQueryable = typeDefinition.IsQueryable; + IsFulltextIndexed = typeDefinition.IsFulltextIndexed; + IsIncludedInSupertypeQuery = typeDefinition.IsIncludedInSupertypeQuery; + IsControllablePolicy = typeDefinition.IsControllablePolicy; + IsControllableAcl = typeDefinition.IsControllableAcl; + if (typeDefinition.PropertyDefinitions != null) + { + foreach (IPropertyDefinition propDef in typeDefinition.PropertyDefinitions) + { + AddPropertyDefinition(propDef); + } + } + } + public void AddPropertyDefinition(IPropertyDefinition propertyDefinition) + { + if (propertyDefinition == null || propertyDefinition.Id == null) + { + return; + } + propertyDefintionList.Add(propertyDefinition); + propertyDefintionDict[propertyDefinition.Id] = propertyDefinition; + } + + public override string ToString() + { + return "TypeDefinition: " + BaseTypeId + " (" + Id + ")"; + } + } + + public class TypeMutability : ExtensionsData, ITypeMutability + { + public bool? CanCreate { get; set; } + public bool? CanUpdate { get; set; } + public bool? CanDelete { get; set; } + } + + public class DocumentTypeDefinition : AbstractTypeDefinition, IDocumentTypeDefinition + { + public bool? IsVersionable { get; set; } + public ContentStreamAllowed? ContentStreamAllowed { get; set; } + } + + public class FolderTypeDefinition : AbstractTypeDefinition, IFolderTypeDefinition + { + } + + public class PolicyTypeDefinition : AbstractTypeDefinition, IPolicyTypeDefinition + { + } + + public class ItemTypeDefinition : AbstractTypeDefinition, IItemTypeDefinition + { + } + + public class SecondaryTypeDefinition : AbstractTypeDefinition, ISecondaryTypeDefinition + { + } + + public class RelationshipTypeDefinition : AbstractTypeDefinition, IRelationshipTypeDefinition + { + public IList<string> AllowedSourceTypeIds { get; set; } + public IList<string> AllowedTargetTypeIds { get; set; } + } + + public class TypeDefinitionList : ExtensionsData, ITypeDefinitionList + { + public IList<ITypeDefinition> List { get; set; } + public bool? HasMoreItems { get; set; } + public BigInteger? NumItems { get; set; } + } + + public class TypeDefinitionContainer : ExtensionsData, ITypeDefinitionContainer + { + public ITypeDefinition TypeDefinition { get; set; } + public IList<ITypeDefinitionContainer> Children { get; set; } + } + + public abstract class PropertyDefinition : ExtensionsData, IPropertyDefinition + { + public string Id { get; set; } + public string LocalName { get; set; } + public string LocalNamespace { get; set; } + public string DisplayName { get; set; } + public string QueryName { get; set; } + public string Description { get; set; } + public PropertyType PropertyType { get; set; } + public Cardinality? Cardinality { get; set; } + public Updatability? Updatability { get; set; } + public bool? IsInherited { get; set; } + public bool? IsRequired { get; set; } + public bool? IsQueryable { get; set; } + public bool? IsOrderable { get; set; } + public bool? IsOpenChoice { get; set; } + } + + public class Choice<T> : IChoice<T> + { + public string DisplayName { get; set; } + public IList<T> Value { get; set; } + public IList<IChoice<T>> Choices { get; set; } + } + + public class PropertyBooleanDefinition : PropertyDefinition, IPropertyBooleanDefinition + { + public IList<bool?> DefaultValue { get; set; } + public IList<IChoice<bool?>> Choices { get; set; } + } + + public class PropertyDateTimeDefinition : PropertyDefinition, IPropertyDateTimeDefinition + { + public IList<DateTime?> DefaultValue { get; set; } + public IList<IChoice<DateTime?>> Choices { get; set; } + public DateTimeResolution? DateTimeResolution { get; set; } + } + + public class PropertyDecimalDefinition : PropertyDefinition, IPropertyDecimalDefinition + { + public IList<decimal?> DefaultValue { get; set; } + public IList<IChoice<decimal?>> Choices { get; set; } + public decimal? MinValue { get; set; } + public decimal? MaxValue { get; set; } + public DecimalPrecision? Precision { get; set; } + } + + public class PropertyHtmlDefinition : PropertyDefinition, IPropertyHtmlDefinition + { + public IList<string> DefaultValue { get; set; } + public IList<IChoice<string>> Choices { get; set; } + } + + public class PropertyIdDefinition : PropertyDefinition, IPropertyIdDefinition + { + public IList<string> DefaultValue { get; set; } + public IList<IChoice<string>> Choices { get; set; } + } + + public class PropertyIntegerDefinition : PropertyDefinition, IPropertyIntegerDefinition + { + public IList<BigInteger?> DefaultValue { get; set; } + public IList<IChoice<BigInteger?>> Choices { get; set; } + public BigInteger? MinValue { get; set; } + public BigInteger? MaxValue { get; set; } + } + + public class PropertyStringDefinition : PropertyDefinition, IPropertyStringDefinition + { + public IList<string> DefaultValue { get; set; } + public IList<IChoice<string>> Choices { get; set; } + public BigInteger? MaxLength { get; set; } + } + + public class PropertyUriDefinition : PropertyDefinition, IPropertyUriDefinition + { + public IList<string> DefaultValue { get; set; } + public IList<IChoice<string>> Choices { get; set; } + } + + public class ObjectData : ExtensionsData, IObjectData + { + public string Id + { + get + { + return GetFirstValue(PropertyIds.ObjectId) as string; + } + } + public BaseTypeId? BaseTypeId + { + get + { + string baseTypeId = GetFirstValue(PropertyIds.BaseTypeId) as string; + if (baseTypeId == null) + { + return null; + } + return baseTypeId.GetCmisEnum<BaseTypeId>(); + } + } + public IProperties Properties { get; set; } + public IAllowableActions AllowableActions { get; set; } + public IList<IObjectData> Relationships { get; set; } + public IChangeEventInfo ChangeEventInfo { get; set; } + public IAcl Acl { get; set; } + public bool? IsExactAcl { get; set; } + public IPolicyIdList PolicyIds { get; set; } + public IList<IRenditionData> Renditions { get; set; } + private object GetFirstValue(string id) + { + if (Properties == null) { return null; } + IPropertyData property = Properties[id]; + if (property == null) + { + return null; + } + return property.FirstValue; + } + } + + public class ObjectList : ExtensionsData, IObjectList + { + public IList<IObjectData> Objects { get; set; } + public bool? HasMoreItems { get; set; } + public BigInteger? NumItems { get; set; } + } + + public class ObjectInFolderData : ExtensionsData, IObjectInFolderData + { + public IObjectData Object { get; set; } + public string PathSegment { get; set; } + } + + public class ObjectInFolderList : ExtensionsData, IObjectInFolderList + { + public IList<IObjectInFolderData> Objects { get; set; } + public bool? HasMoreItems { get; set; } + public BigInteger? NumItems { get; set; } + } + + public class ObjectInFolderContainer : ExtensionsData, IObjectInFolderContainer + { + public IObjectInFolderData Object { get; set; } + public IList<IObjectInFolderContainer> Children { get; set; } + } + + public class ObjectParentData : ExtensionsData, IObjectParentData + { + public IObjectData Object { get; set; } + public string RelativePathSegment { get; set; } + } + + public class Properties : ExtensionsData, IProperties + { + private List<IPropertyData> propertyList = new List<IPropertyData>(); + private Dictionary<string, IPropertyData> propertyDict = new Dictionary<string, IPropertyData>(); + public IPropertyData this[string propertyId] + { + get + { + IPropertyData property = null; + propertyDict.TryGetValue(propertyId, out property); + return property; + } + } + public IList<IPropertyData> PropertyList + { + get + { + return propertyList; + } + } + public void AddProperty(IPropertyData property) + { + if (property == null) + { + return; + } + propertyList.Add(property); + if (property.Id != null) + { + propertyDict[property.Id] = property; + } + } + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + foreach (IPropertyData prop in propertyList) + { + if (sb.Length == 0) { sb.Append("["); } + else { sb.Append(", "); } + sb.Append(prop.ToString()); + } + sb.Append("]"); + return sb.ToString(); + } + } + + public class PropertyData : ExtensionsData, IPropertyData + { + private IList<object> values; + public PropertyData(PropertyType propertyType) + { + PropertyType = propertyType; + } + public string Id { get; set; } + public string LocalName { get; set; } + public string DisplayName { get; set; } + public string QueryName { get; set; } + public PropertyType PropertyType { get; protected set; } + public IList<object> Values + { + get { return values; } + set + { + if (value == null) + { + values = null; + } + else + { + foreach (object o in value) + { + CheckValue(o); + } + values = value; + } + } + } + public object FirstValue { get { return values == null || Values.Count < 1 ? null : values[0]; } } + + public void AddValue(object value) + { + object newValue = CheckValue(value); + if (Values == null) + { + Values = new List<object>(); + } + Values.Add(newValue); + } + + public object CheckValue(object value) + { + switch (PropertyType) + { + case PropertyType.String: + if (!(value is string)) + { + throw new ArgumentException("Property '" + Id + "' is a String property!"); + } + return value; + case PropertyType.Id: + if (!(value is string)) + { + throw new ArgumentException("Property '" + Id + "' is an Id property!"); + } + return value; + case PropertyType.Integer: + if (!(value is sbyte || value is byte || value is short || value is ushort || value is int || value is uint || value is long || value is BigInteger)) + { + throw new ArgumentException("Property '" + Id + "' is an Integer property!"); + } + if (value is BigInteger) + { + return value; + } + else + { + return new BigInteger((long)value); + } + case PropertyType.Boolean: + if (!(value is bool)) + { + throw new ArgumentException("Property '" + Id + "' is a Boolean property!"); + } + return value; + case PropertyType.DateTime: + if (!(value is DateTime)) + { + throw new ArgumentException("Property '" + Id + "' is a DateTime property!"); + } + return value; + case PropertyType.Decimal: + if (!(value is decimal || value is double || value is float)) + { + throw new ArgumentException("Property '" + Id + "' is a Decimal property!"); + } + return value; + case PropertyType.Uri: + if (!(value is string)) + { + throw new ArgumentException("Property '" + Id + "' is a URI property!"); + } + return value; + case PropertyType.Html: + if (!(value is string)) + { + throw new ArgumentException("Property '" + Id + "' is a HTML property!"); + } + return value; + default: + throw new ArgumentException("Unknown property type!"); + } + } + + public override string ToString() + { + return Id + ": " + values; + } + } + + public class Principal : ExtensionsData, IPrincipal + { + public string Id { get; set; } + } + + public class Ace : ExtensionsData, IAce + { + public IPrincipal Principal { get; set; } + public string PrincipalId { get { return Principal == null ? null : Principal.Id; } } + public IList<string> Permissions { get; set; } + public bool? IsDirect { get; set; } + } + + public class Acl : ExtensionsData, IAcl + { + public IList<IAce> Aces { get; set; } + public bool? IsExact { get; set; } + } + + public class ContentStream : ExtensionsData, IContentStream + { + public BigInteger? Length { get; set; } + public string MimeType { get; set; } + public string FileName { get; set; } + public Stream Stream { get; set; } + } + + public class PartialContentStream : ContentStream, IPartialContentStream + { + } + + public class AllowableActions : ExtensionsData, IAllowableActions + { + public ISet<PortCMIS.Enums.Action> Actions { get; set; } + } + + public class RenditionData : ExtensionsData, IRenditionData + { + public string StreamId { get; set; } + public string MimeType { get; set; } + public BigInteger? Length { get; set; } + public string Kind { get; set; } + public string Title { get; set; } + public BigInteger? Height { get; set; } + public BigInteger? Width { get; set; } + public string RenditionDocumentId { get; set; } + } + + public class ChangeEventInfo : ExtensionsData, IChangeEventInfo + { + public ChangeType? ChangeType { get; set; } + public DateTime? ChangeTime { get; set; } + } + + public class PolicyIdList : ExtensionsData, IPolicyIdList + { + public IList<string> PolicyIds { get; set; } + } + + public class FailedToDeleteData : ExtensionsData, IFailedToDeleteData + { + public IList<string> Ids { get; set; } + } + + public class QueryType : ExtensionsData + { + public string Statement { get; set; } + public bool SearchAllVersions { get; set; } + public bool IncludeAllowableActions { get; set; } + public IncludeRelationships IncludeRelationships { get; set; } + public string RenditionFilter { get; set; } + public BigInteger MaxItems { get; set; } + public BigInteger SkipCount { get; set; } + } + + public class BulkUpdateObjectIdAndChangeToken : ExtensionsData, IBulkUpdateObjectIdAndChangeToken + { + public string Id { get; set; } + public string NewId { get; set; } + public string ChangeToken { get; set; } + } + + public class BulkUpdate : ExtensionsData + { + public IList<IBulkUpdateObjectIdAndChangeToken> ObjectIdAndChangeToken { get; set; } + public Properties Properties { get; set; } + public IList<string> AddSecondaryTypeIds { get; set; } + public IList<string> RemoveSecondaryTypeIds { get; set; } + } +} Added: chemistry/portcmis/PortCMIS/data/DataIntf.cs URL: http://svn.apache.org/viewvc/chemistry/portcmis/PortCMIS/data/DataIntf.cs?rev=1691890&view=auto ============================================================================== --- chemistry/portcmis/PortCMIS/data/DataIntf.cs (added) +++ chemistry/portcmis/PortCMIS/data/DataIntf.cs Mon Jul 20 08:48:57 2015 @@ -0,0 +1,406 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* Kind, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +using PortCMIS.Data.Extensions; +using PortCMIS.Enums; +using System; +using System.Collections.Generic; +using System.IO; +using System.Numerics; + +namespace PortCMIS.Data +{ + public interface IRepositoryInfo : IExtensionsData + { + string Id { get; } + string Name { get; } + string Description { get; } + string VendorName { get; } + string ProductName { get; } + string ProductVersion { get; } + string RootFolderId { get; } + IRepositoryCapabilities Capabilities { get; } + IAclCapabilities AclCapabilities { get; } + string LatestChangeLogToken { get; } + string CmisVersionSupported { get; } + string ThinClientUri { get; } + bool? ChangesIncomplete { get; } + IList<BaseTypeId?> ChangesOnType { get; } + string PrincipalIdAnonymous { get; } + string PrincipalIdAnyone { get; } + IList<IExtensionFeature> ExtensionFeatures { get; } + } + + public interface IRepositoryCapabilities : IExtensionsData + { + CapabilityContentStreamUpdates? ContentStreamUpdatesCapability { get; } + CapabilityChanges? ChangesCapability { get; } + CapabilityRenditions? RenditionsCapability { get; } + bool? IsGetDescendantsSupported { get; } + bool? IsGetFolderTreeSupported { get; } + CapabilityOrderBy? OrderByCapability { get; } + bool? IsMultifilingSupported { get; } + bool? IsUnfilingSupported { get; } + bool? IsVersionSpecificFilingSupported { get; } + bool? IsPwcSearchableSupported { get; } + bool? IsPwcUpdatableSupported { get; } + bool? IsAllVersionsSearchableSupported { get; } + CapabilityQuery? QueryCapability { get; } + CapabilityJoin? JoinCapability { get; } + CapabilityAcl? AclCapability { get; } + ICreatablePropertyTypes CreatablePropertyTypes { get; } + INewTypeSettableAttributes NewTypeSettableAttributes { get; } + } + + public interface ICreatablePropertyTypes : IExtensionsData + { + ISet<PropertyType> CanCreate { get; } + } + + public interface INewTypeSettableAttributes : IExtensionsData + { + bool? CanSetId { get; } + bool? CanSetLocalName { get; } + bool? CanSetLocalNamespace { get; } + bool? CanSetDisplayName { get; } + bool? CanSetQueryName { get; } + bool? CanSetDescription { get; } + bool? CanSetCreatable { get; } + bool? CanSetFileable { get; } + bool? CanSetQueryable { get; } + bool? CanSetFulltextIndexed { get; } + bool? CanSetIncludedInSupertypeQuery { get; } + bool? CanSetControllablePolicy { get; } + bool? CanSetControllableAcl { get; } + } + + public interface IAclCapabilities : IExtensionsData + { + SupportedPermissions? SupportedPermissions { get; } + AclPropagation? AclPropagation { get; } + IList<IPermissionDefinition> Permissions { get; } + IDictionary<string, IPermissionMapping> PermissionMapping { get; } + } + + public interface IPermissionDefinition : IExtensionsData + { + string Id { get; } + string Description { get; } + } + + public interface IPermissionMapping : IExtensionsData + { + string Key { get; } + IList<string> Permissions { get; } + } + + public interface IExtensionFeature : IExtensionsData + { + string Id { get; } + string Url { get; } + string CommonName { get; } + string VersionLabel { get; } + string Description { get; } + IDictionary<string, string> FeatureData { get; } + } + + public interface ITypeDefinition : IExtensionsData + { + string Id { get; } + string LocalName { get; } + string LocalNamespace { get; } + string DisplayName { get; } + string QueryName { get; } + string Description { get; } + BaseTypeId BaseTypeId { get; } + string ParentTypeId { get; } + bool? IsCreatable { get; } + bool? IsFileable { get; } + bool? IsQueryable { get; } + bool? IsFulltextIndexed { get; } + bool? IsIncludedInSupertypeQuery { get; } + bool? IsControllablePolicy { get; } + bool? IsControllableAcl { get; } + IPropertyDefinition this[string propertyId] { get; } + IList<IPropertyDefinition> PropertyDefinitions { get; } + ITypeMutability TypeMutability { get; } + } + + public interface ITypeMutability : IExtensionsData + { + bool? CanCreate { get; } + bool? CanUpdate { get; } + bool? CanDelete { get; } + } + + public interface IDocumentTypeDefinition : ITypeDefinition + { + bool? IsVersionable { get; } + ContentStreamAllowed? ContentStreamAllowed { get; } + } + + public interface IFolderTypeDefinition : ITypeDefinition + { + } + + public interface ISecondaryTypeDefinition : ITypeDefinition + { + } + + public interface IPolicyTypeDefinition : ITypeDefinition + { + } + + public interface IItemTypeDefinition : ITypeDefinition + { + } + + public interface IRelationshipTypeDefinition : ITypeDefinition + { + IList<string> AllowedSourceTypeIds { get; } + IList<string> AllowedTargetTypeIds { get; } + } + + public interface ITypeDefinitionList : IExtensionsData + { + IList<ITypeDefinition> List { get; } + bool? HasMoreItems { get; } + BigInteger? NumItems { get; } + } + + public interface ITypeDefinitionContainer : IExtensionsData + { + ITypeDefinition TypeDefinition { get; } + IList<ITypeDefinitionContainer> Children { get; } + } + + public interface IPropertyDefinition : IExtensionsData + { + string Id { get; } + string LocalName { get; } + string LocalNamespace { get; } + string DisplayName { get; } + string QueryName { get; } + string Description { get; } + PropertyType PropertyType { get; } + Cardinality? Cardinality { get; } + Updatability? Updatability { get; } + bool? IsInherited { get; } + bool? IsRequired { get; } + bool? IsQueryable { get; } + bool? IsOrderable { get; } + bool? IsOpenChoice { get; } + } + + public interface IChoice<T> + { + string DisplayName { get; } + IList<T> Value { get; } + IList<IChoice<T>> Choices { get; } + } + + public interface IPropertyBooleanDefinition : IPropertyDefinition + { + IList<bool?> DefaultValue { get; } + IList<IChoice<bool?>> Choices { get; } + } + + public interface IPropertyDateTimeDefinition : IPropertyDefinition + { + IList<DateTime?> DefaultValue { get; } + IList<IChoice<DateTime?>> Choices { get; } + DateTimeResolution? DateTimeResolution { get; } + } + + public interface IPropertyDecimalDefinition : IPropertyDefinition + { + IList<decimal?> DefaultValue { get; } + IList<IChoice<decimal?>> Choices { get; } + decimal? MinValue { get; } + decimal? MaxValue { get; } + DecimalPrecision? Precision { get; } + } + + public interface IPropertyHtmlDefinition : IPropertyDefinition + { + IList<string> DefaultValue { get; } + IList<IChoice<string>> Choices { get; } + } + + public interface IPropertyIdDefinition : IPropertyDefinition + { + IList<string> DefaultValue { get; } + IList<IChoice<string>> Choices { get; } + } + + public interface IPropertyIntegerDefinition : IPropertyDefinition + { + IList<BigInteger?> DefaultValue { get; } + IList<IChoice<BigInteger?>> Choices { get; } + BigInteger? MinValue { get; } + BigInteger? MaxValue { get; } + } + + public interface IPropertyStringDefinition : IPropertyDefinition + { + IList<string> DefaultValue { get; } + IList<IChoice<string>> Choices { get; } + BigInteger? MaxLength { get; } + } + + public interface IPropertyUriDefinition : IPropertyDefinition + { + IList<string> DefaultValue { get; } + IList<IChoice<string>> Choices { get; } + } + + public interface IObjectData : IExtensionsData + { + string Id { get; } + BaseTypeId? BaseTypeId { get; } + IProperties Properties { get; } + IAllowableActions AllowableActions { get; } + IList<IObjectData> Relationships { get; } + IChangeEventInfo ChangeEventInfo { get; } + IAcl Acl { get; } + bool? IsExactAcl { get; } + IPolicyIdList PolicyIds { get; } + IList<IRenditionData> Renditions { get; } + } + + public interface IObjectList : IExtensionsData + { + IList<IObjectData> Objects { get; } + bool? HasMoreItems { get; } + BigInteger? NumItems { get; } + } + + public interface IObjectInFolderData : IExtensionsData + { + IObjectData Object { get; } + string PathSegment { get; } + } + + public interface IObjectInFolderList : IExtensionsData + { + IList<IObjectInFolderData> Objects { get; } + bool? HasMoreItems { get; } + BigInteger? NumItems { get; } + } + + public interface IObjectInFolderContainer : IExtensionsData + { + IObjectInFolderData Object { get; } + IList<IObjectInFolderContainer> Children { get; } + } + + public interface IObjectParentData : IExtensionsData + { + IObjectData Object { get; } + string RelativePathSegment { get; } + } + + public interface IProperties : IExtensionsData + { + IPropertyData this[string propertyId] { get; } + IList<IPropertyData> PropertyList { get; } + } + + public interface IPropertyData : IExtensionsData + { + string Id { get; } + string LocalName { get; } + string DisplayName { get; } + string QueryName { get; } + PropertyType PropertyType { get; } + IList<object> Values { get; } + object FirstValue { get; } + } + + public interface IPrincipal : IExtensionsData + { + string Id { get; } + } + + public interface IAce : IExtensionsData + { + IPrincipal Principal { get; } + string PrincipalId { get; } + IList<string> Permissions { get; } + bool? IsDirect { get; } + } + + public interface IAcl : IExtensionsData + { + IList<IAce> Aces { get; } + bool? IsExact { get; } + } + + public interface IContentStream : IExtensionsData + { + BigInteger? Length { get; } + string MimeType { get; } + string FileName { get; } + Stream Stream { get; } + } + + public interface IPartialContentStream : IContentStream + { + } + + public interface IAllowableActions : IExtensionsData + { + ISet<PortCMIS.Enums.Action> Actions { get; } + } + + public interface IRenditionData : IExtensionsData + { + string StreamId { get; } + string MimeType { get; } + BigInteger? Length { get; } + string Kind { get; } + string Title { get; } + BigInteger? Height { get; } + BigInteger? Width { get; } + string RenditionDocumentId { get; } + } + + public interface IChangeEventInfo : IExtensionsData + { + ChangeType? ChangeType { get; } + DateTime? ChangeTime { get; } + } + + public interface IPolicyIdList : IExtensionsData + { + IList<string> PolicyIds { get; } + } + + public interface IFailedToDeleteData : IExtensionsData + { + IList<string> Ids { get; } + } + + public interface IBulkUpdateObjectIdAndChangeToken : IExtensionsData + { + string Id { get; } + string NewId { get; } + string ChangeToken { get; } + } +} Added: chemistry/portcmis/PortCMIS/data/Extensions.cs URL: http://svn.apache.org/viewvc/chemistry/portcmis/PortCMIS/data/Extensions.cs?rev=1691890&view=auto ============================================================================== --- chemistry/portcmis/PortCMIS/data/Extensions.cs (added) +++ chemistry/portcmis/PortCMIS/data/Extensions.cs Mon Jul 20 08:48:57 2015 @@ -0,0 +1,55 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* Kind, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PortCMIS.Data.Extensions +{ + public interface ICmisExtensionElement + { + string Name { get; } + string Namespace { get; } + string Value { get; } + IDictionary<string, string> Attributes { get; } + IList<ICmisExtensionElement> Children { get; } + } + + public class CmisExtensionElement : ICmisExtensionElement + { + public string Name { get; set; } + public string Namespace { get; set; } + public string Value { get; set; } + public IDictionary<string, string> Attributes { get; set; } + public IList<ICmisExtensionElement> Children { get; set; } + } + + public interface IExtensionsData + { + IList<ICmisExtensionElement> Extensions { get; set; } + } + + public class ExtensionsData : IExtensionsData + { + public IList<ICmisExtensionElement> Extensions { get; set; } + } +}
