4

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.

halfer
  • 19,824
  • 17
  • 99
  • 186
meister_reineke
  • 364
  • 1
  • 14
  • 3
    What happens if you try connecting to the CMIS 1.0 endpoint? IIRC DotCMIS doesn't support CMIS 1.1, for .Net and CMIS 1.1 you need to use [PortCMIS instead](http://chemistry.apache.org/dotnet/portcmis.html) – Gagravarr May 18 '16 at 17:13
  • 2
    Be aware that the cmis:title property is defined on an aspect, so if you use the CMIS 1.0 bindings, which do not understand aspects (CMIS calls them secondary types) natively, you will only see properties defined on the type and you won't see any defined on the aspects that may be applied to the object. – Jeff Potts May 18 '16 at 19:56
  • Thanks a lot Gagravarr, connecting with 1.0 did the Trick! Maybe ill try PortCMIS as well, in case I want to use the aspects as Jeff Potts mentioned. Huge Thanks to both of you! – meister_reineke May 19 '16 at 08:32

1 Answers1

1

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";           
meister_reineke
  • 364
  • 1
  • 14