Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-3726

Import without versions should not override the previous history but only add a version

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Major
    • None
    • 1.9 M1, 1.8.2
    • Observation
    • None
    • Unknown

    Description

      This is the code we need to change:

                      if (!this.backupPack) {
                          // if the import is not a backup pack with set the user to the importing user
                          doc.getDoc().setAuthor(context.getUser());
                          doc.getDoc().setContentAuthor(context.getUser());
                          // if the import is not a backup pack we set the date to now
                          Date date = new Date();
                          doc.getDoc().setDate(date);
                          doc.getDoc().setContentUpdateDate(date);
                      }
      
                      if ((!this.preserveVersion) && (!this.withVersions)) {
                          doc.getDoc().setVersion("1.1");
                      }
      
                      // We don't want date and version to change
                      // So we need to cancel the dirty status
                      doc.getDoc().setContentDirty(false);
                      doc.getDoc().setMetaDataDirty(false);
                      for (XWikiAttachment xa : doc.getDoc().getAttachmentList()) {
                          xa.setMetaDataDirty(false);
                          xa.getAttachment_content().setContentDirty(false);
                      }
      
                      context.getWiki().saveDocument(doc.getDoc(), context);
                      doc.getDoc().saveAllAttachments(false, true, context);
                      addToInstalled(doc.getFullName() + ":" + doc.getLanguage(), context);
      
                      if (this.withVersions) {
                          // we need to force the saving the document archive.
                          if (doc.getDoc().getDocumentArchive() != null) {
                              context.getWiki().getVersioningStore().saveXWikiDocArchive(
                                  doc.getDoc().getDocumentArchive(context), true, context);
                          }
                      }
                      // if there is no archive in xml and content&metaData Dirty is not set
                      // then archive was not saved
                      // so we need save it via resetArchive
                      if ((doc.getDoc().getDocumentArchive() == null)
                          || (doc.getDoc().getDocumentArchive().getNodes() == null) || (!this.withVersions)) {
                          doc.getDoc().resetArchive(context);
                      }
      

      We need to retrieve the history of the previous document in place.

      Attachments

        Issue Links

          Activity

            People

              vmassol Vincent Massol
              ludovic Ludovic Dubost
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: