001/*
002 * The contents of this file are subject to the terms of the Common Development and
003 * Distribution License (the License). You may not use this file except in compliance with the
004 * License.
005 *
006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
007 * specific language governing permission and limitations under the License.
008 *
009 * When distributing Covered Software, include this CDDL Header Notice in each file and include
010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
011 * Header, with the fields enclosed by brackets [] replaced by your own identifying
012 * information: "Portions Copyright [year] [name of copyright owner]".
013 *
014 * Copyright 2008 Sun Microsystems, Inc.
015 * Portions Copyright 2013-2016 ForgeRock AS.
016 */
017package org.forgerock.opendj.server.core;
018
019import org.forgerock.opendj.ldap.LdapPromise;
020import org.forgerock.opendj.ldap.LdapResultHandler;
021import org.forgerock.opendj.ldif.EntryReader;
022
023/**
024 * A data provider which supports LDIF import functionality.
025 * <p>
026 * FIXME: the async APIs used below are a bad fit. We do not want to return an
027 * {@link org.forgerock.opendj.ldap.LdapException}. We really need a more generic promises API.
028 * <p>
029 * FIXME: it would be nice if we can use EntryReader, however we may need to provide an optimized
030 * implementation for use in multi-threaded imports. E.g. performing DN checking as early as
031 * possible before doing schema validation.
032 * <p>
033 * FIXME: import allows you to append, merge, replace entries. Do we need to expose that here?
034 */
035public interface ImportableDataProvider {
036
037    /**
038     * Returns the ID of this data provider.
039     *
040     * @return The ID of this data provider.
041     */
042    DataProviderID getDataProviderID();
043
044    /**
045     * Imports the contents of this data provider from the provided entry
046     * reader.
047     * <p>
048     * Note that the server will not explicitly initialize this data provider
049     * before calling this method.
050     *
051     * @param reader
052     *            The entry reader.
053     * @param handler
054     *            A handler which will be notified when the import completes.
055     * @return A promise representing the completion of the import.
056     */
057    LdapPromise<Void> importEntries(EntryReader reader, LdapResultHandler<Void> handler);
058}