001/*
002 *  Copyright 2017 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.odfsync.cdmfr.transformers;
017
018import java.io.IOException;
019import java.util.Map;
020
021import org.apache.cocoon.ProcessingException;
022import org.w3c.dom.Document;
023import org.xml.sax.SAXException;
024
025/**
026 * Interface for sync transformer objects.
027 */
028public interface CDMFrSyncTransformer
029{
030    /**
031     * Analyze the document and tell if it's support or not by the current transformer.
032     * @param document The document to analyze.
033     * @return TRUE if the document is supported by the transformer, otherwise FALSE.
034     */
035    public boolean supports(Document document);
036    
037    /**
038     * Transform the document to a generic document designed for Ametys importers and synchronizers.
039     * @param document The document to transform.
040     * @param parameters additional parameters for transformation
041     * @return The transformed document.
042     * @throws IOException if an error occurs.
043     * @throws SAXException if an error occurs.
044     * @throws ProcessingException if an error occurs.
045     */
046    public Document transform(Document document, Map<String, Object> parameters) throws IOException, SAXException, ProcessingException;
047}