1. /*
  2. * @(#)AttributeModificationException.java 1.8 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.naming.directory;
  8. import javax.naming.NamingException;
  9. /**
  10. * This exception is thrown when an attempt is
  11. * made to add, or remove, or modify an attribute, its identifier,
  12. * or its values that conflicts with the attribute's (schema) definition
  13. * or the attribute's state.
  14. * It is thrown in response to DirContext.modifyAttributes().
  15. * It contains a list of modifications that have not been performed, in the
  16. * order that they were supplied to modifyAttributes().
  17. * If the list is null, none of the modifications were performed successfully.
  18. *<p>
  19. * An AttributeModificationException instance is not synchronized
  20. * against concurrent multithreaded access. Multiple threads trying
  21. * to access and modify a single AttributeModification instance
  22. * should lock the object.
  23. *
  24. * @author Rosanna Lee
  25. * @author Scott Seligman
  26. * @version 1.8 03/01/23
  27. *
  28. * @see DirContext#modifyAttributes
  29. * @since 1.3
  30. */
  31. /*
  32. *<p>
  33. * The serialized form of an AttributeModificationException object
  34. * consists of the serialized fields of its NamingException
  35. * superclass, followed by an array of ModificationItem objects.
  36. *
  37. */
  38. public class AttributeModificationException extends NamingException {
  39. /**
  40. * Contains the possibly null list of unexecuted modifications.
  41. * @serial
  42. */
  43. private ModificationItem[] unexecs = null;
  44. /**
  45. * Constructs a new instance of AttributeModificationException using
  46. * an explanation. All other fields are set to null.
  47. *
  48. * @param explanation Possibly null additional detail about this exception.
  49. * If null, this exception has no detail message.
  50. * @see java.lang.Throwable#getMessage
  51. */
  52. public AttributeModificationException(String explanation) {
  53. super(explanation);
  54. }
  55. /**
  56. * Constructs a new instance of AttributeModificationException.
  57. * All fields are set to null.
  58. */
  59. public AttributeModificationException() {
  60. super();
  61. }
  62. /**
  63. * Sets the unexecuted modification list to be e.
  64. * Items in the list must appear in the same order in which they were
  65. * originally supplied in DirContext.modifyAttributes().
  66. * The first item in the list is the first one that was not executed.
  67. * If this list is null, none of the operations originally submitted
  68. * to modifyAttributes() were executed.
  69. * @param e The possibly null list of unexecuted modifications.
  70. * @see #getUnexecutedModifications
  71. */
  72. public void setUnexecutedModifications(ModificationItem[] e) {
  73. unexecs = e;
  74. }
  75. /**
  76. * Retrieves the unexecuted modification list.
  77. * Items in the list appear in the same order in which they were
  78. * originally supplied in DirContext.modifyAttributes().
  79. * The first item in the list is the first one that was not executed.
  80. * If this list is null, none of the operations originally submitted
  81. * to modifyAttributes() were executed.
  82. * @return The possibly null unexecuted modification list.
  83. * @see #setUnexecutedModifications
  84. */
  85. public ModificationItem[] getUnexecutedModifications() {
  86. return unexecs;
  87. }
  88. /**
  89. * The string representation of this exception consists of
  90. * information about where the error occurred, and
  91. * the first unexecuted modification.
  92. * This string is meant for debugging and not mean to be interpreted
  93. * programmatically.
  94. * @return The non-null string representation of this exception.
  95. */
  96. public String toString() {
  97. String orig = super.toString();
  98. if (unexecs != null) {
  99. orig += ("First unexecuted modification: " +
  100. unexecs[0].toString());
  101. }
  102. return orig;
  103. }
  104. /**
  105. * Use serialVersionUID from JNDI 1.1.1 for interoperability
  106. */
  107. private static final long serialVersionUID = 8060676069678710186L;
  108. }