Compare commits

...

16 Commits

Author SHA1 Message Date
mohit-singh4
89dfc3c2da [fix/MNT-24172-fixForRecreationOfRendition2Aspect] fix for recreation of rendition2 aspect 2025-02-07 12:06:00 +05:30
mohit-singh4
2506b5d22a Merge branch 'master' of github.com:Alfresco/alfresco-community-repo into fix/MNT-24172-fixForRecreationOfRendition2Aspect 2025-02-07 12:01:06 +05:30
mohit-singh4
c87d1c9475 [fix/MNT-24172-fixRendition2Recreation] Fix for rendition2 recreation 2025-01-16 22:01:13 +05:30
mohit-singh4
d72de6844d Merge branch 'master' of github.com:Alfresco/alfresco-community-repo into fix/MNT-24172-fixRendition2Recreation 2025-01-16 21:33:56 +05:30
mohit-singh4
d95a227bcc [fix/MNT-24172-fixRendition2Recreation] Fix for rendition2 recreation 2025-01-16 21:31:10 +05:30
mohit-singh4
8b3a6f9896 [fix/MNT-24172-fixRendition2Recreation] Fix for rendition2 recreation 2025-01-15 14:04:56 +05:30
mohit-singh4
8fd898024f [fix/MNT-24172-fixRendition2Recreation] Fix for Rendition2 recreation 2025-01-14 13:47:56 +05:30
mohit-singh4
d8e3a5e52f [fix/MNT-24172-fixRendition2Recreation] fix for Rendition2 recreation 2025-01-14 10:43:14 +05:30
mohit-singh4
f1ed3e41b5 [fix/MNT-24172-fixRendition2PdfIndex] fix for rendition2 recreation 2025-01-10 14:01:12 +05:30
mohit-singh4
cb5b09adac [fix/MNT-24172-fixRendition2PdfIndex] fix for rendition2 recreation 2025-01-10 13:46:56 +05:30
mohit-singh4
29c2f47257 [fix/MNT-24172-fixRendition2PdfIndex] fix for rendition2 recreation 2025-01-10 09:50:27 +05:30
mohit-singh4
b18d9e767f Merge branch 'master' of github.com:Alfresco/alfresco-community-repo into fix/MNT-24172-fixRendition2PdfIndex 2025-01-10 09:41:23 +05:30
mohit-singh4
9eef961683 Merge branch 'master' of github.com:Alfresco/alfresco-community-repo into fix/APPS-3154-fixForNumberOfFileField
# Conflicts:
#	repository/src/main/java/org/alfresco/repo/node/sizedetails/NodeSizeDetailsServiceImpl.java
2025-01-09 20:21:23 +05:30
mohit-singh4
98ec2a0419 Merge branch 'master' of github.com:Alfresco/alfresco-community-repo into fix/APPS-3154-fixForNumberOfFileField 2025-01-06 16:31:12 +05:30
mohit-singh4
af740b413f Merge branch 'master' of github.com:Alfresco/alfresco-community-repo into fix/APPS-3154-fixForNumberOfFileField 2024-12-23 11:39:27 +05:30
mohit-singh4
cba3a10a0e [APPS-3154] Fix for numberOfField in response 2024-12-17 15:56:47 +05:30
3 changed files with 1281 additions and 1284 deletions

View File

