2 * ========================LICENSE_START=================================
5 * Copyright (C) 2019 AT&T Intellectual Property
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.oransc.ric.portal.dashboard.model;
23 import java.time.Instant;
26 * This mimics the model Spring-Boot uses for a message returned on failure, to
27 * be serialized as JSON.
29 public class ErrorTransport implements IDashboardResponse {
31 private Instant timestamp;
32 private Integer status;
34 private String message;
38 * Builds an empty object.
40 public ErrorTransport() {
45 * Convenience constructor for minimal value set.
48 * Integer value like 400
52 public ErrorTransport(int status, String error) {
53 this(status, error, null, null);
57 * Convenience constructor for populating an error from an exception
60 * Integer value like 400
62 * The caught exception/throwable to convert to String with
63 * an upper bound on characters
65 public ErrorTransport(int status, Throwable throwable) {
66 this.timestamp = Instant.now();
68 final int enough = 256;
69 String exString = throwable.toString();
70 this.error = exString.length() > enough ? exString.substring(0, enough) : exString;
74 * Builds an object with all fields
77 * Integer value like 500
81 * Additional explanation
85 public ErrorTransport(int status, String error, String message, String path) {
86 this.timestamp = Instant.now();
89 this.message = message;
93 public Integer getStatus() {
97 public void setStatus(Integer status) {
101 public String getMessage() {
105 public void setMessage(String error) {
106 this.message = error;
109 public Instant getTimestamp() {
113 public void setTimestamp(Instant timestamp) {
114 this.timestamp = timestamp;
117 public String getError() {
121 public void setError(String error) {
125 public String getPath() {
129 public void setPath(String path) {