2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
24 package org.openecomp.appc.adapter.restHealthcheck.impl;
26 import org.glassfish.grizzly.http.util.HttpStatus;
28 import com.att.cdp.zones.model.Server;
31 public class RequestFailedException extends Exception {
36 private static final long serialVersionUID = 1L;
39 * The operation that was being requested or performed at the time of the failure.
41 private String operation;
44 * A message that details the reason for the failure
46 private String reason;
49 * The server that was being operated upon
51 private Server server;
54 * The id of the server being operated upon if the server object is not available (such as the server was not found)
56 private String serverId;
59 * The most appropriate Http Status code that reflects the error
61 private HttpStatus status;
66 public RequestFailedException() {
67 // intentionally empty
74 public RequestFailedException(String message) {
79 * Construct the request failed exception with the operation being performed, reason for the failure, http status
80 * code that is most appropriate, and the server we were processing.
83 * The operation being performed
85 * The reason that the operation was failed
87 * The http status code that is most appropriate
89 * The server that we were processing
91 @SuppressWarnings("nls")
92 public RequestFailedException(String operation, String reason, HttpStatus status, Server server) {
93 super(operation + ":" + reason);
94 this.operation = operation;
99 this.serverId = server.getId();
104 * Construct the request failed exception with the operation being performed, reason for the failure, http status
105 * code that is most appropriate, and the server we were processing.
108 * The exception that we are wrapping
110 * The operation being performed
112 * The reason that the operation was failed
114 * The http status code that is most appropriate
116 * The server that we were processing
118 @SuppressWarnings("nls")
119 public RequestFailedException(Throwable ex, String operation, String reason, HttpStatus status, Server server) {
120 super(operation + ":" + reason, ex);
121 this.operation = operation;
122 this.reason = reason;
123 this.status = status;
124 this.server = server;
125 if (server != null) {
126 this.serverId = server.getId();
136 public RequestFailedException(String message, Throwable cause) {
137 super(message, cause);
145 * @param enableSuppression
146 * whether or not suppression is enabled or disabled
147 * @param writableStackTrace
148 * whether or not the stack trace should be writable
150 public RequestFailedException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
151 super(message, cause, enableSuppression, writableStackTrace);
156 * the cause (which is saved for later retrieval by the {@link #getCause()} method). (A null value is
157 * permitted, and indicates that the cause is nonexistent or unknown.)
159 public RequestFailedException(Throwable cause) {
164 * @return The operation being performed
166 public String getOperation() {
171 * @return The reason for the failure
173 public String getReason() {
178 * @return The server being operated upon
180 public Server getServer() {
185 * @return The id of the server being operated upon
187 public String getServerId() {
192 * @return The status code from the operation
194 public HttpStatus getStatus() {
200 * The operation being performed
202 public void setOperation(String operation) {
203 this.operation = operation;
208 * The reason for the failure
210 public void setReason(String reason) {
211 this.reason = reason;
216 * The server being operated upon
218 public void setServer(Server server) {
219 this.server = server;
220 if (server != null) {
221 setServerId(server.getId());
227 * The id of the server being operated upon
229 public void setServerId(String serverId) {
230 this.serverId = serverId;
235 * The status of the request
237 public void setStatus(HttpStatus status) {
238 this.status = status;