1 /* 2 ServiceLocationException.java 3 4 (C) Copyright IBM Corp. 2005, 2009 5 6 THIS FILE IS PROVIDED UNDER THE TERMS OF THE ECLIPSE PUBLIC LICENSE 7 ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE 8 CONSTITUTES RECIPIENTS ACCEPTANCE OF THE AGREEMENT. 9 10 You can obtain a current copy of the Eclipse Public License from 11 http://www.opensource.org/licenses/eclipse-1.0.php 12 13 @author : Roberto Pineiro, IBM, roberto.pineiro@us.ibm.com 14 * @author : Chung-hao Tan, IBM, chungtan@us.ibm.com 15 * 16 * Change History 17 * Flag Date Prog Description 18 *------------------------------------------------------------------------------- 19 * 1516246 2006-07-22 lupusalex Integrate SLP client code 20 * 2003590 2008-06-30 blaschke-oss Change licensing from CPL to EPL 21 * 2524131 2009-01-21 raman_arora Upgrade client to JDK 1.5 (Phase 1) 22 */ 23 24 package org.metricshub.wbem.sblim.slp; 25 26 /*- 27 * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲ 28 * WBEM Java Client 29 * ჻჻჻჻჻჻ 30 * Copyright 2023 - 2025 MetricsHub 31 * ჻჻჻჻჻჻ 32 * Licensed under the Apache License, Version 2.0 (the "License"); 33 * you may not use this file except in compliance with the License. 34 * You may obtain a copy of the License at 35 * 36 * http://www.apache.org/licenses/LICENSE-2.0 37 * 38 * Unless required by applicable law or agreed to in writing, software 39 * distributed under the License is distributed on an "AS IS" BASIS, 40 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 41 * See the License for the specific language governing permissions and 42 * limitations under the License. 43 * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱ 44 */ 45 46 /** 47 * The ServiceLocationException class is thrown by all methods when exceptional 48 * conditions occur in the SLP framework. The error code property determines the 49 * exact nature of the condition, and an optional message may provide more 50 * information. 51 */ 52 public class ServiceLocationException extends Exception { 53 private static final long serialVersionUID = 6414188770647750627L; 54 55 /** 56 * OK 57 */ 58 public static final short OK = 0; 59 60 /** 61 * There is data for the service type in the scope in the AttrRqst or 62 * SrvRqst, but not in the requested language. 63 */ 64 public static final short LANGUAGE_NOT_SUPPORTED = 1; 65 66 /** 67 * The message fails to obey SLP syntax. 68 */ 69 public static final short PARSE_ERROR = 2; 70 71 /** 72 * The SrvReg has problems -- e.g., a zero lifetime or an omitted Language 73 * Tag. 74 */ 75 public static final short INVALID_REGISTRATION = 3; 76 77 /** 78 * The SLP message did not include a scope in its <scope-list> supported by 79 * the SA or DA. 80 */ 81 public static final short SCOPE_NOT_SUPPORTED = 4; 82 83 /** 84 * The DA or SA receives a request for an unsupported SLP SPI. 85 */ 86 public static final short AUTHENTICATION_UNKNOWN = 5; 87 88 /** 89 * The DA expected URL and ATTR authentication in the SrvReg and did not 90 * receive it. 91 */ 92 public static final short AUTHENTICATION_ABSENT = 6; 93 94 /** 95 * The DA detected an authentication error in an Authentication block. 96 */ 97 public static final short AUTHENTICATION_FAILED = 7; 98 99 /** 100 * Unsupported version number in message header. 101 */ 102 public static final short VERSION_NOT_SUPPORTED = 9; 103 104 /** 105 * The DA (or SA) is too sick to respond. 106 */ 107 public static final short INTERNAL_ERROR = 10; 108 109 /** 110 * UA or SA SHOULD retry, using exponential back off. 111 */ 112 public static final short DA_BUSY = 11; 113 114 /** 115 * The DA (or SA) received an unknown option from the mandatory range (see 116 * section 9.1). 117 */ 118 public static final short OPTION_NOT_SUPPORTED = 12; 119 120 /** 121 * The DA received a SrvReg without FRESH set, for an unregistered service 122 * or with inconsistent Service Types. 123 */ 124 public static final short INVALID_UPDATE = 13; 125 126 /** 127 * The SA received an AttrRqst or SrvTypeRqst and does not support it. 128 */ 129 public static final short REQUEST_NOT_SUPPORTED = 14; 130 131 /** 132 * The SA sent a SrvReg or partial SrvDereg to a DA more frequently than the 133 * DA's min-refresh-interval. 134 */ 135 public static final short REFRESH_REJECTED = 15; 136 137 /** 138 * NOT_IMPLEMENTED 139 */ 140 public static final short NOT_IMPLEMENTED = 16; 141 142 /** 143 * NETWORK_INIT_FAILED 144 */ 145 public static final short NETWORK_INIT_FAILED = 17; 146 147 /** 148 * NETWORK_TIMED_OUT 149 */ 150 public static final short NETWORK_TIMED_OUT = 18; 151 152 /** 153 * NETWORK_ERROR 154 */ 155 public static final short NETWORK_ERROR = 19; 156 157 /** 158 * INTERNAL_SYSTEM_ERROR 159 */ 160 public static final short INTERNAL_SYSTEM_ERROR = 20; 161 162 /** 163 * TYPE_ERROR 164 */ 165 public static final short TYPE_ERROR = 21; 166 167 /** 168 * BUFFER_OVERFLOW 169 */ 170 public static final short BUFFER_OVERFLOW = 22; 171 172 /** 173 * PREVIOUS_RESPONDER_OVERFLOW 174 */ 175 public static final short PREVIOUS_RESPONDER_OVERFLOW = 100; 176 177 private static final String[] ERROR_MESSAGES = { 178 "OK", 179 "LANGUAGE_NOT_SUPPORTED", 180 "PARSE_ERROR", 181 "INVALID_REGISTRATION", 182 "SCOPE_NOT_SUPPORTED", 183 "AUTHENTICATION_UNKNOWN", 184 "AUTHENTICATION_ABSENT", 185 "AUTHENTICATION_FAILED", 186 "", 187 "VERSION_NOT_SUPPORTED", 188 "INTERNAL_ERROR", 189 "DA_BUSY", 190 "OPTION_NOT_SUPPORTED", 191 "INVALID_UPDATE", 192 "REQUEST_NOT_SUPPORTED", 193 "REFRESH_REJECTED", 194 "NOT_IMPLEMENTED", 195 "NETWORK_INIT_FAILED", 196 "NETWORK_TIMED_OUT", 197 "NETWORK_ERROR", 198 "INTERNAL_SYSTEM_ERROR", 199 "TYPE_ERROR", 200 "BUFFER_OVERFLOW" 201 }; 202 203 private short iErrorCode; 204 205 /** 206 * Ctor. 207 * 208 * @param pErrorCode 209 * One of the ec constants in this class 210 */ 211 public ServiceLocationException(short pErrorCode) { 212 super(ERROR_MESSAGES[pErrorCode]); 213 this.iErrorCode = pErrorCode; 214 } 215 216 /** 217 * Ctor. 218 * 219 * @param pErrorCode 220 * One of the ec constants in this class 221 * @param pCause 222 * The cause 223 */ 224 public ServiceLocationException(short pErrorCode, Throwable pCause) { 225 super(ERROR_MESSAGES[pErrorCode], pCause); 226 this.iErrorCode = pErrorCode; 227 } 228 229 /** 230 * Ctor. 231 * 232 * @param pErrorCode 233 * One of the ec constants in this class 234 * @param pMessage 235 * A more specific message 236 * @param pCause 237 * 238 */ 239 public ServiceLocationException(short pErrorCode, String pMessage, Throwable pCause) { 240 super(ERROR_MESSAGES[pErrorCode] + "(" + pMessage + ")", pCause); 241 this.iErrorCode = pErrorCode; 242 } 243 244 /** 245 * Ctor. 246 * 247 * @param pErrorCode 248 * One of the error code constants in this class 249 * @param pMessage 250 * A more specific message 251 */ 252 public ServiceLocationException(short pErrorCode, String pMessage) { 253 this(pErrorCode, pMessage, null); 254 } 255 256 /** 257 * Return the error code. The error code takes on one of the static field 258 * values. 259 * 260 * @return The error code 261 */ 262 public short getErrorCode() { 263 return this.iErrorCode; 264 } 265 266 /** 267 * Gets the message associated to this exception. 268 * 269 * @return The message 270 */ 271 @Override 272 public String getMessage() { 273 if (getCause() == null) { 274 return super.getMessage(); 275 } 276 return super.getMessage() + "; nested exception is: \n\t" + getCause().toString(); 277 } 278 }