Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-1064

missing attribute mappings in ocm ClassDescriptorReader

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Won't Fix
    • JCR OCM 2.0.4
    • None
    • JCR
    • None

    Description

      I started using ocm mapping and there are attributes missing in ClassDescriptor reader.

      --mappings.xml----------------------------------------------------

      <!--
      Class: de.dig.cms.common.ocm.Base
      -->
      <class-descriptor
      className="de.dig.cms.common.ocm.Base"
      jcrMixinTypes="mix:referenceable">

      <field-descriptor
      fieldName="id"
      uuid="true" />

      <field-descriptor
      fieldName="name"
      jcrName="true" />

      <field-descriptor
      fieldName="path"
      path="true" />

      <bean-descriptor
      fieldName="parentBase"
      converter="org.apache.jackrabbit.ocm.manager.beanconverter.impl.ReferenceBeanConverterImpl" />
      </class-descriptor>

      --Base.class-----------------------------------
      package ocm;

      /**

      • @ocm.mapped discriminator="true" jcrMixinTypes="mix:referenceable, mix:lockable"
        */
        public class Base {
        private String resourceType;

      /**

      • @ocm.field uuid="true"
        */
        private String id;

      /**

      • @ocm.field jcrName="true"
        */
        private String name;

      /**

      • @ocm.field path="true"
        */
        private String path;

      /**

      • @ocm.bean converter="org.apache.jackrabbit.ocm.manager.beanconverter.impl.ReferenceBeanConverterImpl
        */
        Base parentBase;

      public Base() {
      }

      public String getUuid()

      { return uuid; }

      public void setUuid(String uuid)

      { this.uuid = uuid; }

      public String getName()

      { return name; }

      public void setName(String name)

      { this.name = name; }

      public String getPath()

      { return path; }

      public void setPath(String path)

      { this.path = path; }

      ....

      }

      1. "Uuid" missing in parseFieldDescriptor

      i have a mapped class (see below) and after inserting and retrieving the
      object out of the repository, the id (uuid) is not filled.

      Base base = new Base();
      base.setPath("/ocmtestpath");
      base.setTitle("ocmtesttitle");
      base.setName("ocmtestname");

      objectContentManager.insert(base);
      try {
      Base base = (Base) objectContentManager.getObject(base.getPath());
      // error id is not filled with uuid
      } catch (Exception e) {
      }
      The generated (jcrocm) mappings.xml file has the entry for uuid.

      After patching sling ClassDescriptorReader.parseFieldDescriptor and add
      the following line

      fd.setUuid(this.getOptionalAttribute("uuid", false));

      it works.

      2. "converter" attribute missing in parseBeanDescriptor
      I have a relation to another bean and i am unable to specify the converter class, its not set to jackrabbit in ClassReader

      3. unable to set JcrMixinTypes to more than one, due to an error in setting setJcrMixinTypes in parseClassDescriptor reason strange jackrabbit behaviour.

      In ClassDescriptor you call
      fd.setJcrMixinTypes(this.getOptionalAttribute("jcrMixinTypes", (String[]) null));
      with a String[], thats correct.

      Jackrabbit ClassDescriptor looks like
      /**

      • Sets a comma separated list of mixin types.
        *
      • @param mixinTypes command separated list of mixins
        */
        public void setJcrMixinTypes(String[] mixinTypes)
        Unknown macro: { if (null != mixinTypes && mixinTypes.length == 1) { jcrMixinTypes = mixinTypes[0].split(" *, *"); } }

        public void setJcrMixinTypes(String mixinTypes)

        Unknown macro: { if (mixinTypes != null && ! mixinTypes.equals("")) { jcrMixinTypes = mixinTypes.split(" *, *"); } }

      as you see "setJcrMixinTypes(String[] mixinTypes)" uses only the first!!! array entry and only if it has a length of 1 !

      so i prefer calling the method setJcrMixinTypes(String mixinTypes), it will split by themself and then it will work.

      fd.setJcrMixinTypes(this.getOptionalAttribute("jcrMixinTypes", (String) null));

      Markus

      Attachments

        1. slingclassdescriptor.patch
          2 kB
          Markus Pallo

        Activity

          People

            Unassigned Unassigned
            pallo Markus Pallo
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: