001/* 002 * Copyright 2017-2018 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright (C) 2017-2018 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.controls; 022 023 024 025import com.unboundid.util.StaticUtils; 026import com.unboundid.util.ThreadSafety; 027import com.unboundid.util.ThreadSafetyLevel; 028 029 030 031/** 032 * This enum defines the set of validation level values that may be used in 033 * conjunction with the {@link UniquenessRequestControl}. 034 * <BR> 035 * <BLOCKQUOTE> 036 * <B>NOTE:</B> This class, and other classes within the 037 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 038 * supported for use against Ping Identity, UnboundID, and 039 * Nokia/Alcatel-Lucent 8661 server products. These classes provide support 040 * for proprietary functionality or for external specifications that are not 041 * considered stable or mature enough to be guaranteed to work in an 042 * interoperable way with other types of LDAP servers. 043 * </BLOCKQUOTE> 044 */ 045@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 046public enum UniquenessValidationLevel 047{ 048 /** 049 * Indicates that no uniqueness validation should be performed. This 050 * validation level has the same effect for requests sent directly to a 051 * Directory Server and requests sent through a Directory Proxy Server. 052 */ 053 NONE(0), 054 055 056 057 /** 058 * Indicates that a single search should be performed per subtree view to 059 * ensure that there are no uniqueness conflicts. This has the following 060 * behavior: 061 * <UL> 062 * <LI> 063 * If the request is received by a Directory Server instance, then only 064 * that instance will be searched for potential conflicts. No replicas 065 * will be examined. 066 * </LI> 067 * <LI> 068 * If the request is received by a Directory Proxy Server instance that 069 * does not use entry balancing, then only one backend server will be 070 * searched for potential conflicts. 071 * </LI> 072 * <LI> 073 * If the request is received by a Directory Proxy Server instance that 074 * uses entry balancing, then the server may only search one backend 075 * server in one backend set if it can use its global index to identify 076 * which backend set is appropriate. However, if the scope of the 077 * uniqueness request control contains the entire set of entry-balanced 078 * data and the global index does not include enough information to 079 * restrict the search to one backend set, then it may be necessary to 080 * issue the search to one server in each backend set. 081 * </LI> 082 * </UL> 083 */ 084 ALL_SUBTREE_VIEWS(1), 085 086 087 088 /** 089 * Indicates that one server from each entry-balanced backend set should be 090 * searched for potential uniqueness conflicts. This has the following 091 * behavior: 092 * <UL> 093 * <LI> 094 * If the request is received by a Directory Server instance, then only 095 * that instance will be searched for potential conflicts. No replicas 096 * will be examined. 097 * </LI> 098 * <LI> 099 * If the request is received by a Directory Proxy Server instance that 100 * does not use entry balancing, then only one backend server will be 101 * searched for potential conflicts. 102 * </LI> 103 * <LI> 104 * If the request is received by a Directory Proxy Server instance that 105 * uses entry balancing and the scope of the uniqueness request control 106 * covers the entire set of entry-balanced data, then one server from each 107 * backend set will be searched for potential conflicts. 108 * </LI> 109 * <LI> 110 * If the request is received by a Directory Proxy Server instance that 111 * uses entry balancing, and if the uniqueness request control has a base 112 * DN that is below the balancing point, and if the server's global index 113 * can be used to identify which backend set contains the entry with that 114 * DN, then it may only be necessary to search within that one backend 115 * set, and only within one server in that set. However, if the global 116 * index cannot be used to identify the appropriate backend set, then it 117 * may be necessary to search one server in each backend set. 118 * </LI> 119 * </UL> 120 */ 121 ALL_BACKEND_SETS(2), 122 123 124 125 /** 126 * Indicates that all available servers within the scope of the uniqueness 127 * criteria should be searched for potential uniqueness conflicts. This has 128 * the following behavior: 129 * <UL> 130 * <LI> 131 * If the request is received by a Directory Server instance, then only 132 * that instance will be searched for potential conflicts. No replicas 133 * will be examined. 134 * </LI> 135 * <LI> 136 * If the request is received by a Directory Proxy Server instance that 137 * does not use entry balancing, then all backend servers with a health 138 * check state of "AVAILABLE" will be searched for potential conflicts. 139 * </LI> 140 * <LI> 141 * If the request is received by a Directory Proxy Server instance that 142 * uses entry balancing and the scope of the uniqueness request control 143 * covers the entire set of entry-balanced data, then all backend servers 144 * with a health check state of "AVAILABLE" will be searched for 145 * potential conflicts, across all backend sets. 146 * </LI> 147 * <LI> 148 * If the request is received by a Directory Proxy Server instance that 149 * uses entry balancing, and if the uniqueness request control has a base 150 * DN that is below the balancing point, and if the server's global index 151 * can be used to identify which backend set contains the entry with that 152 * DN, then it may only be necessary to search all available servers 153 * within that one backend set. However, if the global index cannot be 154 * used to identify the appropriate backend set, then it may be necessary 155 * to search all available servers in all backend sets. 156 * </LI> 157 * </UL> 158 */ 159 ALL_AVAILABLE_BACKEND_SERVERS(3); 160 161 162 163 // The integer value for this uniqueness validation level. 164 private final int intValue; 165 166 167 168 /** 169 * Creates a new uniqueness validation level with the provided integer value. 170 * 171 * @param intValue The integer value for this uniqueness validation level. 172 */ 173 UniquenessValidationLevel(final int intValue) 174 { 175 this.intValue = intValue; 176 } 177 178 179 180 /** 181 * Retrieves the integer value for this uniqueness validation level. 182 * 183 * @return The integer value for this uniqueness validation level. 184 */ 185 public int intValue() 186 { 187 return intValue; 188 } 189 190 191 192 /** 193 * Retrieves the uniqueness validation level with the specified integer value. 194 * 195 * @param intValue The integer value for the uniqueness validation level to 196 * retrieve. 197 * 198 * @return The uniqueness validation level for the provided integer value, or 199 * {@code null} if there is no validation level with the given 200 * integer value. 201 */ 202 public static UniquenessValidationLevel valueOf(final int intValue) 203 { 204 switch (intValue) 205 { 206 case 0: 207 return NONE; 208 case 1: 209 return ALL_SUBTREE_VIEWS; 210 case 2: 211 return ALL_BACKEND_SETS; 212 case 3: 213 return ALL_AVAILABLE_BACKEND_SERVERS; 214 default: 215 return null; 216 } 217 } 218 219 220 221 /** 222 * Retrieves the uniqueness validation level with the specified name. 223 * 224 * @param name The name of the uniqueness validation level to retrieve. It 225 * must not be {@code null}. 226 * 227 * @return The requested uniqueness validation level, or {@code null} if no 228 * such level is defined. 229 */ 230 public static UniquenessValidationLevel forName(final String name) 231 { 232 switch (StaticUtils.toLowerCase(name)) 233 { 234 case "none": 235 return NONE; 236 case "allsubtreeviews": 237 case "all-subtree-views": 238 case "all_subtree_views": 239 return ALL_SUBTREE_VIEWS; 240 case "allbackendsets": 241 case "all-backend-sets": 242 case "all_backend_sets": 243 return ALL_BACKEND_SETS; 244 case "allavailablebackendservers": 245 case "all-available-backend-servers": 246 case "all_available_backend_servers": 247 return ALL_AVAILABLE_BACKEND_SERVERS; 248 default: 249 return null; 250 } 251 } 252}