Uploaded image for project: 'Jackrabbit Oak'
  1. Jackrabbit Oak
  2. OAK-7479

custom property does not respect type

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Invalid
    • 1.6.1, 1.8.1
    • None
    • core
    • None

    Description

      I've defined a custom mixin with s single long property. When I add that mixin to a node I can set a value of a different type (e.g. string) without any error. Same behaviour if I define the mixin using the customCND or using the NodeTypeTemplate.

       Here the code example:

      NodeTypeManager nodeTypeManager = session.getWorkspace().getNodeTypeManager();
      NodeTypeTemplate nt = nodeTypeManager.createNodeTypeTemplate();
      nt.setName("custom:runtime");
      nt.setMixin(true);
      PropertyDefinitionTemplate opt = nodeTypeManager.createPropertyDefinitionTemplate();
      opt.setMandatory(false);
      opt.setName("custom:runtimeTest");
      opt.setRequiredType(PropertyType.LONG);
      opt.setOnParentVersion(OnParentVersionAction.COPY);
      List pdt = nt.getPropertyDefinitionTemplates();
      pdt.add(opt);
      nodeTypeManager.registerNodeType(nt, true);
      
      session.save();
      
      Node mynode = JcrUtils.getOrAddNode(session.getRootNode(), "mynode");
      mynode.addMixin("custom:runtime");
      session.save();
      mynode.setProperty("custom:runtimeTest", "my test value");
      session.save();

      If I open the repository using oak-run the property custom:runtimeTest has type STRING and not LONG (attached image)

      Attachments

        1. oakRunImage.png
          111 kB
          Marco Piovesana

        Activity

          People

            Unassigned Unassigned
            iosonomarco Marco Piovesana
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: