Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-26178

Fix version increment when importing text file to create 'Note' document

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 9.10, 10.2
    • Fix Version/s: 10.10
    • Component/s: Core
    • Release Notes Summary:
      A note created with D&D will only create one version.
    • Backlog priority:
      1,500
    • Impact type:
      API change
    • Upgrade notes:
      Hide

      All FileManager#createDocumentFromBlob methods have been deprecated, you should now use FileManager#createOrUpdateDocument(FileImporterContext) method to create or update documents from blobs.

      FileImporter#create method has been deprecated, you should use FileImporter#createOrUpdate(FileImporterContext) method.

      The FileImporterContext class contains everything needed to create a document from a blob, see https://github.com/nuxeo/nuxeo/blob/release-10.10/nuxeo-services/nuxeo-platform-filemanager-api/src/main/java/org/nuxeo/ecm/platform/filemanager/api/FileImporterContext.java.

      Before:

      DocumentModel doc = fileManager.createDocumentFromBlob(session, blob, parentPath, /* overwrite */ true, /* filename */ "foo.html");
      

      After:

      FileImporterContext context = FileImporterContext.builder(session, blob, parentPath)
          .overwrite(true)
          .fileName("foo.html")
          .build();
      DocumentModel doc = fileManager.createOrUpdateDocument(context);
      

      The FileImporterContext#getBlob's file name is used by default now, but you can still override it with FileImporterContext.Builder#fileName(String).

      If the underlying FileImporter handles it, there is now a way to let the FileManager create a document from a blob without persisting it using FileImporterContext.Builder#persistDocument(boolean). It's then the caller's responsibility to actually persist the document.

      FileImporterContext fileCreationContext = FileImporterContext.builder(session, blob, parentPath)
          .persistDocument(false)
          .build();
      DocumentModel doc = fileManager.createOrUpdateDocument(fileCreationContext);
      // doc is not persisted
      // doc.isDirty() => true
      // doc.getId() => null
      // do domething on doc
      doc = session.createDocument(doc);
      // doc is persisted
      

      A new atomic operation FileManager.ImportWithProperties has been added allowing to create a document from a blob and setting properties at the same time.
      See https://github.com/nuxeo/nuxeo/blob/release-10.10/nuxeo-features/nuxeo-automation/nuxeo-automation-features/src/main/java/org/nuxeo/ecm/automation/core/operations/services/FileManagerImportWithProperties.java

      Breaking Change

      Custom importers implementing FileImporter or extending AbstractFileImport must be updated to override the #createOrUpdate(FileImporterContext) method instead of the #create method. Not overriding the #createOrUpdate(FileImporterContext) method will make your custom importer useless as it will never be called.

      See this commit for a sample of migrating to #createOrUpdate(FileImporterContext).

      Show
      All FileManager#createDocumentFromBlob methods have been deprecated, you should now use FileManager#createOrUpdateDocument(FileImporterContext) method to create or update documents from blobs. FileImporter#create method has been deprecated, you should use FileImporter#createOrUpdate(FileImporterContext) method. The FileImporterContext class contains everything needed to create a document from a blob, see https://github.com/nuxeo/nuxeo/blob/release-10.10/nuxeo-services/nuxeo-platform-filemanager-api/src/main/java/org/nuxeo/ecm/platform/filemanager/api/FileImporterContext.java . Before: DocumentModel doc = fileManager.createDocumentFromBlob(session, blob, parentPath, /* overwrite */ true , /* filename */ "foo.html" ); After: FileImporterContext context = FileImporterContext.builder(session, blob, parentPath) .overwrite( true ) .fileName( "foo.html" ) .build(); DocumentModel doc = fileManager.createOrUpdateDocument(context); The FileImporterContext#getBlob 's file name is used by default now, but you can still override it with FileImporterContext.Builder#fileName(String) . If the underlying FileImporter handles it, there is now a way to let the FileManager create a document from a blob without persisting it using FileImporterContext.Builder#persistDocument(boolean) . It's then the caller's responsibility to actually persist the document. FileImporterContext fileCreationContext = FileImporterContext.builder(session, blob, parentPath) .persistDocument( false ) .build(); DocumentModel doc = fileManager.createOrUpdateDocument(fileCreationContext); // doc is not persisted // doc.isDirty() => true // doc.getId() => null // do domething on doc doc = session.createDocument(doc); // doc is persisted A new atomic operation FileManager.ImportWithProperties has been added allowing to create a document from a blob and setting properties at the same time. See https://github.com/nuxeo/nuxeo/blob/release-10.10/nuxeo-features/nuxeo-automation/nuxeo-automation-features/src/main/java/org/nuxeo/ecm/automation/core/operations/services/FileManagerImportWithProperties.java Breaking Change Custom importers implementing FileImporter or extending AbstractFileImport must be updated to override the #createOrUpdate(FileImporterContext) method instead of the #create method. Not overriding the #createOrUpdate(FileImporterContext) method will make your custom importer useless as it will never be called. See this commit for a sample of migrating to #createOrUpdate(FileImporterContext) .
    • Sprint:
      nxfit 10.10.5
    • Story Points:
      2

      Description

      When importing a text file using the Import button with a selected Nature, version is incremented twice, setting it to 0.2.

      How to reproduce:

      • create a text file named testNote1.txt on local filesystem
      • login to Nuxeo JSF UI
      • navigate to a Workspace or Folder
      • click the IMPORT button to open the import dialog box:
        • select text file testFolder1.txt in Where widget
        • select or drag-and-drop text file testNote1.txt in Files field
        • select Application in Nature field
        • click Import button

      Expected result: Note document named testNote1.txt is created with version 0.1.
      Actual result: Note document named testNote1.txt is created with version 0.2.

      Note: the double version increment does not happen if no value is selected for Nature field.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 days, 1 hour, 45 minutes
                2d 1h 45m