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