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