001/* 002 * (C) Copyright 2010-2016 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 * 016 * Contributors: 017 * Nuxeo - initial API and implementation 018 */ 019package org.nuxeo.ecm.platform.rendition.service; 020 021import java.io.Serializable; 022import java.util.List; 023import java.util.Map; 024 025import org.nuxeo.ecm.core.api.DocumentModel; 026import org.nuxeo.ecm.core.api.DocumentRef; 027import org.nuxeo.ecm.platform.rendition.Rendition; 028 029/** 030 * Service handling Rendition Definitions and actual render based on a Rendition Definition 031 * 032 * @author <a href="mailto:troger@nuxeo.com">Thomas Roger</a> 033 * @author <a href="mailto:tdelprat@nuxeo.com">Tiry</a> 034 * @since 5.4.1 035 */ 036public interface RenditionService { 037 038 /** 039 * Returns a {@code List} of registered {@code RenditionDefinition}. The order of the List does not depend on the 040 * registering order. 041 * 042 * @deprecated since 7.2 because unused 043 */ 044 @Deprecated 045 List<RenditionDefinition> getDeclaredRenditionDefinitions(); 046 047 /** 048 * Returns a {@code List} of registered {@code RenditionDefinition} matching a given provider type 049 * 050 * @deprecated since 7.2 because unused 051 */ 052 @Deprecated 053 List<RenditionDefinition> getDeclaredRenditionDefinitionsForProviderType(String providerType); 054 055 /** 056 * Returns a {@code List} of {@code RenditionDefinition} available on the given Document. The order of the List does 057 * not depend on the registering order. 058 */ 059 List<RenditionDefinition> getAvailableRenditionDefinitions(DocumentModel doc); 060 061 /** 062 * Render a document based on the given rendition definition name and returns the stored Rendition 063 * {@link DocumentRef}. 064 * <p> 065 * Only the user launching the render operation has the Read right on the returned document. 066 * 067 * @param sourceDocument the document to render 068 * @param renditionDefinitionName the rendition definition to use 069 * @return the {@code DocumentRef} of the newly created Rendition document. 070 */ 071 DocumentRef storeRendition(DocumentModel sourceDocument, String renditionDefinitionName); 072 073 /** 074 * Return the {@link Rendition} object for the given {@link DocumentModel} and a rendition definition name. 075 * <p> 076 * A stored rendition is returned if found and up to date, a new Rendition is created otherwise. 077 * 078 * @param doc the document to render 079 * @param renditionName the name of the rendition definition 080 * @return the {@link Rendition} object 081 */ 082 Rendition getRendition(DocumentModel doc, String renditionName); 083 084 /** 085 * Return the default {@link Rendition} object for the given {@link DocumentModel}. 086 * <p> 087 * A stored rendition is returned if found and up to date, a new Rendition is created otherwise. 088 * 089 * @param doc the document to render 090 * @param reason the reason the rendition is being rendered (optional) 091 * @param extendedInfos map of extended info added in the default rendition computation (optional) 092 * @since 9.3 093 * @return the default {@link Rendition} object 094 */ 095 Rendition getDefaultRendition(DocumentModel doc, String reason, Map<String, Serializable> extendedInfos); 096 097 /** 098 * Return the {@link Rendition} object for the given {@link DocumentModel} and a rendition definition name. 099 * <p> 100 * A stored rendition is returned if found and up to date, a new (live) Rendition is created otherwise. 101 * <p> 102 * If store parameter is true, the new created rendition is stored too and returned 103 * 104 * @param doc the document to render 105 * @param renditionName the name of the rendition definition 106 * @param store indicates if the rendition must be stored 107 * @return the {@link Rendition} object 108 */ 109 Rendition getRendition(DocumentModel doc, String renditionName, boolean store); 110 111 /** 112 * Returns a {@code List} of {@code Rendition} available on the given Document. 113 * <p> 114 * The order of the List does not depend on the registering order. 115 * <p> 116 * The returned rendition may be live or stored 117 */ 118 List<Rendition> getAvailableRenditions(DocumentModel doc); 119 120 /** 121 * Returns a {@code List} of {@code Rendition} available on the given Document. 122 * <p> 123 * If {@code onlyVisible} is true, returns only the rendition marked as visible. 124 * <p> 125 * The order of the List does not depend on the registering order. 126 * <p> 127 * The returned rendition may be live or stored 128 * 129 * @since 7.2 130 */ 131 List<Rendition> getAvailableRenditions(DocumentModel doc, boolean onlyVisible); 132 133 /** 134 * Query and delete stored renditions where the related version or live document does not exist anymore. 135 * 136 * @since 8.4 137 */ 138 void deleteStoredRenditions(String repositoryName); 139}