NoSuchAttributeFault.java
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 when a requested 
33  * attribute is not found on the target ws resource.
34  
35  @author Andrea Gazzarini
36  */
37 public class NoSuchAttributeFault extends QManFault 
38 {
39   private static final long serialVersionUID = 5977379710882983474L;
40 
41   private String _attributeName;
42   
43   /**
44    * Builds a new exception with the given endpoint reference, JMX object name 
45    * and attribute that hasn't been found.
46    
47    @param endpointReference the endpoint reference.
48    @param attributeName the name of the attribute that hasn't been found.
49    */
50   public NoSuchAttributeFault(EndpointReference endpointReference, String attributeName
51   {
52     super(
53         endpointReference,
54         new QName(
55             Names.NAMESPACE_URI,
56             "NoSuchAttributeFault",
57             Names.PREFIX),
58         "Attribute not found on this WS-Resource.");
59     _attributeName = attributeName;
60   }
61   
62   @Override
63   public Element getDetail()
64   {
65     Element detail = super.getDetail();
66     Document owner = detail.getOwnerDocument();
67     detail.appendChild(XmlUtils.createElement(owner, Names.QMAN_STATUS_ATTRIBUTE_NAME,_attributeName));
68     return detail;
69   }
70 }