001/*
002 * (C) Copyright 2002-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 *
014 * Contributors:
015 *     Nuxeo - initial API and implementation
016 *
017 */
018
019package org.nuxeo.ecm.platform.convert.plugins;
020
021import java.io.Serializable;
022import java.util.Map;
023
024import org.nuxeo.ecm.core.api.Blob;
025import org.nuxeo.ecm.core.api.blobholder.BlobHolder;
026import org.nuxeo.ecm.core.convert.api.ConversionException;
027import org.nuxeo.ecm.core.convert.extension.Converter;
028import org.nuxeo.ecm.core.convert.extension.ConverterDescriptor;
029
030/**
031 * Zip2Html converter.
032 *
033 * @author ldoguin
034 */
035public class Zip2HtmlConverter implements Converter {
036
037    public BlobHolder convert(BlobHolder blobHolder, Map<String, Serializable> parameters) throws ConversionException {
038        Blob blob = blobHolder.getBlob();
039        String mimeType = blob.getMimeType();
040        if (!mimeType.equals("application/zip")) {
041            throw new ConversionException("not a zip file");
042        }
043        return new ZipCachableBlobHolder(blob);
044    }
045
046    public void init(ConverterDescriptor descriptor) {
047    }
048
049}