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.capabilities;
22
23 import javax.management.ObjectName;
24
25 /**
26 * Thrown when the artifacts related to a specific resource cannot be built.
27 *
28 * @author Andrea Gazzarini
29 */
30 public class ArtifactsNotAvailableException extends Exception
31 {
32 private static final long serialVersionUID = -9010460152421791926L;
33
34 private final WsArtifacts _artifacts;
35 private final ObjectName _objectName;
36
37 /**
38 * Builds a new exception with the given arguments.
39 *
40 * @param artifacts the artifacts built.
41 * @param cause the exception cause.
42 * @param objectName the object name of the corresponding JMX entity.
43 */
44 public ArtifactsNotAvailableException(
45 WsArtifacts artifacts,
46 Throwable cause,
47 ObjectName objectName)
48 {
49 super(cause);
50 this._artifacts = artifacts;
51 this._objectName = objectName;
52 }
53
54 /**
55 * Returns a message that indicates which artifacts were built.
56 *
57 * @return a message that indicates which artifacts were built.
58 */
59 @Override
60 public String getMessage()
61 {
62 StringBuilder builder = new StringBuilder();
63 if (_artifacts == null)
64 {
65 return super.getMessage();
66 }
67
68 builder.append("Built artifacts for ")
69 .append(_objectName)
70 .append(" : ")
71 .append( (_artifacts.getWsdl() != null) ? "WSDL," : "")
72 .append( (_artifacts.getCapabilityClass() != null) ? "Capability Class," : "")
73 .append( (_artifacts.getResourceMetadataDescriptor() != null) ? "Resource Metadata Descriptor," : "");
74 return builder.toString();
75 }
76 }
|