001/*
002 *  Copyright 2010 Anyware Services
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 */
016package org.ametys.runtime.exception;
017
018/**
019 * Exception representing a 503 response.
020 */
021public class ServiceUnavailableException extends RuntimeException
022{
023    private boolean _forceMaintenanceMode = true;
024    
025    /**
026     * Constructs a new ServiceUnavailableException.
027     */
028    public ServiceUnavailableException()
029    {
030        super();
031    }
032    
033    /**
034     * Constructs a new ServiceUnavailableException with the specified cause.
035     * @param message the cause of the exception.
036     */
037    public ServiceUnavailableException(String message)
038    {
039        super(message);
040    }
041    
042    /**
043     * Constructs a new ServiceUnavailableException with the specified cause.
044     * @param message the cause of the exception.
045     * @param forceMaintenanceMode <code>true</code> to force the maintenance mode, <code>true</code> is the default value.
046     */
047    public ServiceUnavailableException(String message, boolean forceMaintenanceMode)
048    {
049        super(message);
050        _forceMaintenanceMode = forceMaintenanceMode;
051    }
052    
053    /**
054     * Check if the exception force the maintenance mode.
055     * @return <code>true</code> if the maintenance mode has to be forced
056     */
057    public boolean forceMaintenanceMode()
058    {
059        return _forceMaintenanceMode;
060    }
061}