Uploaded image for project: 'CMS'
  1. CMS
  2. CMS-719

FileCompositeMetadata doesn't handle empty composite metadatas

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • Icon: Major Major
    • 4.2.0
    • 2.9.19
    • Plugins (others)
    • None

      FileCompositeMetadata.java
      public boolean isCompositeMetadata(String metadataName) throws RepositoryException
      {
          Configuration metadataConfig = _configuration.getChild(metadataName, false);
      
          if (metadataConfig == null)
          {
              return false;
          }
      
          return metadataConfig.getChildren().length > 0;
      }
      

      "File" implementation of CompositeMetadata doens't handle child CompositeMetadata well.
      If it encounters an empty metadata tag, it will assume it's not composite : an empty composite metadata is not possible.

      This leads to errors in constructs such as generation's SitemapInputData :

      SitemapInputData.java
      if (!metadataHolder.isCompositeMetadata(name) && !metadataHolder.isBinaryMetadata(name))
      {
          String[] metadata = metadataHolder.getMetadataAsStringArray(name);
      
          if (metadata.length == 1)
          {
              attrs.addAttribute("", name, name, "CDATA", metadata[0]);
          }
      }
      

      This generates an exception as the empty metadata is assumed not to be composite but has no text value, and getMetadataAsXXX methods doesn't accept empty XML tags.

            Unassigned Unassigned
            ngavalda Nicolas Gavalda (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: