0

早上好,我需要用 Apache chemistry dotcmis 创建一堆文档。然而,即使在最简单的情况下,SharePoint 在调用 folder.CreateDocument 时也会触发 CmisConstraintException。我已经对所有可用的 VersioningStates 进行了测试,但这并不能解决问题。我使用 dotCmis 0.6。顺便说一句,我的应用程序的 Alfresco 部分运行良好。

-阿明

这是我的模型。

using DotCMIS;
using DotCMIS.Client;
using DotCMIS.Client.Impl;
using DotCMIS.Data.Impl;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
    static void Main(string[] args)
    {
        Dictionary<string, string> parameters;
        parameters = new Dictionary<string, string>();
        parameters[SessionParameter.BindingType] = BindingType.AtomPub;
        parameters[SessionParameter.AtomPubUrl] = "http://coretwo/" + "websites/migrationtest" + "/_vti_bin/cmis/rest?getRepositories";
        parameters[SessionParameter.User] = "joe@test.org";
        parameters[SessionParameter.Password] = "whoknows";


        var session = SessionFactory.NewInstance().GetRepositories(parameters).Single(r => r.Name.Equals("Dokumente")).CreateSession();
        var rFolder = session.GetRootFolder();


        IDictionary<string, object> properties = new Dictionary<string, object>();
        properties[PropertyIds.Name] = "Hello World Document";
        properties[PropertyIds.ObjectTypeId] = "cmis:document";

        byte[] content = UTF8Encoding.UTF8.GetBytes("Hello World!");

        ContentStream contentStream = new ContentStream();
        contentStream.FileName = "hello-world.txt";
        contentStream.MimeType = "text/plain";
        contentStream.Length = content.Length;
        contentStream.Stream = new MemoryStream(content);

        IDocument doc = rFolder.CreateDocument(properties, contentStream, null);  

    }
}

}

4

1 回答 1

1

墨菲无处不在……我在这里发帖几分钟后找到了答案。诀窍是在调用 CreateDocument 时使用 DotCMIS.Enums.VersioningState.CheckedOut 并在之后进行签入。

所以这对我有用:

IDocument doc = rFolder.CreateDocument(properties, contentStream, DotCMIS.Enums.VersioningState.CheckedOut);
doc.CheckIn(true, null, null, "Checkin", null, null, null);
于 2014-04-10T06:27:24.600 回答