dotCmis .CreateDocument with Sharepoint 2013



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

-Armin

这是我的模型。

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);  
    }
}

}

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

以下是适用于我的:

IDocument doc = rFolder.CreateDocument(properties, contentStream, DotCMIS.Enums.VersioningState.CheckedOut);
doc.CheckIn(true, null, null, "Checkin", null, null, null);

相关内容

  • 没有找到相关文章

最新更新