diff --git a/source/java/org/alfresco/repo/audit/access/NodeChange.java b/source/java/org/alfresco/repo/audit/access/NodeChange.java index d8dacb12f3..010c588b19 100644 --- a/source/java/org/alfresco/repo/audit/access/NodeChange.java +++ b/source/java/org/alfresco/repo/audit/access/NodeChange.java @@ -126,6 +126,7 @@ import org.alfresco.service.namespace.QName; private NodeInfo nodeInfo; private String action; + private String runAsUser; private boolean auditSubActions = false; private Set subActions = new LinkedHashSet(); @@ -157,6 +158,8 @@ import org.alfresco.service.namespace.QName; { // Derive higher level action String action; + boolean keepRunAsUser = false; + if (subActions.contains(CHECK_OUT)) { action = "CHECK OUT"; @@ -181,6 +184,8 @@ import org.alfresco.service.namespace.QName; { // Reads in combinations with other actions tend to only facilitate the other action. action = "READ"; + // MNT-8810 fix, action is considered as READ -> so let's keep actual user who performed readContent + keepRunAsUser = true; } else if (subActions.contains(DELETE_NODE)) { @@ -203,7 +208,10 @@ import org.alfresco.service.namespace.QName; // Default to first sub-action action = this.action; } - + if (!keepRunAsUser) + { + runAsUser = null; + } return action; } @@ -455,6 +463,8 @@ import org.alfresco.service.namespace.QName; { appendSubAction(new NodeChange(nodeInfoFactory, namespaceService, nodeRef). setAction(READ_CONTENT)); + // MNT-8810 fix, remember runAsUser for read operation + runAsUser = AuthenticationUtil.getRunAsUser(); } @Override @@ -524,7 +534,9 @@ import org.alfresco.service.namespace.QName; if (!subAction) // no need to repeat for sub actions { - auditMap.put(USER, AuthenticationUtil.getFullyAuthenticatedUser()); + // MNT-8810 fix, if runAsUser is not null this means that this is READ action and we should use real user who performed readContent, + // not the current user as actual read may be executed in runAs block (for example for thumbnail creation) + auditMap.put(USER, (runAsUser == null ? AuthenticationUtil.getFullyAuthenticatedUser() : runAsUser)); addSubActionsToAuditMap(auditMap); auditMap.put(NODE, nodeInfo.getNodeRef()); diff --git a/source/java/org/alfresco/repo/jscript/ScriptNode.java b/source/java/org/alfresco/repo/jscript/ScriptNode.java index 5d8fd93605..ba08ce872d 100644 --- a/source/java/org/alfresco/repo/jscript/ScriptNode.java +++ b/source/java/org/alfresco/repo/jscript/ScriptNode.java @@ -2917,8 +2917,7 @@ public class ScriptNode implements Scopeable, NamespacePrefixResolverProvider String nodeMimeType = getMimetype(); Serializable value = this.nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT); ContentData contentData = DefaultTypeConverter.INSTANCE.convert(ContentData.class, value); - if (!ContentData.hasContent(contentData) || - !services.getContentService().getReader(nodeRef, ContentModel.PROP_CONTENT).exists()) + if (!ContentData.hasContent(contentData)) { if (logger.isDebugEnabled()) logger.debug("Unable to create thumbnail '" + details.getName() + "' as there is no content"); @@ -3023,16 +3022,17 @@ public class ScriptNode implements Scopeable, NamespacePrefixResolverProvider */ public String[] getThumbnailDefinitions() { - ContentService contentService = this.services.getContentService(); ThumbnailService thumbnailService = this.services.getThumbnailService(); List result = new ArrayList(7); - ContentReader contentReader = contentService.getReader(this.nodeRef, ContentModel.PROP_CONTENT); - if (contentReader != null) + Serializable value = this.nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT); + ContentData contentData = DefaultTypeConverter.INSTANCE.convert(ContentData.class, value); + + if (ContentData.hasContent(contentData)) { - String mimetype = contentReader.getMimetype(); - List thumbnailDefinitions = thumbnailService.getThumbnailRegistry().getThumbnailDefinitions(mimetype, contentReader.getSize()); + String mimetype = contentData.getMimetype(); + List thumbnailDefinitions = thumbnailService.getThumbnailRegistry().getThumbnailDefinitions(mimetype, contentData.getSize()); for (ThumbnailDefinition thumbnailDefinition : thumbnailDefinitions) { result.add(thumbnailDefinition.getName()); diff --git a/source/java/org/alfresco/repo/rendition/executer/AbstractRenderingEngine.java b/source/java/org/alfresco/repo/rendition/executer/AbstractRenderingEngine.java index cde75f0473..5ebe8fac50 100644 --- a/source/java/org/alfresco/repo/rendition/executer/AbstractRenderingEngine.java +++ b/source/java/org/alfresco/repo/rendition/executer/AbstractRenderingEngine.java @@ -36,6 +36,7 @@ import org.alfresco.model.RenditionModel; import org.alfresco.repo.action.ParameterDefinitionImpl; import org.alfresco.repo.action.executer.ActionExecuterAbstractBase; import org.alfresco.repo.content.MimetypeMap; +import org.alfresco.repo.content.transform.UnimportantTransformException; import org.alfresco.repo.nodelocator.NodeLocator; import org.alfresco.repo.nodelocator.SelfNodeLocator; import org.alfresco.repo.policy.BehaviourFilter; @@ -830,7 +831,7 @@ public abstract class AbstractRenderingEngine extends ActionExecuterAbstractBase ContentReader contentReader = contentService.getReader(sourceNode, srcContentProp); if (contentReader == null || !contentReader.exists()) { - throw new RenditionServiceException(CONTENT_READER_NOT_FOUND_MESSAGE); + throw new UnimportantTransformException(CONTENT_READER_NOT_FOUND_MESSAGE); } return contentReader; } diff --git a/source/test-java/org/alfresco/repo/rendition/RenditionServiceIntegrationTest.java b/source/test-java/org/alfresco/repo/rendition/RenditionServiceIntegrationTest.java index 1ac5e9f159..90f34a9758 100644 --- a/source/test-java/org/alfresco/repo/rendition/RenditionServiceIntegrationTest.java +++ b/source/test-java/org/alfresco/repo/rendition/RenditionServiceIntegrationTest.java @@ -42,6 +42,7 @@ import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.content.transform.AbstractContentTransformerTest; import org.alfresco.repo.content.transform.ContentTransformer; import org.alfresco.repo.content.transform.ContentTransformerRegistry; +import org.alfresco.repo.content.transform.UnimportantTransformException; import org.alfresco.repo.content.transform.magick.ImageTransformationOptions; import org.alfresco.repo.jscript.ClasspathScriptLocation; import org.alfresco.repo.model.Repository; @@ -1237,7 +1238,7 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest performAsyncRendition(testTargetFolder, callback, latch, results); assertNull(results.getAssoc()); - assertEquals("Expected a RenditionServiceException", RenditionCancelledException.class, results.getThrowable().getClass()); + assertEquals("Expected a UnimportantTransformException", UnimportantTransformException.class, results.getThrowable().getClass()); } /**