cancel
Showing results for 
Search instead for 
Did you mean: 

Apache Chemistry Versoning error

shivtechno
Champ in-the-making
Champ in-the-making

Hi

I am creating versoning of document also i had tried on to solve the error but some time cant access and apache chemistry error find while stack trace in code

or conflict message throw so how can i solve this error using below code . or updating the below code ..

--

Dictionary<string, string> parameters = new Dictionary<string, string>();

                parameters[DotCMIS.SessionParameter.BindingType] = BindingType.AtomPub;

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

                parameters[DotCMIS.SessionParameter.User] = UserName;

                parameters[DotCMIS.SessionParameter.Password] = Password;

               

                SessionFactory factory = SessionFactory.NewInstance();

                ISession session = factory.GetRepositories(parameters)[0].CreateSession();

  Document doc = ((Document)session.GetObject("workspace://SpacesStore/"+objectId));

                string objId = string.Empty;

                try

                {

                    // checkout the doc

                    IObjectId Iobj = doc.CheckOut();

                    objId = Iobj.Id;

                    Response.Write("Checked out doc ID: " + objId);

                }

                catch (Exception cbe)

                {

                    // cancel the checkout incase of exception

                    doc.CancelCheckOut();

                    Response.Write("Exception checking out; must be checked out already: " + cbe.Message);

                }

                // define dictionary for document

                IDictionary<string, object> properties = new Dictionary<string, object>();

                properties.Add(PropertyIds.Name, file.FileName);

                properties.Add(PropertyIds.ObjectTypeId, "cmis:document");

                properties.Add(PropertyIds.ObjectId, objId);

                string[] separatingChars = { "/" };

                string text = doc.Paths[0];

                string[] words = text.Split(separatingChars, System.StringSplitOptions.RemoveEmptyEntries);

                string Path = words[0];

                //string Path = doc.Paths[0];

                IFolder folder = (IFolder)session.GetObjectByPath("/" + Path + "/");

                byte[] data = new byte[file.ContentLength];

                file.InputStream.Read(data, 0, data.Length);

                // define new document stream object

                ContentStream contentStream = new ContentStream

                {

                    FileName = file.FileName,

                    MimeType = file.ContentType,// MimeType = "application/msword",

                    Length = file.ContentLength,

                    Stream = new MemoryStream(data)

                };

                // create/update the document with new stream & version

                folder.CreateDocument(properties, contentStream,DotCMIS.Enums.VersioningState.Minor);

                // finally check in the document

                try

                {

                    IObjectId ob = doc.CheckIn(false, properties, null, "Version Update Document..");

                }

                catch(Exception ex) { }

                //Get All Version and seeking through ViewBag

                IList<IDocument> docs = doc.GetAllVersions();

                ViewBag.Mesg = docs;

                ViewBag.Message = "Document Version updated Successfully to alfresco..!";

            }

---

Regards,

Shiva Swamy

1 ACCEPTED ANSWER

kaynezhang
World-Class Innovator
World-Class Innovator

Try to use cmis version 1.1 instead of 1.0,and use the latest dotcmis version 0.7

http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/atom

View answer in original post

4 REPLIES 4

mrks_js1
Star Contributor
Star Contributor

Hi

What version of alfresco are you using?

Have you tried debugging your code? Which part seems to fail?

Have you seen this guide http://chemistry.apache.org/java/developing/guide.html

shivtechno
Champ in-the-making
Champ in-the-making

Thanks Markus for helping i was gone thorugh the openCMIS Code and it helps lot to understand the code logic used to create versoning of document.

kaynezhang
World-Class Innovator
World-Class Innovator

Try to use cmis version 1.1 instead of 1.0,and use the latest dotcmis version 0.7

http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/atom

Thank you Kayne .. Smiley Happy