While uploading document to Alfresco Content services using CMIS we are passing Metadata as Alfresco Custom Properties along with it. All Custom propertis are being accepted and document content uploaded, but values for some custom properties are not being set. Their values are shown as none. For example custom properties such as string, DateTime and long are bein set along with their values, but Custom property value for int (integer) is not being set in ACS(value is shown as (None).
Solved! Go to Solution.
I have found solution and you can see it in source code I have sent in previous post. I converted C# property to type long instead of int and pass it to Alfresco property which is (in Alfresco Content service model) type of int.
Can you share some source code?
The description of your problem doesn't fit with any other issue related with CMIS I've heard of before...
public static AlfrescoSearchItem UploadDocument(string fileName, string filePath, string nodeName, SaveVersion version = null) { IDocument remoteDocument = null; IOperationContext oc = session.CreateOperationContext(); oc.IncludeAcls = true; IFolder folder = session.GetRootFolder(oc); folder = (IFolder)session.GetObject(nodeName); IDictionary<string, object> properties = new Dictionary<string, object>(); properties.Add(alfObjectType, $"D:{alfModelPrefix}:{alfModelType}"); properties.Add(PropertyIds.Name, fileName); foreach (var prop in version.VersionProperties) { if (!(prop.Name == DMS.pathMetaData)) { SetAlfrescoProperty(prop, properties); } } ContentStream contentStream = new ContentStream(); contentStream.FileName = fileName; contentStream.MimeType = System.Web.MimeMapping.GetMimeMapping(fileName); contentStream.Stream = System.IO.File.OpenRead(filePath); remoteDocument = folder.CreateDocument(properties, contentStream, null); } private static void SetAlfrescoProperty(VersionProperty prop, IDictionary<string, object> properties) { var alfrescoPropName = mappingProps.Where(x => x.CTXPropName == prop.Name).Select(x => x.AlfrescoPropName).FirstOrDefault(); var alfrescoPropType = mappingProps.Where(x => x.CTXPropName == prop.Name).Select(x => x.PropTypeName).FirstOrDefault(); switch (alfrescoPropType) { case "int": long intConverted; if (long.TryParse(prop.Value, out intConverted)) { properties.Add(alfrescoPropName, intConverted); } else { var exc = new Exception($"Bad 'int' format in File property: {prop.Name} with value={prop.Value}"); exc.Data.Add(prop.Name.ToString(), prop.Value.ToString()); throw exc; } break; case "float": float floatConverted; if (float.TryParse(prop.Value, out floatConverted)) { properties.Add(alfrescoPropName, floatConverted); } else { var exc = new Exception($"Bad 'float' format in File property: {prop.Name} with value={prop.Value}"); exc.Data.Add(prop.Name.ToString(), prop.Value.ToString()); throw exc; } break; case "long": long longConverted; if (long.TryParse(prop.Value, out longConverted)) { properties.Add(alfrescoPropName, longConverted); } else { var exc = new Exception($"Bad 'long' format in File property: {prop.Name} with value={prop.Value}"); exc.Data.Add(prop.Name.ToString(), prop.Value.ToString()); throw exc; } break; case "double": double doubleConverted; if (double.TryParse(prop.Value, out doubleConverted)) { properties.Add(alfrescoPropName, doubleConverted); } else { var exc = new Exception($"Bad 'double' format in File property: {prop.Name} with value={prop.Value}"); exc.Data.Add(prop.Name.ToString(), prop.Value.ToString()); throw exc; } break; case "dateTime": DateTime dateTimeconverted; if (DateTime.TryParse(prop.Value, out dateTimeconverted)) { properties.Add(alfrescoPropName, dateTimeconverted); } else { var exc = new Exception($"Bad 'DateTime' format in File property: {prop.Name} with value={prop.Value}"); exc.Data.Add(prop.Name.ToString(), prop.Value.ToString()); throw exc; } break; case "boolean": bool boolConverted; if (bool.TryParse(prop.Value, out boolConverted)) { properties.Add(alfrescoPropName, boolConverted); } else { var exc = new Exception($"Bad 'boolean' format in File property: {prop.Name} with value={prop.Value}"); exc.Data.Add(prop.Name.ToString(), prop.Value.ToString()); throw exc; } break; default: properties.Add(alfrescoPropName, prop.Value); break; } }
I have found solution and you can see it in source code I have sent in previous post. I converted C# property to type long instead of int and pass it to Alfresco property which is (in Alfresco Content service model) type of int.
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.