早上好,我需要用 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);
}
}
}