1 16 package org.apache.juddi.error; 17 18 import org.apache.juddi.datatype.RegistryObject; 19 import org.apache.juddi.datatype.response.DispositionReport; 20 import org.apache.juddi.datatype.response.Result; 21 22 27 public class RegistryException extends Exception implements RegistryObject 28 { 29 private String faultActor; 31 32 private String faultCode; 34 35 private String faultString; 37 38 private DispositionReport dispReport; 40 41 45 public RegistryException(String msg) 46 { 47 super(msg); 48 49 setFaultCode(null); 50 setFaultString(msg); 51 setFaultActor(null); 52 } 53 54 58 public RegistryException(Exception ex) 59 { 60 super(ex); 61 62 if (ex != null) 63 { 64 if (ex instanceof RegistryException) 70 { 71 RegistryException regex = (RegistryException)ex; 72 setFaultCode(regex.getFaultCode()); 73 setFaultString(regex.getFaultString()); 74 setFaultActor(regex.getFaultActor()); 75 setDispositionReport(regex.getDispositionReport()); 76 } 77 else { 79 setFaultString(ex.getMessage()); 80 } 81 } 82 } 83 84 88 public RegistryException(String fCode,String fString,String fActor,DispositionReport dispRpt) 89 { 90 super(fString); 91 92 setFaultCode(fCode); 93 setFaultString(fString); 94 setFaultActor(fActor); 95 setDispositionReport(dispRpt); 96 } 97 98 102 RegistryException(String fCode,int errno,String msg) 103 { 104 super(buildMessage(errno,msg)); 105 106 String errCode = Result.lookupErrCode(errno); 107 108 setFaultCode(fCode); 109 setFaultString(getMessage()); 110 addResult(new Result(errno,errCode,getMessage())); 111 } 112 113 117 public void setFaultActor(String actor) 118 { 119 this.faultActor = actor; 120 } 121 122 126 public String getFaultActor() 127 { 128 return this.faultActor; 129 } 130 131 135 public void setFaultCode(String code) 136 { 137 this.faultCode = code; 138 } 139 140 144 public String getFaultCode() 145 { 146 return this.faultCode; 147 } 148 149 153 public void setFaultString(String value) 154 { 155 this.faultString = value; 156 } 157 158 162 public String getFaultString() 163 { 164 return this.faultString; 165 } 166 167 173 public void setDispositionReport(DispositionReport dispRpt) 174 { 175 this.dispReport = dispRpt; 176 } 177 178 184 public DispositionReport getDispositionReport() 185 { 186 return this.dispReport; 187 } 188 189 193 public void addResult(Result result) 194 { 195 if (this.dispReport==null) 196 this.dispReport = new DispositionReport(); 197 this.dispReport.addResult(result); 198 } 199 200 203 public String toString() 204 { 205 String msg = getMessage(); 206 if (msg == null) 207 return ""; 208 else 209 return getMessage(); 210 } 211 212 private static final String buildMessage(int errno,String msg) 213 { 214 StringBuffer buffer = new StringBuffer (); 215 216 String errCode = Result.lookupErrCode(errno); 217 if (errCode != null) 218 { 219 buffer.append(errCode); 220 buffer.append(" "); 221 } 222 223 buffer.append("("); 224 buffer.append(errno); 225 buffer.append(") "); 226 227 String errText = Result.lookupErrText(errno); 228 if (errText != null) 229 { 230 buffer.append(errText); 231 buffer.append(" "); 232 } 233 234 if ((msg != null) && (msg.trim().length() > 0)) 235 { 236 buffer.append(msg); 237 } 238 239 return buffer.toString(); 240 } 241 242 243 244 245 246 247 248 public static void main(String [] args) 249 throws RegistryException 250 { 251 System.out.println(new AccountLimitExceededException("Additional error information.")); 252 System.out.println(new AssertionNotFoundException("Additional error information.")); 253 System.out.println(new AuthTokenExpiredException("Additional error information.")); 254 System.out.println(new AuthTokenRequiredException("Additional error information.")); 255 System.out.println(new BusyException("Additional error information.")); 256 System.out.println(new CategorizationNotAllowedException("Additional error information.")); 257 System.out.println(new FatalErrorException("Additional error information.")); 258 System.out.println(new InvalidCategoryException("Additional error information.")); 259 System.out.println(new InvalidCompletionStatusException("Additional error information.")); 260 System.out.println(new InvalidKeyPassedException("Additional error information.")); 261 System.out.println(new InvalidProjectionException("Additional error information.")); 262 System.out.println(new InvalidTimeException("Additional error information.")); 263 System.out.println(new InvalidURLPassedException("Additional error information.")); 264 System.out.println(new InvalidValueException("Additional error information.")); 265 System.out.println(new KeyRetiredException("Additional error information.")); 266 System.out.println(new LanguageErrorException("Additional error information.")); 267 System.out.println(new MessageTooLargeException("Additional error information.")); 268 System.out.println(new NameTooLongException("Additional error information.")); 269 System.out.println(new OperatorMismatchException("Additional error information.")); 270 System.out.println(new PublisherCancelledException("Additional error information.")); 271 System.out.println(new RequestDeniedException("Additional error information.")); 272 System.out.println(new RequestTimeoutException("Additional error information.")); 273 System.out.println(new ResultSetTooLargeException("Additional error information.")); 274 System.out.println(new SecretUnknownException("Additional error information.")); 275 System.out.println(new TooManyOptionsException("Additional error information.")); 276 System.out.println(new TransferAbortedException("Additional error information.")); 277 System.out.println(new UnknownUserException("Additional error information.")); 278 System.out.println(new UnknownUserException("Additional error information.")); 279 System.out.println(new UnrecognizedVersionException("Additional error information.")); 280 System.out.println(new UnsupportedException("Additional error information.")); 281 System.out.println(new UnvalidatableException("Additional error information.")); 282 System.out.println(new UserMismatchException("Additional error information.")); 283 System.out.println(new ValueNotAllowedException("Additional error information.")); 284 285 System.out.println("\n----- RegistryException(String) -----"); 286 287 System.out.println(new RegistryException((String )null)); 288 System.out.println(new RegistryException("Additional error information.")); 289 290 System.out.println("\n----- RegistryException(Exception) -----"); 291 292 System.out.println(new RegistryException((Exception )null)); 293 System.out.println(new RegistryException((Exception )new Exception ("Additional error information."))); 294 System.out.println(new RegistryException((Exception )new RegistryException("Additional error information."))); 295 System.out.println(new RegistryException((Exception )new UnknownUserException("Additional error information."))); 296 297 System.out.println("\n----- RegistryException(FaultCode,errno,String) -----"); 298 299 System.out.println(new RegistryException(null,-1,null)); 300 System.out.println(new RegistryException("Server",-1,null)); 301 System.out.println(new RegistryException("Server",Result.E_BUSY,null)); 302 System.out.println(new RegistryException("Server",Result.E_BUSY,"Additional error information.")); 303 } 304 } | Popular Tags |