use of org.alfresco.repo.rendition.RenditionNodeManager in project alfresco-repository by Alfresco.
the class AbstractRenderingEngine method createOrUpdateRendition.
/**
* @param sourceNode The node that has been rendered
* @param tempRendition The relationship between the node and its rendition
* @param renditionDefinition The definition of the rendition that has just been performed.
* In the case of a composite rendition, this parameter refers
* to that CompositeRendition and not to any of its component renditions.
* @return ChildAssociationRef
*/
private ChildAssociationRef createOrUpdateRendition(NodeRef sourceNode, ChildAssociationRef tempRendition, RenditionDefinition renditionDefinition) {
NodeRef tempRenditionNode = tempRendition.getChildRef();
RenditionLocation renditionLocation = resolveRenditionLocation(sourceNode, renditionDefinition, tempRenditionNode);
QName renditionQName = renditionDefinition.getRenditionName();
RenditionNodeManager renditionNodeManager = new RenditionNodeManager(sourceNode, tempRenditionNode, renditionLocation, renditionDefinition, nodeService, renditionService, behaviourFilter);
ChildAssociationRef renditionNode = renditionNodeManager.findOrCreateRenditionNode();
// Set the name property on the rendition if it has not already been
// set.
String renditionName = getRenditionName(tempRenditionNode, renditionLocation, renditionDefinition);
// to manager
nodeService.setProperty(renditionNode.getChildRef(), ContentModel.PROP_NAME, renditionName);
// Add temporary aspect for temporary rendition node
// When this node id deleted, will not appear in user's trashcan
nodeService.addAspect(tempRendition.getChildRef(), ContentModel.ASPECT_TEMPORARY, null);
// Delete the temporary rendition.
nodeService.removeChildAssociation(tempRendition);
if (logger.isDebugEnabled()) {
logger.debug("Removed temporary child-association " + tempRendition);
}
// Handle the rendition aspects
manageRenditionAspects(sourceNode, renditionNode);
// Verify that everything has gone to plan, and nothing got lost on the way!
ChildAssociationRef renditionAssoc = renditionService.getRenditionByName(sourceNode, renditionQName);
if (renditionAssoc == null) {
String msg = "A rendition of name: " + renditionQName + " should have been created for source node: " + sourceNode;
throw new RenditionServiceException(msg);
}
// Return the link between the source and the new, final rendition
return renditionAssoc;
}
Aggregations