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: ObjectInUseException.java,v 1.2 2008/06/25 05:43:44 qcheng Exp $
026 *
027 */
028
029
030
031
032package com.sun.identity.policy;
033
034
035/**
036 * Exception thrown to indicate that an object you are trying to
037 * remove is in use and therefore can not be removed.
038 *
039 * @supported.all.api
040 */
041public class ObjectInUseException extends PolicyException {
042
043    private String name;
044    private Object user;
045
046    /**
047     * Constructs an <code>ObjectInUseException</code> object
048     * @param msg exception message
049     * @param name name of the object that is in use 
050     * @param user object that is using the object you are trying to remove
051     */
052    public ObjectInUseException(String msg, String name, Object user) {
053        super(msg);
054        this.name = name;
055        this.user = user;
056    }
057
058    /**
059     * Constructs an <code>ObjectInUseException</code> object
060     * @param rbName Resource bundle name of exception message
061     * @param errCode id used with resource bundle to get error message
062     * @param args any arguments for message formatting. null if no
063     * additional arguments are necessary
064     * @param name name of the object that is in use
065     * @param user object that is using the object you are trying to remove
066     */
067    public ObjectInUseException(String rbName, String errCode,         
068        Object[] args, String name, Object user) 
069    {
070        super(rbName, errCode, args,null);
071        this.name = name;
072        this.user = user;
073    }
074
075    /**
076     * Constructs an <code>ObjectInUseException</code> object
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 of the object that is in use
083     * @param user object that is using the object you are trying to remove
084     */
085    public ObjectInUseException(String rbName, String errCode,         
086        Object[] args, Throwable t, String name, Object user) 
087    {
088        super(rbName, errCode, args,t);
089        this.name = name;
090        this.user = user;
091    }
092
093    /**
094     * Constructs an <code>ObjectInUseException</code> object
095     * @param t nested root cause exception
096     * @param name name of the object that is in use 
097     * @param user object that is using the object you are trying to remove
098     */
099    public ObjectInUseException(Throwable t, String name, Object user) {
100        super(t);
101        this.name = name;
102        this.user = user;
103    }
104
105    /**
106     * Gets the name that is in use.
107     *
108     * @return name of the object that is in use
109     */
110    public String getName() {
111        return (name);
112    }
113}