8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The contents of this file are subject to the terms
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * of the Common Development and Distribution License
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (the License). You may not use this file except in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * compliance with the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * You can obtain a copy of the License at
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * See the License for the specific language governing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * permission and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * When distributing Covered Code, include this CDDL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Header Notice in each file and include the License file
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * If applicable, add the following below the CDDL Header,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * with the fields enclosed by brackets [] replaced by
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * your own identifying information:
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * $Id: AMException.java,v 1.7 2009/01/28 05:34:47 ww203982 Exp $
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington * Portions Copyright 2015 ForgeRock AS.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.shared.locale.L10NMessage;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>AMException</code> is thrown whenever an error is is encountered
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * while performing an operation on the data store.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @deprecated As of Sun Java System Access Manager 7.1.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @supported.all.api
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpublic class AMException extends Exception implements L10NMessage {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static final long serialVersionUID = -660487903675407220L;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Constructs a new <code>AMException</code> with detailed message.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param msg
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The detailed message
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param errorCode
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Matches the appropriate entry in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public AMException(String msg, String errorCode) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Convenience method (protected)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public AMException(SSOToken token, String errorCode) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster this.localizedMsg = AMSDKBundle.getString(errorCode, AMCommonUtils
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Constructs a new <code>AMException</code> with detailed message.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param msg
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The detailed message.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param errorCode
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Matches the appropriate entry in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if the root cause is a <code>UMSException</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public AMException(String msg, String errorCode, UMSException ue) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Constructs a new <code>AMException</code> with detailed message.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param token
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * a valid single sign on token of the user performing the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * operation.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param errorCode
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Matches the appropriate entry in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if the root cause is a <code>UMSException</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public AMException(SSOToken token, String errorCode, UMSException ue) {
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington ldapErrCode = Integer.toString(rootCause.getResult().getResultCode().intValue());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ldapErrorMsg = AMSDKBundle.getString(ldapErrCode);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String message = AMSDKBundle.getString(errorCode, AMCommonUtils
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Constructs a new <code>AMException</code> with detailed message.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param msg
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The detailed message.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param errorCode
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Matches the appropriate entry in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param args
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * arguments if the error message needs specific values to be
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public AMException(String msg, String errorCode, Object[] args) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Constructs a new <code>AMException</code> with detailed message.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param msg
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The detailed message
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param errorCode
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Matches the appropriate entry in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param args
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if the error message needs specific values to be set.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if the root cause is a <code>UMSException</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public AMException(String msg, String errorCode, Object args[],
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington ldapErrCode = Integer.toString(rootCause.getResult().getResultCode().intValue());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ldapErrorMsg = AMSDKBundle.getString(ldapErrCode);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the error code. This error code can be used with the arguments to
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * construct a localized message.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return the error code which can be used to map the message to a user
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * specific locale.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the arguments corresponding to the error code.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return the arguments corresponding to the error code or null if no
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * arguments are need to construct the message.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Overrides the default <code>getMessage()</code> method of super class
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Exception.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return The error message string.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Method to obtain the LDAP error code.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return The error code, which can be used to map the message to a
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * specific locale. Returns a null, if not an LDAP error.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the root <code>LDAPException</code> of this
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>AMException</code>, if any.
ce4d3fddc8fe2eddd68a20af9570b3cc63ece5abNeil Madden * @return The {@link LdapException} that caused this
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>AMException</code>. If null, it means no root
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>LDAPException</code> has been set.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns localized error message.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param locale
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * locale of the error message.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return Localized error message.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ResourceBundle rb = AMSDKBundle.getBundleFromHash(locale);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String mid = com.sun.identity.shared.locale.Locale.getString(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster result = ((args == null) || (args.length == 0)) ? mid
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns ResourceBundle Name associated with this exception
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return ResourceBundle Name associated with this exception.