001/*
002 * (C) Copyright 2012 Nuxeo SA (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     ataillefer
016 */
017package org.nuxeo.ecm.diff.service;
018
019import java.io.Serializable;
020
021import org.custommonkey.xmlunit.Diff;
022import org.nuxeo.ecm.core.api.CoreSession;
023import org.nuxeo.ecm.core.api.DocumentModel;
024import org.nuxeo.ecm.diff.model.DocumentDiff;
025
026/**
027 * Handles a diff between two documents.
028 *
029 * @author <a href="mailto:ataillefer@nuxeo.com">Antoine Taillefer</a>
030 * @since 5.6
031 */
032public interface DocumentDiffService extends Serializable {
033
034    /**
035     * Makes a diff between leftDoc and rightDoc. Returns a DocumentDiff object that wraps the differences, schema by
036     * schema and field by field.
037     *
038     * @param session the session
039     * @param leftDoc the left doc
040     * @param rightDoc the right doc
041     * @return the document diff
042     */
043    DocumentDiff diff(CoreSession session, DocumentModel leftDoc, DocumentModel rightDoc);
044
045    /**
046     * Makes a diff between leftXML and rightXML. Returns a DocumentDiff object that wraps the differences, schema by
047     * schema and field by field.
048     *
049     * @param leftXML the left XML
050     * @param rightXML the right XML
051     * @return the document diff
052     */
053    DocumentDiff diff(String leftXML, String rightXML);
054
055    /**
056     * Configures XMLUnit.
057     */
058    void configureXMLUnit();
059
060    /**
061     * Configures the diff.
062     *
063     * @param diff the diff
064     */
065    void configureDiff(Diff diff);
066
067}