001/*
002 * (C) Copyright 2002 - 2006 Nuxeo SARL <http://nuxeo.com> and others
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     Nuxeo - initial API and implementation
011 *
012 *
013 * $Id: Plugin.java 4449 2006-10-19 11:51:56Z janguenot $
014 */
015
016package org.nuxeo.ecm.platform.filemanager.service.extension;
017
018import java.io.IOException;
019import java.io.Serializable;
020import java.util.List;
021
022import org.nuxeo.ecm.core.api.Blob;
023import org.nuxeo.ecm.core.api.CoreSession;
024import org.nuxeo.ecm.core.api.DocumentModel;
025import org.nuxeo.ecm.platform.filemanager.service.FileManagerService;
026import org.nuxeo.ecm.platform.types.TypeManager;
027
028/**
029 * FileManagerServiceCommon plugin default interface.
030 * <p>
031 * Responsible for converting given sources to a given type of Document using default.
032 *
033 * @author <a href="mailto:andreas.kalogeropoulos@nuxeo.com">Andreas Kalogeropoulos</a>
034 * @author Anahide Tchertchian
035 */
036public interface FileImporter extends Serializable, Comparable<FileImporter> {
037
038    // XXX: OG: why make plugin serializable?
039
040    /**
041     * Gets the plugin name.
042     *
043     * @return a string holding the plugin name
044     */
045    String getName();
046
047    /**
048     * Returns the document type configured for this {@code FileImporter}, {@code null} if no document type is
049     * configured.
050     *
051     * @since 5.5
052     */
053    String getDocType();
054
055    /**
056     * Sets the document type configured for this importer.
057     * <p>
058     *
059     * @since 5.5
060     */
061    void setDocType(String docType);
062
063    /**
064     * Gets filters.
065     * <p>
066     * The filters are all the mime/type this plugin can deal with.
067     *
068     * @return list of string holding each filters.
069     */
070    List<String> getFilters();
071
072    /**
073     * Sets plugin name.
074     *
075     * @param name a string holding the name
076     */
077    void setName(String name);
078
079    /**
080     * Sets filters.
081     * <p>
082     * The filters are all the mime/types this plugin can deal with.
083     *
084     * @param filters a list of strings representing each filter
085     */
086    void setFilters(List<String> filters);
087
088    /**
089     * Embeds a reference to the holding FileManagerService instance to be able to reuse generic file creation utility
090     * methods in specific plugin implementations.
091     *
092     * @param fileManagerService instance where the Plugin is registered as a contribution
093     */
094    void setFileManagerService(FileManagerService fileManagerService);
095
096    /**
097     * Tests whether plugin is suitable for the given mimetype.
098     *
099     * @param mimeType the mimetype to test
100     */
101    boolean matches(String mimeType);
102
103    /**
104     * Creates the document.
105     *
106     * @param documentManager the manager used to create the Document
107     * @param content the content of the File
108     * @param path the path of current document
109     * @param overwrite a boolean deciding whether to create or update if we find a document with the same fileName
110     * @param filename the filename of the File
111     */
112    DocumentModel create(CoreSession documentManager, Blob content, String path, boolean overwrite, String filename,
113            TypeManager typeService) throws IOException;
114
115    boolean isEnabled();
116
117    void setEnabled(boolean enabled);
118
119    /**
120     * Returns the plugin order for sorting.
121     */
122    Integer getOrder();
123
124    /**
125     * Sets the plugin order for sorting.
126     */
127    void setOrder(Integer order);
128
129}