001/*
002 * Copyright 2012-2022 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright 2012-2022 Ping Identity Corporation
007 *
008 * Licensed under the Apache License, Version 2.0 (the "License");
009 * you may not use this file except in compliance with the License.
010 * You may obtain a copy of the License at
011 *
012 *    http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing, software
015 * distributed under the License is distributed on an "AS IS" BASIS,
016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017 * See the License for the specific language governing permissions and
018 * limitations under the License.
019 */
020/*
021 * Copyright (C) 2012-2022 Ping Identity Corporation
022 *
023 * This program is free software; you can redistribute it and/or modify
024 * it under the terms of the GNU General Public License (GPLv2 only)
025 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
026 * as published by the Free Software Foundation.
027 *
028 * This program is distributed in the hope that it will be useful,
029 * but WITHOUT ANY WARRANTY; without even the implied warranty of
030 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
031 * GNU General Public License for more details.
032 *
033 * You should have received a copy of the GNU General Public License
034 * along with this program; if not, see <http://www.gnu.org/licenses>.
035 */
036package com.unboundid.ldap.sdk.unboundidds.extensions;
037
038
039
040import com.unboundid.util.NotNull;
041import com.unboundid.util.Nullable;
042import com.unboundid.util.StaticUtils;
043
044
045
046/**
047 * This enum defines the set of possible error behavior values that may be used
048 * in the multi-update extended request.
049 * <BR>
050 * <BLOCKQUOTE>
051 *   <B>NOTE:</B>  This class, and other classes within the
052 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
053 *   supported for use against Ping Identity, UnboundID, and
054 *   Nokia/Alcatel-Lucent 8661 server products.  These classes provide support
055 *   for proprietary functionality or for external specifications that are not
056 *   considered stable or mature enough to be guaranteed to work in an
057 *   interoperable way with other types of LDAP servers.
058 * </BLOCKQUOTE>
059 *
060 * @see MultiUpdateExtendedRequest
061 */
062public enum MultiUpdateErrorBehavior
063{
064  /**
065   * The behavior which indicates that all operations must be processed
066   * atomically.  The entire set of updates will succeed or fail as a single
067   * unit, and directory clients will not see any updates while the multi-update
068   * request is in progress.  Note that the server may place constraints on
069   * the ability to use this error behavior such that it may not be usable in
070   * all circumstances (e.g., when passing through a Directory Proxy Server with
071   * entry balancing enabled or that would otherwise need to communicate with
072   * multiple servers, or if it is necessary to interact with entries in
073   * multiple Directory Server backends).
074   */
075  ATOMIC(0),
076
077
078
079  /**
080   * The behavior which indicates that processing will end for the multi-update
081   * operation after the first failure is encountered while attempting to
082   * apply a change.  Any changes processed before the first failure was
083   * encountered will still have been applied, and clients accessing the server
084   * in the course of processing the multi-update request may see changes after
085   * only some of them have been completed.
086   */
087  ABORT_ON_ERROR(1),
088
089
090
091  /**
092   * The behavior which indicates that the server should attempt to process all
093   * elements of the multi-update request even if one or more failures are
094   * encountered.  Clients accessing the server in the course of processing the
095   * multi-update request may see changes after only some of them have been
096   * completed.
097   */
098  CONTINUE_ON_ERROR(2);
099
100
101
102  // The integer value associated with this error behavior.
103  private final int intValue;
104
105
106
107  /**
108   * Creates a new multi-update error behavior value with the provided integer
109   * representation.
110   *
111   * @param  intValue  The integer value associated with this error behavior.
112   */
113  MultiUpdateErrorBehavior(final int intValue)
114  {
115    this.intValue = intValue;
116  }
117
118
119
120  /**
121   * Retrieves the integer value associated with this error behavior.
122   *
123   * @return  The integer value associated with this error behavior.
124   */
125  public int intValue()
126  {
127    return intValue;
128  }
129
130
131
132  /**
133   * Retrieves the multi-update error behavior value with the specified integer
134   * value.
135   *
136   * @param  intValue  The integer value for the error behavior to retrieve.
137   *
138   * @return  The multi-update error behavior with the specified integer value,
139   *          or {@code null} if there is no error behavior with the specified
140   *          value.
141   */
142  @Nullable()
143  public static MultiUpdateErrorBehavior valueOf(final int intValue)
144  {
145    for (final MultiUpdateErrorBehavior v : values())
146    {
147      if (intValue == v.intValue)
148      {
149        return v;
150      }
151    }
152
153    return null;
154  }
155
156
157
158  /**
159   * Retrieves the multi-update error behavior with the specified name.
160   *
161   * @param  name  The name of the multi-update error behavior to retrieve.  It
162   *               must not be {@code null}.
163   *
164   * @return  The requested multi-update error behavior, or {@code null} if no
165   *          such behavior is defined.
166   */
167  @Nullable()
168  public static MultiUpdateErrorBehavior forName(@NotNull final String name)
169  {
170    switch (StaticUtils.toLowerCase(name))
171    {
172      case "atomic":
173        return ATOMIC;
174      case "abortonerror":
175      case "abort-on-error":
176      case "abort_on_error":
177        return ABORT_ON_ERROR;
178      case "continueonerror":
179      case "continue-on-error":
180      case "continue_on_error":
181        return CONTINUE_ON_ERROR;
182      default:
183        return null;
184    }
185  }
186}