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.service;
020
021import java.util.List;
022
023import org.nuxeo.ecm.core.api.DocumentModel;
024import org.nuxeo.ecm.core.api.DocumentRef;
025import org.nuxeo.ecm.platform.rendition.Rendition;
026
027/**
028 * Service handling Rendition Definitions and actual render based on a Rendition Definition
029 *
030 * @author <a href="mailto:troger@nuxeo.com">Thomas Roger</a>
031 * @author <a href="mailto:tdelprat@nuxeo.com">Tiry</a>
032 * @since 5.4.1
033 */
034public interface RenditionService {
035
036    /**
037     * Returns a {@code List} of registered {@code RenditionDefinition}. The order of the List does not depend on the
038     * registering order.
039     * @deprecated since 7.2. Not used.
040     */
041    @Deprecated
042    List<RenditionDefinition> getDeclaredRenditionDefinitions();
043
044    /**
045     * Returns a {@code List} of registered {@code RenditionDefinition} matching a given provider type
046     * @deprecated since 7.2. Not used
047     */
048    @Deprecated
049    List<RenditionDefinition> getDeclaredRenditionDefinitionsForProviderType(String providerType);
050
051    /**
052     * Returns a {@code List} of {@code RenditionDefinition} available on the given Document. The order of the List does
053     * not depend on the registering order.
054     */
055    List<RenditionDefinition> getAvailableRenditionDefinitions(DocumentModel doc);
056
057    /**
058     * Render a document based on the given rendition definition name and returns the stored Rendition
059     * {@link DocumentRef}.
060     * <p>
061     * Only the user launching the render operation has the Read right on the returned document.
062     *
063     * @param sourceDocument the document to render
064     * @param renditionDefinitionName the rendition definition to use
065     * @return the {@code DocumentRef} of the newly created Rendition document.
066     */
067    DocumentRef storeRendition(DocumentModel sourceDocument, String renditionDefinitionName);
068
069    /**
070     * Return the {@link Rendition} object for the given {@link DocumentModel} and a rendition definition name.
071     * <p>
072     * A stored rendition is returned if found and up to date, a new Rendition is created otherwise.
073     *
074     * @param doc the document to render
075     * @param renditionName the name of the rendition definition
076     * @return the {@link Rendition} object
077     */
078    Rendition getRendition(DocumentModel doc, String renditionName);
079
080    /**
081     * Return the {@link Rendition} object for the given {@link DocumentModel} and a rendition definition name.
082     * <p>
083     * A stored rendition is returned if found and up to date, a new (live) Rendition is created otherwise.
084     * <p>
085     * If store parameter is true, the new created rendition is stored too and returned
086     *
087     * @param doc the document to render
088     * @param renditionName the name of the rendition definition
089     * @param store indicates if the rendition must be stored
090     * @return the {@link Rendition} object
091     */
092    Rendition getRendition(DocumentModel doc, String renditionName, boolean store);
093
094    /**
095     * Returns a {@code List} of {@code Rendition} available on the given Document.
096     * <p>
097     * The order of the List does not depend on the registering order.
098     * <p>
099     * The returned rendition may be live or stored
100     */
101    List<Rendition> getAvailableRenditions(DocumentModel doc);
102
103    /**
104     * Returns a {@code List} of {@code Rendition} available on the given Document.
105     * <p>
106     * If {@code onlyVisible} is true, returns only the rendition marked as visible.
107     * <p>
108     * The order of the List does not depend on the registering order.
109     * <p>
110     * The returned rendition may be live or stored
111     *
112     * @since 7.2
113     */
114    List<Rendition> getAvailableRenditions(DocumentModel doc, boolean onlyVisible);
115
116}