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: NameAlreadyExistsException.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 a name of an object such as policy, rule or 034 * referral already exists (used by another object of the same type) 035 * 036 * @supported.all.api 037 */ 038public class NameAlreadyExistsException extends PolicyException { 039 040 private String name; 041 private int type; 042 043 /** 044 * Constructs a <code>NameAlreadyExistsException</code> instance. 045 * 046 * @param msg exception message 047 * @param name name that already exists 048 * @param type type of object whose name already exist 049 */ 050 public NameAlreadyExistsException(String msg, String name, int type) { 051 super(msg); 052 this.name = name; 053 this.type = type; 054 fillInStackTrace(); 055 } 056 057 /** 058 * Constructs a <code>NameAlreadyExistsException</code> instance. 059 * With localized error message 060 * 061 * @param rbName Resource bundle name 062 * @param errorCode error code to use access the resource bundle 063 * @param args parameters for message formatting 064 * @param name name that already exists 065 * @param type type of object whose name already exist 066 */ 067 public NameAlreadyExistsException(String rbName,String errorCode, 068 Object[] args, String name, int type) 069 { 070 super(rbName,errorCode,args,null); 071 this.name = name; 072 this.type = type; 073 fillInStackTrace(); 074 } 075 076 /** 077 * Constructs a <code>NameAlreadyExistsException</code> instance. 078 * With localized error message 079 * 080 * @param rbName Resource bundle name 081 * @param errorCode error code to use access the resource bundle 082 * @param args parameters for message formatting 083 * @param t nested root cause exception 084 * @param name name that already exists 085 * @param type type of object whose name already exist 086 */ 087 public NameAlreadyExistsException(String rbName,String errorCode, 088 Object[] args, Throwable t, String name, int type) 089 { 090 super(rbName,errorCode,args,t); 091 this.name = name; 092 this.type = type; 093 fillInStackTrace(); 094 } 095 096 /** 097 * Constructs a <code>NameAlreadyExistsException</code> instance. 098 * 099 * @param t nested root cause exception 100 * @param name name that already exists 101 * @param type type of object whose name already exist 102 */ 103 public NameAlreadyExistsException(Throwable t, String name, int type) { 104 super(t); 105 this.name = name; 106 this.type = type; 107 fillInStackTrace(); 108 } 109 110 /** 111 * Gets the name that already exists. 112 * 113 * @return name that already exists 114 */ 115 public String getName() { 116 return (name); 117 } 118 119 /** 120 * Gets the type of object which encountered 121 * the invalid name. The defined objects are <code>POLICY</code>, 122 * <code>RULE</code>, <code>ORGANIZATION</code>, 123 * <code>USER_COLLECTION</code> 124 * <code>RESPONSE_PROVIDER_COLLECTION</code> 125 * <code>CONDITION_COLLECTION</code> 126 * <code>REFERRAL_COLLECTION</code> 127 * <code>REFERRAL_TYPE</code> 128 * <code>SUBJECT_TYPE</code> 129 * and <code>SERVICE</code> 130 * 131 * @return type of object that already exists 132 */ 133 public int getObjectType() { 134 return (type); 135 } 136}