public void TestAcl() { IDocument doc = null; try { doc = CreateTextDocument(Session.GetRootFolder(), "acl.txt", "Hello Joe!"); Ace joeAce = new Ace() { Principal = new Principal() { Id = "joe" }, Permissions = new List <string> { "cmis:write" } }; // apply ACL and test result IAcl newAcl = doc.ApplyAcl(new List <IAce> { joeAce }, null, AclPropagation.RepositoryDetermined); Assert.IsNotNull(newAcl); Assert.IsNotNull(newAcl.Aces); Assert.IsTrue(newAcl.Aces.Count > 0); // retrieve ACL and test IAcl acl2 = Session.GetAcl(doc, true); Assert.IsNotNull(acl2); Assert.IsNotNull(acl2.Aces); Assert.IsTrue(acl2.Aces.Count > 0); // fetch document and test IDocument doc2 = (IDocument)Session.GetObject(doc, OperationContextUtils.CreateMaximumOperationContext()); Assert.IsNotNull(doc2.Acl); Assert.IsNotNull(doc2.Acl.Aces); Assert.IsTrue(doc2.Acl.Aces.Count > 0); } finally { if (doc != null) { doc.Delete(); Assert.IsFalse(Session.Exists(doc)); } } }
protected void Initialize(ISession session, IObjectType objectType, IObjectData objectData, IOperationContext context) { if (session == null) { throw new ArgumentNullException("session"); } if (objectType == null) { throw new ArgumentNullException("objectType"); } if (objectType.PropertyDefinitions == null || objectType.PropertyDefinitions.Count < 9) { // there must be at least the 9 standard properties that all objects have throw new ArgumentException("Object type must have property defintions!"); } this.Session = session; this.objectType = objectType; this.extensions = new Dictionary<ExtensionLevel, IList<ICmisExtensionElement>>(); this.CreationContext = new OperationContext(context); this.RefreshTimestamp = DateTime.UtcNow; IObjectFactory of = Session.ObjectFactory; if (objectData != null) { // handle properties if (objectData.Properties != null) { properties = of.ConvertProperties(objectType, objectData.Properties); extensions[ExtensionLevel.Properties] = objectData.Properties.Extensions; } // handle allowable actions if (objectData.AllowableActions != null) { allowableActions = objectData.AllowableActions; extensions[ExtensionLevel.AllowableActions] = objectData.AllowableActions.Extensions; } // handle renditions if (objectData.Renditions != null) { renditions = new List<IRendition>(); foreach (IRenditionData rd in objectData.Renditions) { renditions.Add(of.ConvertRendition(Id, rd)); } } // handle ACL if (objectData.Acl != null) { acl = objectData.Acl; extensions[ExtensionLevel.Acl] = objectData.Acl.Extensions; } // handle policies if (objectData.PolicyIds != null && objectData.PolicyIds.PolicyIds != null) { policies = new List<IPolicy>(); foreach (string pid in objectData.PolicyIds.PolicyIds) { IPolicy policy = Session.GetObject(Session.CreateObjectId(pid)) as IPolicy; if (policy != null) { policies.Add(policy); } } extensions[ExtensionLevel.Policies] = objectData.PolicyIds.Extensions; } // handle relationships if (objectData.Relationships != null) { relationships = new List<IRelationship>(); foreach (IObjectData rod in objectData.Relationships) { IRelationship relationship = of.ConvertObject(rod, CreationContext) as IRelationship; if (relationship != null) { relationships.Add(relationship); } } } extensions[ExtensionLevel.Object] = objectData.Extensions; } }
public string CreatePolicy(string repositoryId, IProperties properties, string folderId, IList<string> policies, IAcl addAces, IAcl removeAces, IExtensionsData extension) { ObjectServicePortClient port = Provider.GetObjectService(); try { cmisExtensionType cmisExtension = Converter.ConvertExtension(extension); string objectId = port.createPolicy(repositoryId, Converter.Convert(properties), folderId, Converter.ConvertList(policies), Converter.Convert(addAces), Converter.Convert(removeAces), ref cmisExtension); Converter.ConvertExtension(cmisExtension, extension); return objectId; } catch (FaultException<cmisFaultType> fe) { throw ConvertException(fe); } catch (Exception e) { throw new CmisRuntimeException("Error: " + e.Message, e); } }
public string CreateDocumentFromSource(string repositoryId, string sourceId, IProperties properties, string folderId, VersioningState? versioningState, IList<string> policies, IAcl addAces, IAcl removeAces, IExtensionsData extension) { ObjectServicePortClient port = Provider.GetObjectService(); try { cmisExtensionType cmisExtension = Converter.ConvertExtension(extension); string objectId = port.createDocumentFromSource(repositoryId, sourceId, Converter.Convert(properties), folderId, (enumVersioningState?)CmisValue.CmisToSerializerEnum(versioningState), Converter.ConvertList(policies), Converter.Convert(addAces), Converter.Convert(removeAces), ref cmisExtension); Converter.ConvertExtension(cmisExtension, extension); return objectId; } catch (FaultException<cmisFaultType> fe) { throw ConvertException(fe); } catch (Exception e) { throw new CmisRuntimeException("Error: " + e.Message, e); } }
public IAcl ApplyAcl(string repositoryId, string objectId, IAcl addAces, IAcl removeAces, AclPropagation? aclPropagation, IExtensionsData extension) { ACLServicePortClient port = Provider.GetAclService(); try { return Converter.Convert(port.applyACL(repositoryId, objectId, Converter.Convert(addAces), Converter.Convert(removeAces), (enumACLPropagation?)CmisValue.CmisToSerializerEnum(aclPropagation), Converter.ConvertExtension(extension))); } catch (FaultException<cmisFaultType> fe) { throw ConvertException(fe); } catch (Exception e) { throw new CmisRuntimeException("Error: " + e.Message, e); } }
public void CheckIn(string repositoryId, ref string objectId, bool? major, IProperties properties, IContentStream contentStream, string checkinComment, IList<string> policies, IAcl addAces, IAcl removeAces, IExtensionsData extension) { VersioningServicePortClient port = Provider.GetVersioningService(); try { cmisExtensionType cmisExtension = Converter.ConvertExtension(extension); port.checkIn(repositoryId, ref objectId, major, Converter.Convert(properties), Converter.Convert(contentStream), checkinComment, Converter.ConvertList(policies), Converter.Convert(addAces), Converter.Convert(removeAces), ref cmisExtension); Converter.ConvertExtension(cmisExtension, extension); } catch (FaultException<cmisFaultType> fe) { throw ConvertException(fe); } catch (Exception e) { throw new CmisRuntimeException("Error: " + e.Message, e); } }