Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 2FD77200C47 for ; Thu, 30 Mar 2017 13:44:05 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 2C9CD160B8B; Thu, 30 Mar 2017 11:44:05 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id EFA64160B78 for ; Thu, 30 Mar 2017 13:44:03 +0200 (CEST) Received: (qmail 78220 invoked by uid 500); 30 Mar 2017 11:44:03 -0000 Mailing-List: contact commits-help@chemistry.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@chemistry.apache.org Delivered-To: mailing list commits@chemistry.apache.org Received: (qmail 78209 invoked by uid 99); 30 Mar 2017 11:44:03 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Mar 2017 11:44:03 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 60AEF3A04A5 for ; Thu, 30 Mar 2017 11:44:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1789499 - in /chemistry/portcmis/trunk: PortCMIS/binding/atompub/AtomPubBinding.cs PortCMIS/client/ClientIntf.cs PortCMIS/client/ClientObjects.cs PortCMIS/client/SessionParameter.cs PortCMISTests/SimpleCmisTest.cs Date: Thu, 30 Mar 2017 11:44:01 -0000 To: commits@chemistry.apache.org From: fmui@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20170330114402.60AEF3A04A5@svn01-us-west.apache.org> archived-at: Thu, 30 Mar 2017 11:44:05 -0000 Author: fmui Date: Thu Mar 30 11:44:01 2017 New Revision: 1789499 URL: http://svn.apache.org/viewvc?rev=1789499&view=rev Log: PortCMIS: ported a few features from OpenCMIS Modified: chemistry/portcmis/trunk/PortCMIS/binding/atompub/AtomPubBinding.cs chemistry/portcmis/trunk/PortCMIS/client/ClientIntf.cs chemistry/portcmis/trunk/PortCMIS/client/ClientObjects.cs chemistry/portcmis/trunk/PortCMIS/client/SessionParameter.cs chemistry/portcmis/trunk/PortCMISTests/SimpleCmisTest.cs Modified: chemistry/portcmis/trunk/PortCMIS/binding/atompub/AtomPubBinding.cs URL: http://svn.apache.org/viewvc/chemistry/portcmis/trunk/PortCMIS/binding/atompub/AtomPubBinding.cs?rev=1789499&r1=1789498&r2=1789499&view=diff ============================================================================== --- chemistry/portcmis/trunk/PortCMIS/binding/atompub/AtomPubBinding.cs (original) +++ chemistry/portcmis/trunk/PortCMIS/binding/atompub/AtomPubBinding.cs Thu Mar 30 11:44:01 2017 @@ -3129,6 +3129,30 @@ namespace PortCMIS.Binding.AtomPub { ReturnVersion returnVersion = (major == true ? ReturnVersion.LatestMajor : ReturnVersion.Latest); + // workaround for SharePoint - use the version series ID instead of the object ID + if (Session.GetValue(SessionParameter.LatestVersionWithVersionSeriesId, false)) + { + if (versionSeriesId != null) + { + objectId = versionSeriesId; + } + else + { + IObjectData obj = GetObjectInternal(repositoryId, IdentifierType.ID, objectId, null, + PropertyIds.ObjectId + "," + PropertyIds.VersionSeriesId, false, + IncludeRelationships.None, "cmis:none", false, false, extension); + + if (obj.Properties != null) + { + IPropertyData versionSeriesProp = obj.Properties[PropertyIds.VersionSeriesId]; + if (versionSeriesProp != null && versionSeriesProp.FirstValue is string) + { + objectId = (string)versionSeriesProp.FirstValue; + } + } + } + } + return GetObjectInternal(repositoryId, IdentifierType.ID, objectId, returnVersion, filter, includeAllowableActions, includeRelationships, renditionFilter, includePolicyIds, includeAcl, extension); } Modified: chemistry/portcmis/trunk/PortCMIS/client/ClientIntf.cs URL: http://svn.apache.org/viewvc/chemistry/portcmis/trunk/PortCMIS/client/ClientIntf.cs?rev=1789499&r1=1789498&r2=1789499&view=diff ============================================================================== --- chemistry/portcmis/trunk/PortCMIS/client/ClientIntf.cs (original) +++ chemistry/portcmis/trunk/PortCMIS/client/ClientIntf.cs Thu Mar 30 11:44:01 2017 @@ -1661,11 +1661,18 @@ namespace PortCMIS.Client void RemovePolicy(params IObjectId[] policyId); /// - /// Gets a list of policies applied to this object. + /// Returns the applied policies if they have been fetched for this object. + /// This method fetches the policy objects from the repository when this method is called for the first time. Policy objects that don't exist are ignored. /// IList Policies { get; } /// + /// Returns the applied policy IDs if they have been fetched for this object. + /// All applied policy IDs are returned, even IDs of policies that don't exist. + /// + IList PolicyIds { get; } + + /// /// Adds and removes ACEs to this object. /// /// the new ACL of this object @@ -1773,6 +1780,11 @@ namespace PortCMIS.Client bool? IsLatestMajorVersion { get; } /// + /// Gets if this CMIS object is the PWC (CMIS property cmis:isPrivateWorkingCopy). + /// + bool? IsPrivateWorkingCopy { get; } + + /// /// Gets the version label (CMIS property cmis:versionLabel). /// string VersionLabel { get; } @@ -1826,6 +1838,11 @@ namespace PortCMIS.Client /// Gets the content stream hashes or null if the document has no content or the repository hasn't provided content hashes (CMIS property cmis:contentStreamHash). /// IList ContentStreamHashes { get; } + + /// + /// Gets the latest accessible state ID (CMIS property cmis:latestAccessibleStateId). + /// + string LatestAccessibleStateId { get; } } /// @@ -1834,6 +1851,22 @@ namespace PortCMIS.Client public interface IDocument : IFileableCmisObject, IDocumentProperties { /// + /// Returns the object type as a document type. + /// + IDocumentType DocumentType { get; } + + /// + /// Returns whether the document is versionable or not. + /// + bool IsVersionable { get; } + + /// + /// Determines whether this document is the PWC in the version series or not. + /// + /// true if it is the PWC, false if it is not the PWC, or null if it can't be determined + bool? IsVersionSeriesPrivateWorkingCopy { get; } + + /// /// Deletes all versions of this document. /// void DeleteAllVersions(); @@ -2006,6 +2039,11 @@ namespace PortCMIS.Client public interface IFolder : IFileableCmisObject, IFolderProperties { /// + /// Returns the object type as a folder type. + /// + IFolderType FolderType { get; } + + /// /// Creates a new document in this folder. /// /// the new document object @@ -2184,6 +2222,10 @@ namespace PortCMIS.Client /// public interface IPolicy : IFileableCmisObject, IPolicyProperties { + /// + /// Returns the object type as a policy type. + /// + IPolicyType PolicyType { get; } } /// @@ -2208,6 +2250,11 @@ namespace PortCMIS.Client public interface IRelationship : ICmisObject, IRelationshipProperties { /// + /// Returns the object type as a relationship type. + /// + IRelationshipType RelationshipType { get; } + + /// /// Gets the relationship source object. /// /// @@ -2252,6 +2299,10 @@ namespace PortCMIS.Client /// public interface IItem : IFileableCmisObject, ItemProperties { + /// + /// Returns the object type as an item type. + /// + IItemType ItemType { get; } } /// Modified: chemistry/portcmis/trunk/PortCMIS/client/ClientObjects.cs URL: http://svn.apache.org/viewvc/chemistry/portcmis/trunk/PortCMIS/client/ClientObjects.cs?rev=1789499&r1=1789498&r2=1789499&view=diff ============================================================================== --- chemistry/portcmis/trunk/PortCMIS/client/ClientObjects.cs (original) +++ chemistry/portcmis/trunk/PortCMIS/client/ClientObjects.cs Thu Mar 30 11:44:01 2017 @@ -101,6 +101,7 @@ namespace PortCMIS.Client.Impl private IAllowableActions allowableActions; private IList renditions; private IAcl acl; + private IList policyIds; private IList policies; private IList relationships; private IDictionary> extensions; @@ -231,22 +232,22 @@ namespace PortCMIS.Client.Impl } // handle policies + policies = null; if (objectData.PolicyIds != null && objectData.PolicyIds.PolicyIds != null) { - policies = new List(); - foreach (string pid in objectData.PolicyIds.PolicyIds) + if (objectData.PolicyIds.PolicyIds.Count == 0) { - IPolicy policy = Session.GetObject(Session.CreateObjectId(pid)) as IPolicy; - if (policy != null) - { - policies.Add(policy); - } + policyIds = null; + } + else + { + policyIds = objectData.PolicyIds.PolicyIds; } extensions[ExtensionLevel.Policies] = objectData.PolicyIds.Extensions; } else { - policies = null; + policyIds = null; } // handle relationships @@ -644,11 +645,47 @@ namespace PortCMIS.Client.Impl { lock (objectLock) { + if (policies != null || policyIds == null) + { + return policies; + } + + policies = new List(); + foreach (string pid in policyIds) + { + try + { + ICmisObject policy = Session.GetObject(pid); + + if (policy is IPolicy) + { + policies.Add((IPolicy)policy); + } + } + catch (CmisObjectNotFoundException) + { + // ignore + } + } + return policies; } } } + /// + public virtual IList PolicyIds + { + get + { + lock (objectLock) + { + return policyIds; + } + } + } + + // --- relationships --- /// @@ -886,6 +923,64 @@ namespace PortCMIS.Client.Impl Initialize(session, objectType, objectData, context); } + /// + public virtual IDocumentType DocumentType + { + get + { + if (ObjectType is IDocumentType) + { + return (IDocumentType)ObjectType; + } + else + { + throw new InvalidCastException("Object type is not a document type."); + } + } + } + + /// + public virtual bool IsVersionable + { + get + { + return DocumentType.IsVersionable == true; + } + } + + /// + public virtual bool? IsVersionSeriesPrivateWorkingCopy + { + get + { + if (DocumentType.IsVersionable == false) + { + return false; + } + + if (IsVersionSeriesCheckedOut == false) + { + return false; + } + + bool? isPWC = IsPrivateWorkingCopy; + if (isPWC != null) + { + return isPWC; + } + + string vsCoId = VersionSeriesCheckedOutId; + if (vsCoId == null) + { + // we don't know ... + return null; + } + + return vsCoId == Id; + } + } + + // properties /// @@ -901,6 +996,9 @@ namespace PortCMIS.Client.Impl public virtual bool? IsLatestMajorVersion { get { return GetPropertyAsBoolValue(PropertyIds.IsLatestMajorVersion); } } /// + public virtual bool? IsPrivateWorkingCopy { get { return GetPropertyAsBoolValue(PropertyIds.IsPrivateWorkingCopy); } } + + /// public virtual string VersionLabel { get { return GetPropertyAsStringValue(PropertyIds.VersionLabel); } } /// @@ -931,6 +1029,9 @@ namespace PortCMIS.Client.Impl public virtual string ContentStreamId { get { return GetPropertyAsStringValue(PropertyIds.ContentStreamId); } } /// + public virtual string LatestAccessibleStateId { get { return GetPropertyAsStringValue(PropertyIds.LatestAccessibleStateId); } } + + /// public virtual IList ContentStreamHashes { get @@ -1364,6 +1465,22 @@ namespace PortCMIS.Client.Impl } /// + public virtual IFolderType FolderType + { + get + { + if (ObjectType is IFolderType) + { + return (IFolderType)ObjectType; + } + else + { + throw new InvalidCastException("Object type is not a folder type."); + } + } + } + + /// public virtual IDocument CreateDocument(IDictionary properties, IContentStream contentStream, VersioningState? versioningState, IList policies, IList addAces, IList removeAces, IOperationContext context) { @@ -1518,7 +1635,7 @@ namespace PortCMIS.Client.Impl IObjectFactory of = Session.ObjectFactory; IOperationContext ctxt = new OperationContext(context); - PageFetcher.FetchPage fetchPageDelegate = delegate(BigInteger maxNumItems, BigInteger skipCount) + PageFetcher.FetchPage fetchPageDelegate = delegate (BigInteger maxNumItems, BigInteger skipCount) { // get checked out documents for this folder IObjectList checkedOutDocs = service.GetCheckedOutDocs(RepositoryId, objectId, ctxt.FilterString, ctxt.OrderBy, ctxt.IncludeAllowableActions, @@ -1561,7 +1678,7 @@ namespace PortCMIS.Client.Impl IObjectFactory of = Session.ObjectFactory; IOperationContext ctxt = new OperationContext(context); - PageFetcher.FetchPage fetchPageDelegate = delegate(BigInteger maxNumItems, BigInteger skipCount) + PageFetcher.FetchPage fetchPageDelegate = delegate (BigInteger maxNumItems, BigInteger skipCount) { // get the children IObjectInFolderList children = service.GetChildren(RepositoryId, objectId, ctxt.FilterString, ctxt.OrderBy, ctxt.IncludeAllowableActions, @@ -1780,6 +1897,22 @@ namespace PortCMIS.Client.Impl } /// + public virtual IPolicyType PolicyType + { + get + { + if (ObjectType is IPolicyType) + { + return (IPolicyType)ObjectType; + } + else + { + throw new InvalidCastException("Object type is not a policy type."); + } + } + } + + /// public virtual string PolicyText { get { return GetPropertyAsStringValue(PropertyIds.PolicyText); } } } @@ -1801,6 +1934,22 @@ namespace PortCMIS.Client.Impl } /// + public virtual IRelationshipType RelationshipType + { + get + { + if (ObjectType is IRelationshipType) + { + return (IRelationshipType)ObjectType; + } + else + { + throw new InvalidCastException("Object type is not a relationship type."); + } + } + } + + /// public virtual ICmisObject GetSource() { return GetSource(Session.DefaultContext); @@ -1889,6 +2038,22 @@ namespace PortCMIS.Client.Impl { Initialize(session, objectType, objectData, context); } + + /// + public virtual IItemType ItemType + { + get + { + if (ObjectType is IItemType) + { + return (IItemType)ObjectType; + } + else + { + throw new InvalidCastException("Object type is not an item type."); + } + } + } } /// Modified: chemistry/portcmis/trunk/PortCMIS/client/SessionParameter.cs URL: http://svn.apache.org/viewvc/chemistry/portcmis/trunk/PortCMIS/client/SessionParameter.cs?rev=1789499&r1=1789498&r2=1789499&view=diff ============================================================================== --- chemistry/portcmis/trunk/PortCMIS/client/SessionParameter.cs (original) +++ chemistry/portcmis/trunk/PortCMIS/client/SessionParameter.cs Thu Mar 30 11:44:01 2017 @@ -144,5 +144,9 @@ namespace PortCMIS.Client /// Defines if the document name should be added to the properties on check in if no properties are updated /// (Workaround for SharePoint 2010 and SharePoint 2013) public const string AddNameOnCheckIn = "org.apache.chemistry.portcmis.workaround.addNameOnCheckIn"; + + /// Defines if getObjectOfLatestVersion should use the version series ID instead of the object ID + /// (Workaround for SharePoint 2010 and SharePoint 2013) + public const string LatestVersionWithVersionSeriesId = "org.apache.chemistry.portcmis.workaround.getLatestVersionWithVersionSeriesId"; } } \ No newline at end of file Modified: chemistry/portcmis/trunk/PortCMISTests/SimpleCmisTest.cs URL: http://svn.apache.org/viewvc/chemistry/portcmis/trunk/PortCMISTests/SimpleCmisTest.cs?rev=1789499&r1=1789498&r2=1789499&view=diff ============================================================================== --- chemistry/portcmis/trunk/PortCMISTests/SimpleCmisTest.cs (original) +++ chemistry/portcmis/trunk/PortCMISTests/SimpleCmisTest.cs Thu Mar 30 11:44:01 2017 @@ -332,6 +332,7 @@ namespace PortCMISTests IObjectId pwcId = doc.CheckOut(); IDocument pwc = (IDocument)Session.GetObject(pwcId, noCacheOC); + Assert.AreEqual(true, pwc.IsPrivateWorkingCopy); pwc.Rename(name2);