2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.apihandlerinfra.exceptions;
24 import java.util.List;
26 import org.onap.so.apihandlerinfra.logging.AlarmLoggerInfo;
27 import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
29 public abstract class ApiException extends Exception{
33 private static final long serialVersionUID = 683162058616691134L;
34 private int httpResponseCode;
35 private String messageID;
36 private ErrorLoggerInfo errorLoggerInfo;
37 private AlarmLoggerInfo alarmLoggerInfo;
38 private List<String> variables;
40 public ApiException(Builder builder){
41 super(builder.message, builder.cause);
43 this.httpResponseCode = builder.httpResponseCode;
44 this.messageID = builder.messageID;
45 this.variables = builder.variables;
46 this.errorLoggerInfo = builder.errorLoggerInfo;
47 this.alarmLoggerInfo = builder.alarmLoggerInfo;
48 this.variables = builder.variables;
51 public ApiException(String message, Throwable cause) {
52 super(message, cause);
55 public String getMessageID() {
59 public int getHttpResponseCode() {
60 return httpResponseCode;
63 public ErrorLoggerInfo getErrorLoggerInfo() {
64 return errorLoggerInfo;
67 public AlarmLoggerInfo getAlarmLoggerInfo() {
68 return alarmLoggerInfo;
71 public List<String> getVariables() {
75 public static class Builder<T extends Builder<T>> {
76 private String message;
77 private Throwable cause = null;
78 private int httpResponseCode;
79 private String messageID;
80 private ErrorLoggerInfo errorLoggerInfo = null;
81 private AlarmLoggerInfo alarmLoggerInfo = null;
82 private List<String> variables = null;
84 public Builder(String message, int httpResponseCode, String messageID) {
85 this.message = message;
86 this.httpResponseCode = httpResponseCode;
87 this.messageID = messageID;
90 public T message(String message) {
91 this.message = message;
95 public T cause(Throwable cause) {
100 public T httpResponseCode(int httpResponseCode) {
101 this.httpResponseCode = httpResponseCode;
105 public T messageID(String messageID) {
106 this.messageID = messageID;
110 public T errorInfo(ErrorLoggerInfo errorLoggerInfo){
111 this.errorLoggerInfo = errorLoggerInfo;
115 public T alarmInfo(AlarmLoggerInfo alarmLoggerInfo){
116 this.alarmLoggerInfo = alarmLoggerInfo;
120 public T variables(List<String> variables) {
121 this.variables = variables;