AnsweredAssumed Answered

Apache Chemistry Versoning error

Question asked by shivtechno on Oct 16, 2016
Latest reply on Oct 17, 2016 by shivtechno

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

Outcomes