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