Search in sources :

Example 1 with RenditionNodeManager

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;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) QName(org.alfresco.service.namespace.QName) RenditionNodeManager(org.alfresco.repo.rendition.RenditionNodeManager) RenditionLocation(org.alfresco.repo.rendition.RenditionLocation) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) RenditionServiceException(org.alfresco.service.cmr.rendition.RenditionServiceException)

Aggregations

RenditionLocation (org.alfresco.repo.rendition.RenditionLocation)1 RenditionNodeManager (org.alfresco.repo.rendition.RenditionNodeManager)1 RenditionServiceException (org.alfresco.service.cmr.rendition.RenditionServiceException)1 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)1 NodeRef (org.alfresco.service.cmr.repository.NodeRef)1 QName (org.alfresco.service.namespace.QName)1