mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Further fix for ALF-3991. Thumbnail generation modifies the source document auditable properties.
There were a couple of code paths missed in the previous check-in for this issue. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@23290 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -31,6 +31,7 @@ import java.util.Map.Entry;
|
|||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.model.RenditionModel;
|
import org.alfresco.model.RenditionModel;
|
||||||
|
import org.alfresco.repo.policy.BehaviourFilter;
|
||||||
import org.alfresco.repo.rendition.executer.AbstractRenderingEngine;
|
import org.alfresco.repo.rendition.executer.AbstractRenderingEngine;
|
||||||
import org.alfresco.service.cmr.rendition.RenditionDefinition;
|
import org.alfresco.service.cmr.rendition.RenditionDefinition;
|
||||||
import org.alfresco.service.cmr.rendition.RenditionService;
|
import org.alfresco.service.cmr.rendition.RenditionService;
|
||||||
@@ -70,6 +71,7 @@ public class RenditionNodeManager
|
|||||||
private final RenditionDefinition renditionDefinition;
|
private final RenditionDefinition renditionDefinition;
|
||||||
private final RenditionLocation location;
|
private final RenditionLocation location;
|
||||||
private final NodeService nodeService;
|
private final NodeService nodeService;
|
||||||
|
private BehaviourFilter behaviourFilter;
|
||||||
private final RenditionService renditionService;
|
private final RenditionService renditionService;
|
||||||
private final NodeRef oldRendition;
|
private final NodeRef oldRendition;
|
||||||
private ChildAssociationRef finalRenditionAssoc;
|
private ChildAssociationRef finalRenditionAssoc;
|
||||||
@@ -84,7 +86,8 @@ public class RenditionNodeManager
|
|||||||
* @param renditionService
|
* @param renditionService
|
||||||
*/
|
*/
|
||||||
public RenditionNodeManager(NodeRef sourceNode, NodeRef tempRenditionNode, RenditionLocation location,
|
public RenditionNodeManager(NodeRef sourceNode, NodeRef tempRenditionNode, RenditionLocation location,
|
||||||
RenditionDefinition renditionDefinition, NodeService nodeService, RenditionService renditionService)
|
RenditionDefinition renditionDefinition, NodeService nodeService, RenditionService renditionService,
|
||||||
|
BehaviourFilter behaviourFilter)
|
||||||
{
|
{
|
||||||
this.sourceNode = sourceNode;
|
this.sourceNode = sourceNode;
|
||||||
this.tempRenditionNode = tempRenditionNode;
|
this.tempRenditionNode = tempRenditionNode;
|
||||||
@@ -92,6 +95,7 @@ public class RenditionNodeManager
|
|||||||
this.renditionDefinition = renditionDefinition;
|
this.renditionDefinition = renditionDefinition;
|
||||||
this.nodeService = nodeService;
|
this.nodeService = nodeService;
|
||||||
this.renditionService = renditionService;
|
this.renditionService = renditionService;
|
||||||
|
this.behaviourFilter = behaviourFilter;
|
||||||
|
|
||||||
this.oldRendition = this.getOldRenditionIfExists(sourceNode, renditionDefinition);
|
this.oldRendition = this.getOldRenditionIfExists(sourceNode, renditionDefinition);
|
||||||
|
|
||||||
@@ -333,7 +337,16 @@ public class RenditionNodeManager
|
|||||||
if (parentIsSource == false)
|
if (parentIsSource == false)
|
||||||
{
|
{
|
||||||
NodeRef rendition = primaryAssoc.getChildRef();
|
NodeRef rendition = primaryAssoc.getChildRef();
|
||||||
ChildAssociationRef newChild = nodeService.addChild(sourceNode, rendition, renditionType, renditionName);
|
ChildAssociationRef newChild = null;
|
||||||
|
behaviourFilter.disableBehaviour(sourceNode, ContentModel.ASPECT_AUDITABLE);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newChild = nodeService.addChild(sourceNode, rendition, renditionType, renditionName);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
behaviourFilter.enableBehaviour(sourceNode, ContentModel.ASPECT_AUDITABLE);
|
||||||
|
}
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
|
@@ -28,6 +28,7 @@ import junit.framework.TestCase;
|
|||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.model.RenditionModel;
|
import org.alfresco.model.RenditionModel;
|
||||||
|
import org.alfresco.repo.policy.BehaviourFilter;
|
||||||
import org.alfresco.service.cmr.rendition.RenditionDefinition;
|
import org.alfresco.service.cmr.rendition.RenditionDefinition;
|
||||||
import org.alfresco.service.cmr.rendition.RenditionService;
|
import org.alfresco.service.cmr.rendition.RenditionService;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
@@ -44,6 +45,7 @@ public class RenditionNodeManagerTest extends TestCase
|
|||||||
{
|
{
|
||||||
private final NodeService nodeService = mock(NodeService.class);
|
private final NodeService nodeService = mock(NodeService.class);
|
||||||
private final RenditionService renditionService = mock(RenditionService.class);
|
private final RenditionService renditionService = mock(RenditionService.class);
|
||||||
|
private final BehaviourFilter behaviourFilter = mock(BehaviourFilter.class);
|
||||||
|
|
||||||
private final NodeRef source = new NodeRef("http://test/sourceId");
|
private final NodeRef source = new NodeRef("http://test/sourceId");
|
||||||
private final NodeRef destination = new NodeRef("http://test/destinationId");
|
private final NodeRef destination = new NodeRef("http://test/destinationId");
|
||||||
@@ -59,7 +61,7 @@ public class RenditionNodeManagerTest extends TestCase
|
|||||||
ChildAssociationRef parentAssoc = makeAssoc(source, destination, true);
|
ChildAssociationRef parentAssoc = makeAssoc(source, destination, true);
|
||||||
when(nodeService.getPrimaryParent(any(NodeRef.class))).thenReturn(parentAssoc);
|
when(nodeService.getPrimaryParent(any(NodeRef.class))).thenReturn(parentAssoc);
|
||||||
RenditionLocation location = new RenditionLocationImpl(source, destination, "destinationName");
|
RenditionLocation location = new RenditionLocationImpl(source, destination, "destinationName");
|
||||||
RenditionNodeManager manager = new RenditionNodeManager(source, null, location, definition, nodeService, renditionService);
|
RenditionNodeManager manager = new RenditionNodeManager(source, null, location, definition, nodeService, renditionService, behaviourFilter);
|
||||||
ChildAssociationRef result = manager.findOrCreateRenditionNode();
|
ChildAssociationRef result = manager.findOrCreateRenditionNode();
|
||||||
assertEquals(parentAssoc, result);
|
assertEquals(parentAssoc, result);
|
||||||
}
|
}
|
||||||
@@ -74,7 +76,7 @@ public class RenditionNodeManagerTest extends TestCase
|
|||||||
.thenReturn(parentAssoc);
|
.thenReturn(parentAssoc);
|
||||||
|
|
||||||
RenditionLocation location = new RenditionLocationImpl(source, null, renditionName.getLocalName());
|
RenditionLocation location = new RenditionLocationImpl(source, null, renditionName.getLocalName());
|
||||||
RenditionNodeManager manager = new RenditionNodeManager(source, null, location, definition, nodeService, renditionService);
|
RenditionNodeManager manager = new RenditionNodeManager(source, null, location, definition, nodeService, renditionService, behaviourFilter);
|
||||||
ChildAssociationRef result = manager.findOrCreateRenditionNode();
|
ChildAssociationRef result = manager.findOrCreateRenditionNode();
|
||||||
assertEquals(parentAssoc, result);
|
assertEquals(parentAssoc, result);
|
||||||
}
|
}
|
||||||
@@ -90,7 +92,7 @@ public class RenditionNodeManagerTest extends TestCase
|
|||||||
.thenReturn(parentAssoc);
|
.thenReturn(parentAssoc);
|
||||||
|
|
||||||
RenditionLocation location = new RenditionLocationImpl(parent, null, renditionName.getLocalName());
|
RenditionLocation location = new RenditionLocationImpl(parent, null, renditionName.getLocalName());
|
||||||
RenditionNodeManager manager = new RenditionNodeManager(source, null, location, definition, nodeService, renditionService);
|
RenditionNodeManager manager = new RenditionNodeManager(source, null, location, definition, nodeService, renditionService, behaviourFilter);
|
||||||
ChildAssociationRef result = manager.findOrCreateRenditionNode();
|
ChildAssociationRef result = manager.findOrCreateRenditionNode();
|
||||||
assertEquals(parentAssoc, result);
|
assertEquals(parentAssoc, result);
|
||||||
// Check the rendition association is created.
|
// Check the rendition association is created.
|
||||||
@@ -103,7 +105,7 @@ public class RenditionNodeManagerTest extends TestCase
|
|||||||
public void testHasOldRenditionMatchesSpecifiedDestinationNode()
|
public void testHasOldRenditionMatchesSpecifiedDestinationNode()
|
||||||
{
|
{
|
||||||
RenditionLocation location = new RenditionLocationImpl(source, oldRendition, renditionName.getLocalName());
|
RenditionLocation location = new RenditionLocationImpl(source, oldRendition, renditionName.getLocalName());
|
||||||
RenditionNodeManager manager = new RenditionNodeManager(source, oldRendition, location, definition, nodeService, renditionService);
|
RenditionNodeManager manager = new RenditionNodeManager(source, oldRendition, location, definition, nodeService, renditionService, behaviourFilter);
|
||||||
manager.findOrCreateRenditionNode();
|
manager.findOrCreateRenditionNode();
|
||||||
verify(nodeService).getPrimaryParent(oldRendition);
|
verify(nodeService).getPrimaryParent(oldRendition);
|
||||||
}
|
}
|
||||||
@@ -118,7 +120,7 @@ public class RenditionNodeManagerTest extends TestCase
|
|||||||
when(nodeService.getPrimaryParent(oldRendition)).thenReturn(parentAssoc);
|
when(nodeService.getPrimaryParent(oldRendition)).thenReturn(parentAssoc);
|
||||||
|
|
||||||
RenditionLocation location = new RenditionLocationImpl(parent, null, null);
|
RenditionLocation location = new RenditionLocationImpl(parent, null, null);
|
||||||
RenditionNodeManager manager = new RenditionNodeManager(source, oldRendition, location, definition, nodeService, renditionService);
|
RenditionNodeManager manager = new RenditionNodeManager(source, oldRendition, location, definition, nodeService, renditionService, behaviourFilter);
|
||||||
ChildAssociationRef result = manager.findOrCreateRenditionNode();
|
ChildAssociationRef result = manager.findOrCreateRenditionNode();
|
||||||
assertEquals(parentAssoc, result);
|
assertEquals(parentAssoc, result);
|
||||||
verify(nodeService, times(2)).getPrimaryParent(oldRendition);
|
verify(nodeService, times(2)).getPrimaryParent(oldRendition);
|
||||||
@@ -137,7 +139,7 @@ public class RenditionNodeManagerTest extends TestCase
|
|||||||
.thenReturn(rendName);
|
.thenReturn(rendName);
|
||||||
|
|
||||||
RenditionLocationImpl location = new RenditionLocationImpl(parent, null, rendName);
|
RenditionLocationImpl location = new RenditionLocationImpl(parent, null, rendName);
|
||||||
RenditionNodeManager manager = new RenditionNodeManager(source, oldRendition, location, definition, nodeService, renditionService);
|
RenditionNodeManager manager = new RenditionNodeManager(source, oldRendition, location, definition, nodeService, renditionService, behaviourFilter);
|
||||||
ChildAssociationRef result = manager.findOrCreateRenditionNode();
|
ChildAssociationRef result = manager.findOrCreateRenditionNode();
|
||||||
assertEquals(parentAssoc, result);
|
assertEquals(parentAssoc, result);
|
||||||
verify(nodeService, times(2)).getPrimaryParent(oldRendition);
|
verify(nodeService, times(2)).getPrimaryParent(oldRendition);
|
||||||
@@ -156,7 +158,7 @@ public class RenditionNodeManagerTest extends TestCase
|
|||||||
when(nodeService.moveNode(oldRendition, parent, ContentModel.ASSOC_CONTAINS, renditionName))
|
when(nodeService.moveNode(oldRendition, parent, ContentModel.ASSOC_CONTAINS, renditionName))
|
||||||
.thenReturn(parentAssoc);
|
.thenReturn(parentAssoc);
|
||||||
RenditionLocationImpl location = new RenditionLocationImpl(parent, null, null);
|
RenditionLocationImpl location = new RenditionLocationImpl(parent, null, null);
|
||||||
RenditionNodeManager manager = new RenditionNodeManager(source, oldRendition, location, definition, nodeService, renditionService);
|
RenditionNodeManager manager = new RenditionNodeManager(source, oldRendition, location, definition, nodeService, renditionService, behaviourFilter);
|
||||||
ChildAssociationRef result = manager.findOrCreateRenditionNode();
|
ChildAssociationRef result = manager.findOrCreateRenditionNode();
|
||||||
assertEquals(parentAssoc, result);
|
assertEquals(parentAssoc, result);
|
||||||
verify(nodeService).moveNode(oldRendition, parent, ContentModel.ASSOC_CONTAINS, renditionName);
|
verify(nodeService).moveNode(oldRendition, parent, ContentModel.ASSOC_CONTAINS, renditionName);
|
||||||
@@ -166,7 +168,7 @@ public class RenditionNodeManagerTest extends TestCase
|
|||||||
when(nodeService.moveNode(oldRendition, source, RenditionModel.ASSOC_RENDITION, renditionName))
|
when(nodeService.moveNode(oldRendition, source, RenditionModel.ASSOC_RENDITION, renditionName))
|
||||||
.thenReturn(sourceAssoc);
|
.thenReturn(sourceAssoc);
|
||||||
location = new RenditionLocationImpl(source, null, null);
|
location = new RenditionLocationImpl(source, null, null);
|
||||||
manager = new RenditionNodeManager(source, oldRendition, location, definition, nodeService, renditionService);
|
manager = new RenditionNodeManager(source, oldRendition, location, definition, nodeService, renditionService, behaviourFilter);
|
||||||
result = manager.findOrCreateRenditionNode();
|
result = manager.findOrCreateRenditionNode();
|
||||||
assertEquals(sourceAssoc, result);
|
assertEquals(sourceAssoc, result);
|
||||||
verify(nodeService).moveNode(oldRendition, source, RenditionModel.ASSOC_RENDITION, renditionName);
|
verify(nodeService).moveNode(oldRendition, source, RenditionModel.ASSOC_RENDITION, renditionName);
|
||||||
@@ -180,7 +182,7 @@ public class RenditionNodeManagerTest extends TestCase
|
|||||||
when(nodeService.moveNode(oldRendition, newParent, ContentModel.ASSOC_CONTAINS, renditionName))
|
when(nodeService.moveNode(oldRendition, newParent, ContentModel.ASSOC_CONTAINS, renditionName))
|
||||||
.thenReturn(newParentAssoc);
|
.thenReturn(newParentAssoc);
|
||||||
location = new RenditionLocationImpl(newParent, null, null);
|
location = new RenditionLocationImpl(newParent, null, null);
|
||||||
manager = new RenditionNodeManager(source, oldRendition, location, definition, nodeService, renditionService);
|
manager = new RenditionNodeManager(source, oldRendition, location, definition, nodeService, renditionService, behaviourFilter);
|
||||||
result = manager.findOrCreateRenditionNode();
|
result = manager.findOrCreateRenditionNode();
|
||||||
assertEquals(newParentAssoc, result);
|
assertEquals(newParentAssoc, result);
|
||||||
verify(nodeService).moveNode(oldRendition, newParent, ContentModel.ASSOC_CONTAINS, renditionName);
|
verify(nodeService).moveNode(oldRendition, newParent, ContentModel.ASSOC_CONTAINS, renditionName);
|
||||||
@@ -202,7 +204,7 @@ public class RenditionNodeManagerTest extends TestCase
|
|||||||
|
|
||||||
String newName = "newName";
|
String newName = "newName";
|
||||||
RenditionLocationImpl location = new RenditionLocationImpl(parent, null, newName);
|
RenditionLocationImpl location = new RenditionLocationImpl(parent, null, newName);
|
||||||
RenditionNodeManager manager = new RenditionNodeManager(source, oldRendition, location, definition, nodeService, renditionService);
|
RenditionNodeManager manager = new RenditionNodeManager(source, oldRendition, location, definition, nodeService, renditionService, behaviourFilter);
|
||||||
ChildAssociationRef result = manager.findOrCreateRenditionNode();
|
ChildAssociationRef result = manager.findOrCreateRenditionNode();
|
||||||
assertEquals(parentAssoc, result);
|
assertEquals(parentAssoc, result);
|
||||||
verify(nodeService).moveNode(oldRendition, parent, ContentModel.ASSOC_CONTAINS, renditionName);
|
verify(nodeService).moveNode(oldRendition, parent, ContentModel.ASSOC_CONTAINS, renditionName);
|
||||||
|
@@ -847,7 +847,7 @@ public abstract class AbstractRenderingEngine extends ActionExecuterAbstractBase
|
|||||||
// doesn't already have it.
|
// doesn't already have it.
|
||||||
if (!nodeService.hasAspect(actionedUponNodeRef, RenditionModel.ASPECT_RENDITIONED))
|
if (!nodeService.hasAspect(actionedUponNodeRef, RenditionModel.ASPECT_RENDITIONED))
|
||||||
{
|
{
|
||||||
// Ensure we do not update the 'modifier' due to thumbnail addition
|
// Ensure we do not update the 'modifier' due to rendition addition
|
||||||
behaviourFilter.disableBehaviour(actionedUponNodeRef, ContentModel.ASPECT_AUDITABLE);
|
behaviourFilter.disableBehaviour(actionedUponNodeRef, ContentModel.ASPECT_AUDITABLE);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -938,7 +938,7 @@ public abstract class AbstractRenderingEngine extends ActionExecuterAbstractBase
|
|||||||
QName renditionQName = renditionDefinition.getRenditionName();
|
QName renditionQName = renditionDefinition.getRenditionName();
|
||||||
|
|
||||||
RenditionNodeManager renditionNodeManager = new RenditionNodeManager(sourceNode, tempRenditionNode,
|
RenditionNodeManager renditionNodeManager = new RenditionNodeManager(sourceNode, tempRenditionNode,
|
||||||
renditionLocation, renditionDefinition, nodeService, renditionService);
|
renditionLocation, renditionDefinition, nodeService, renditionService, behaviourFilter);
|
||||||
ChildAssociationRef renditionNode = renditionNodeManager.findOrCreateRenditionNode();
|
ChildAssociationRef renditionNode = renditionNodeManager.findOrCreateRenditionNode();
|
||||||
|
|
||||||
// Copy relevant properties from the temporary node to the new rendition
|
// Copy relevant properties from the temporary node to the new rendition
|
||||||
@@ -982,8 +982,17 @@ public abstract class AbstractRenderingEngine extends ActionExecuterAbstractBase
|
|||||||
if (primaryParent.equals(sourceNode))
|
if (primaryParent.equals(sourceNode))
|
||||||
{
|
{
|
||||||
// It should be a 'hidden' rendition.
|
// It should be a 'hidden' rendition.
|
||||||
nodeService.addAspect(renditionNode, RenditionModel.ASPECT_HIDDEN_RENDITION, null);
|
// Ensure we do not update the 'modifier' due to rendition addition
|
||||||
nodeService.removeAspect(renditionNode, RenditionModel.ASPECT_VISIBLE_RENDITION);
|
behaviourFilter.disableBehaviour(renditionNode, ContentModel.ASPECT_AUDITABLE);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
nodeService.addAspect(renditionNode, RenditionModel.ASPECT_HIDDEN_RENDITION, null);
|
||||||
|
nodeService.removeAspect(renditionNode, RenditionModel.ASPECT_VISIBLE_RENDITION);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
behaviourFilter.enableBehaviour(renditionNode, ContentModel.ASPECT_AUDITABLE);
|
||||||
|
}
|
||||||
// We remove the other aspect to cover the potential case where a
|
// We remove the other aspect to cover the potential case where a
|
||||||
// rendition
|
// rendition
|
||||||
// has been updated in a different location.
|
// has been updated in a different location.
|
||||||
@@ -991,8 +1000,16 @@ public abstract class AbstractRenderingEngine extends ActionExecuterAbstractBase
|
|||||||
{
|
{
|
||||||
// Renditions stored underneath any node other than their source are
|
// Renditions stored underneath any node other than their source are
|
||||||
// 'visible'.
|
// 'visible'.
|
||||||
nodeService.addAspect(renditionNode, RenditionModel.ASPECT_VISIBLE_RENDITION, null);
|
behaviourFilter.disableBehaviour(renditionNode, ContentModel.ASPECT_AUDITABLE);
|
||||||
nodeService.removeAspect(renditionNode, RenditionModel.ASPECT_HIDDEN_RENDITION);
|
try
|
||||||
|
{
|
||||||
|
nodeService.addAspect(renditionNode, RenditionModel.ASPECT_VISIBLE_RENDITION, null);
|
||||||
|
nodeService.removeAspect(renditionNode, RenditionModel.ASPECT_HIDDEN_RENDITION);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
behaviourFilter.enableBehaviour(renditionNode, ContentModel.ASPECT_AUDITABLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user