001/*
002 * (C) Copyright 2012 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 *     ataillefer
018 */
019package org.nuxeo.ecm.diff.service;
020
021import java.io.Serializable;
022
023import org.custommonkey.xmlunit.Diff;
024import org.nuxeo.ecm.core.api.CoreSession;
025import org.nuxeo.ecm.core.api.DocumentModel;
026import org.nuxeo.ecm.diff.model.DocumentDiff;
027
028/**
029 * Handles a diff between two documents.
030 *
031 * @author <a href="mailto:ataillefer@nuxeo.com">Antoine Taillefer</a>
032 * @since 5.6
033 */
034public interface DocumentDiffService extends Serializable {
035
036    /**
037     * Makes a diff between leftDoc and rightDoc. Returns a DocumentDiff object that wraps the differences, schema by
038     * schema and field by field.
039     *
040     * @param session the session
041     * @param leftDoc the left doc
042     * @param rightDoc the right doc
043     * @return the document diff
044     */
045    DocumentDiff diff(CoreSession session, DocumentModel leftDoc, DocumentModel rightDoc);
046
047    /**
048     * Makes a diff between leftXML and rightXML. Returns a DocumentDiff object that wraps the differences, schema by
049     * schema and field by field.
050     *
051     * @param leftXML the left XML
052     * @param rightXML the right XML
053     * @return the document diff
054     */
055    DocumentDiff diff(String leftXML, String rightXML);
056
057    /**
058     * Configures XMLUnit.
059     */
060    void configureXMLUnit();
061
062    /**
063     * Configures the diff.
064     *
065     * @param diff the diff
066     */
067    void configureDiff(Diff diff);
068
069}