1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 package org.ogf.graap.wsag.wsrf.faults;
36
37 import java.util.GregorianCalendar;
38
39 import javax.xml.namespace.QName;
40
41 import org.apache.muse.util.xml.XmlUtils;
42 import org.apache.muse.util.xml.XsdUtils;
43 import org.apache.muse.ws.addressing.EndpointReference;
44 import org.apache.muse.ws.resource.WsrfConstants;
45 import org.apache.muse.ws.resource.basefaults.BaseFault;
46 import org.apache.muse.ws.resource.basefaults.WsbfConstants;
47 import org.ogf.schemas.graap.wsAgreement.ContinuingFaultDocument;
48 import org.ogf.schemas.graap.wsAgreement.ContinuingFaultType;
49 import org.w3c.dom.Element;
50
51
52
53
54
55
56
57 public abstract class AbstractAgreementFault extends BaseFault
58 {
59
60 private static final long serialVersionUID = 1L;
61
62
63
64
65
66
67 public AbstractAgreementFault( Element element )
68 {
69 super( element );
70 }
71
72
73
74
75
76
77
78
79
80 public AbstractAgreementFault( QName name, String message )
81 {
82 super( name, message );
83 }
84
85
86
87
88
89
90
91
92
93
94 public AbstractAgreementFault( QName name, String message, Throwable throwable )
95 {
96 super( name, message, throwable );
97 }
98
99
100
101
102
103
104
105
106 public AbstractAgreementFault( QName name, Throwable throwable )
107 {
108 super( name, throwable );
109 }
110
111
112
113
114 protected void createDetail()
115 {
116 Element baseFault = XmlUtils.createElement( getName() );
117
118 Element timestamp =
119 XmlUtils.createElement( new QName( WsrfConstants.NAMESPACE_URI, "Timestamp", WsrfConstants.PREFIX ),
120 XsdUtils.getLocalTimeString( getTimestamp() ) );
121
122 Element description =
123 XmlUtils.createElement( new QName( WsrfConstants.NAMESPACE_URI, "Description",
124 WsrfConstants.PREFIX ), getMessage() );
125
126 baseFault.appendChild( timestamp );
127 baseFault.appendChild( description );
128
129 setDetail( baseFault );
130 }
131
132
133
134
135
136
137 @Override
138 public Element getDetail()
139 {
140 Element baseFault = XmlUtils.createElement( getName() );
141 XmlUtils.setElement( baseFault, WsbfConstants.TIMESTAMP_QNAME, getTimestamp() );
142
143 EndpointReference originEPR = getOriginReference();
144
145 if ( originEPR != null )
146 {
147 Element originXML = originEPR.toXML();
148 baseFault.appendChild( originXML );
149 }
150
151 Element errorCode = getErrorCode();
152
153 if ( errorCode != null )
154 {
155 Element errorXML = XmlUtils.createElement( WsbfConstants.ERROR_CODE_QNAME );
156 errorXML.setAttribute( WsbfConstants.ERROR_CODE_DIALECT, getErrorCodeDialect() );
157 XmlUtils.setElement( errorXML, WsbfConstants.ERROR_CODE_QNAME, errorCode, false );
158 baseFault.appendChild( errorXML );
159 }
160
161 try
162 {
163
164
165
166
167 Throwable cause = getCause().getCause();
168 if ( cause != null )
169 {
170 ContinuingFaultType fault =
171 ContinuingFaultDocument.Factory.newInstance().addNewContinuingFault();
172 fault.addNewDescription();
173 fault.getDescriptionArray( 0 ).setLang( "en" );
174 fault.getDescriptionArray( 0 ).setStringValue( cause.getMessage() );
175 GregorianCalendar cal = new GregorianCalendar();
176 cal.setTime( getTimestamp() );
177 fault.setTimestamp( cal );
178 Element causeXML = XmlUtils.createElement( WsbfConstants.FAULT_CAUSE_QNAME );
179 XmlUtils.setElement( causeXML, ContinuingFaultDocument.type.getDocumentElementName(),
180 fault.getDomNode(), true );
181 XmlUtils.setElement( baseFault, WsbfConstants.FAULT_CAUSE_QNAME, causeXML, true );
182 }
183 }
184 catch ( Exception e )
185 {
186
187 }
188
189 return baseFault;
190 }
191 }