我有一个关于Alfresco和dotCMIS库的问题。基本上,我想进入一个特定的文件夹,并在那里创建一个文档。
此时我有以下代码(我知道这是混乱的,但它是用于测试):
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters[SessionParameter.BindingType] = BindingType.AtomPub;
parameters[SessionParameter.AtomPubUrl] = "http://webadress:2005/alfresco/service/cmis";
parameters[SessionParameter.User] = "amdin";
parameters[SessionParameter.Password] = "admpsw";
SessionFactory factory = SessionFactory.NewInstance();
IList<DotCMIS.Client.IRepository> repositories = factory.GetRepositories(parameters);
DotCMIS.Client.ISession session = repositories[0].CreateSession();
foreach (ICmisObject cmisObject in rootFolder.GetChildren())
{
Console.WriteLine(cmisObject.Name);
if (cmisObject.Name.Equals("AlfresCO"))
{
var type = cmisObject.GetType();
IFolder circabcfolder = cmisObject as IFolder;
foreach (ICmisObject obj in circabcfolder.GetChildren())
{
Console.WriteLine(obj.Name);
if (obj.Name.Equals("SubFolder1"))
{
IFolder circabcfolder2 = obj as IFolder;
foreach (ICmisObject obj2 in circabcfolder2.GetChildren())
{
Console.WriteLine(obj2.Name);
foreach (ICmisObject obj3 in (obj2 as IFolder).GetChildren())
{
Console.WriteLine(obj3.Name);
if (obj3.Name.Equals("Library"))
{
foreach (ICmisObject obj4 in (obj3 as IFolder).GetChildren())
{
Console.WriteLine(obj4.Name);
if (obj4.Name.Equals("MyFolder"))
{
IDictionary<string, object> properties2 = new Dictionary<string, object>();
properties2[PropertyIds.ObjectTypeId]= "cmis:folder";
properties2[PropertyIds.Name] = "Test Folder";
IFolder newFolder = (obj4 as IFolder).CreateFolder(properties2);
}
}
}
}
}
}
}
}
}
它只是打开一个根文件夹,这意味着我在'alfresco',例如,然后我必须导航到另一个子文件夹,然后另一个,然后最后我得到:/Library,/Groups,/Newsgroups…等。在图书馆,我可以打开"我的文件夹",但有没有更简单的方法,只是打开/图书馆/我的文件夹,而不是真正通过所有的图层得到正确的文件夹…?
我可以做一些像…session.GetFolderByName("MyFolder")
我也不能依赖于ID,例如在其他门户中,为文件夹随机生成的ID可以是不同的,所以我不能说GetFolderById(..);
有什么想法吗?
我对DotCMISClient不是很熟悉,但是如果你看一下总的服务(应该通过客户端可用),那么你会看到有两个服务可以完成这个任务
- GetObjectByPath 查询
当类型为cmis:folder,名称为"MyFolder"时,查询非常容易。