001/* 002 * Copyright 2019 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright (C) 2019 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; 026 027 028 029/** 030 * This enum defines a set of values that provide information about the result 031 * of validation processing that the server performed in response to a 032 * {@link UniquenessRequestControl}. 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 038 * Nokia/Alcatel-Lucent 8661 server products. These classes provide support 039 * for proprietary functionality or for external specifications that are not 040 * considered stable or mature enough to be guaranteed to work in an 041 * interoperable way with other types of LDAP servers. 042 * </BLOCKQUOTE> 043 */ 044public enum UniquenessValidationResult 045{ 046 /** 047 * Indicates that the server verified that the requested update did not 048 * conflict with any existing entries at the time the validation processing 049 * was performed. 050 */ 051 VALIDATION_PASSED("validation-passed"), 052 053 054 055 /** 056 * Indicates that the server found at least one other entry in the server that 057 * conflicted with the attempted write operation. 058 */ 059 VALIDATION_FAILED("validation-failed"), 060 061 062 063 /** 064 * Indicates that the server did not attempt any uniqueness validation 065 * processing at the associated point in operation processing. Potential 066 * reasons that no validation may have been attempted include that the 067 * {@link UniquenessRequestControl} indicated that no validation was required 068 * at that point in the processing, because the uniqueness constraint did 069 * not apply to the associated operation (for example, the control indicated 070 * that uniqueness should be maintained for an attribute that was not included 071 * in the update), or that the operation failed for some reason that was not 072 * related to uniqueness processing. 073 */ 074 VALIDATION_NOT_ATTEMPTED("validation-not-attempted"); 075 076 077 078 // The name for this validation result. 079 private final String name; 080 081 082 083 /** 084 * Creates a new uniqueness validation result with the provided name. 085 * 086 * @param name The name for this uniqueness validation result. 087 */ 088 UniquenessValidationResult(final String name) 089 { 090 this.name = name; 091 } 092 093 094 095 /** 096 * Retrieves the name for this uniqueness validation result. 097 * 098 * @return The name for this uniqueness validation result. 099 */ 100 public String getName() 101 { 102 return name; 103 } 104 105 106 107 /** 108 * Retrieves the uniqueness validation result with the given name. 109 * 110 * @param name The name for the uniqueness validation result to retrieve. 111 * It must not be {@code null}. 112 * 113 * @return The uniqueness validation result with the given name, or 114 * {@code null} if there is no result with the given name. 115 */ 116 public static UniquenessValidationResult forName(final String name) 117 { 118 final String n = StaticUtils.toLowerCase(name).replace('_', '-'); 119 for (final UniquenessValidationResult r : values()) 120 { 121 if (r.getName().equals(n)) 122 { 123 return r; 124 } 125 } 126 127 return null; 128 } 129 130 131 132 /** 133 * Retrieves a string representation for this uniqueness validation result. 134 * 135 * @return A string representation for this uniqueness validation result. 136 */ 137 @Override() 138 public String toString() 139 { 140 return name; 141 } 142}