1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.openehealth.ipf.commons.ihe.xds.core.responses;
17
18 import lombok.EqualsAndHashCode;
19 import lombok.ToString;
20
21 import javax.xml.bind.annotation.XmlAccessType;
22 import javax.xml.bind.annotation.XmlAccessorType;
23 import javax.xml.bind.annotation.XmlElement;
24 import javax.xml.bind.annotation.XmlRootElement;
25 import javax.xml.bind.annotation.XmlType;
26 import java.io.Serializable;
27 import java.util.ArrayList;
28 import java.util.List;
29
30
31
32
33
34
35
36
37 @XmlAccessorType(XmlAccessType.FIELD)
38 @XmlType(name = "Response", propOrder = {"status", "errors"})
39 @XmlRootElement(name = "response")
40 @EqualsAndHashCode(doNotUseGetters = true)
41 @ToString(doNotUseGetters = true)
42 public class Response implements Serializable {
43 private static final long serialVersionUID = -6370795461214680771L;
44
45 private Status status;
46 @XmlElement(name = "error")
47 private List<ErrorInfo> errors = new ArrayList<>();
48
49
50
51
52 public Response() {}
53
54
55
56
57
58
59 public Response(Status status) {
60 this.status = status;
61 }
62
63
64
65
66
67
68
69
70
71
72
73
74
75 public Response(
76 Throwable throwable,
77 ErrorCode defaultMetaDataError,
78 ErrorCode defaultError,
79 String location)
80 {
81 this.status = Status.FAILURE;
82 this.errors.add(new ErrorInfo(throwable, defaultMetaDataError, defaultError, location));
83 }
84
85
86
87
88 public Status getStatus() {
89 return status;
90 }
91
92
93
94
95
96 public void setStatus(Status status) {
97 this.status = status;
98 }
99
100
101
102
103 public List<ErrorInfo> getErrors() {
104 return errors;
105 }
106
107
108
109
110
111 public void setErrors(List<ErrorInfo> errors) {
112 this.errors = errors;
113 }
114
115
116 }