001/*
002 * Copyright 2012-2019 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright (C) 2015-2019 Ping Identity Corporation
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 */
021package com.unboundid.ldap.sdk.unboundidds.extensions;
022
023
024
025import com.unboundid.util.StaticUtils;
026
027
028
029/**
030 * This enum defines the set of possible error behavior values that may be used
031 * in the multi-update extended request.
032 * <BR>
033 * <BLOCKQUOTE>
034 *   <B>NOTE:</B>  This class, and other classes within the
035 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
036 *   supported for use against Ping Identity, UnboundID, and
037 *   Nokia/Alcatel-Lucent 8661 server products.  These classes provide support
038 *   for proprietary functionality or for external specifications that are not
039 *   considered stable or mature enough to be guaranteed to work in an
040 *   interoperable way with other types of LDAP servers.
041 * </BLOCKQUOTE>
042 *
043 * @see MultiUpdateExtendedRequest
044 */
045public enum MultiUpdateErrorBehavior
046{
047  /**
048   * The behavior which indicates that all operations must be processed
049   * atomically.  The entire set of updates will succeed or fail as a single
050   * unit, and directory clients will not see any updates while the multi-update
051   * request is in progress.  Note that the server may place constraints on
052   * the ability to use this error behavior such that it may not be usable in
053   * all circumstances (e.g., when passing through a Directory Proxy Server with
054   * entry balancing enabled or that would otherwise need to communicate with
055   * multiple servers, or if it is necessary to interact with entries in
056   * multiple Directory Server backends).
057   */
058  ATOMIC(0),
059
060
061
062  /**
063   * The behavior which indicates that processing will end for the multi-update
064   * operation after the first failure is encountered while attempting to
065   * apply a change.  Any changes processed before the first failure was
066   * encountered will still have been applied, and clients accessing the server
067   * in the course of processing the multi-update request may see changes after
068   * only some of them have been completed.
069   */
070  ABORT_ON_ERROR(1),
071
072
073
074  /**
075   * The behavior which indicates that the server should attempt to process all
076   * elements of the multi-update request even if one or more failures are
077   * encountered.  Clients accessing the server in the course of processing the
078   * multi-update request may see changes after only some of them have been
079   * completed.
080   */
081  CONTINUE_ON_ERROR(2);
082
083
084
085  // The integer value associated with this error behavior.
086  private final int intValue;
087
088
089
090  /**
091   * Creates a new multi-update error behavior value with the provided integer
092   * representation.
093   *
094   * @param  intValue  The integer value associated with this error behavior.
095   */
096  MultiUpdateErrorBehavior(final int intValue)
097  {
098    this.intValue = intValue;
099  }
100
101
102
103  /**
104   * Retrieves the integer value associated with this error behavior.
105   *
106   * @return  The integer value associated with this error behavior.
107   */
108  public int intValue()
109  {
110    return intValue;
111  }
112
113
114
115  /**
116   * Retrieves the multi-update error behavior value with the specified integer
117   * value.
118   *
119   * @param  intValue  The integer value for the error behavior to retrieve.
120   *
121   * @return  The multi-update error behavior with the specified integer value,
122   *          or {@code null} if there is no error behavior with the specified
123   *          value.
124   */
125  public static MultiUpdateErrorBehavior valueOf(final int intValue)
126  {
127    for (final MultiUpdateErrorBehavior v : values())
128    {
129      if (intValue == v.intValue)
130      {
131        return v;
132      }
133    }
134
135    return null;
136  }
137
138
139
140  /**
141   * Retrieves the multi-update error behavior with the specified name.
142   *
143   * @param  name  The name of the multi-update error behavior to retrieve.  It
144   *               must not be {@code null}.
145   *
146   * @return  The requested multi-update error behavior, or {@code null} if no
147   *          such behavior is defined.
148   */
149  public static MultiUpdateErrorBehavior forName(final String name)
150  {
151    switch (StaticUtils.toLowerCase(name))
152    {
153      case "atomic":
154        return ATOMIC;
155      case "abortonerror":
156      case "abort-on-error":
157      case "abort_on_error":
158        return ABORT_ON_ERROR;
159      case "continueonerror":
160      case "continue-on-error":
161      case "continue_on_error":
162        return CONTINUE_ON_ERROR;
163      default:
164        return null;
165    }
166  }
167}