]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
67b60efebc60626f9e8918b43f7cce5c43d757bf
[tmp/jakarta-migration.git] /
1 package org.collectionspace.services.nuxeo.client.java;
2
3 import org.collectionspace.services.common.CSWebApplicationException;
4 import org.collectionspace.services.common.document.DocumentException;
5 import org.nuxeo.ecm.core.api.WrappedException;
6
7 public class NuxeoDocumentException extends DocumentException {
8
9         /**
10          * 
11          */
12         private static final long serialVersionUID = 1L;
13
14         public NuxeoDocumentException() {
15                 super();
16         }
17
18         public NuxeoDocumentException(String msg) {
19                 super(msg);
20                 // TODO Auto-generated constructor stub
21         }
22
23         public NuxeoDocumentException(int errorCode) {
24                 super(errorCode);
25                 // TODO Auto-generated constructor stub
26         }
27
28         public NuxeoDocumentException(int errorCode, String errorReason) {
29                 super(errorCode, errorReason);
30                 // TODO Auto-generated constructor stub
31         }
32
33         public NuxeoDocumentException(String message, Throwable cause) {
34                 super(message, cause);
35                 // TODO Auto-generated constructor stub
36         }
37
38         public NuxeoDocumentException(Throwable cause) {
39                 super(cause);
40                 // TODO Auto-generated constructor stub
41         }
42         
43         private static String getExceptionClassName(Throwable exception) {
44                 String result = null;
45                 
46                 if (exception != null) {
47                         result = exception.getClass().getCanonicalName();
48                         if (exception instanceof WrappedException) {
49                                 result = ((WrappedException)exception).getClassName();  // Nuxeo wraps the original exception, so we need to get the name of it.
50                         }
51                 }
52                 
53                 return result;
54         }
55
56         @Override
57         public boolean exceptionChainContainsNetworkError() {
58                 boolean result = false;
59                 
60                 Throwable cause = this;
61                 while (cause != null) {
62                         String exceptionClassName = getExceptionClassName(cause);
63                         if (CSWebApplicationException.isExceptionNetworkRelated(exceptionClassName) == true) {
64                                 result = true;
65                                 break;
66                         }
67                         
68                         cause = cause.getCause();
69                 }
70
71                 return result;
72         }
73         
74 }