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