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: NameNotFoundException.java,v 1.2 2008/06/25 05:43:44 qcheng Exp $
026 *
027 */
028
029
030
031package com.sun.identity.policy;
032
033/**
034 * Exception thrown if an object such as policy, rule or 
035 * referral for the given name does not exist.
036 *
037 * @supported.all.api
038 */
039public class NameNotFoundException extends PolicyException {
040
041    private String name;
042    private int type;
043
044    /**
045     * Constructor
046     * @param msg exception message
047     * @param name name that was not found
048     * @param type type of object whose name was not found
049     */
050    public NameNotFoundException(String msg, String name, int type) {
051        super(msg);
052        this.name = name;
053        this.type = type;
054        fillInStackTrace();
055    }
056
057    /**
058     * Constructor
059     * @param rbName Resource bundle name of exception message
060     * @param errCode id used with resource bundle to get error message
061     * @param args any arguments for message formatting. null if no
062     * additional arguments are necessary
063     * @param name name that was not found
064     * @param type type of object whose name was not found
065     */
066    public NameNotFoundException(String rbName, String errCode,         
067        Object[] args, String name, int type) 
068    {
069        super(rbName, errCode, args,null);
070        fillInStackTrace();
071        this.name = name;
072        this.type = type;
073    }
074
075    /**
076     * Constructor
077     * @param rbName Resource bundle name of exception message
078     * @param errCode id used with resource bundle to get error message
079     * @param args any arguments for message formatting. null if no
080     * additional arguments are necessary
081     * @param t nested root cause exception
082     * @param name name that was not found
083     * @param type type of object whose name was not found
084     */
085    public NameNotFoundException(String rbName, String errCode,         
086        Object[] args, Throwable t, String name, int type) 
087    {
088        super(rbName, errCode, args,t);
089        fillInStackTrace();
090        this.name = name;
091        this.type = type;
092    }
093
094    /**
095     * Constructor
096     * @param t nested root cause exception
097     * @param name name that was not found
098     * @param type type of object whose name was not found
099     */
100    public NameNotFoundException(Throwable t, String name, int type) {
101        super(t);
102        this.name = name;
103        this.type = type;
104        fillInStackTrace();
105    }
106
107    /**
108     * Gets the name that was not found.
109     *
110     * @return name that was not found.
111     */
112    public String getName() {
113        return (name);
114    }
115
116    /**
117     * Gets the type of object which encountered
118     * the invalid name. The defined objects are <code>POLICY</code>,
119     * <code>RULE</code>, <code>ORGANIZATION</code>,
120     * <code>USER_COLLECTION</code>
121     * <code>RESPONSE_PROVIDER_COLLECTION</code>
122     * <code>CONDITION_COLLECTION</code>
123     * <code>REFERRAL_COLLECTION</code>
124     * <code>REFERRAL_TYPE</code>
125     * <code>SUBJECT_TYPE</code>
126     * and <code>SERVICE</code>
127     *
128     * @return type of object for which name was not found
129     */
130    public int getObjectType() {
131        return (type);
132    }
133}