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: PolicyEvaluationException.java,v 1.2 2008/06/25 05:43:53 qcheng Exp $ 026 * 027 */ 028 029package com.sun.identity.policy.remote; 030 031import com.sun.identity.policy.PolicyException; 032 033/** 034 * The class <code>PolicyEvaluationException</code> is the exception 035 * for the error happening in policy request XML parsing and policy 036 * request evaluation. 037 * 038 * @supported.all.api 039 */ 040public class PolicyEvaluationException extends PolicyException { 041 042 // The id of the policy request 043 private String reqId; 044 045 /** 046 * Constructs an instance of the <code>PolicyEvaluationException</code>. 047 * 048 * @param message The message provided by the object that is throwing the 049 * exception. 050 */ 051 public PolicyEvaluationException(String message) { 052 super(message); 053 reqId = "-1"; 054 } 055 056 /** 057 * Constructs an instance of the <code>PolicyEvaluationException</code> 058 * 059 * @param nestedException the exception caught by the code block creating 060 * this. 061 */ 062 public PolicyEvaluationException(Throwable nestedException) { 063 super(nestedException); 064 reqId = "-1"; 065 } 066 067 /** 068 * Constructs an instance of the <code>PolicyEvaluationException</code> 069 * class. 070 * 071 * @param nestedException the exception caught by the code block creating 072 * this 073 * @param reqId The id of the policy request exception. 074 */ 075 public PolicyEvaluationException(Throwable nestedException, String reqId) { 076 super(nestedException); 077 this.reqId = reqId; 078 } 079 080 /** 081 * Constructs an instance of <code> PolicyEvaluationException </code> 082 * to pass the localized error message 083 * At this level, the locale of the caller is not known and it is 084 * not possible to throw localized error message at this level. 085 * Instead this constructor provides Resource Bundle name and error code 086 * for correctly locating the error message. The default 087 * <code>getMessage()</code> will always return English messages only. This 088 * is in consistent with current JRE. 089 * 090 * @param rbName Resource Bundle Name to be used for getting 091 * localized error message. 092 * @param errorCode Key to resource bundle. You can use 093 * <pre> 094 * ResourceBundle rb = ResourceBunde.getBundle (rbName,locale); 095 * String localizedStr = rb.getString(errorCode); 096 * </pre> 097 * @param args arguments to message. If it is not present pass the 098 * as null 099 * @param nestedException the exception caught by the code block creating 100 * this 101 * @param reqId The id of the policy request exception. 102 */ 103 public PolicyEvaluationException (String rbName, String errorCode, 104 Object[] args, Throwable nestedException, String reqId) { 105 super (rbName,errorCode,args,nestedException); 106 this.reqId = reqId; 107 } 108 109 /** 110 * Constructs an instance of <code> PolicyEvaluationException </code> 111 * to pass the localized error message 112 * At this level, the locale of the caller is not known and it is 113 * not possible to throw localized error message at this level. 114 * Instead this constructor provides Resource Bundle name and error code 115 * for correctly locating the error message. The default 116 * <code>getMessage()</code> will always return English messages only. 117 * This is in consistent with current JRE. 118 * 119 * @param rbName Resource Bundle Name to be used for getting 120 * localized error message. 121 * @param errorCode Key to resource bundle. You can use 122 * <pre> 123 * ResourceBundle rb = ResourceBunde.getBundle (rbName,locale); 124 * String localizedStr = rb.getString(errorCode): 125 * </pre> 126 * @param args arguments to message. If it is not present pass the 127 * as null 128 * @param nestedException the exception caught by the code block creating 129 * this 130 */ 131 public PolicyEvaluationException (String rbName, String errorCode, 132 Object[] args, Throwable nestedException) { 133 super (rbName,errorCode,args,nestedException); 134 } 135 136 /** 137 * Constructs an instance of the <code>PolicyEvaluationException</code> 138 * class. 139 * @param message The message provided by the object that is throwing the 140 * exception. 141 * @param reqId The id of the policy request exception. 142 */ 143 public PolicyEvaluationException(String message, String reqId) { 144 super(message); 145 this.reqId = reqId; 146 } 147 148 /** 149 * Constructs an instance of the <code>PolicyEvaluationException</code> 150 * class. 151 * @param message message of this exception 152 * @param nestedException the exception caught by the code block creating 153 * this exception. 154 */ 155 public PolicyEvaluationException(String message, Throwable nestedException){ 156 super(message, nestedException); 157 reqId = "-1"; 158 } 159 160 /** 161 * Constructs an instance of the <code>PolicyEvaluationException</code> 162 * class. 163 * 164 * @param message message of this exception 165 * @param nestedException the exception caught by the code 166 * block creating this exception 167 * @param reqId The id of the policy request 168 */ 169 public PolicyEvaluationException(String message, Throwable nestedException, 170 String reqId) { 171 super(message, nestedException); 172 this.reqId = reqId; 173 } 174 175 /** 176 * Returns the request Id. 177 * 178 * @return the request Id. 179 */ 180 public String getRequestId() { 181 return reqId; 182 } 183}