001/* 002 * Copyright 2010-2019 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright (C) 2010-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.controls; 022 023 024 025import com.unboundid.util.StaticUtils; 026 027 028 029/** 030 * This enum defines the synchronization states for entries returned with the 031 * content synchronization state control. See the documentation for the 032 * {@link ContentSyncRequestControl} class for more information about using the 033 * content synchronization operation. 034 */ 035public enum ContentSyncInfoType 036{ 037 /** 038 * Indicates that the associated content synchronization info response only 039 * provides a new state cookie. 040 */ 041 NEW_COOKIE((byte) 0x80), 042 043 044 045 /** 046 * Indicates that the associated content synchronization info response is used 047 * to indicate that a delete phase has ended. 048 */ 049 REFRESH_DELETE((byte) 0xA1), 050 051 052 053 /** 054 * Indicates that the associated content synchronization info response is used 055 * to indicate that a present phase has ended. 056 */ 057 REFRESH_PRESENT((byte) 0xA2), 058 059 060 061 /** 062 * Indicates that the associated content synchronization info response is used 063 * to provide information about multiple entries which have been deleted or 064 * multiple entries which have remained unchanged. 065 */ 066 SYNC_ID_SET((byte) 0xA3); 067 068 069 070 // The BER type used for this sync info type in the value of a content 071 // synchronization info message. 072 private final byte type; 073 074 075 076 /** 077 * Creates a new content synchronization info type value with the specified 078 * BER type. 079 * 080 * @param type The BER type used for this sync info type in the value of a 081 * content synchronization info message. 082 */ 083 ContentSyncInfoType(final byte type) 084 { 085 this.type = type; 086 } 087 088 089 090 /** 091 * Retrieves the BER type for this synchronization info type value. 092 * 093 * @return The BER type for this synchronization info type value. 094 */ 095 public byte getType() 096 { 097 return type; 098 } 099 100 101 102 /** 103 * Retrieves the content synchronization info type with the specified BER 104 * type. 105 * 106 * @param type The BER type of the content synchronization info type value 107 * to retrieve. 108 * 109 * @return The content synchronization info value with the specified BER 110 * type, or {@code null} if the given value does not correspond with 111 * any defined type. 112 */ 113 public static ContentSyncInfoType valueOf(final byte type) 114 { 115 if (type == NEW_COOKIE.getType()) 116 { 117 return NEW_COOKIE; 118 } 119 else if (type == REFRESH_DELETE.getType()) 120 { 121 return REFRESH_DELETE; 122 } 123 else if (type == REFRESH_PRESENT.getType()) 124 { 125 return REFRESH_PRESENT; 126 } 127 else if (type == SYNC_ID_SET.getType()) 128 { 129 return SYNC_ID_SET; 130 } 131 else 132 { 133 return null; 134 } 135 } 136 137 138 139 /** 140 * Retrieves the content synchronization info type with the specified name. 141 * 142 * @param name The name of the content synchronization info type to 143 * retrieve. It must not be {@code null}. 144 * 145 * @return The requested content sync info type, or {@code null} if no such 146 * type is defined. 147 */ 148 public static ContentSyncInfoType forName(final String name) 149 { 150 switch (StaticUtils.toLowerCase(name)) 151 { 152 case "newcookie": 153 case "new-cookie": 154 case "new_cookie": 155 return NEW_COOKIE; 156 case "refreshdelete": 157 case "refresh-delete": 158 case "refresh_delete": 159 return REFRESH_DELETE; 160 case "refreshpresent": 161 case "refresh-present": 162 case "refresh_present": 163 return REFRESH_PRESENT; 164 case "syncidset": 165 case "sync-id-set": 166 case "sync_id_set": 167 return SYNC_ID_SET; 168 default: 169 return null; 170 } 171 } 172}