PageRenderTime 49ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapReferralException.cs

https://bitbucket.org/danipen/mono
C# | 297 lines | 94 code | 20 blank | 183 comment | 7 complexity | 859e8f22bae1f5a4fbf46d367a789b9f MD5 | raw file
Possible License(s): Unlicense, Apache-2.0, LGPL-2.0, MPL-2.0-no-copyleft-exception, CC-BY-SA-3.0, GPL-2.0
  1. /******************************************************************************
  2. * The MIT License
  3. * Copyright (c) 2003 Novell Inc. www.novell.com
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6. * of this software and associated documentation files (the Software), to deal
  7. * in the Software without restriction, including without limitation the rights
  8. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. * copies of the Software, and to permit persons to whom the Software is
  10. * furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included in
  13. * all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. * SOFTWARE.
  22. *******************************************************************************/
  23. //
  24. // Novell.Directory.Ldap.LdapReferralException.cs
  25. //
  26. // Author:
  27. // Sunil Kumar (Sunilk@novell.com)
  28. //
  29. // (C) 2003 Novell, Inc (http://www.novell.com)
  30. //
  31. using System;
  32. using Novell.Directory.Ldap.Utilclass;
  33. namespace Novell.Directory.Ldap
  34. {
  35. /// <summary> Thrown when a server returns a referral and when a referral has not
  36. /// been followed. It contains a list of URL strings corresponding
  37. /// to the referrals or search continuation references received on an Ldap
  38. /// operation.
  39. /// </summary>
  40. public class LdapReferralException:LdapException
  41. {
  42. /// <summary> Sets a referral that could not be processed
  43. ///
  44. /// </summary>
  45. /// <param name="url">The referral URL that could not be processed.
  46. /// </param>
  47. virtual public System.String FailedReferral
  48. {
  49. /* Gets the referral that could not be processed. If multiple referrals
  50. * could not be processed, the method returns one of them.
  51. *
  52. * @return the referral that could not be followed.
  53. */
  54. get
  55. {
  56. return failedReferral;
  57. }
  58. set
  59. {
  60. failedReferral = value;
  61. return ;
  62. }
  63. }
  64. private System.String failedReferral = null;
  65. private System.String[] referrals = null;
  66. /// <summary> Constructs a default exception with no specific error information.</summary>
  67. public LdapReferralException():base()
  68. {
  69. return ;
  70. }
  71. /// <summary> Constructs a default exception with a specified string as additional
  72. /// information.
  73. ///
  74. /// This form is used for lower-level errors.
  75. ///
  76. /// </summary>
  77. /// <param name="message">The additional error information.
  78. /// </param>
  79. public LdapReferralException(System.String message):base(message, LdapException.REFERRAL, (System.String) null)
  80. {
  81. return ;
  82. }
  83. /// <summary> Constructs a default exception with a specified string as additional
  84. /// information.
  85. ///
  86. /// This form is used for lower-level errors.
  87. ///
  88. ///
  89. /// </summary>
  90. /// <param name="arguments"> The modifying arguments to be included in the
  91. /// message string.
  92. ///
  93. /// </param>
  94. /// <param name="message">The additional error information.
  95. /// </param>
  96. public LdapReferralException(System.String message, System.Object[] arguments):base(message, arguments, LdapException.REFERRAL, (System.String) null)
  97. {
  98. return ;
  99. }
  100. /// <summary> Constructs a default exception with a specified string as additional
  101. /// information and an exception that indicates a failure to follow a
  102. /// referral. This excepiton applies only to synchronous operations and
  103. /// is thrown only on receipt of a referral when the referral was not
  104. /// followed.
  105. ///
  106. /// </summary>
  107. /// <param name="message">The additional error information.
  108. ///
  109. ///
  110. /// </param>
  111. /// <param name="rootException">An exception which caused referral following to fail.
  112. /// </param>
  113. public LdapReferralException(System.String message, System.Exception rootException):base(message, LdapException.REFERRAL, null, rootException)
  114. {
  115. return ;
  116. }
  117. /// <summary> Constructs a default exception with a specified string as additional
  118. /// information and an exception that indicates a failure to follow a
  119. /// referral. This excepiton applies only to synchronous operations and
  120. /// is thrown only on receipt of a referral when the referral was not
  121. /// followed.
  122. ///
  123. /// </summary>
  124. /// <param name="message">The additional error information.
  125. ///
  126. ///
  127. /// </param>
  128. /// <param name="arguments"> The modifying arguments to be included in the
  129. /// message string.
  130. ///
  131. /// </param>
  132. /// <param name="rootException">An exception which caused referral following to fail.
  133. /// </param>
  134. public LdapReferralException(System.String message, System.Object[] arguments, System.Exception rootException):base(message, arguments, LdapException.REFERRAL, null, rootException)
  135. {
  136. return ;
  137. }
  138. /// <summary> Constructs an exception with a specified error string, result code, and
  139. /// an error message from the server.
  140. ///
  141. /// </summary>
  142. /// <param name="message"> The additional error information.
  143. ///
  144. /// </param>
  145. /// <param name="resultCode"> The result code returned.
  146. ///
  147. /// </param>
  148. /// <param name="serverMessage"> Error message specifying additional information
  149. /// from the server.
  150. /// </param>
  151. public LdapReferralException(System.String message, int resultCode, System.String serverMessage):base(message, resultCode, serverMessage)
  152. {
  153. return ;
  154. }
  155. /// <summary> Constructs an exception with a specified error string, result code, and
  156. /// an error message from the server.
  157. ///
  158. /// </summary>
  159. /// <param name="message"> The additional error information.
  160. ///
  161. /// </param>
  162. /// <param name="arguments"> The modifying arguments to be included in the
  163. /// message string.
  164. ///
  165. /// </param>
  166. /// <param name="resultCode"> The result code returned.
  167. ///
  168. /// </param>
  169. /// <param name="serverMessage"> Error message specifying additional information
  170. /// from the server.
  171. /// </param>
  172. public LdapReferralException(System.String message, System.Object[] arguments, int resultCode, System.String serverMessage):base(message, arguments, resultCode, serverMessage)
  173. {
  174. return ;
  175. }
  176. /// <summary> Constructs an exception with a specified error string, result code,
  177. /// an error message from the server, and an exception that indicates
  178. /// a failure to follow a referral.
  179. ///
  180. /// </summary>
  181. /// <param name="message"> The additional error information.
  182. ///
  183. /// </param>
  184. /// <param name="resultCode"> The result code returned.
  185. ///
  186. /// </param>
  187. /// <param name="serverMessage"> Error message specifying additional information
  188. /// from the server.
  189. /// </param>
  190. public LdapReferralException(System.String message, int resultCode, System.String serverMessage, System.Exception rootException):base(message, resultCode, serverMessage, rootException)
  191. {
  192. return ;
  193. }
  194. /// <summary> Constructs an exception with a specified error string, result code,
  195. /// an error message from the server, and an exception that indicates
  196. /// a failure to follow a referral.
  197. ///
  198. /// </summary>
  199. /// <param name="message"> The additional error information.
  200. ///
  201. /// </param>
  202. /// <param name="arguments"> The modifying arguments to be included in the
  203. /// message string.
  204. ///
  205. /// </param>
  206. /// <param name="resultCode"> The result code returned.
  207. ///
  208. /// </param>
  209. /// <param name="serverMessage"> Error message specifying additional information
  210. /// from the server.
  211. /// </param>
  212. public LdapReferralException(System.String message, System.Object[] arguments, int resultCode, System.String serverMessage, System.Exception rootException):base(message, arguments, resultCode, serverMessage, rootException)
  213. {
  214. return ;
  215. }
  216. /// <summary> Gets the list of referral URLs (Ldap URLs to other servers) returned by
  217. /// the Ldap server.
  218. ///
  219. /// The referral list may include URLs of a type other than ones for an Ldap
  220. /// server (for example, a referral URL other than ldap://something).
  221. ///
  222. /// </summary>
  223. /// <returns> The list of URLs that comprise this referral
  224. /// </returns>
  225. public virtual System.String[] getReferrals()
  226. {
  227. return referrals;
  228. }
  229. /// <summary> Sets the list of referrals
  230. ///
  231. /// </summary>
  232. /// <param name="urls">the list of referrals returned by the Ldap server in a
  233. /// single response.
  234. /// </param>
  235. /* package */
  236. internal virtual void setReferrals(System.String[] urls)
  237. {
  238. referrals = urls;
  239. return ;
  240. }
  241. /// <summary> returns a string of information about the exception and the
  242. /// the nested exceptions, if any.
  243. /// </summary>
  244. public override System.String ToString()
  245. {
  246. System.String msg, tmsg;
  247. // Format the basic exception information
  248. msg = getExceptionString("LdapReferralException");
  249. // Add failed referral information
  250. if ((System.Object) failedReferral != null)
  251. {
  252. tmsg = ResourcesHandler.getMessage("FAILED_REFERRAL", new System.Object[]{"LdapReferralException", failedReferral});
  253. // If found no string from resource file, use a default string
  254. if (tmsg.ToUpper().Equals("SERVER_MSG".ToUpper()))
  255. {
  256. tmsg = "LdapReferralException: Failed Referral: " + failedReferral;
  257. }
  258. msg = msg + '\n' + tmsg;
  259. }
  260. // Add referral information, display all the referrals in the list
  261. if (referrals != null)
  262. {
  263. for (int i = 0; i < referrals.Length; i++)
  264. {
  265. tmsg = ResourcesHandler.getMessage("REFERRAL_ITEM", new System.Object[]{"LdapReferralException", referrals[i]});
  266. // If found no string from resource file, use a default string
  267. if (tmsg.ToUpper().Equals("SERVER_MSG".ToUpper()))
  268. {
  269. tmsg = "LdapReferralException: Referral: " + referrals[i];
  270. }
  271. msg = msg + '\n' + tmsg;
  272. }
  273. }
  274. return msg;
  275. }
  276. }
  277. }