001/*
002 * (C) Copyright 2010 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 * Contributors:
016 * Nuxeo - initial API and implementation
017 */
018
019package org.nuxeo.ecm.platform.rendition.extension;
020
021import java.util.List;
022
023import org.nuxeo.ecm.core.api.Blob;
024import org.nuxeo.ecm.core.api.DocumentModel;
025import org.nuxeo.ecm.platform.rendition.Rendition;
026import org.nuxeo.ecm.platform.rendition.service.RenditionDefinition;
027
028/**
029 * Interface to hide providers of {@link Rendition}. A provider could be converter based, template based, or Automation
030 * based
031 *
032 * @since 5.6
033 * @author <a href="mailto:tdelprat@nuxeo.com">Tiry</a>
034 */
035public interface RenditionProvider {
036
037    /**
038     * Test if the Rendition is available on the given DocumentModel
039     */
040    boolean isAvailable(DocumentModel doc, RenditionDefinition definition);
041
042    /**
043     * Generate the rendition Blobs for a given {@link RenditionDefinition}. Return is a List of Blob for bigger
044     * flexibility (typically HTML rendition with resources)
045     *
046     * @param doc the target {@link DocumentModel}
047     * @param definition the {@link RenditionDefinition} to use
048     * @return The list of Blobs
049     */
050    List<Blob> render(DocumentModel doc, RenditionDefinition definition);
051
052    /**
053     * Gets the optional {@link org.nuxeo.ecm.platform.rendition.Constants#RENDITION_VARIANT_PROPERTY
054     * RENDITION_VARIANT_PROPERTY} value for a given {@link RenditionDefinition}.
055     *
056     * @param doc the target document
057     * @param definition the rendition definition to use
058     * @return the generated {@link org.nuxeo.ecm.platform.rendition.Constants#RENDITION_VARIANT_PROPERTY
059     *         RENDITION_VARIANT_PROPERTY} value, or {@code null}
060     * @since 8.1
061     */
062    default String getVariant(DocumentModel doc, RenditionDefinition definition) {
063        return null;
064    }
065
066}