mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.1/Cloud)
94144: Merged 5.0.N (5.0.1) to HEAD-BUG-FIX (5.1/Cloud) 94082: Merged V4.2-BUG-FIX (4.2.5) to 5.0.N (5.0.1) 93943: Merged V4.1-BUG-FIX (4.1.10) to V4.2-BUG-FIX (4.2.5) 93775: Merged DEV to V4.1-BUG-FIX (4.1.10) 93465: MNT-8810 : Audit: Double READ on first Share preview - Audit READ for cm:content no longer occurs when thumbnail is created or read. - Audit READ for cm:thumbnail occurs when content of doclib or webpreview is read. 93874: MNT-8810 : Audit: Double READ on first Share preview - Fixed test failure. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@95045 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -126,6 +126,7 @@ import org.alfresco.service.namespace.QName;
|
|||||||
private NodeInfo nodeInfo;
|
private NodeInfo nodeInfo;
|
||||||
|
|
||||||
private String action;
|
private String action;
|
||||||
|
private String runAsUser;
|
||||||
|
|
||||||
private boolean auditSubActions = false;
|
private boolean auditSubActions = false;
|
||||||
private Set<String> subActions = new LinkedHashSet<String>();
|
private Set<String> subActions = new LinkedHashSet<String>();
|
||||||
@@ -157,6 +158,8 @@ import org.alfresco.service.namespace.QName;
|
|||||||
{
|
{
|
||||||
// Derive higher level action
|
// Derive higher level action
|
||||||
String action;
|
String action;
|
||||||
|
boolean keepRunAsUser = false;
|
||||||
|
|
||||||
if (subActions.contains(CHECK_OUT))
|
if (subActions.contains(CHECK_OUT))
|
||||||
{
|
{
|
||||||
action = "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.
|
// Reads in combinations with other actions tend to only facilitate the other action.
|
||||||
action = "READ";
|
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))
|
else if (subActions.contains(DELETE_NODE))
|
||||||
{
|
{
|
||||||
@@ -203,7 +208,10 @@ import org.alfresco.service.namespace.QName;
|
|||||||
// Default to first sub-action
|
// Default to first sub-action
|
||||||
action = this.action;
|
action = this.action;
|
||||||
}
|
}
|
||||||
|
if (!keepRunAsUser)
|
||||||
|
{
|
||||||
|
runAsUser = null;
|
||||||
|
}
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -455,6 +463,8 @@ import org.alfresco.service.namespace.QName;
|
|||||||
{
|
{
|
||||||
appendSubAction(new NodeChange(nodeInfoFactory, namespaceService, nodeRef).
|
appendSubAction(new NodeChange(nodeInfoFactory, namespaceService, nodeRef).
|
||||||
setAction(READ_CONTENT));
|
setAction(READ_CONTENT));
|
||||||
|
// MNT-8810 fix, remember runAsUser for read operation
|
||||||
|
runAsUser = AuthenticationUtil.getRunAsUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -524,7 +534,9 @@ import org.alfresco.service.namespace.QName;
|
|||||||
|
|
||||||
if (!subAction) // no need to repeat for sub actions
|
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);
|
addSubActionsToAuditMap(auditMap);
|
||||||
|
|
||||||
auditMap.put(NODE, nodeInfo.getNodeRef());
|
auditMap.put(NODE, nodeInfo.getNodeRef());
|
||||||
|
@@ -2917,8 +2917,7 @@ public class ScriptNode implements Scopeable, NamespacePrefixResolverProvider
|
|||||||
String nodeMimeType = getMimetype();
|
String nodeMimeType = getMimetype();
|
||||||
Serializable value = this.nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT);
|
Serializable value = this.nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT);
|
||||||
ContentData contentData = DefaultTypeConverter.INSTANCE.convert(ContentData.class, value);
|
ContentData contentData = DefaultTypeConverter.INSTANCE.convert(ContentData.class, value);
|
||||||
if (!ContentData.hasContent(contentData) ||
|
if (!ContentData.hasContent(contentData))
|
||||||
!services.getContentService().getReader(nodeRef, ContentModel.PROP_CONTENT).exists())
|
|
||||||
{
|
{
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
logger.debug("Unable to create thumbnail '" + details.getName() + "' as there is no content");
|
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()
|
public String[] getThumbnailDefinitions()
|
||||||
{
|
{
|
||||||
ContentService contentService = this.services.getContentService();
|
|
||||||
ThumbnailService thumbnailService = this.services.getThumbnailService();
|
ThumbnailService thumbnailService = this.services.getThumbnailService();
|
||||||
|
|
||||||
List<String> result = new ArrayList<String>(7);
|
List<String> result = new ArrayList<String>(7);
|
||||||
|
|
||||||
ContentReader contentReader = contentService.getReader(this.nodeRef, ContentModel.PROP_CONTENT);
|
Serializable value = this.nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT);
|
||||||
if (contentReader != null)
|
ContentData contentData = DefaultTypeConverter.INSTANCE.convert(ContentData.class, value);
|
||||||
|
|
||||||
|
if (ContentData.hasContent(contentData))
|
||||||
{
|
{
|
||||||
String mimetype = contentReader.getMimetype();
|
String mimetype = contentData.getMimetype();
|
||||||
List<ThumbnailDefinition> thumbnailDefinitions = thumbnailService.getThumbnailRegistry().getThumbnailDefinitions(mimetype, contentReader.getSize());
|
List<ThumbnailDefinition> thumbnailDefinitions = thumbnailService.getThumbnailRegistry().getThumbnailDefinitions(mimetype, contentData.getSize());
|
||||||
for (ThumbnailDefinition thumbnailDefinition : thumbnailDefinitions)
|
for (ThumbnailDefinition thumbnailDefinition : thumbnailDefinitions)
|
||||||
{
|
{
|
||||||
result.add(thumbnailDefinition.getName());
|
result.add(thumbnailDefinition.getName());
|
||||||
|
@@ -36,6 +36,7 @@ import org.alfresco.model.RenditionModel;
|
|||||||
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
||||||
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
|
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
|
||||||
import org.alfresco.repo.content.MimetypeMap;
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
|
import org.alfresco.repo.content.transform.UnimportantTransformException;
|
||||||
import org.alfresco.repo.nodelocator.NodeLocator;
|
import org.alfresco.repo.nodelocator.NodeLocator;
|
||||||
import org.alfresco.repo.nodelocator.SelfNodeLocator;
|
import org.alfresco.repo.nodelocator.SelfNodeLocator;
|
||||||
import org.alfresco.repo.policy.BehaviourFilter;
|
import org.alfresco.repo.policy.BehaviourFilter;
|
||||||
@@ -830,7 +831,7 @@ public abstract class AbstractRenderingEngine extends ActionExecuterAbstractBase
|
|||||||
ContentReader contentReader = contentService.getReader(sourceNode, srcContentProp);
|
ContentReader contentReader = contentService.getReader(sourceNode, srcContentProp);
|
||||||
if (contentReader == null || !contentReader.exists())
|
if (contentReader == null || !contentReader.exists())
|
||||||
{
|
{
|
||||||
throw new RenditionServiceException(CONTENT_READER_NOT_FOUND_MESSAGE);
|
throw new UnimportantTransformException(CONTENT_READER_NOT_FOUND_MESSAGE);
|
||||||
}
|
}
|
||||||
return contentReader;
|
return contentReader;
|
||||||
}
|
}
|
||||||
|
@@ -42,6 +42,7 @@ import org.alfresco.repo.content.MimetypeMap;
|
|||||||
import org.alfresco.repo.content.transform.AbstractContentTransformerTest;
|
import org.alfresco.repo.content.transform.AbstractContentTransformerTest;
|
||||||
import org.alfresco.repo.content.transform.ContentTransformer;
|
import org.alfresco.repo.content.transform.ContentTransformer;
|
||||||
import org.alfresco.repo.content.transform.ContentTransformerRegistry;
|
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.content.transform.magick.ImageTransformationOptions;
|
||||||
import org.alfresco.repo.jscript.ClasspathScriptLocation;
|
import org.alfresco.repo.jscript.ClasspathScriptLocation;
|
||||||
import org.alfresco.repo.model.Repository;
|
import org.alfresco.repo.model.Repository;
|
||||||
@@ -1237,7 +1238,7 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest
|
|||||||
performAsyncRendition(testTargetFolder, callback, latch, results);
|
performAsyncRendition(testTargetFolder, callback, latch, results);
|
||||||
|
|
||||||
assertNull(results.getAssoc());
|
assertNull(results.getAssoc());
|
||||||
assertEquals("Expected a RenditionServiceException", RenditionCancelledException.class, results.getThrowable().getClass());
|
assertEquals("Expected a UnimportantTransformException", UnimportantTransformException.class, results.getThrowable().getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user