diff --git a/repository/src/main/java/org/alfresco/repo/rendition2/RenditionService2Impl.java b/repository/src/main/java/org/alfresco/repo/rendition2/RenditionService2Impl.java index cbe5e95f72..4de95b295c 100644 --- a/repository/src/main/java/org/alfresco/repo/rendition2/RenditionService2Impl.java +++ b/repository/src/main/java/org/alfresco/repo/rendition2/RenditionService2Impl.java @@ -514,15 +514,11 @@ public class RenditionService2Impl implements RenditionService2, InitializingBea NodeRef renditionNode = getRenditionNode(sourceNodeRef, renditionName); boolean createRenditionNode = renditionNode == null; boolean sourceHasAspectRenditioned = nodeService.hasAspect(sourceNodeRef, RenditionModel.ASPECT_RENDITIONED); - boolean sourceChanges = !sourceHasAspectRenditioned || createRenditionNode || transformInputStream == null; try { - if (sourceChanges) - { - ruleService.disableRuleType(RuleType.UPDATE); - behaviourFilter.disableBehaviour(sourceNodeRef, ContentModel.ASPECT_AUDITABLE); - behaviourFilter.disableBehaviour(sourceNodeRef, ContentModel.ASPECT_VERSIONABLE); - } + ruleService.disableRuleType(RuleType.UPDATE); + behaviourFilter.disableBehaviour(sourceNodeRef, ContentModel.ASPECT_AUDITABLE); + behaviourFilter.disableBehaviour(sourceNodeRef, ContentModel.ASPECT_VERSIONABLE); // If they do not exist create the rendition association and the rendition node. if (createRenditionNode) @@ -592,12 +588,9 @@ public class RenditionService2Impl implements RenditionService2, InitializingBea } finally { - if (sourceChanges) - { - behaviourFilter.enableBehaviour(sourceNodeRef, ContentModel.ASPECT_AUDITABLE); - behaviourFilter.enableBehaviour(sourceNodeRef, ContentModel.ASPECT_VERSIONABLE); - ruleService.enableRuleType(RuleType.UPDATE); - } + behaviourFilter.enableBehaviour(sourceNodeRef, ContentModel.ASPECT_AUDITABLE); + behaviourFilter.enableBehaviour(sourceNodeRef, ContentModel.ASPECT_VERSIONABLE); + ruleService.enableRuleType(RuleType.UPDATE); } return null; }, false, true)); diff --git a/repository/src/test/java/org/alfresco/repo/rendition2/RenditionService2IntegrationTest.java b/repository/src/test/java/org/alfresco/repo/rendition2/RenditionService2IntegrationTest.java index f32e425847..ec72dcfbb5 100644 --- a/repository/src/test/java/org/alfresco/repo/rendition2/RenditionService2IntegrationTest.java +++ b/repository/src/test/java/org/alfresco/repo/rendition2/RenditionService2IntegrationTest.java @@ -30,6 +30,7 @@ import static org.junit.Assert.assertNotEquals; import java.io.ByteArrayInputStream; import java.io.InputStream; +import java.util.ArrayList; import java.util.List; import org.alfresco.model.ContentModel; @@ -419,6 +420,65 @@ public class RenditionService2IntegrationTest extends AbstractRenditionIntegrati assertTrue("New rendition content hash code was not generated", isValidRenditionContentHashCode(contentHashCode3)); } + @Test + public void testModifierAfterMultipleRenditionRequests() throws InterruptedException + { + String user1 = createRandomUser(); + String user2 = createRandomUser(); + List nodes = new ArrayList(); + + final int TOTAL_NODES = 10; + + // Create nodes + for (int i = 0; i < TOTAL_NODES; i++) + { + NodeRef n = createSource(user1, "quick.jpg"); + render(user1, n, DOC_LIB); + nodes.add(n); + } + + // Ask rendition multiple times with 'user2' + for (int j = 0; j < 10; j++) + { + for (int i = 0; i < TOTAL_NODES; i++) + { + render(user2, nodes.get(i), DOC_LIB); + } + } + + for (int i = 0; i < TOTAL_NODES; i++) + { + waitForRendition(user1, nodes.get(i), DOC_LIB, true); + } + + // Check the modifier is still user1 + assertEquals(TOTAL_NODES, countModifier(nodes, user1)); + } + + private int countModifier(List nodes, String user) + { + int count = 0; + for (int i = 0; i < nodes.size(); i++) + { + count += compareModifier(nodes.get(i), user); + } + return count; + } + + private int compareModifier(NodeRef nodeRef, String user) + { + int res = 0; + if (nodeRef != null && user != null) + { + String modifier = nodeService.getProperty(nodeRef, ContentModel.PROP_MODIFIER).toString(); + if (user.equals(modifier)) + { + res = 1; + } + } + return res; + } + /** * @deprecated can be removed when we remove the original RenditionService */ @@ -622,4 +682,4 @@ public class RenditionService2IntegrationTest extends AbstractRenditionIntegrati renditionService2.setEnabled(true); } } -} \ No newline at end of file +}