001/* 002 * (C) Copyright 2006-2008 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 * 019 * $Id$ 020 */ 021 022package org.nuxeo.ecm.platform.picture.api.adapters; 023 024import java.io.IOException; 025import java.util.ArrayList; 026import java.util.List; 027import java.util.Map; 028 029import org.nuxeo.ecm.core.api.Blob; 030import org.nuxeo.ecm.core.api.DocumentModel; 031import org.nuxeo.ecm.core.api.PropertyException; 032import org.nuxeo.ecm.platform.picture.api.ImageInfo; 033 034public interface PictureResourceAdapter { 035 036 void setDocumentModel(DocumentModel doc); 037 038 /** 039 * @deprecated since 5.7. Use 040 * {@link #fillPictureViews(org.nuxeo.ecm.core.api.Blob, String, String, java.util.ArrayList)} instead. 041 */ 042 @Deprecated 043 boolean createPicture(Blob fileContent, String filename, String title, 044 ArrayList<Map<String, Object>> pictureConversions) throws IOException; 045 046 /** 047 * Fill this Picture views using the given {@code pictureConversions} and {@code blob} to compute the picture views. 048 * <p> 049 * The {@code blob} is converted to fit the defined {@code pictureConversions}. 050 * 051 * @since 5.7 052 */ 053 boolean fillPictureViews(Blob blob, String filename, String title, ArrayList<Map<String, Object>> pictureConversions) 054 throws IOException; 055 056 /** 057 * This method just delegate the job to 058 * {@link PictureResourceAdapter#fillPictureViews(Blob, String, String, ArrayList)} by passing null instead of 059 * statics picture templates. <br/> 060 * <br/> 061 * This will fill the picture views by using the registered picture templates. 062 * 063 * @see {@link PictureResourceAdapter#fillPictureViews(Blob, String, String, ArrayList)} 064 * @since 6.9.6 065 */ 066 boolean fillPictureViews(Blob blob, String filename, String title) throws IOException; 067 068 /** 069 * Pre-fill this Picture views using the given {@code pictureConversions} and {@code blob}. 070 * <p> 071 * The {@code blob} is not converted and just stored as the Blob of the picture views. 072 * 073 * @since 5.7 074 */ 075 void preFillPictureViews(Blob blob, List<Map<String, Object>> pictureConversions, ImageInfo imageInfo) 076 throws IOException; 077 078 void doRotate(int angle); 079 080 void doCrop(String coords); 081 082 Blob getPictureFromTitle(String title) throws PropertyException; 083 084 /** 085 * Returns the XPath of the given view name, or {@code null} if the view is not found on the Picture. 086 * 087 * @param viewName the view name 088 */ 089 String getViewXPath(String viewName); 090 091 /** 092 * Convenience method to get the XPath of the first view of the Picture. 093 * 094 * @return the XPath of the first view 095 */ 096 String getFirstViewXPath(); 097 098}