Uploaded image for project: 'Felix'
  1. Felix
  2. FELIX-4665

Metatype service does not allow a default empty string in XML resource

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • metatype-1.0.10
    • metatype-1.0.12
    • Metatype Service
    • None

    Description

      An entry like the following will be treated as invalid and the default will change to null instead of an empty string:

      <AD id="string.prop" cardinality="0" required="false" default="" type="String" description="Some string property"/>
      

      MetaDataReader.readAD() method will first set the default value, then later check if the value is required:

      ad.setDefaultValue( this.getOptionalAttribute( "default" ) );
      ad.setRequired( this.getOptionalAttribute( "required", true ) );
      

      However, setDefaultValue method will check if the value is required (before it is known) in ADValidator.validateString():

      if (ad.isRequired() && ((value == null) || (length == 0)))
      {
          // Possible if the cardinality != 0 and input was something like
          // "0,,1"...
          return AD.VALIDATE_MISSING;
      }
      

      The call to isRequired() will always be true at the time of the call.

      Attachments

        Activity

          People

            Unassigned Unassigned
            kmart216 David Humeniuk
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: