01 /*
02 *
03 * Licensed to the Apache Software Foundation (ASF) under one
04 * or more contributor license agreements. See the NOTICE file
05 * distributed with this work for additional information
06 * regarding copyright ownership. The ASF licenses this file
07 * to you under the Apache License, Version 2.0 (the
08 * "License"); you may not use this file except in compliance
09 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 */
21 package org.apache.qpid.management.wsdm.common;
22
23 import javax.xml.namespace.QName;
24
25 import org.apache.muse.util.xml.XmlUtils;
26 import org.apache.muse.ws.addressing.EndpointReference;
27 import org.apache.qpid.management.Names;
28 import org.w3c.dom.Document;
29 import org.w3c.dom.Element;
30
31 /**
32 * This is the exception encapsulating the fault that will be thrown in case of
33 * method invocation failure.
34 *
35 * @author Andrea Gazzarini
36 */
37 public class MethodInvocationFault extends QManFault
38 {
39 private static final long serialVersionUID = 5977379710882983474L;
40
41 private String _message;
42 private long _returnCode;
43
44 /**
45 * Builds a new exception with the given endpoint reference and method invocation exception.
46 * This constructor will be used when the invocation thrown the MethodInvocationException.
47 *
48 * @param endpointReference the endpoint reference.
49 * @param methodName the name of the method.
50 * @param message the explanatio message.
51 * @param returnCode the a mnemonic code associated with the failure.
52 */
53 public MethodInvocationFault(
54 EndpointReference endpointReference,
55 String methodName,
56 String message,
57 long returnCode)
58 {
59 super(
60 endpointReference,
61 new QName(
62 Names.NAMESPACE_URI,
63 "OperationInvocationFault",
64 Names.PREFIX),
65 String.format("OPERATION \"%s\" FAILURE. See detail section for further details.",methodName));
66 this._message = message;
67 this._returnCode = returnCode;
68 }
69
70 @Override
71 public Element getDetail()
72 {
73 Element detail = super.getDetail();
74 Document owner = detail.getOwnerDocument();
75 detail.appendChild(XmlUtils.createElement(owner, Names.QMAN_STATUS_TEXT_NAME,_message));
76 detail.appendChild(XmlUtils.createElement(owner, Names.QMAN_STATUS_CODE_NAME,_returnCode));
77 return detail;
78 }
79 }
|