View Javadoc
1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    * 
10   *    https://www.apache.org/licenses/LICENSE-2.0
11   * 
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License.
18   * 
19   */
20  package org.apache.directory.api.ldap.model.schema;
21  
22  import java.util.List;
23  
24  import org.slf4j.Logger;
25  
26  
27  /**
28   * Interface for handling errors that occur during schema processing.
29   * 
30   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
31   */
32  public interface SchemaErrorHandler
33  {
34      /**
35       * Handle schema error. Implementation is free to log the error, ignore the error or
36       * do anything else. If the error is not ignored then implementation should remember
37       * the error and reflect that in its state. Other methods of this interface should
38       * behave in accord with that state.
39       * 
40       * @param log Logger that could be used to record error messages.
41       * @param message Error message.
42       * @param exception Exception (if available). Exception may provide more structured description
43       *                  of the error. But it may not be available for all error states. However, only
44       *                  those invocations of handle() method that contain an exceptions are considered to
45       *                  be errors. The implementation may ignore any invocations that do not contain exception.
46       */
47      void handle( Logger log, String message, Throwable exception );
48  
49      /**
50       * Returns true if the implementation handled at least one error.
51       * This method is used for checks whether the schema processing should proceed or
52       * stop, e.g. in cases when we want to stop processing on errors.
53       * 
54       * @return <tt>true</tt> if at least one error was met
55       */
56      boolean wasError();
57      
58      /**
59       * Returns list of handled errors.
60       * 
61       * @return The list of found errors
62       */
63      List<Throwable> getErrors();
64      
65      /**
66       * Resets implementation state. This cleans up any recorded errors.
67       */
68      void reset();
69  }