@@ -25,7 +25,7 @@
*/
package org.alfresco.model;
import org.alfresco.api.AlfrescoPublicApi;
import org.alfresco.api.AlfrescoPublicApi;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
@@ -36,20 +36,17 @@ import org.alfresco.service.namespace.QName;
public interface RenditionModel
{
/**
* Aspect added to renditions created by RenditionService2.
* Initially used to avoid duplicate rendition requests via the original RenditionService and the new one.
* Aspect added to renditions created by RenditionService2. Initially used to avoid duplicate rendition requests via the original RenditionService and the new one.
*/
static final QName ASPECT_RENDITION2 = QName.createQName(NamespaceService.RENDITION_MODEL_1_0_URI, "rendition2");
/**
* The source node's content hash code. Used to work out if a transform should replace the existing rendition,
* as transforms may be provided out of order.
* The source node's content hash code. Used to work out if a transform should replace the existing rendition, as transforms may be provided out of order.
*/
static final QName PROP_RENDITION_CONTENT_HASH_CODE = QName.createQName(NamespaceService.RENDITION_MODEL_1_0_URI, "contentHashCode");
/**
* @deprecated This rendition aspect will no longger be needed once the original RenditionService has been
* replaced by RenditionService2 which additionally uses a rendition2 aspect to mark its renditions.
* @deprecated This rendition aspect will no longger be needed once the original RenditionService has been replaced by RenditionService2 which additionally uses a rendition2 aspect to mark its renditions.
*/
@Deprecated
static final QName ASPECT_RENDITION = QName.createQName(NamespaceService.RENDITION_MODEL_1_0_URI, "rendition");
@@ -68,9 +65,10 @@ public interface RenditionModel
static final QName ASPECT_RENDITIONED = QName.createQName(NamespaceService.RENDITION_MODEL_1_0_URI, "renditioned");
static final QName ASSOC_RENDITION = QName.createQName(NamespaceService.RENDITION_MODEL_1_0_URI, "rendition");
/**
* @since 4.0.1
*/
static final QName ASPECT_PREVENT_RENDITIONS = QName.createQName(NamespaceService.RENDITION_MODEL_1_0_URI, "preventRenditions");
}

View File

