Search code examples
c#alfrescodotcmis

Error "Property 'cm:title' doesn't exsist" while using DotCMIS for Alfresco


I established a session via dotCMIS with a local Alfresco-Server using Visual Studio 2010 C# via

Dictionary<string, string> parameters = new Dictionary<string, string>();    
parameters[DotCMIS.SessionParameter.BindingType] = BindingType.AtomPub;      
parameters[DotCMIS.SessionParameter.AtomPubUrl] = "http://127.0.0.1:8888/alfresco/api/-default-/public/cmis/versions/1.1/atom";           
parameters[DotCMIS.SessionParameter.User] = "admin";
parameters[DotCMIS.SessionParameter.Password] = "admin";           
SessionFactory factory = SessionFactory.NewInstance();    
IList<IRepository> repos = factory.GetRepositories(parameters);
ISession session = repos.ElementAt(0).CreateSession();    

But when I try to get a the root folder like

IFolder root = session.GetRootFolder(); 

or run a query like

string queryGetDoc = "SELECT * FROM cmis:document WHERE cmis:name='Bug101.png'";
IItemEnumerable<IQueryResult> docResults = session.Query(queryGetDoc, false);
IQueryResult docHit = docResults.FirstOrDefault();
string docId = docHit["cmis:objectId"].FirstValue.ToString();

IDocument document = session.GetObject(docId) as IDocument;

IList<IProperty> listOfProperties = document.Properties;

foreach (IProperty p in listOfProperties)
{
    Console.WriteLine(p.QueryName);
}

I get an error message:

DotCMIS.Exceptions.CmisRuntimeException: Property 'cm:title' doesn't exist! bei DotCMIS.Client.Impl.ObjectFactory.ConvertProperty(IObjectType objectType, IPropertyData pd) bei DotCMIS.Client.Impl.ObjectFactory.ConvertProperties(IObjectType objectType, IProperties properties) bei DotCMIS.Client.Impl.AbstractCmisObject.Initialize(ISession session, IObjectType objectType, IObjectData objectData, IOperationContext context) bei DotCMIS.Client.Impl.Folder..ctor(ISession session, IObjectType objectType, IObjectData objectData, IOperationContext context) bei DotCMIS.Client.Impl.ObjectFactory.ConvertObject(IObjectData objectData, IOperationContext context) bei DotCMIS.Client.Impl.Session.GetObject(String objectId, IOperationContext context) bei DotCMIS.Client.Impl.Session.GetObject(IObjectId objectId, IOperationContext context) bei DotCMIS.Client.Impl.Session.GetRootFolder(IOperationContext context) bei DotCMIS.Client.Impl.Session.GetRootFolder() bei ConsoleApplication3.Program.ConnectingUsingAtomPub_CreateFolder()

I can just guess, that I'm missing some fundamentals here, but I searched the web, only finding https://github.com/wk-j/alfresco-cmis/issues/1.

However I have no idea how to apply that, or if it is the right thing at all.


Solution

  • As Gagravarr suggested, it is as easy as that: Change the connection endpoint to CMIS 1.0, and the query works fine. If I find a propper solution with PortCMIS and CMIS 1.1 I'll post that later.

    parameters[DotCMIS.SessionParameter.AtomPubUrl] = "http://127.0.0.1:8888/alfresco/api/-default-/public/cmis/versions/1.0/atom";