10-16-2016 08:31 AM
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
10-17-2016 12:36 AM
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
10-16-2016 09:06 AM
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
10-17-2016 01:58 AM
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.
10-17-2016 12:36 AM
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
10-17-2016 01:58 AM
Thank you Kayne ..
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.