Uploaded image for project: 'Chemistry (Retired)'
  1. Chemistry (Retired)
  2. CMIS-497

Creating Extensions on Properties Fails When Creating XML to Submit to Server

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • DotCMIS 0.3
    • DotCMIS 0.4
    • dotcmis

    Description

      The following code should work but fails with a "Value cannot be set on Element" error.

          class Program
          {
              static void Main()
              {
                  const string description = "this is a new description";
      
                  const string repositoryId = "7270744f-c07c-48c9-aa01-ef90089785e3";
                  string documentId = "workspace://SpacesStore/f8e3dc76-4781-49d6-b5d1-d3af1299ea80";
      
                  Dictionary<string, string> parameters = new Dictionary<string, string>();
                  parameters[SessionParameter.BindingType] = BindingType.AtomPub;
                  parameters[SessionParameter.AtomPubUrl] = "http://localhost:8082/alfresco/service/cmis";
                  parameters[SessionParameter.User] = "admin";
                  parameters[SessionParameter.Password] = "admin";
                  parameters[SessionParameter.RepositoryId] = repositoryId;
      
                  SessionFactory factory = SessionFactory.NewInstance();
                  ISession session = factory.CreateSession(parameters);
      
                  string changeToken = null; // not sure why I need this
      
                  Properties props = new Properties();
                  props.Extensions = CreateData(description).Extensions;
                  session.Binding.GetObjectService().UpdateProperties(repositoryId, ref documentId, ref changeToken, props, null);
              }
      
              private static ExtensionsData CreateData(string description)
              {
                  ExtensionsData data = new ExtensionsData();
                  data.Extensions = new List<ICmisExtensionElement>();
                  CmisExtensionElement element = new CmisExtensionElement
                      {
                          Name = "alf:setAspects",
                          Namespace = "http://www.alfresco.org",
                          Children = new List<ICmisExtensionElement>
                          {
                              new CmisExtensionElement
                                  {
                                      Name = "alf:properties",
                                      Namespace = "http://www.alfresco.org",
                                      Children = new List<ICmisExtensionElement>
                                          {
                                              new CmisExtensionElement
                                                  {
                                                      Name = "cmis:propertyString",
                                                      Namespace = "http://docs.oasis-open.org/ns/cmis/core/200908/",
                                                      Attributes = new Dictionary<string, string>
                                                              {
                                                                  {"propertyDefinitionId","cm:description"},
                                                                  {"displayName","Description"},
                                                                  {"queryName","cm:description"}
                                                              },
                                                      Children = new List<ICmisExtensionElement>
                                                              {
                                                                  new CmisExtensionElement
                                                                      {
                                                                          Name = "cmis:value",
                                                                          Namespace = "http://docs.oasis-open.org/ns/cmis/core/200908/",
                                                                          Value = description
                                                                      }
                                                              }
                                                  }
                                          }
                                  }
                          }
                      };
                  data.Extensions.Add(element);
      
                  return data;
              }
      

      The following change in converter.cs, line 1869 in Converter::CreateXMLElement(XmlDocument doc, ICmisExtensionElement element) should be made:

      result.Value = element.Value;
      // should be
      result.InnerText = element.Value;
      

      Attachments

        Activity

          People

            fmui Florian Müller
            phil.barr Phil Barr
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: