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

XML Restoration Failed due to NULL values from Cloud Site XML Backup

    XMLWordPrintable

Details

    Description

      NOTE: This bug report is for Confluence Server. Using Confluence Cloud? See the corresponding bug report.

      Summary

      Site XML backup import on Confluence Server failed, specifically when the site XML backup was generated from Confluence Cloud instance.

      Steps to Reproduce

      Follow the migration (Confluence Cloud to Confluence Server) steps as outlined in the Migrate From Confluence Cloud To Serve documentation.

      Expected Results

      The Cloud generated site XML backup could be imported to Confluence Server successfully.

      Actual Results

      The below exception is thrown in the <Confluence-Home>/logs/atlassian-confluence.log file:

      2017-03-11 02:43:38,237 ERROR [Long running task: Importing data] [confluence.importexport.actions.ImportLongRunningTask] runInternal Failure during import
       -- url: /longrunningtaskxml.action | referer: <ConfluenceServerBaseURL>/admin/restore-local-file.action | traceId: 2ba25c33acba79a6 | userName: sysadmin | action: longrun
      ningtaskxml
      com.atlassian.confluence.importexport.ImportExportException: com.atlassian.confluence.importexport.ImportExportException: Unable to complete import: Error while importing backup: 
      No enum constant com.atlassian.crowd.embedded.api.DirectoryType.
              at com.atlassian.confluence.importexport.xmlimport.BackupImporter.importEntities(BackupImporter.java:404)
              at com.atlassian.confluence.importexport.xmlimport.BackupImporter.importEverything(BackupImporter.java:365)
              at com.atlassian.confluence.importexport.xmlimport.FileBackupImporter.importEverything(FileBackupImporter.java:133)
              at com.atlassian.confluence.importexport.xmlimport.BackupImporter$1.doInTransactionWithoutResult(BackupImporter.java:257)
      ...
      Caused by: com.atlassian.confluence.importexport.ImportExportException: Unable to complete import: Error while importing backup: No enum constant com.atlassian.crowd.embedded.api.
      DirectoryType.
              at com.atlassian.confluence.importexport.xmlimport.DefaultXmlImporter.doImport(DefaultXmlImporter.java:67)
              at com.atlassian.confluence.importexport.xmlimport.BackupImporter.importEntities(BackupImporter.java:396)
              ... 39 more
      Caused by: org.xml.sax.SAXException: Error while importing backup: No enum constant com.atlassian.crowd.embedded.api.DirectoryType.
      java.lang.IllegalArgumentException: No enum constant com.atlassian.crowd.embedded.api.DirectoryType.
              at com.atlassian.confluence.importexport.xmlimport.parser.BackupParser.endElement(BackupParser.java:45)
              at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
      ...
      Caused by: java.lang.IllegalArgumentException: No enum constant com.atlassian.crowd.embedded.api.DirectoryType.
              at java.lang.Enum.valueOf(Enum.java:238)
              at com.atlassian.confluence.importexport.xmlimport.model.EnumProperty.getEnumValue(EnumProperty.java:41)
      ...
      

      Workaround

      The import failed as some non-nullable values in the cwd_directory table are NULL in the Cloud generated XML backup, e.g. implementationClass, lowerImplementationClass and type parameters. Whereby, by default only the description column of cwd_directory table is allowed to be nullable - in both Confluence Server and Confluence Cloud Database.

      <object class="DirectoryImpl" package="com.atlassian.crowd.model.directory">
      <id name="id">98305</id>
      <property name="name"><![CDATA[Confluence Internal Directory]]></property>
      <property name="lowerName"><![CDATA[confluence internal directory]]></property>
      <property name="createdDate">2016-11-21 08:31:58.196</property>
      <property name="updatedDate">2016-11-21 08:31:58.196</property>
      <property name="active">true</property>
      <property name="description"/><property name="implementationClass"/><property name="lowerImplementationClass"/><property name="type" enum-class="DirectoryType" package="com.atlassian.crowd.embedded.api"/><collection name="attributes" class="java.util.Map"></collection>
      </object>
      

      Therefore, as a workaround we'd then need to modify the entities.xml file as per follow and retried to import it in Confluence server again.

      <object class="DirectoryImpl" package="com.atlassian.crowd.model.directory">
      <id name="id">98305</id>
      <property name="name"><![CDATA[Confluence Internal Directory]]></property>
      <property name="lowerName"><![CDATA[confluence internal directory]]></property>
      <property name="createdDate">2016-11-21 08:31:58.196</property>
      <property name="updatedDate">2016-11-21 08:31:58.196</property>
      <property name="active">true</property>
      <property name="description"><![CDATA[Confluence default internal directory]]></property>
      <property name="implementationClass"><![CDATA[com.atlassian.crowd.directory.InternalDirectory]]></property>
      <property name="lowerImplementationClass"><![CDATA[com.atlassian.crowd.directory.internaldirectory]]></property>
      <property name="type" enum-class="DirectoryType" package="com.atlassian.crowd.embedded.api">INTERNAL</property>
      <collection name="allowedOperations" class="java.util.Set"><element enum-class="OperationType" package="com.atlassian.crowd.embedded.api">UPDATE_USER_ATTRIBUTE</element>
      <element enum-class="OperationType" package="com.atlassian.crowd.embedded.api">CREATE_USER</element>
      <element enum-class="OperationType" package="com.atlassian.crowd.embedded.api">UPDATE_GROUP_ATTRIBUTE</element>
      <element enum-class="OperationType" package="com.atlassian.crowd.embedded.api">UPDATE_USER</element>
      <element enum-class="OperationType" package="com.atlassian.crowd.embedded.api">DELETE_ROLE</element>
      <element enum-class="OperationType" package="com.atlassian.crowd.embedded.api">DELETE_GROUP</element>
      <element enum-class="OperationType" package="com.atlassian.crowd.embedded.api">DELETE_USER</element>
      <element enum-class="OperationType" package="com.atlassian.crowd.embedded.api">CREATE_GROUP</element>
      <element enum-class="OperationType" package="com.atlassian.crowd.embedded.api">CREATE_ROLE</element>
      <element enum-class="OperationType" package="com.atlassian.crowd.embedded.api">UPDATE_GROUP</element>
      <element enum-class="OperationType" package="com.atlassian.crowd.embedded.api">UPDATE_ROLE</element>
      <element enum-class="OperationType" package="com.atlassian.crowd.embedded.api">UPDATE_ROLE_ATTRIBUTE</element>
      </collection>
      <collection name="attributes" class="java.util.Map"><element name="user_encryption_method" type="string"><![CDATA[atlassian-security]]></element>
      </collection>
      </object>
      

      If the directory attributes are missing, be sure to add it back to the entities.xml file. Otherwise, users in the internal directory won't be able to log in. In particular, this XML block needs to exist:

      <collection name="attributes" class="java.util.Map"><element name="user_encryption_method" type="string"><![CDATA[atlassian-security]]></element>
      </collection>
      

      Attachments

        Issue Links

          Activity

            People

              rranjan rahulr
              lrura Lauretha Rura
              Votes:
              4 Vote for this issue
              Watchers:
              23 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: