001/* 002 * (C) Copyright 2010 Nuxeo SAS (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * Contributors: 014 * Nuxeo - initial API and implementation 015 */ 016 017package org.nuxeo.ecm.platform.rendition.impl; 018 019import java.util.List; 020 021import org.nuxeo.ecm.core.api.Blob; 022import org.nuxeo.ecm.core.api.DocumentModel; 023import org.nuxeo.ecm.core.api.blobholder.BlobHolder; 024import org.nuxeo.ecm.platform.rendition.Rendition; 025import org.nuxeo.ecm.platform.rendition.service.RenditionDefinition; 026 027/** 028 * Implementation of the {@link Rendition} interface for rendition that are stored in the Repository 029 * 030 * @author <a href="mailto:tdelprat@nuxeo.com">Tiry</a> 031 */ 032public class StoredRendition extends AbstractRendition implements Rendition { 033 034 protected final DocumentModel stored; 035 036 public StoredRendition(DocumentModel stored, RenditionDefinition definition) { 037 super(definition); 038 this.stored = stored; 039 } 040 041 @Override 042 public boolean isStored() { 043 return true; 044 } 045 046 @Override 047 public boolean isCompleted() { 048 return true; 049 } 050 051 @Override 052 public Blob getBlob() { 053 return stored.getAdapter(BlobHolder.class).getBlob(); 054 } 055 056 @Override 057 public List<Blob> getBlobs() { 058 return stored.getAdapter(BlobHolder.class).getBlobs(); 059 } 060 061 @Override 062 public DocumentModel getHostDocument() { 063 return stored; 064 } 065 066}