001 /*
002 * Copyright 2009-2014 UnboundID Corp.
003 * All Rights Reserved.
004 */
005 /*
006 * Copyright (C) 2009-2014 UnboundID Corp.
007 *
008 * This program is free software; you can redistribute it and/or modify
009 * it under the terms of the GNU General Public License (GPLv2 only)
010 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
011 * as published by the Free Software Foundation.
012 *
013 * This program is distributed in the hope that it will be useful,
014 * but WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
016 * GNU General Public License for more details.
017 *
018 * You should have received a copy of the GNU General Public License
019 * along with this program; if not, see <http://www.gnu.org/licenses>.
020 */
021 package com.unboundid.ldap.sdk.migrate.ldapjdk;
022
023
024
025 import com.unboundid.ldap.sdk.SearchResultReference;
026 import com.unboundid.util.NotExtensible;
027 import com.unboundid.util.NotMutable;
028 import com.unboundid.util.ThreadSafety;
029 import com.unboundid.util.ThreadSafetyLevel;
030
031
032
033 /**
034 * This class provides an exception that may be returned if a referral is
035 * returned in response for an operation.
036 * <BR><BR>
037 * This class is primarily intended to be used in the process of updating
038 * applications which use the Netscape Directory SDK for Java to switch to or
039 * coexist with the UnboundID LDAP SDK for Java. For applications not written
040 * using the Netscape Directory SDK for Java, the
041 * {@link com.unboundid.ldap.sdk.LDAPException} class should be used instead.
042 */
043 @NotExtensible()
044 @NotMutable()
045 @ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
046 public class LDAPReferralException
047 extends LDAPException
048 {
049 /**
050 * The serial version UID for this serializable class.
051 */
052 private static final long serialVersionUID = 7867903105944011998L;
053
054
055
056 // The referral URLs for this exception.
057 private final String[] referralURLs;
058
059
060
061 /**
062 * Creates a new LDAP referral exception with no information.
063 */
064 public LDAPReferralException()
065 {
066 super(null, REFERRAL);
067
068 referralURLs = new String[0];
069 }
070
071
072
073 /**
074 * Creates a new LDAP referral exception with the provided information.
075 *
076 * @param message The message for this LDAP referral exception.
077 * @param resultCode The result code for this LDAP referral
078 * exception.
079 * @param serverErrorMessage The error message returned from the server.
080 */
081 public LDAPReferralException(final String message, final int resultCode,
082 final String serverErrorMessage)
083 {
084 super(message, resultCode, serverErrorMessage, null);
085
086 referralURLs = new String[0];
087 }
088
089
090
091 /**
092 * Creates a new LDAP referral exception with the provided information.
093 *
094 * @param message The message for this LDAP referral exception.
095 * @param resultCode The result code for this LDAP referral exception.
096 * @param referrals The set of referrals for this exception.
097 */
098 public LDAPReferralException(final String message, final int resultCode,
099 final String[] referrals)
100 {
101 super(message, resultCode, null, null);
102
103 referralURLs = referrals;
104 }
105
106
107
108 /**
109 * Creates a new LDAP referral exception from the provided
110 * {@link com.unboundid.ldap.sdk.LDAPException} object.
111 *
112 * @param ldapException The {@code LDAPException} object to use for this
113 * LDAP interrupted exception.
114 */
115 public LDAPReferralException(
116 final com.unboundid.ldap.sdk.LDAPException ldapException)
117 {
118 super(ldapException);
119
120 referralURLs = ldapException.getReferralURLs();
121 }
122
123
124
125 /**
126 * Creates a new LDAP referral exception from the provided
127 * {@link SearchResultReference} object.
128 *
129 * @param reference The {@code SearchResultReference} object to use to
130 * create this exception.
131 */
132 public LDAPReferralException(final SearchResultReference reference)
133 {
134 super(null, REFERRAL);
135
136 referralURLs = reference.getReferralURLs();
137 }
138
139
140
141 /**
142 * Retrieves the set of referral URLs for this exception.
143 *
144 * @return The set of referral URLs for this exception.
145 */
146 public String[] getURLs()
147 {
148 return referralURLs;
149 }
150 }