2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright (C) 2017 Amdocs
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=========================================================
20 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
25 package org.openecomp.appc.adapter.restHealthcheck.impl;
27 import org.glassfish.grizzly.http.util.HttpStatus;
29 import com.att.cdp.zones.model.Server;
32 public class RequestFailedException extends Exception {
37 private static final long serialVersionUID = 1L;
40 * The operation that was being requested or performed at the time of the failure.
42 private String operation;
45 * A message that details the reason for the failure
47 private String reason;
50 * The server that was being operated upon
52 private Server server;
55 * The id of the server being operated upon if the server object is not available (such as the server was not found)
57 private String serverId;
60 * The most appropriate Http Status code that reflects the error
62 private HttpStatus status;
67 public RequestFailedException() {
68 // intentionally empty
75 public RequestFailedException(String message) {
80 * Construct the request failed exception with the operation being performed, reason for the failure, http status
81 * code that is most appropriate, and the server we were processing.
84 * The operation being performed
86 * The reason that the operation was failed
88 * The http status code that is most appropriate
90 * The server that we were processing
92 @SuppressWarnings("nls")
93 public RequestFailedException(String operation, String reason, HttpStatus status, Server server) {
94 super(operation + ":" + reason);
95 this.operation = operation;
100 this.serverId = server.getId();
105 * Construct the request failed exception with the operation being performed, reason for the failure, http status
106 * code that is most appropriate, and the server we were processing.
109 * The exception that we are wrapping
111 * The operation being performed
113 * The reason that the operation was failed
115 * The http status code that is most appropriate
117 * The server that we were processing
119 @SuppressWarnings("nls")
120 public RequestFailedException(Throwable ex, String operation, String reason, HttpStatus status, Server server) {
121 super(operation + ":" + reason, ex);
122 this.operation = operation;
123 this.reason = reason;
124 this.status = status;
125 this.server = server;
126 if (server != null) {
127 this.serverId = server.getId();
137 public RequestFailedException(String message, Throwable cause) {
138 super(message, cause);
146 * @param enableSuppression
147 * whether or not suppression is enabled or disabled
148 * @param writableStackTrace
149 * whether or not the stack trace should be writable
151 public RequestFailedException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
152 super(message, cause, enableSuppression, writableStackTrace);
157 * the cause (which is saved for later retrieval by the {@link #getCause()} method). (A null value is
158 * permitted, and indicates that the cause is nonexistent or unknown.)
160 public RequestFailedException(Throwable cause) {
165 * @return The operation being performed
167 public String getOperation() {
172 * @return The reason for the failure
174 public String getReason() {
179 * @return The server being operated upon
181 public Server getServer() {
186 * @return The id of the server being operated upon
188 public String getServerId() {
193 * @return The status code from the operation
195 public HttpStatus getStatus() {
201 * The operation being performed
203 public void setOperation(String operation) {
204 this.operation = operation;
209 * The reason for the failure
211 public void setReason(String reason) {
212 this.reason = reason;
217 * The server being operated upon
219 public void setServer(Server server) {
220 this.server = server;
221 if (server != null) {
222 setServerId(server.getId());
228 * The id of the server being operated upon
230 public void setServerId(String serverId) {
231 this.serverId = serverId;
236 * The status of the request
238 public void setStatus(HttpStatus status) {
239 this.status = status;