001 /* 002 * Copyright 2008-2015 UnboundID Corp. 003 * All Rights Reserved. 004 */ 005 /* 006 * Copyright (C) 2015 UnboundID Corp. 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 */ 021 package com.unboundid.ldap.sdk.unboundidds.controls; 022 023 024 025 import com.unboundid.ldap.sdk.Control; 026 import com.unboundid.ldap.sdk.LDAPException; 027 import com.unboundid.ldap.sdk.ResultCode; 028 import com.unboundid.util.NotMutable; 029 import com.unboundid.util.ThreadSafety; 030 import com.unboundid.util.ThreadSafetyLevel; 031 032 import static com.unboundid.ldap.sdk.unboundidds.controls.ControlMessages.*; 033 034 035 036 /** 037 * <BLOCKQUOTE> 038 * <B>NOTE:</B> This class is part of the Commercial Edition of the UnboundID 039 * LDAP SDK for Java. It is not available for use in applications that 040 * include only the Standard Edition of the LDAP SDK, and is not supported for 041 * use in conjunction with non-UnboundID products. 042 * </BLOCKQUOTE> 043 * This class provides a request control which may be used to request the server 044 * ID of the server that actually processed the associated request. It may be 045 * used for requests sent directly to a Directory Server, but it is more useful 046 * when the request will pass through a Directory Proxy Server instance because 047 * the corresponding {@link GetServerIDResponseControl} will provide the server 048 * ID of the backend server used to process the request. This server ID may be 049 * used in a {@link RouteToServerRequestControl} instance to request that 050 * subsequent operations be processed by the same server. See the documentation 051 * for the {@code RouteToServerRequestControl} for an example that demonstrates 052 * this. 053 * <BR><BR> 054 * This control does not have a value. The criticality may be either 055 * {@code true} or {@code false}. 056 */ 057 @NotMutable() 058 @ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 059 public final class GetServerIDRequestControl 060 extends Control 061 { 062 /** 063 * The OID (1.3.6.1.4.1.30221.2.5.14) for the get server ID request control. 064 */ 065 public static final String GET_SERVER_ID_REQUEST_OID = 066 "1.3.6.1.4.1.30221.2.5.14"; 067 068 069 /** 070 * The serial version UID for this serializable class. 071 */ 072 private static final long serialVersionUID = -6015835755174298354L; 073 074 075 076 /** 077 * Creates a new get server ID request control. It will not be marked 078 * critical. 079 */ 080 public GetServerIDRequestControl() 081 { 082 this(false); 083 } 084 085 086 087 /** 088 * Creates a new get server ID request control with the specified 089 * criticality. 090 * 091 * @param isCritical Indicates whether this control should be marked 092 * critical. 093 */ 094 public GetServerIDRequestControl(final boolean isCritical) 095 { 096 super(GET_SERVER_ID_REQUEST_OID, isCritical, null); 097 } 098 099 100 101 /** 102 * Creates a new get server ID request control which is decoded from the 103 * provided generic control. 104 * 105 * @param control The generic control to be decoded as a get server ID 106 * request control. 107 * 108 * @throws LDAPException If the provided control cannot be decoded as a get 109 * server ID request control. 110 */ 111 public GetServerIDRequestControl(final Control control) 112 throws LDAPException 113 { 114 super(control); 115 116 if (control.hasValue()) 117 { 118 throw new LDAPException(ResultCode.DECODING_ERROR, 119 ERR_GET_SERVER_ID_REQUEST_HAS_VALUE.get()); 120 } 121 } 122 123 124 125 /** 126 * {@inheritDoc} 127 */ 128 @Override() 129 public String getControlName() 130 { 131 return INFO_CONTROL_NAME_GET_SERVER_ID_REQUEST.get(); 132 } 133 134 135 136 /** 137 * {@inheritDoc} 138 */ 139 @Override() 140 public void toString(final StringBuilder buffer) 141 { 142 buffer.append("GetServerIDRequestControl(isCritical="); 143 buffer.append(isCritical()); 144 buffer.append(')'); 145 } 146 }