2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * =============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 * ============LICENSE_END=========================================================
27 package org.onap.appc.adapter.restHealthcheck.impl;
29 import org.glassfish.grizzly.http.util.HttpStatus;
31 import com.att.cdp.zones.model.Server;
34 public class RequestFailedException extends Exception {
39 private static final long serialVersionUID = 1L;
42 * The operation that was being requested or performed at the time of the failure.
44 private String operation;
47 * A message that details the reason for the failure
49 private String reason;
52 * The server that was being operated upon
54 private Server server;
57 * The id of the server being operated upon if the server object is not available (such as the server was not found)
59 private String serverId;
62 * The most appropriate Http Status code that reflects the error
64 private HttpStatus status;
69 public RequestFailedException() {
70 // intentionally empty
77 public RequestFailedException(String message) {
82 * Construct the request failed exception with the operation being performed, reason for the failure, http status
83 * code that is most appropriate, and the server we were processing.
86 * The operation being performed
88 * The reason that the operation was failed
90 * The http status code that is most appropriate
92 * The server that we were processing
94 @SuppressWarnings("nls")
95 public RequestFailedException(String operation, String reason, HttpStatus status, Server server) {
96 super(operation + ":" + reason);
97 this.operation = operation;
100 this.server = server;
101 if (server != null) {
102 this.serverId = server.getId();
107 * Construct the request failed exception with the operation being performed, reason for the failure, http status
108 * code that is most appropriate, and the server we were processing.
111 * The exception that we are wrapping
113 * The operation being performed
115 * The reason that the operation was failed
117 * The http status code that is most appropriate
119 * The server that we were processing
121 @SuppressWarnings("nls")
122 public RequestFailedException(Throwable ex, String operation, String reason, HttpStatus status, Server server) {
123 super(operation + ":" + reason, ex);
124 this.operation = operation;
125 this.reason = reason;
126 this.status = status;
127 this.server = server;
128 if (server != null) {
129 this.serverId = server.getId();
139 public RequestFailedException(String message, Throwable cause) {
140 super(message, cause);
148 * @param enableSuppression
149 * whether or not suppression is enabled or disabled
150 * @param writableStackTrace
151 * whether or not the stack trace should be writable
153 public RequestFailedException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
154 super(message, cause, enableSuppression, writableStackTrace);
159 * the cause (which is saved for later retrieval by the {@link #getCause()} method). (A null value is
160 * permitted, and indicates that the cause is nonexistent or unknown.)
162 public RequestFailedException(Throwable cause) {
167 * @return The operation being performed
169 public String getOperation() {
174 * @return The reason for the failure
176 public String getReason() {
181 * @return The server being operated upon
183 public Server getServer() {
188 * @return The id of the server being operated upon
190 public String getServerId() {
195 * @return The status code from the operation
197 public HttpStatus getStatus() {
203 * The operation being performed
205 public void setOperation(String operation) {
206 this.operation = operation;
211 * The reason for the failure
213 public void setReason(String reason) {
214 this.reason = reason;
219 * The server being operated upon
221 public void setServer(Server server) {
222 this.server = server;
223 if (server != null) {
224 setServerId(server.getId());
230 * The id of the server being operated upon
232 public void setServerId(String serverId) {
233 this.serverId = serverId;
238 * The status of the request
240 public void setStatus(HttpStatus status) {
241 this.status = status;