001/*
002 * (C) Copyright 2006-2008 Nuxeo SAS (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 *     Nuxeo - initial API and implementation
016 *
017 * $Id$
018 */
019
020package org.nuxeo.ecm.platform.importer.factories;
021
022import java.io.IOException;
023
024import org.nuxeo.ecm.core.api.CoreSession;
025import org.nuxeo.ecm.core.api.DocumentModel;
026import org.nuxeo.ecm.platform.importer.base.GenericThreadedImportTask;
027import org.nuxeo.ecm.platform.importer.source.SourceNode;
028
029/**
030 * Interface for DocumentModel factory
031 *
032 * @author Thierry Delprat
033 * @author Antoine Taillefer
034 */
035public interface ImporterDocumentModelFactory {
036
037    public boolean isTargetDocumentModelFolderish(SourceNode node);
038
039    public DocumentModel createFolderishNode(CoreSession session, DocumentModel parent, SourceNode node) throws IOException;
040
041    public DocumentModel createLeafNode(CoreSession session, DocumentModel parent, SourceNode node) throws IOException;
042
043    /**
044     * Defines the process to execute when a folderish node creation error occurs.
045     * <p>
046     * This method is called by
047     * {@link GenericThreadedImportTask#doCreateFolderishNode(DocumentModel parent, SourceNode node)} if an exception is
048     * thrown by {@link #createFolderishNode(CoreSession, DocumentModel, SourceNode)}.
049     * </p>
050     *
051     * @return true if the global import task should continue after processing the error, false if it should be stopped
052     *         immediately after processing the error.
053     */
054    public boolean processFolderishNodeCreationError(CoreSession session, DocumentModel parent, SourceNode node);
055
056    /**
057     * Defines the process to execute when a leaf node creation error occurs.
058     * <p>
059     * This method is called by {@link GenericThreadedImportTask#doCreateLeafNode(DocumentModel parent, SourceNode node)}
060     * if an exception is thrown by {@link #createLeafNode(CoreSession, DocumentModel, SourceNode)}.
061     * </p>
062     *
063     * @return true if the global import task should continue after processing the error, false if it should be stopped
064     *         immediately after processing the error.
065     */
066    public boolean processLeafNodeCreationError(CoreSession session, DocumentModel parent, SourceNode node);
067
068}