早上好, 我需要用Apache化学dotcmis创建一堆文档。但是,即使在最简单的情况下,SharePoint在调用folder.CreateDocument时也会触发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);
}
}
}
答案 0 :(得分:1)
Murphy到处都是......我在帖子发布后找到了答案。诀窍是在调用CreateDocument时使用DotCMIS.Enums.VersioningState.CheckedOut并在此后进行检查。
所以这对我有用:
IDocument doc = rFolder.CreateDocument(properties, contentStream, DotCMIS.Enums.VersioningState.CheckedOut);
doc.CheckIn(true, null, null, "Checkin", null, null, null);