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:
Neil McErlean
2010-10-27 08:01:50 +00:00
parent 38dd0ad972
commit 2c64a45a44
3 changed files with 50 additions and 18 deletions

View File

@@ -31,6 +31,7 @@ import java.util.Map.Entry;
import org.alfresco.model.ContentModel;
import org.alfresco.model.RenditionModel;
import org.alfresco.repo.policy.BehaviourFilter;
import org.alfresco.repo.rendition.executer.AbstractRenderingEngine;
import org.alfresco.service.cmr.rendition.RenditionDefinition;
import org.alfresco.service.cmr.rendition.RenditionService;
@@ -70,6 +71,7 @@ public class RenditionNodeManager
private final RenditionDefinition renditionDefinition;
private final RenditionLocation location;
private final NodeService nodeService;
private BehaviourFilter behaviourFilter;
private final RenditionService renditionService;
private final NodeRef oldRendition;
private ChildAssociationRef finalRenditionAssoc;
@@ -84,7 +86,8 @@ public class RenditionNodeManager
* @param renditionService
*/
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.tempRenditionNode = tempRenditionNode;
@@ -92,6 +95,7 @@ public class RenditionNodeManager
this.renditionDefinition = renditionDefinition;
this.nodeService = nodeService;
this.renditionService = renditionService;
this.behaviourFilter = behaviourFilter;
this.oldRendition = this.getOldRenditionIfExists(sourceNode, renditionDefinition);
@@ -333,7 +337,16 @@ public class RenditionNodeManager
if (parentIsSource == false)
{
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())
{

View File

@@ -28,6 +28,7 @@ import junit.framework.TestCase;
import org.alfresco.model.ContentModel;
import org.alfresco.model.RenditionModel;
import org.alfresco.repo.policy.BehaviourFilter;
import org.alfresco.service.cmr.rendition.RenditionDefinition;
import org.alfresco.service.cmr.rendition.RenditionService;
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 RenditionService renditionService = mock(RenditionService.class);
private final BehaviourFilter behaviourFilter = mock(BehaviourFilter.class);
private final NodeRef source = new NodeRef("http://test/sourceId");
private final NodeRef destination = new NodeRef("http://test/destinationId");
@@ -59,7 +61,7 @@ public class RenditionNodeManagerTest extends TestCase
ChildAssociationRef parentAssoc = makeAssoc(source, destination, true);
when(nodeService.getPrimaryParent(any(NodeRef.class))).thenReturn(parentAssoc);
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();
assertEquals(parentAssoc, result);
}
@@ -74,7 +76,7 @@ public class RenditionNodeManagerTest extends TestCase
.thenReturn(parentAssoc);
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();
assertEquals(parentAssoc, result);
}
@@ -90,7 +92,7 @@ public class RenditionNodeManagerTest extends TestCase
.thenReturn(parentAssoc);
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();
assertEquals(parentAssoc, result);
// Check the rendition association is created.
@@ -103,7 +105,7 @@ public class RenditionNodeManagerTest extends TestCase
public void testHasOldRenditionMatchesSpecifiedDestinationNode()
{
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();
verify(nodeService).getPrimaryParent(oldRendition);
}
@@ -118,7 +120,7 @@ public class RenditionNodeManagerTest extends TestCase
when(nodeService.getPrimaryParent(oldRendition)).thenReturn(parentAssoc);
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();
assertEquals(parentAssoc, result);
verify(nodeService, times(2)).getPrimaryParent(oldRendition);
@@ -137,7 +139,7 @@ public class RenditionNodeManagerTest extends TestCase
.thenReturn(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();
assertEquals(parentAssoc, result);
verify(nodeService, times(2)).getPrimaryParent(oldRendition);
@@ -156,7 +158,7 @@ public class RenditionNodeManagerTest extends TestCase
when(nodeService.moveNode(oldRendition, parent, ContentModel.ASSOC_CONTAINS, renditionName))
.thenReturn(parentAssoc);
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();
assertEquals(parentAssoc, result);
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))
.thenReturn(sourceAssoc);
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();
assertEquals(sourceAssoc, result);
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))
.thenReturn(newParentAssoc);
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();
assertEquals(newParentAssoc, result);
verify(nodeService).moveNode(oldRendition, newParent, ContentModel.ASSOC_CONTAINS, renditionName);
@@ -202,7 +204,7 @@ public class RenditionNodeManagerTest extends TestCase
String newName = "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();
assertEquals(parentAssoc, result);
verify(nodeService).moveNode(oldRendition, parent, ContentModel.ASSOC_CONTAINS, renditionName);

View File

@@ -847,7 +847,7 @@ public abstract class AbstractRenderingEngine extends ActionExecuterAbstractBase
// doesn't already have it.
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);
try
{
@@ -938,7 +938,7 @@ public abstract class AbstractRenderingEngine extends ActionExecuterAbstractBase
QName renditionQName = renditionDefinition.getRenditionName();
RenditionNodeManager renditionNodeManager = new RenditionNodeManager(sourceNode, tempRenditionNode,
renditionLocation, renditionDefinition, nodeService, renditionService);
renditionLocation, renditionDefinition, nodeService, renditionService, behaviourFilter);
ChildAssociationRef renditionNode = renditionNodeManager.findOrCreateRenditionNode();
// 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))
{
// It should be a 'hidden' rendition.
// Ensure we do not update the 'modifier' due to rendition addition
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
// rendition
// has been updated in a different location.
@@ -991,9 +1000,17 @@ public abstract class AbstractRenderingEngine extends ActionExecuterAbstractBase
{
// Renditions stored underneath any node other than their source are
// 'visible'.
behaviourFilter.disableBehaviour(renditionNode, ContentModel.ASPECT_AUDITABLE);
try
{
nodeService.addAspect(renditionNode, RenditionModel.ASPECT_VISIBLE_RENDITION, null);
nodeService.removeAspect(renditionNode, RenditionModel.ASPECT_HIDDEN_RENDITION);
}
finally
{
behaviourFilter.enableBehaviour(renditionNode, ContentModel.ASPECT_AUDITABLE);
}
}
}
/**