001/* 002 * Copyright 2011 Anyware Services 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 */ 016package org.ametys.plugins.webcontentio; 017 018import java.io.File; 019import java.io.IOException; 020import java.util.Map; 021 022import org.ametys.cms.repository.Content; 023import org.ametys.web.repository.content.ModifiableWebContent; 024import org.ametys.web.repository.page.ModifiablePage; 025 026/** 027 * Component responsible for populating a Content from an existing file.<br> 028 * Contents are meant to be provided totally empty, 029 * so that it is up to the implementation to set every metadata on the Content, 030 * even the content type, the workflow id, ... 031 */ 032public interface ContentImporter 033{ 034 /** 035 * Extracts file content and populates the given {@link Content}. 036 * Typical usage is to provide a newly created empty Content. 037 * @param file the source. 038 * @param content the {@link Content} to be populated. 039 * @param params in/out params to set and get additional data to and from the importer. 040 * @throws IOException if an error occurs processing the stream. 041 */ 042 public void importContent(File file, ModifiableWebContent content, Map<String, String> params) throws IOException; 043 044 /** 045 * Returns all mime types handled by this importer. 046 * @return all mime types handled by this importer. 047 */ 048 public String[] getMimeTypes(); 049 050 /** 051 * Post treatment after import process 052 * @param page The created page 053 * @param content The created content 054 * @param file The imported file 055 * @throws IOException if an error occurred 056 */ 057 public void postTreatment(ModifiablePage page, Content content, File file) throws IOException; 058}