001/*
002 * (C) Copyright 2017-2020 Nuxeo (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *    http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Kevin Leturc <kleturc@nuxeo.com>
018 *     Anahide Tchertchian
019 */
020package org.nuxeo.runtime;
021
022import java.util.List;
023import java.util.function.Predicate;
024
025import org.nuxeo.runtime.RuntimeMessage.Level;
026
027/**
028 * Handles runtime message.
029 *
030 * @since 9.10
031 */
032public interface RuntimeMessageHandler {
033
034    /**
035     * Adds the following message.
036     *
037     * @since 11.3
038     */
039    void addMessage(RuntimeMessage message);
040
041    /**
042     * Returns all messages strings, filtered by given level.
043     *
044     * @since 11.3
045     */
046    List<String> getMessages(Level level);
047
048    /**
049     * Returns all messages strings, filtered by given predicate.
050     *
051     * @since 11.3
052     */
053    List<String> getMessages(Predicate<RuntimeMessage> predicate);
054
055    /**
056     * Returns all messages, filtered by given level.
057     *
058     * @since 11.3
059     */
060    List<RuntimeMessage> getRuntimeMessages(Level level);
061
062    /**
063     * Returns all messages, filtered by given predicate.
064     *
065     * @since 11.3
066     */
067    List<RuntimeMessage> getRuntimeMessages(Predicate<RuntimeMessage> predicate);
068
069    /**
070     * Warning messages don't block server startup.
071     *
072     * @deprecated since 11.3, use {@link #addMessage(RuntimeMessage)} instead.
073     */
074    @Deprecated
075    void addWarning(String message);
076
077    /**
078     * @return an unmodifiable {@link List} of warning messages
079     * @deprecated since 11.3, use {@link #getMessages(Level)} instead
080     */
081    @Deprecated
082    List<String> getWarnings();
083
084    /**
085     * Add new error.
086     * <p>
087     * Error messages block server startup in strict mode.
088     *
089     * @deprecated since 11.3, use {@link #addMessage(RuntimeMessage)} instead.
090     */
091    @Deprecated
092    void addError(String message);
093
094    /**
095     * @return an unmodifiable {@link List} of error messages
096     * @deprecated since 11.3, use {@link #getMessages(Level)} instead
097     */
098    @Deprecated
099    List<String> getErrors();
100
101}