001/* 002 * Copyright 2013-2022 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright 2013-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) 2013-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.controls; 037 038 039 040import com.unboundid.util.StaticUtils; 041import com.unboundid.util.NotNull; 042import com.unboundid.util.Nullable; 043import com.unboundid.util.ThreadSafety; 044import com.unboundid.util.ThreadSafetyLevel; 045 046 047 048/** 049 * This enum defines an assurance level that may be used for servers in the 050 * same location as the server receiving the change. 051 * <BR> 052 * <BLOCKQUOTE> 053 * <B>NOTE:</B> This class, and other classes within the 054 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 055 * supported for use against Ping Identity, UnboundID, and 056 * Nokia/Alcatel-Lucent 8661 server products. These classes provide support 057 * for proprietary functionality or for external specifications that are not 058 * considered stable or mature enough to be guaranteed to work in an 059 * interoperable way with other types of LDAP servers. 060 * </BLOCKQUOTE> 061 */ 062@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 063public enum AssuredReplicationLocalLevel 064{ 065 /** 066 * Indicates that no local assurance is desired for the associated operation. 067 */ 068 NONE(0), 069 070 071 072 /** 073 * Indicates that the operation result should not be returned to the client 074 * until the change has been received by at least one other replication server 075 * in same location. Note that this level does not require the change to have 076 * already been processed by any other directory server, but merely requires 077 * that it exist in at least one other replication server for the sake of 078 * redundancy. If the client interacts with another local directory server 079 * immediately after receiving a result with this level of assurance, there is 080 * no guarantee that the associated change will be visible on that server. 081 */ 082 RECEIVED_ANY_SERVER(1), 083 084 085 086 /** 087 * Indicates that the operation result should not be returned to the client 088 * until the change has been processed by all available directory servers in 089 * the same location as the original server. 090 */ 091 PROCESSED_ALL_SERVERS(2); 092 093 094 095 // The integer value for this local assurance level. 096 private final int intValue; 097 098 099 100 /** 101 * Creates a new local assurance level with the provided integer value. 102 * 103 * @param intValue The integer value for this local assurance level. 104 */ 105 AssuredReplicationLocalLevel(final int intValue) 106 { 107 this.intValue = intValue; 108 } 109 110 111 112 /** 113 * Retrieves integer value for this local assurance level. 114 * 115 * @return The integer value for this local assurance level. 116 */ 117 public int intValue() 118 { 119 return intValue; 120 } 121 122 123 124 /** 125 * Retrieves the local assurance level with the specified integer value. 126 * 127 * @param intValue The integer value for the local assurance level to 128 * retrieve. 129 * 130 * @return The requested local assurance level, or {@code null} if there is 131 * no local assurance level with the specified integer value. 132 */ 133 @Nullable() 134 public static AssuredReplicationLocalLevel valueOf(final int intValue) 135 { 136 for (final AssuredReplicationLocalLevel l : values()) 137 { 138 if (l.intValue == intValue) 139 { 140 return l; 141 } 142 } 143 144 return null; 145 } 146 147 148 149 /** 150 * Retrieves the local assurance level with the specified name. 151 * 152 * @param name The name of the local assurance level to retrieve. It must 153 * not be {@code null}. 154 * 155 * @return The requested local assurance level, or {@code null} if no such 156 * level is defined. 157 */ 158 @Nullable() 159 public static AssuredReplicationLocalLevel forName(@NotNull final String name) 160 { 161 switch (StaticUtils.toLowerCase(name)) 162 { 163 case "none": 164 return NONE; 165 case "receivedanyserver": 166 case "received-any-server": 167 case "received_any_server": 168 return RECEIVED_ANY_SERVER; 169 case "processedallservers": 170 case "processed-all-servers": 171 case "processed_all_servers": 172 return PROCESSED_ALL_SERVERS; 173 default: 174 return null; 175 } 176 } 177 178 179 180 /** 181 * Retrieves the less strict of the two provided assured replication local 182 * level values. If the two provided values are the same, then that value 183 * will be returned. 184 * 185 * @param l1 The first value to compare. 186 * @param l2 The second value to compare. 187 * 188 * @return The less strict of the two provided assured replication local 189 * level values. 190 */ 191 @NotNull() 192 public static AssuredReplicationLocalLevel getLessStrict( 193 @NotNull final AssuredReplicationLocalLevel l1, 194 @NotNull final AssuredReplicationLocalLevel l2) 195 { 196 // At present, the integer values can be used to make the comparison. If 197 // any more enum values are added, this may need to be changed. 198 if (l1.intValue <= l2.intValue) 199 { 200 return l1; 201 } 202 else 203 { 204 return l2; 205 } 206 } 207 208 209 210 /** 211 * Retrieves the more strict of the two provided assured replication local 212 * level values. If the two provided values are the same, then that value 213 * will be returned. 214 * 215 * @param l1 The first value to compare. 216 * @param l2 The second value to compare. 217 * 218 * @return The more strict of the two provided assured replication local 219 * level values. 220 */ 221 @NotNull() 222 public static AssuredReplicationLocalLevel getMoreStrict( 223 @NotNull final AssuredReplicationLocalLevel l1, 224 @NotNull final AssuredReplicationLocalLevel l2) 225 { 226 // At present, the integer values can be used to make the comparison. If 227 // any more enum values are added, this may need to be changed. 228 if (l1.intValue >= l2.intValue) 229 { 230 return l1; 231 } 232 else 233 { 234 return l2; 235 } 236 } 237}