cancel
Showing results for 
Search instead for 
Did you mean: 

CreateDocument in DotCMIS error 'Type or type property must be set'

lozzad
Champ in-the-making
Champ in-the-making
Hi,

I am looking at creating a Word Add-in in visual studio using DotCMIS in C#.

I am using code as below which is largely taken from the CMISandApacheChemistryinAction book.

I am using DotCMIS 0.5 And Alfresco Community 4.2.d


       private void test()
       {
        Dictionary<string, string> parameters =
        new Dictionary<string, string>();
        // define binding type, in our example we are using ATOMPUB as stated above
        parameters[DotCMIS.SessionParameter.BindingType] = BindingType.AtomPub;
        // define CMIS available path which is already available under alfresco
        parameters[DotCMIS.SessionParameter.AtomPubUrl] = "http://blah:8080/alfresco/service/cmis";
        // alfresco portal admin user name
        parameters[DotCMIS.SessionParameter.User] = "admin";
        // alfresco portal admin password
        parameters[DotCMIS.SessionParameter.Password] = "admin";
        SessionFactory factory = SessionFactory.NewInstance();
        ISession session = factory.GetRepositories(parameters)[0].
        CreateSession();
        Dictionary<string, object> properties = new Dictionary<string,object>()
        {
        {"cmis:name", "exampleName" },
        {"cmisSmiley SurprisedbjectType", "cmis:document"},
        };

        IFolder rootFolder = session.GetRootFolder();
        string filePath = "\\exampleFile";
        string fileName = "exampleFile";
        FileStream stream = File.Create(filePath);
        IObjectFactory objectFactory = session.ObjectFactory;
        IContentStream contentStream = session.ObjectFactory.
        CreateContentStream(fileName, stream.Length, "text/plain", stream);
        IDocument firstDoc = rootFolder.CreateDocument(properties, contentStream,
        VersioningState.Major);
       }


I get an error "Type or type property must be set!" on the last line of code            
IDocument firstDoc = folder.CreateDocument(properties, contentStream,
VersioningState.Major);


I have no prior experience with CMIS and just want to get something working so any help appreciated.
1 REPLY 1

lozzad
Champ in-the-making
Champ in-the-making
CreateFolder worked though the above problem with CreateFile still persists.

            IDictionary<string, object> propertiesfolder = new Dictionary<string, object>();
            // below property define name
            propertiesfolder.Add(PropertyIds.Name, "ICreated");
            // below propert define object type & object types can be folder, document etc.., in our case it is folder
            propertiesfolder.Add(PropertyIds.ObjectTypeId, "cmis:folder");
            IFolder newFolder = rootFolder.CreateFolder(propertiesfolder);