001/* 002 * CDDL HEADER START 003 * 004 * The contents of this file are subject to the terms of the 005 * Common Development and Distribution License, Version 1.0 only 006 * (the "License"). You may not use this file except in compliance 007 * with the License. 008 * 009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt 010 * or http://forgerock.org/license/CDDLv1.0.html. 011 * See the License for the specific language governing permissions 012 * and limitations under the License. 013 * 014 * When distributing Covered Code, include this CDDL HEADER in each 015 * file and include the License file at legal-notices/CDDLv1_0.txt. 016 * If applicable, add the following below this CDDL HEADER, with the 017 * fields enclosed by brackets "[]" replaced with your own identifying 018 * information: 019 * Portions Copyright [yyyy] [name of copyright owner] 020 * 021 * CDDL HEADER END 022 * 023 * 024 * Copyright 2014-2015 ForgeRock AS 025 */ 026package org.opends.server.backends.pluggable.spi; 027 028import java.io.Closeable; 029 030import org.forgerock.opendj.ldap.ByteSequence; 031import org.forgerock.opendj.ldap.ByteString; 032 033/** 034 * Allows to run an import. For performance reasons, imports are run without transactions. 035 */ 036public interface Importer extends Closeable 037{ 038 /** 039 * Creates a new tree identified by the provided name. 040 * 041 * @param name 042 * the tree name 043 */ 044 void createTree(TreeName name); 045 046 /** 047 * Creates a record with the provided key and value in the tree identified by the provided name. 048 * 049 * @param treeName 050 * the tree name 051 * @param key 052 * the new record's key 053 * @param value 054 * the new record's value 055 */ 056 void put(TreeName treeName, ByteSequence key, ByteSequence value); 057 058 /** 059 * Deletes the record with the provided key, in the tree whose name is provided. 060 * 061 * @param treeName 062 * the tree name 063 * @param key 064 * the key of the record to delete 065 * @return {@code true} if the record could be deleted, {@code false} otherwise 066 */ 067 boolean delete(TreeName treeName, ByteSequence key); 068 069 /** 070 * Reads the record's value associated to the provided key, in the tree whose name is provided. 071 * 072 * @param treeName 073 * the tree name 074 * @param key 075 * the record's key 076 * @return the record's value, or {@code null} if none exists 077 */ 078 ByteString read(TreeName treeName, ByteSequence key); 079 080 /** {@inheritDoc} */ 081 @Override 082 void close(); 083}