001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.directory.api.ldap.model.message.extended; 021 022 023import org.apache.directory.api.i18n.I18n; 024import org.apache.directory.api.ldap.model.message.DeleteResponseImpl; 025import org.apache.directory.api.ldap.model.message.ResultCodeEnum; 026import org.apache.directory.api.util.Strings; 027 028 029/** 030 * An extended operation intended for notifying clients of upcoming 031 * disconnection for the Delete response. 032 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 033 */ 034public final class DeleteNoDResponse extends DeleteResponseImpl 035{ 036 /** The OID of the NotiveOfDisconnect extended operation. */ 037 public static final String EXTENSION_OID = NoticeOfDisconnect.EXTENSION_OID; 038 039 /** The single instance with unavailable result code. */ 040 public static final DeleteNoDResponse UNAVAILABLE = new DeleteNoDResponse( ResultCodeEnum.UNAVAILABLE ); 041 042 /** The single instance with protocolError result code. */ 043 public static final DeleteNoDResponse PROTOCOLERROR = new DeleteNoDResponse( ResultCodeEnum.PROTOCOL_ERROR ); 044 045 /** The single instance with strongAuthRequired result code. */ 046 public static final DeleteNoDResponse STRONGAUTHREQUIRED = new DeleteNoDResponse( 047 ResultCodeEnum.STRONG_AUTH_REQUIRED ); 048 049 050 /** 051 * Creates a new instance of NoticeOfDisconnect. 052 */ 053 private DeleteNoDResponse( ResultCodeEnum rcode ) 054 { 055 super(); 056 057 switch ( rcode ) 058 { 059 case UNAVAILABLE: 060 break; 061 062 case PROTOCOL_ERROR: 063 break; 064 065 case STRONG_AUTH_REQUIRED: 066 break; 067 068 default: 069 throw new IllegalArgumentException( I18n.err( I18n.ERR_04166, ResultCodeEnum.UNAVAILABLE, 070 ResultCodeEnum.PROTOCOL_ERROR, ResultCodeEnum.STRONG_AUTH_REQUIRED ) ); 071 } 072 073 super.getLdapResult().setDiagnosticMessage( rcode.toString() + ": The server will disconnect!" ); 074 super.getLdapResult().setMatchedDn( null ); 075 super.getLdapResult().setResultCode( rcode ); 076 } 077 078 079 // ------------------------------------------------------------------------ 080 // ExtendedResponse Interface Method Implementations 081 // ------------------------------------------------------------------------ 082 /** 083 * Gets the reponse OID specific encoded response values. 084 * 085 * @return the response specific encoded response values. 086 */ 087 public byte[] getResponse() 088 { 089 return Strings.EMPTY_BYTES; 090 } 091 092 093 /** 094 * Gets the OID uniquely identifying this extended response (a.k.a. its 095 * name). 096 * 097 * @return the OID of the extended response type. 098 */ 099 public String getResponseName() 100 { 101 return EXTENSION_OID; 102 } 103}