001/*
002 *  Licensed to the Apache Software Foundation (ASF) under one
003 *  or more contributor license agreements.  See the NOTICE file
004 *  distributed with this work for additional information
005 *  regarding copyright ownership.  The ASF licenses this file
006 *  to you under the Apache License, Version 2.0 (the
007 *  "License"); you may not use this file except in compliance
008 *  with the License.  You may obtain a copy of the License at
009 * 
010 *    https://www.apache.org/licenses/LICENSE-2.0
011 * 
012 *  Unless required by applicable law or agreed to in writing,
013 *  software distributed under the License is distributed on an
014 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 *  KIND, either express or implied.  See the License for the
016 *  specific language governing permissions and limitations
017 *  under the License.
018 * 
019 */
020package org.apache.directory.api.ldap.model.schema;
021
022import java.util.List;
023
024import org.slf4j.Logger;
025
026
027/**
028 * Interface for handling errors that occur during schema processing.
029 * 
030 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
031 */
032public interface SchemaErrorHandler
033{
034    /**
035     * Handle schema error. Implementation is free to log the error, ignore the error or
036     * do anything else. If the error is not ignored then implementation should remember
037     * the error and reflect that in its state. Other methods of this interface should
038     * behave in accord with that state.
039     * 
040     * @param log Logger that could be used to record error messages.
041     * @param message Error message.
042     * @param exception Exception (if available). Exception may provide more structured description
043     *                  of the error. But it may not be available for all error states. However, only
044     *                  those invocations of handle() method that contain an exceptions are considered to
045     *                  be errors. The implementation may ignore any invocations that do not contain exception.
046     */
047    void handle( Logger log, String message, Throwable exception );
048
049    /**
050     * Returns true if the implementation handled at least one error.
051     * This method is used for checks whether the schema processing should proceed or
052     * stop, e.g. in cases when we want to stop processing on errors.
053     * 
054     * @return <tt>true</tt> if at least one error was met
055     */
056    boolean wasError();
057    
058    /**
059     * Returns list of handled errors.
060     * 
061     * @return The list of found errors
062     */
063    List<Throwable> getErrors();
064    
065    /**
066     * Resets implementation state. This cleans up any recorded errors.
067     */
068    void reset();
069}