jsr-283
  1. jsr-283
  2. JSR_283-811

nt:propertyDefinition has incorrect value constraints for property types

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: not determined
    • Fix Version/s: None
    • Component/s: node types
    • Labels:
      None

      Description

      Discovered by Michael Dürig:

      [nt:propertyDefinition]
      ...

      • jcr:requiredType (STRING) protected mandatory
        < 'STRING', 'URI', 'BINARY', 'LONG', 'DOUBLE',
        'DECIMAL', 'BOOLEAN', 'DATE', 'NAME', 'PATH',
        'REFERENCE', 'WEAKREFERENCE', 'UNDEFINED'

      The type names are defined in javax.jcr.PropertyType. For example

      TYPENAME_STRING = "String";

      Now JSR-283 says about string constraints (3.7.3.6.1): "For STRING and URI properties, the constraint string is a regular expression pattern according to the syntax of java.util.regex.Pattern."

      So jcr:requiredType can be for example "STRING" but not "String". The former however results in an IllegalArgumentException when passed to PropertyType.valueFromName().

      It appears the simplest possible fix would be to tune the type names in the value constraints.

        Activity

        reschke created issue -
        reschke made changes -
        Field Original Value New Value
        Summary nt:propertyDefinition has incorrect value constrains for property types nt:propertyDefinition has incorrect value constraints for property types
        Hide
        rhauch added a comment - - edited

        (This is the same comment I just added to the http://java.net/jira/browse/JSR_283-811 issue.)

        While I agree that this was a problem in JSR-283, I don't believe it's necessary or even advisable to fix or address.

        First of all, changing the "jcr:requiredType" property definition to use the same case as the constants in javax.jcr.PropertyType will not be backward compatible. This is because a JSR-283 repository can represent the node type definitions, property definitions, and child node definitions within the "/jcr:system/jcr:nodeTypes" subgraph. Changing the constraints would make all these "nt:propertyDefinition" nodes in existing repositories invalid. (Note that the "jcr:requiredType" property is mandatory.

        Secondly, this shouldn't be an issue for an implementation. This is because the javax.jcr.nodetype.PropertyDefinition interface defines the "getRequiredType()" method as returning an int, not a string. In other words, the string representation of the required type within the "/jcr:system/jcr:nodeType" subgraph cannot be used within the implementations javax.jcr.nodetype.PropertyDefinition implementation without converting to an integer. Yes, an implementation will not be able to use existing javax.jcr.PropertyType.valueFromName(String) to perform the conversion, and instead needs to use a case-insensitive version. But that is purely an implementation detail.

        Perhaps a better alternative change would be to change the existing "javax.jcr.PropertyType.valueFromName(String)" implementation to be case-insensitive. Consider that the CND notation introduced in JSR-283 specifically states in Section 25.2.3.1 "Case Insensitive Keywords" specifically states:

        The keywords of CND, though defined above as terminal strings with specific cases, are in fact case-insensitive.
        For example, STRING can be written string, String or even StRiNg.

        Therefore, an implementation that parses a CND file already has to convert a property definition's type in a case-insensitive manner, and changing the existing "javax.jcr.PropertyType.valueFromName(String)" implementation to be case-insensitive would allow an implementation to use that method in CND parsing rather than its own custom implementation.

        However, I'm actually in favor of doing none of these, and marking this issue as 'not a bug'.

        Show
        rhauch added a comment - - edited (This is the same comment I just added to the http://java.net/jira/browse/JSR_283-811 issue.) While I agree that this was a problem in JSR-283, I don't believe it's necessary or even advisable to fix or address. First of all, changing the "jcr:requiredType" property definition to use the same case as the constants in javax.jcr.PropertyType will not be backward compatible. This is because a JSR-283 repository can represent the node type definitions, property definitions, and child node definitions within the "/jcr:system/jcr:nodeTypes" subgraph. Changing the constraints would make all these "nt:propertyDefinition" nodes in existing repositories invalid. (Note that the "jcr:requiredType" property is mandatory. Secondly, this shouldn't be an issue for an implementation. This is because the javax.jcr.nodetype.PropertyDefinition interface defines the "getRequiredType()" method as returning an int, not a string. In other words, the string representation of the required type within the "/jcr:system/jcr:nodeType" subgraph cannot be used within the implementations javax.jcr.nodetype.PropertyDefinition implementation without converting to an integer. Yes, an implementation will not be able to use existing javax.jcr.PropertyType.valueFromName(String) to perform the conversion, and instead needs to use a case-insensitive version. But that is purely an implementation detail. Perhaps a better alternative change would be to change the existing "javax.jcr.PropertyType.valueFromName(String)" implementation to be case-insensitive. Consider that the CND notation introduced in JSR-283 specifically states in Section 25.2.3.1 "Case Insensitive Keywords" specifically states: The keywords of CND, though defined above as terminal strings with specific cases, are in fact case-insensitive. For example, STRING can be written string, String or even StRiNg. Therefore, an implementation that parses a CND file already has to convert a property definition's type in a case-insensitive manner, and changing the existing "javax.jcr.PropertyType.valueFromName(String)" implementation to be case-insensitive would allow an implementation to use that method in CND parsing rather than its own custom implementation. However, I'm actually in favor of doing none of these, and marking this issue as 'not a bug'.
        Hide
        rhauch added a comment -

        I've logged a similar issue with proposed fix on JSR-333: http://java.net/jira/browse/JSR_333-52

        Show
        rhauch added a comment - I've logged a similar issue with proposed fix on JSR-333: http://java.net/jira/browse/JSR_333-52

          People

          • Assignee:
            Unassigned
            Reporter:
            reschke
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: