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

A DocumentModel added to a collection should be immediately aware of its collection membership

    XMLWordPrintable

    Details

      Description

      This was detected by NXMOB-238: the document returned by the Document.AddToFavorites operation was showing false for the isFavorite enricher although it had actually been added as a Favorite.

      This was due to the use of a temporary DocumentModel in

      CollectionManagerImpl#addToCollection(final DocumentModel collection, final DocumentModel documentToBeAdded, final CoreSession session)

      that forced the need to re-fetch the document from the session once added to a collection to get a fresh state, which was done in the tests, but not in Document.AddToFavorites:

          public DocumentModel run(DocumentModel doc) {
              favoritesManager.addToFavorites(doc, session);
              return doc;
          }
      

      The fix allows to remove these extra doc = session.getDocument(doc.getRef()) calls from the tests.

      Note that the problem didn't happen when removing a document from a collection because there is no such use of a temporary DocumentModel in

      CollectionManagerImpl#doRemoveFromCollection(DocumentModel documentToBeRemoved, String collectionId, CoreSession session)

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: