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

It should not be possible to pass an attached DocumentModel to createDocument

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 7.10, 8.10, 9.10, 10.1
    • Fix Version/s: QualifiedToSchedule
    • Component/s: Core

      Description

      To understand what's happening, the following test is failing

             @Test
      	public void testName() throws Exception {
      		DocumentModel doc = session.createDocumentModel("/", "test", "Note");
      		doc.setPropertyValue("dc:title", "Title");
      		doc = session.createDocument(doc);
      
      		doc.setPropertyValue("dc:title", "Title");
      		doc = session.createDocument(doc);
      
      		doc = session.getDocument(doc.getRef());
      
      		assertEquals("Title", doc.getPropertyValue("dc:title"));
      	}
      
      

      with

      java.lang.AssertionError: expected:<Title> but was:<null>
      	at org.junit.Assert.fail(Assert.java:88)
      	at org.junit.Assert.failNotEquals(Assert.java:743)
             ...
      

      This is because of the reuse of an already attached DocumentModel, then the dc:title is not dirty and the underlying property is not set.

      So reusing a DocumentModel that has already a session (attached) should throw an IllegalArgumentException.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              dmetzler Damien Metzler
              Participants:
            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: