001/**
002 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003 *
004 * Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
005 *
006 * The contents of this file are subject to the terms
007 * of the Common Development and Distribution License
008 * (the License). You may not use this file except in
009 * compliance with the License.
010 *
011 * You can obtain a copy of the License at
012 * https://opensso.dev.java.net/public/CDDLv1.0.html or
013 * opensso/legal/CDDLv1.0.txt
014 * See the License for the specific language governing
015 * permission and limitations under the License.
016 *
017 * When distributing Covered Code, include this CDDL
018 * Header Notice in each file and include the License file
019 * at opensso/legal/CDDLv1.0.txt.
020 * If applicable, add the following below the CDDL Header,
021 * with the fields enclosed by brackets [] replaced by
022 * your own identifying information:
023 * "Portions Copyrighted [year] [name of copyright owner]"
024 *
025 * $Id: LimitExceededException.java,v 1.2 2008/06/25 05:43:44 qcheng Exp $
026 *
027 */
028
029
030package com.sun.identity.policy;
031
032/**
033 * Exception thrown if any configured limit is exceeded
034 *
035 * @supported.all.api
036 */
037public class LimitExceededException extends PolicyException {
038
039    private String name;
040    private int type;
041
042    /**
043     * Constructor
044     * @param msg exception message
045     * @param name name of the object for which limit was exceeded
046     * @param type type of object for which the limit was exceeded
047     */
048    public LimitExceededException(String msg, String name, int type) {
049        super(msg);
050        this.name = name;
051        this.type = type;
052        fillInStackTrace();
053    }
054
055    /**
056     * Constructor
057     * @param rbName Resource bundle name of exception message
058     * @param errCode id used with resource bundle to get error message
059     * @param args any arguments for message formatting. null if no
060     * additional arguments are necessary
061     * @param name of the object for which limit was exceeded
062     * @param type of object for which the limit was exceeded
063     */
064    public LimitExceededException(String rbName, String errCode,         
065        Object[] args, String name, int type) 
066    {
067        super(rbName, errCode, args,null);
068        fillInStackTrace();
069        this.name = name;
070        this.type = type;
071    }
072
073    /**
074     * Constructor
075     * @param rbName Resource bundle name of exception message
076     * @param errCode id used with resource bundle to get error message
077     * @param args any arguments for message formatting. null if no
078     * additional arguments are necessary
079     * @param t nested root cause exception
080     * @param name of the object for which limit was exceeded
081     * @param type of object for which the limit was exceeded
082     */
083    public LimitExceededException(String rbName, String errCode,         
084        Object[] args, Throwable t, String name, int type) 
085    {
086        super(rbName, errCode, args,t);
087        fillInStackTrace();
088        this.name = name;
089        this.type = type;
090    }
091
092    /**
093     * Constructor
094     * @param t nested root cause exception
095     * @param name of the object for which limit was exceeded
096     * @param type of object for which the limit was exceeded
097     */
098    public LimitExceededException(Throwable t, String name, int type) {
099        super(t);
100        this.name = name;
101        this.type = type;
102        fillInStackTrace();
103    }
104
105    /**
106     * Constructor
107     * @param msg exception message
108     * @param t nested root cause exception
109     * @param name of the object for which limit was exceeded
110     * @param type of object for which the limit was exceeded
111     */
112    public LimitExceededException(String msg, Throwable t,
113        String name, int type) {
114        super(msg, t);
115        this.name = name;
116        this.type = type;
117        fillInStackTrace();
118    }
119
120    /**
121     * Gets the name of the object for which limit was exceeded
122     * @return name of the object for which limit was exceeded
123     */
124    public String getName() {
125        return (name);
126    }
127
128    /**
129     * Gets the type of object which encountered
130     * the invalid name. The defined objects are <code>POLICY</code>,
131     * <code>RULE</code>, <code>ORGANIZATION</code>,
132     * <code>USER_COLLECTION</code>
133     * <code>RESPONSE_PROVIDER_COLLECTION</code>
134     * <code>CONDITION_COLLECTION</code>
135     * <code>REFERRAL_COLLECTION</code>
136     * <code>REFERRAL_TYPE</code>
137     * <code>SUBJECT_TYPE</code>
138     * and <code>SERVICE</code>
139     *
140     * @return type of object for which limit was exceeded
141     */
142    public int getObjectType() {
143        return (type);
144    }
145}