@@ -2,7 +2,7 @@
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* Copyright (C) 2005 - 2025 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
@@ -25,6 +25,24 @@
*/
package org.alfresco.repo.rendition2;
import static org.alfresco.model.ContentModel.PROP_CONTENT;
import static org.alfresco.model.RenditionModel.PROP_RENDITION_CONTENT_HASH_CODE;
import static org.alfresco.service.namespace.QName.createQName;
import java.io.InputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.InitializingBean;
import org.alfresco.model.ContentModel;
import org.alfresco.model.RenditionModel;
import org.alfresco.repo.content.ContentServicePolicies;
@@ -51,23 +69,6 @@ import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.PropertyCheck;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.InitializingBean;
import java.io.InputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import static org.alfresco.model.ContentModel.PROP_CONTENT;
import static org.alfresco.model.RenditionModel.PROP_RENDITION_CONTENT_HASH_CODE;
import static org.alfresco.service.namespace.QName.createQName;
/**
* The Async Rendition service. Replaces the original deprecated RenditionService.
@@ -95,12 +96,10 @@ public class RenditionService2Impl implements RenditionService2, InitializingBea
abstract RenditionDefinition2 getRenditionDefinition();
void handleUnsupported(UnsupportedOperationException e)
{
}
{}
void throwIllegalStateExceptionIfAlreadyDone(int sourceContentHashCode)
{
}
{}
}
private TransactionService transactionService;
@@ -217,8 +216,7 @@ public class RenditionService2Impl implements RenditionService2, InitializingBea
@Override
public void transform(NodeRef sourceNodeRef, TransformDefinition transformDefinition)
{
requestAsyncTransformOrRendition(sourceNodeRef, new RenderOrTransformCallBack()
{
requestAsyncTransformOrRendition(sourceNodeRef, new RenderOrTransformCallBack() {
@Override
public String getName()
{
@@ -237,8 +235,7 @@ public class RenditionService2Impl implements RenditionService2, InitializingBea
@Override
public void render(NodeRef sourceNodeRef, String renditionName)
{
requestAsyncTransformOrRendition(sourceNodeRef, new RenderOrTransformCallBack()
{
requestAsyncTransformOrRendition(sourceNodeRef, new RenderOrTransformCallBack() {
@Override
public String getName()
{
@@ -261,7 +258,7 @@ public class RenditionService2Impl implements RenditionService2, InitializingBea
@Override
public void handleUnsupported(UnsupportedOperationException e)
{
// On the initial request for a rendition throw the exception.
// On the initial request for a rendition throw the exception.
NodeRef renditionNode = getRenditionNode(sourceNodeRef, renditionName);
if (renditionNode == null)
{
@@ -277,7 +274,7 @@ public class RenditionService2Impl implements RenditionService2, InitializingBea
int renditionContentHashCode = getRenditionContentHashCode(renditionNode);
if (logger.isDebugEnabled())
{
logger.debug(getName() + ": Source " + sourceContentHashCode + " rendition " + renditionContentHashCode+ " hashCodes");
logger.debug(getName() + ": Source " + sourceContentHashCode + " rendition " + renditionContentHashCode + " hashCodes");
}
if (renditionContentHashCode == sourceContentHashCode)
{
@@ -299,14 +296,14 @@ public class RenditionService2Impl implements RenditionService2, InitializingBea
if (!nodeService.exists(sourceNodeRef))
{
throw new IllegalArgumentException(renderOrTransform.getName()+ ": The supplied sourceNodeRef "+sourceNodeRef+" does not exist.");
throw new IllegalArgumentException(renderOrTransform.getName() + ": The supplied sourceNodeRef " + sourceNodeRef + " does not exist.");
}
RenditionDefinition2 renditionDefinition = renderOrTransform.getRenditionDefinition();
if (logger.isDebugEnabled())
{
logger.debug(renderOrTransform.getName()+ ": transform " +sourceNodeRef);
logger.debug(renderOrTransform.getName() + ": transform " + sourceNodeRef);
}
AtomicBoolean supported = new AtomicBoolean(true);
@@ -328,14 +325,13 @@ public class RenditionService2Impl implements RenditionService2, InitializingBea
}
String user = AuthenticationUtil.getRunAsUser();
RetryingTransactionHelper.RetryingTransactionCallback callback = () ->
{
RetryingTransactionHelper.RetryingTransactionCallback callback = () -> {
int sourceContentHashCode = getSourceContentHashCode(sourceNodeRef);
if (!supported.get())
{
if (logger.isDebugEnabled())
{
logger.debug(renderOrTransform.getName() +" is not supported. " +
logger.debug(renderOrTransform.getName() + " is not supported. " +
"The content might be too big or the source mimetype cannot be converted.");
}
failure(sourceNodeRef, renditionDefinition, sourceContentHashCode);
@@ -372,26 +368,24 @@ public class RenditionService2Impl implements RenditionService2, InitializingBea
public void failure(NodeRef sourceNodeRef, RenditionDefinition2 renditionDefinition, int transformContentHashCode)
{
// The original transaction may have already have failed
AuthenticationUtil.runAsSystem((AuthenticationUtil.RunAsWork<Void>) () ->
transactionService.getRetryingTransactionHelper().doInTransaction(() ->
{
consume(sourceNodeRef, null, renditionDefinition, transformContentHashCode);
return null;
}, false, true));
AuthenticationUtil.runAsSystem((AuthenticationUtil.RunAsWork<Void>) () -> transactionService.getRetryingTransactionHelper().doInTransaction(() -> {
consume(sourceNodeRef, null, renditionDefinition, transformContentHashCode);
return null;
}, false, true));
}
public void consume(NodeRef sourceNodeRef, InputStream transformInputStream, RenditionDefinition2 renditionDefinition,
int transformContentHashCode)
int transformContentHashCode)
{
int sourceContentHashCode = getSourceContentHashCode(sourceNodeRef);
if (logger.isDebugEnabled())
{
logger.debug("Consume: Source " + sourceContentHashCode + " and transform's source " + transformContentHashCode+" hashcodes");
logger.debug("Consume: Source " + sourceContentHashCode + " and transform's source " + transformContentHashCode + " hashcodes");
}
if (renditionDefinition instanceof TransformDefinition)
{
TransformDefinition transformDefinition = (TransformDefinition)renditionDefinition;
TransformDefinition transformDefinition = (TransformDefinition) renditionDefinition;
String targetMimetype = transformDefinition.getTargetMimetype();
if (AsynchronousExtractor.isMetadataExtractMimetype(targetMimetype))
{
@@ -413,7 +407,7 @@ public class RenditionService2Impl implements RenditionService2, InitializingBea
}
private void consumeExtractedMetadata(NodeRef nodeRef, int sourceContentHashCode, InputStream transformInputStream,
TransformDefinition transformDefinition, int transformContentHashCode)
TransformDefinition transformDefinition, int transformContentHashCode)
{
if (transformInputStream == null)
{
@@ -440,7 +434,7 @@ public class RenditionService2Impl implements RenditionService2, InitializingBea
}
private void consumeEmbeddedMetadata(NodeRef nodeRef, int sourceContentHashCode, InputStream transformInputStream,
TransformDefinition transformDefinition, int transformContentHashCode)
TransformDefinition transformDefinition, int transformContentHashCode)
{
if (transformInputStream == null)
{
@@ -468,7 +462,7 @@ public class RenditionService2Impl implements RenditionService2, InitializingBea
}
private void consumeTransformReply(NodeRef sourceNodeRef, InputStream transformInputStream,
TransformDefinition transformDefinition, int transformContentHashCode)
TransformDefinition transformDefinition, int transformContentHashCode)
{
if (logger.isDebugEnabled())
{
@@ -484,12 +478,10 @@ public class RenditionService2Impl implements RenditionService2, InitializingBea
}
/**
* Takes a transformation (InputStream) and attaches it as a rendition to the source node.
* Does nothing if there is already a newer rendition.
* If the transformInputStream is null, this is taken to be a transform failure.
* Takes a transformation (InputStream) and attaches it as a rendition to the source node. Does nothing if there is already a newer rendition. If the transformInputStream is null, this is taken to be a transform failure.
*/
private void consumeRendition(NodeRef sourceNodeRef, int sourceContentHashCode, InputStream transformInputStream,
RenditionDefinition2 renditionDefinition, int transformContentHashCode)
RenditionDefinition2 renditionDefinition, int transformContentHashCode)
{
String renditionName = renditionDefinition.getRenditionName();
if (transformContentHashCode != sourceContentHashCode)
@@ -507,93 +499,93 @@ public class RenditionService2Impl implements RenditionService2, InitializingBea
(transformInputStream == null ? " to null as the transform failed" : " to the transform result"));
}
AuthenticationUtil.runAsSystem((AuthenticationUtil.RunAsWork<Void>) () ->
transactionService.getRetryingTransactionHelper().doInTransaction(() ->
AuthenticationUtil.runAsSystem((AuthenticationUtil.RunAsWork<Void>) () -> transactionService.getRetryingTransactionHelper().doInTransaction(() -> {
// Ensure that the creation of a rendition does not cause updates to the modified, modifier properties on the source node
NodeRef renditionNode = getRenditionNode(sourceNodeRef, renditionName);
boolean createRenditionNode = renditionNode == null;
boolean sourceHasAspectRenditioned = nodeService.hasAspect(sourceNodeRef, RenditionModel.ASPECT_RENDITIONED);
try
{
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)
{
renditionNode = createRenditionNode(sourceNodeRef, renditionDefinition);
}
else if (!nodeService.hasAspect(renditionNode, RenditionModel.ASPECT_RENDITION2))
{
nodeService.addAspect(renditionNode, RenditionModel.ASPECT_RENDITION2, null);
if (logger.isDebugEnabled())
{
logger.debug("Added rendition2 aspect to rendition " + renditionName + " on " + sourceNodeRef);
}
}
if (logger.isDebugEnabled())
{
logger.debug("Set ThumbnailLastModified for " + renditionName);
}
setThumbnailLastModified(sourceNodeRef, renditionName);
if (transformInputStream != null)
{
// Ensure that the creation of a rendition does not cause updates to the modified, modifier properties on the source node
NodeRef renditionNode = getRenditionNode(sourceNodeRef, renditionName);
boolean createRenditionNode = renditionNode == null;
boolean sourceHasAspectRenditioned = nodeService.hasAspect(sourceNodeRef, RenditionModel.ASPECT_RENDITIONED);
try
{
ruleService.disableRuleType(RuleType.UPDATE);
behaviourFilter.disableBehaviour(sourceNodeRef, ContentModel.ASPECT_AUDITABLE);
behaviourFilter.disableBehaviour(sourceNodeRef, ContentModel.ASPECT_VERSIONABLE);
// Set or replace rendition content
ContentWriter contentWriter = contentService.getWriter(renditionNode, DEFAULT_RENDITION_CONTENT_PROP, true);
String targetMimetype = renditionDefinition.getTargetMimetype();
contentWriter.setMimetype(targetMimetype);
contentWriter.setEncoding(DEFAULT_ENCODING);
ContentWriter renditionWriter = contentWriter;
renditionWriter.putContent(transformInputStream);
// If they do not exist create the rendition association and the rendition node.
if (createRenditionNode)
ContentReader contentReader = renditionWriter.getReader();
long sizeOfRendition = contentReader.getSize();
if (sizeOfRendition > 0L)
{
renditionNode = createRenditionNode(sourceNodeRef, renditionDefinition);
}
else if (!nodeService.hasAspect(renditionNode, RenditionModel.ASPECT_RENDITION2))
{
nodeService.addAspect(renditionNode, RenditionModel.ASPECT_RENDITION2, null);
if (logger.isDebugEnabled())
{
logger.debug("Added rendition2 aspect to rendition " + renditionName + " on " + sourceNodeRef);
}
}
if (logger.isDebugEnabled())
{
logger.debug("Set ThumbnailLastModified for " + renditionName);
}
setThumbnailLastModified(sourceNodeRef, renditionName);
if (transformInputStream != null)
{
try
{
// Set or replace rendition content
ContentWriter contentWriter = contentService.getWriter(renditionNode, DEFAULT_RENDITION_CONTENT_PROP, true);
String targetMimetype = renditionDefinition.getTargetMimetype();
contentWriter.setMimetype(targetMimetype);
contentWriter.setEncoding(DEFAULT_ENCODING);
ContentWriter renditionWriter = contentWriter;
renditionWriter.putContent(transformInputStream);
ContentReader contentReader = renditionWriter.getReader();
long sizeOfRendition = contentReader.getSize();
if (sizeOfRendition > 0L)
{
if (logger.isDebugEnabled()) {
logger.debug("Set rendition hashcode for " + renditionName);
}
nodeService.setProperty(renditionNode, RenditionModel.PROP_RENDITION_CONTENT_HASH_CODE, transformContentHashCode);
}
else
{
logger.error("Transform was zero bytes for " + renditionName + " on " + sourceNodeRef);
clearRenditionContentData(renditionNode);
}
}
catch (Exception e)
{
logger.error("Failed to copy transform InputStream into rendition " + renditionName + " on " + sourceNodeRef);
throw e;
logger.debug("Set rendition hashcode for " + renditionName);
}
nodeService.setProperty(renditionNode, RenditionModel.PROP_RENDITION_CONTENT_HASH_CODE, transformContentHashCode);
}
else
{
logger.error("Transform was zero bytes for " + renditionName + " on " + sourceNodeRef);
clearRenditionContentData(renditionNode);
}
if (!sourceHasAspectRenditioned)
{
nodeService.addAspect(sourceNodeRef, RenditionModel.ASPECT_RENDITIONED, null);
}
}
catch (Exception e)
{
throw new RenditionService2Exception(TRANSFORMING_ERROR_MESSAGE + e.getMessage(), e);
logger.error("Failed to copy transform InputStream into rendition " + renditionName + " on " + sourceNodeRef);
throw e;
}
finally
{
behaviourFilter.enableBehaviour(sourceNodeRef, ContentModel.ASPECT_AUDITABLE);
behaviourFilter.enableBehaviour(sourceNodeRef, ContentModel.ASPECT_VERSIONABLE);
ruleService.enableRuleType(RuleType.UPDATE);
}
return null;
}, false, true));
}
else
{
clearRenditionContentData(renditionNode);
}
if (!sourceHasAspectRenditioned)
{
nodeService.addAspect(sourceNodeRef, RenditionModel.ASPECT_RENDITIONED, null);
}
}
catch (Exception e)
{
throw new RenditionService2Exception(TRANSFORMING_ERROR_MESSAGE + e.getMessage(), e);
}
finally
{
behaviourFilter.enableBehaviour(sourceNodeRef, ContentModel.ASPECT_AUDITABLE);
behaviourFilter.enableBehaviour(sourceNodeRef, ContentModel.ASPECT_VERSIONABLE);
ruleService.enableRuleType(RuleType.UPDATE);
}
return null;
}, false, true));
}
}
@@ -634,14 +626,14 @@ public class RenditionService2Impl implements RenditionService2, InitializingBea
if (logger.isTraceEnabled())
{
logger.trace("Setting thumbnail last modified date to " + lastModifiedValue +" on source node: " + sourceNodeRef);
logger.trace("Setting thumbnail last modified date to " + lastModifiedValue + " on source node: " + sourceNodeRef);
}
if (nodeService.hasAspect(sourceNodeRef, ContentModel.ASPECT_THUMBNAIL_MODIFICATION))
{
List<String> thumbnailMods = (List<String>) nodeService.getProperty(sourceNodeRef, ContentModel.PROP_LAST_THUMBNAIL_MODIFICATION_DATA);
String target = null;
for (String currThumbnailMod: thumbnailMods)
for (String currThumbnailMod : thumbnailMods)
{
if (currThumbnailMod.startsWith(prefix))
{
@@ -665,8 +657,7 @@ public class RenditionService2Impl implements RenditionService2, InitializingBea
}
/**
* Returns the hash code of the source node's content url. As transformations may be returned in a different
* sequences to which they were requested, this is used work out if a rendition should be replaced.
* Returns the hash code of the source node's content url. As transformations may be returned in a different sequences to which they were requested, this is used work out if a rendition should be replaced.
*/
private int getSourceContentHashCode(NodeRef sourceNodeRef)
{
@@ -675,7 +666,7 @@ public class RenditionService2Impl implements RenditionService2, InitializingBea
if (contentData != null)
{
// Originally we used the contentData URL, but that is not enough if the mimetype changes.
String contentString = contentData.getContentUrl()+contentData.getMimetype();
String contentString = contentData.getContentUrl() + contentData.getMimetype();
if (contentString != null)
{
hashCode = contentString.hashCode();
@@ -685,13 +676,11 @@ public class RenditionService2Impl implements RenditionService2, InitializingBea
}
/**
* Returns the hash code of source node's content url on the rendition node (node may be null) if it does not exist.
* Used work out if a rendition should be replaced. {@code -2} is returned if the rendition does not exist or was
* not created by RenditionService2. {@code -1} is returned if there was no source content or the rendition failed.
* Returns the hash code of source node's content url on the rendition node (node may be null) if it does not exist. Used work out if a rendition should be replaced. {@code -2} is returned if the rendition does not exist or was not created by RenditionService2. {@code -1} is returned if there was no source content or the rendition failed.
*/
private int getRenditionContentHashCode(NodeRef renditionNode)
{
if ( renditionNode == null || !nodeService.hasAspect(renditionNode, RenditionModel.ASPECT_RENDITION2))
if (renditionNode == null || !nodeService.hasAspect(renditionNode, RenditionModel.ASPECT_RENDITION2))
{
return RENDITION2_DOES_NOT_EXIST;
}
@@ -699,7 +688,7 @@ public class RenditionService2Impl implements RenditionService2, InitializingBea
Serializable hashCode = nodeService.getProperty(renditionNode, PROP_RENDITION_CONTENT_HASH_CODE);
return hashCode == null
? SOURCE_HAS_NO_CONTENT
: (int)hashCode;
: (int) hashCode;
}
private NodeRef getRenditionNode(NodeRef sourceNodeRef, String renditionName)
@@ -769,15 +758,25 @@ public class RenditionService2Impl implements RenditionService2, InitializingBea
{
logger.debug("Cleared rendition hashcode");
}
if (nodeService.hasAspect(renditionNode, RenditionModel.ASPECT_RENDITION2))
{
nodeService.removeAspect(renditionNode, RenditionModel.ASPECT_RENDITION2);
if (logger.isDebugEnabled())
{
logger.debug("Cleared rendition2 aspect");
}
}
}
}
/**
* This method checks whether the specified source node is of a content class which has been registered for
* rendition prevention.
* This method checks whether the specified source node is of a content class which has been registered for rendition prevention.
*
* @param sourceNode the node to check.
* @throws RenditionService2PreventedException if the source node is configured for rendition prevention.
* @param sourceNode
* the node to check.
* @throws RenditionService2PreventedException
* if the source node is configured for rendition prevention.
*/
// This code is based on the old RenditionServiceImpl.checkSourceNodeForPreventionClass(...)
private void checkSourceNodeForPreventionClass(NodeRef sourceNode)
@@ -823,7 +822,7 @@ public class RenditionService2Impl implements RenditionService2, InitializingBea
for (ChildAssociationRef childAssoc : childAsocs)
{
NodeRef renditionNode = childAssoc.getChildRef();
NodeRef renditionNode = childAssoc.getChildRef();
if (isRenditionAvailable(sourceNodeRef, renditionNode))
{
result.add(childAssoc);
@@ -833,8 +832,7 @@ public class RenditionService2Impl implements RenditionService2, InitializingBea
}
/**
* Indicates if the rendition is available. Failed renditions (there was an error) don't have a contentUrl
* and out of date renditions or those still being created don't have a matching contentHashCode.
* Indicates if the rendition is available. Failed renditions (there was an error) don't have a contentUrl and out of date renditions or those still being created don't have a matching contentHashCode.
*/
public boolean isRenditionAvailable(NodeRef sourceNodeRef, NodeRef renditionNode)
{
@@ -842,6 +840,7 @@ public class RenditionService2Impl implements RenditionService2, InitializingBea
if (nodeService.hasAspect(renditionNode, RenditionModel.ASPECT_RENDITION2))
{
Serializable contentUrl = nodeService.getProperty(renditionNode, ContentModel.PROP_CONTENT);
if (contentUrl == null)
{
available = false;
@@ -852,7 +851,7 @@ public class RenditionService2Impl implements RenditionService2, InitializingBea
int renditionContentHashCode = getRenditionContentHashCode(renditionNode);
if (logger.isDebugEnabled())
{
logger.debug("isRenditionAvailable source " + sourceContentHashCode + " and rendition " + renditionContentHashCode+" hashcodes");
logger.debug("isRenditionAvailable source " + sourceContentHashCode + " and rendition " + renditionContentHashCode + " hashcodes");
}
if (sourceContentHashCode != renditionContentHashCode)
{
@@ -892,19 +891,17 @@ public class RenditionService2Impl implements RenditionService2, InitializingBea
}
ChildAssociationRef childAssoc = renditions.get(0);
NodeRef renditionNode = childAssoc.getChildRef();
return !isRenditionAvailable(sourceNodeRef, renditionNode) ? null: childAssoc;
return !isRenditionAvailable(sourceNodeRef, renditionNode) ? null : childAssoc;
}
}
@Override
public void clearRenditionContentDataInTransaction(NodeRef renditionNode)
{
AuthenticationUtil.runAsSystem((AuthenticationUtil.RunAsWork<Void>) () ->
transactionService.getRetryingTransactionHelper().doInTransaction(() ->
{
clearRenditionContentData(renditionNode);
return null;
}, false, true));
AuthenticationUtil.runAsSystem((AuthenticationUtil.RunAsWork<Void>) () -> transactionService.getRetryingTransactionHelper().doInTransaction(() -> {
clearRenditionContentData(renditionNode);
return null;
}, false, true));
}
@Override
@@ -949,5 +946,4 @@ public class RenditionService2Impl implements RenditionService2, InitializingBea
}
}
}
}