-
Type: Bug
-
Status: Resolved
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 8.10, 9.10, 10.2
-
Component/s: Core
-
Release Notes Summary:The copy of a documentModel handles dynamic facets and schemas.
-
Tags:
-
Sprint:nxFG 10.3.2
The rendition service, during the rendition process (class RenditionCreator), creates a copy of the source document (create document with same doc type + copy facets/schemas) using DocumentModel#copyContent. The problem is that copyContent expects both source and destination document to have the same schemas, which is not always the case i.e. the source document is member of a collection, meaning it was dynamically assigned an additonal schema collectionMember (by adding facet CollectionMember). In this case, the destination document won't have this schema at creation time, subsequent call to saveDocument would then throw an exception because of the missing fields in the destination document.
Also make sure that the dynamically-added facets are not copied because it could produce a data inconsistency, the facet is copied but the associated schema is not, a service could rely on the fact that the facet is present to presume the associated schema is present too.
Here is a unit test to demonstrate the exception:
@Test public void testCanCopyContentOfDocumentInACollectionAndSaveTarget() { DocumentModel testWorkspace = session.createDocumentModel("/default-domain/workspaces", "testWorkspace", "Workspace"); testWorkspace = session.createDocument(testWorkspace); DocumentModel testFile1 = session.createDocumentModel(testWorkspace.getPathAsString(), "File 1", "File"); testFile1 = session.createDocument(testFile1); DocumentModel testFile2 = session.createDocumentModel(testWorkspace.getPathAsString(), "File 2", "File"); testFile2 = session.createDocument(testFile2); collectionManager.addToNewCollection(COLLECTION_NAME, COLLECTION_DESCRIPTION, testFile1, session); assertTrue(collectionManager.isCollected(testFile1)); assertFalse(collectionManager.isCollected(testFile2)); testFile2.copyContent(testFile1); testFile2 = session.saveDocument(testFile2); assertFalse(collectionManager.isCollected(testFile2)); }