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