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