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 */ 020 package org.apache.directory.shared.ldap.message.extended; 021 022 023 import org.apache.directory.shared.i18n.I18n; 024 import org.apache.directory.shared.ldap.message.ExtendedResponseImpl; 025 import org.apache.directory.shared.ldap.message.ResultCodeEnum; 026 027 028 /** 029 * The response sent back from the server with a LaunchDiagnosticUiRequest 030 * extended operation. 031 * 032 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 033 * @version $Rev: 912436 $ 034 */ 035 public class LaunchDiagnosticUiResponse extends ExtendedResponseImpl 036 { 037 private static final long serialVersionUID = -3824715470944544189L; 038 039 public static final String EXTENSION_OID = "1.3.6.1.4.1.18060.0.1.2"; 040 041 private static final byte[] EMPTY_RESPONSE = new byte[0]; 042 043 044 public LaunchDiagnosticUiResponse(int messageId, ResultCodeEnum rcode) 045 { 046 super( messageId, EXTENSION_OID ); 047 048 switch ( rcode ) 049 { 050 case SUCCESS : 051 break; 052 053 case OPERATIONS_ERROR : 054 break; 055 056 case INSUFFICIENT_ACCESS_RIGHTS : 057 break; 058 059 default: 060 throw new IllegalArgumentException( I18n.err( I18n.ERR_04166, ResultCodeEnum.SUCCESS, 061 ResultCodeEnum.OPERATIONS_ERROR, ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS ) ); 062 } 063 064 super.getLdapResult().setMatchedDn( null ); 065 super.getLdapResult().setResultCode( rcode ); 066 } 067 068 069 public LaunchDiagnosticUiResponse(int messageId) 070 { 071 super( messageId, EXTENSION_OID ); 072 super.getLdapResult().setMatchedDn( null); 073 super.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS ); 074 } 075 076 077 // ------------------------------------------------------------------------ 078 // ExtendedResponse Interface Method Implementations 079 // ------------------------------------------------------------------------ 080 081 /** 082 * Gets the reponse OID specific encoded response values. 083 * 084 * @return the response specific encoded response values. 085 */ 086 public byte[] getResponse() 087 { 088 return EMPTY_RESPONSE; 089 } 090 091 092 /** 093 * Sets the reponse OID specific encoded response values. 094 * 095 * @param value 096 * the response specific encoded response values. 097 */ 098 public void setResponse( byte[] value ) 099 { 100 throw new UnsupportedOperationException( I18n.err( I18n.ERR_04173 ) ); 101 } 102 103 104 /** 105 * Gets the OID uniquely identifying this extended response (a.k.a. its 106 * name). 107 * 108 * @return the OID of the extended response type. 109 */ 110 public String getResponseName() 111 { 112 return EXTENSION_OID; 113 } 114 115 116 /** 117 * Sets the OID uniquely identifying this extended response (a.k.a. its 118 * name). 119 * 120 * @param oid 121 * the OID of the extended response type. 122 */ 123 public void setResponseName( String oid ) 124 { 125 throw new UnsupportedOperationException( I18n.err( I18n.ERR_04168, EXTENSION_OID ) ); 126 } 127 128 129 public boolean equals( Object obj ) 130 { 131 if ( obj == this ) 132 { 133 return true; 134 } 135 136 if ( obj instanceof LaunchDiagnosticUiResponse ) 137 { 138 return true; 139 } 140 141 return false; 142 } 143 }