001/*
002 * (C) Copyright 2013-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 *     Florent Guillaume
018 */
019package org.nuxeo.ecm.platform.picture.api.adapters;
020
021import java.util.List;
022import java.util.Map;
023
024import org.nuxeo.ecm.core.api.Blob;
025import org.nuxeo.ecm.core.api.PropertyException;
026import org.nuxeo.ecm.platform.picture.api.ImageInfo;
027
028/**
029 * Picture adapter that creates no picture views at all.
030 */
031public class NoPictureAdapter extends AbstractPictureAdapter {
032
033    public static final String ORIGINAL_VIEW_NAME = "Original";
034
035    @Override
036    public void doRotate(int angle) {
037    }
038
039    @Override
040    public void doCrop(String coords) {
041    }
042
043    @Override
044    public Blob getPictureFromTitle(String title) throws PropertyException {
045        if (ORIGINAL_VIEW_NAME.equals(title)) {
046            return (Blob) doc.getPropertyValue("file:content");
047        }
048        return null;
049    }
050
051    @Override
052    public String getFirstViewXPath() {
053        return "file:"; // "content" added by caller
054    }
055
056    @Override
057    public String getViewXPath(String viewName) {
058        if (ORIGINAL_VIEW_NAME.equals(viewName)) {
059            return getFirstViewXPath();
060        }
061        return null;
062    }
063
064    @Override
065    public boolean fillPictureViews(Blob blob, String filename, String title,
066            List<Map<String, Object>> pictureConversions) {
067        return true;
068    }
069
070    @Override
071    public void preFillPictureViews(Blob blob, List<Map<String, Object>> pictureConversions, ImageInfo imageInfo) {
072    }
073
074}