Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-28666

Invalid XML entities are created in an export when they have a non-nullable foreign key referencing an entity excluded from the export

    XMLWordPrintable

Details

    Description

      This is the underlying cause of CONF-28553, which was fixed by adding a specific guard condition when importing the invalid LikeEntity.

      We should prevent invalid XML entities from being included in the export in the first place. The results of aragot's investigation while reviewing the fix for CONF-28553 are below.


      That's a problem located in com.atlassian.hibernate.extras.XMLDatabinder#excludeClass(). At export time, the following call fails at excluding the Like when the compulsory ContentEntityObject is missing:

          if (context != null && !context.isExportComments())
          {
              databinder.excludeClass(Comment.class);
          }
      

      If you look how excluded classes are used, you find isExcludedAsProperty() in:

          private void renderProperty(Writer writer, String name, Type type, Object value, String componentName, String propertyName,
                                      String collectionName, boolean doType) throws HibernateException, IOException
          {
              ...
              else if (type.isEntityType())
              {
                  renderEntityType(writer, name, type, value, propertyName);
                  if (!isExcludedAsProperty(value))
                      associatedObjectFound(value);
              }
      

      and you notice the 'if' has no 'else'. It will just forget to render the [mandatory] property, producing an invalid entity in the XML. We should probably fix that problem if we don't want to be bitten later (Note: Will only cause problem when we have a foreign key, a not-null and an excluded entity).

      Attachments

        Activity

          People

            shaffenden Steve Haffenden (Inactive)
            etom edith (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: