001/*
002        $Id: PermissionDeniedException.java 3207 2009-04-09 06:48:11Z gregory $
003
004        Copyright (C) 2006 Gregory Vincic, Olle Mansson
005        Copyright (C) 2007 Gregory Vincic
006
007        This file is part of Proteios.
008        Available at http://www.proteios.org/
009
010        Proteios is free software; you can redistribute it and/or modify it
011        under the terms of the GNU General Public License as published by
012        the Free Software Foundation; either version 2 of the License, or
013        (at your option) any later version.
014
015        Proteios is distributed in the hope that it will be useful, but
016        WITHOUT ANY WARRANTY; without even the implied warranty of
017        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
018        General Public License for more details.
019
020        You should have received a copy of the GNU General Public License
021        along with this program; if not, write to the Free Software
022        Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
023        02111-1307, USA.
024*/
025package org.proteios.core;
026
027/**
028        This exception is thrown when trying to load or manipulate an 
029        item in the database and you don't have the required permission.
030
031        @author Nicklas
032        @version 2.0
033*/
034@SuppressWarnings("serial")
035public class PermissionDeniedException
036        extends BaseException
037{
038        /**
039                Creates a new <code>PermissionDeniedException</code>. The error 
040                message produced will look like: <code>Permission denied: Not 
041                allowed to write</code>
042
043                @param permission The permission requested. Should be one of the 
044                        values defined in the {@link Permission} class}
045        */
046        public PermissionDeniedException(Permission permission)
047        {
048                super("Permission denied: Not allowed to "+
049                        (permission == Permission.DENIED ? "access" : permission.toString()));
050        }
051
052        /**
053                Creates a new <code>PermissionDeniedException</code>. The error 
054                message produced will look like: <code>Permission denied: 
055                Not allowed to read User[ID=1]</code>
056
057                @param permission The permission requested. Should be one of the 
058                        values defined in the {@link Permission} class}
059                @param what A description of what access is denied to, for
060                        example: User[ID=1]
061        */
062        public PermissionDeniedException(Permission permission, String what)
063        {
064                super("Permission denied: Not allowed to "+
065                        (permission == Permission.DENIED ? "access" : permission.toString())+" "+what);
066        }
067
068        /**
069                Creates a new <code>PermissionDeniedException</code>. The error
070                message produced will look like: 
071                <code>Permission denied: <i>message</i></code>
072
073                @param message The message explaining why permission was denied
074        */
075        public PermissionDeniedException(String message)
076        {
077                super("Permission denied: "+message);
078        }
079
080}
081
082
083