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 */ 040 List<RenditionDefinition> getDeclaredRenditionDefinitions(); 041 042 /** 043 * Returns a {@code List} of registered {@code RenditionDefinition} matching a given provider type 044 */ 045 List<RenditionDefinition> getDeclaredRenditionDefinitionsForProviderType(String providerType); 046 047 /** 048 * Returns a {@code List} of {@code RenditionDefinition} available on the given Document. The order of the List does 049 * not depend on the registering order. 050 */ 051 List<RenditionDefinition> getAvailableRenditionDefinitions(DocumentModel doc); 052 053 /** 054 * Render a document based on the given rendition definition name and returns the stored Rendition 055 * {@link DocumentRef}. 056 * <p> 057 * Only the user launching the render operation has the Read right on the returned document. 058 * 059 * @param sourceDocument the document to render 060 * @param renditionDefinitionName the rendition definition to use 061 * @return the {@code DocumentRef} of the newly created Rendition document. 062 */ 063 DocumentRef storeRendition(DocumentModel sourceDocument, String renditionDefinitionName); 064 065 /** 066 * Return the {@link Rendition} object for the given {@link DocumentModel} and a rendition definition name. 067 * <p> 068 * A stored rendition is returned if found and up to date, a new Rendition is created otherwise. 069 * 070 * @param doc the document to render 071 * @param renditionName the name of the rendition definition 072 * @return the {@link Rendition} object 073 */ 074 Rendition getRendition(DocumentModel doc, String renditionName); 075 076 /** 077 * Return the {@link Rendition} object for the given {@link DocumentModel} and a rendition definition name. 078 * <p> 079 * A stored rendition is returned if found and up to date, a new (live) Rendition is created otherwise. 080 * <p> 081 * If store parameter is true, the new created rendition is stored too and returned 082 * 083 * @param doc the document to render 084 * @param renditionName the name of the rendition definition 085 * @param store indicates if the rendition must be stored 086 * @return the {@link Rendition} object 087 */ 088 Rendition getRendition(DocumentModel doc, String renditionName, boolean store); 089 090 /** 091 * Returns a {@code List} of {@code Rendition} available on the given Document. 092 * <p> 093 * The order of the List does not depend on the registering order. 094 * <p> 095 * The returned rendition may be live or stored 096 */ 097 List<Rendition> getAvailableRenditions(DocumentModel doc); 098 099 /** 100 * Returns a {@code List} of {@code Rendition} available on the given Document. 101 * <p> 102 * If {@code onlyVisible} is true, returns only the rendition marked as visible. 103 * <p> 104 * The order of the List does not depend on the registering order. 105 * <p> 106 * The returned rendition may be live or stored 107 * 108 * @since 7.2 109 */ 110 List<Rendition> getAvailableRenditions(DocumentModel doc, boolean onlyVisible); 111 112 /** 113 * Query and delete stored renditions where the related version or live document does not exist anymore. 114 * 115 * @since 8.4 116 */ 117 void deleteStoredRenditions(String repositoryName); 118}