【问题标题】:CMIS Sharepoint 2013 - Cannot Update DocumentCMIS Sharepoint 2013 - 无法更新文档
【发布时间】:2015-04-08 10:05:13
【问题描述】:

我无法使用 CMIS for Sharepoint 2013 更新文档。我不断收到错误消息“操作正在尝试更新不再是当前的对象。”我不知道为什么会这样。

请你检查一下我下面的代码有什么问题:

        Dictionary<string, string> parameters = new Dictionary<string, string>();
        parameters[DotCMIS.SessionParameter.BindingType] = BindingType.AtomPub;
        parameters[DotCMIS.SessionParameter.AtomPubUrl] = url;
        parameters[DotCMIS.SessionParameter.User] = username;
        parameters[DotCMIS.SessionParameter.Password] = password;
        parameters[SessionParameter.RepositoryId] = repositoryID;

        SessionFactory factory = SessionFactory.NewInstance();
        ISession session = factory.CreateSession(parameters);
        ICmisObject cmisobj = session.GetObject("12345");

        IDictionary<String, Object> properties = new Dictionary<String, Object>();
        properties["cmis:name"] = "MyNewName";

        IObjectId newId = cmisobj.UpdateProperties(properties);

感谢您的回复。我尝试添加 IOperationContext 但我仍然收到相同的错误。我是不是执行错了?

        SessionFactory factory = SessionFactory.NewInstance();
        ISession session = factory.CreateSession(parameters);

        IOperationContext oc = session.CreateOperationContext();
        ICmisObject cmisobj = session.GetObject("12345", oc);

        IDictionary<String, Object> properties = new Dictionary<String, Object>();
        properties["cmis:name"] = "MyNewName";

        IObjectId newId = cmisobj.UpdateProperties(properties);

【问题讨论】:

    标签: c# sharepoint sharepoint-2013 opencmis dotcmis


    【解决方案1】:

    这是一个已知的 SharePoint 错误。如果您在更新请求中包含更改令牌(属性“cmis:changeToken”),则会失败并显示此错误。 DotCMIS 会自动添加此属性以防止丢失更新。

    要排除更改令牌,您在获取对象时不得请求它。 使用IOperationContext 对象调用GetObject(),该对象具有不包含“cmis:changeToken”的属性过滤器。然后 SharePoint 将接受更新请求。

    【讨论】:

    • 感谢您的回复。我尝试添加 IOperationContext 但仍然收到相同的错误 SessionFactory factory = SessionFactory.NewInstance(); ISession session = factory.CreateSession(parameterconfiguration); IOperationContext oc = session.CreateOperationContext(); ICmisObject cmisobj = session.GetObject("12345", oc); IDictionary 属性 = new Dictionary();属性["cmis:name"] = "新名称"; IObjectId newId = cmisobj.UpdateProperties(properties);
    • 您错过了一步。在调用 GetObject() 之前添加这一行:oc.FilterString = "cmis:objectId,cmis:objectTypeId,cmis:name"; // add all the properties you need here
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-26
    相关资源
    最近更新 更多