Search in sources :

Example 1 with RenditionPreventedException

use of org.alfresco.service.cmr.rendition.RenditionPreventedException in project alfresco-repository by Alfresco.

the class RenditionServiceImpl method checkSourceNodeForPreventionClass.

/**
 * 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 RenditionPreventedException if the source node is configured for rendition prevention.
 * @since 4.0.1
 * @see RenditionPreventionRegistry
 */
private void checkSourceNodeForPreventionClass(NodeRef sourceNode) {
    // We'll not check the source node for null and leave that to the rendering action.
    if (sourceNode != null && nodeService.exists(sourceNode)) {
        Set<QName> nodeContentClasses = nodeService.getAspects(sourceNode);
        nodeContentClasses.add(nodeService.getType(sourceNode));
        for (QName contentClass : nodeContentClasses) {
            if (renditionPreventionRegistry.isContentClassRegistered(contentClass)) {
                StringBuilder msg = new StringBuilder();
                msg.append("Node ").append(sourceNode).append(" cannot be renditioned as it is of class ").append(contentClass);
                if (log.isDebugEnabled()) {
                    log.debug(msg.toString());
                }
                throw new RenditionPreventedException(msg.toString());
            }
        }
    }
}
Also used : QName(org.alfresco.service.namespace.QName) RenditionPreventedException(org.alfresco.service.cmr.rendition.RenditionPreventedException)

Aggregations

RenditionPreventedException (org.alfresco.service.cmr.rendition.RenditionPreventedException)1 QName (org.alfresco.service.namespace.QName)1