Project

General

Profile

Download (2.17 KB) Statistics
| Branch: | Tag: | Revision:
1
package eu.etaxonomy.cdm.io.jaxb;
2

    
3
import java.util.ArrayList;
4
import java.util.List;
5

    
6
import javax.xml.bind.annotation.XmlAccessType;
7
import javax.xml.bind.annotation.XmlAccessorType;
8
import javax.xml.bind.annotation.XmlAttribute;
9
import javax.xml.bind.annotation.XmlElement;
10
import javax.xml.bind.annotation.XmlElementWrapper;
11
import javax.xml.bind.annotation.XmlRootElement;
12
import javax.xml.bind.annotation.XmlType;
13

    
14
@XmlAccessorType(XmlAccessType.FIELD)
15
@XmlType(name = "Error", propOrder = {
16
	    "code",
17
	    "message",
18
		"resource",
19
		"cause",
20
		"stackTrace"
21
})
22
@XmlRootElement(name = "Error")
23
public class Error {
24
	@XmlAttribute
25
	private Integer status;
26

    
27
	@XmlElement(name = "Message")
28
	private String message;
29
	
30
	@XmlElement(name = "Resource")
31
	private String resource;
32
	
33
	@XmlElement(name = "Cause")
34
	private String cause;
35
	
36
	@XmlElement(name = "Code")
37
	private String code;
38

    
39
	@XmlElementWrapper(name = "StackTrace")
40
	@XmlElement(name = "StackTraceElement")
41
	private List<String> stackTrace;
42

    
43
	public Error() {
44
		
45
	}
46
	
47
	public Error(Throwable throwable) {
48
		if(throwable.getCause() != null) {
49
		    this.cause = throwable.getCause().getClass().getName();
50
		}
51
		this.message = throwable.getLocalizedMessage();
52
		this.stackTrace = new ArrayList<String>();
53
		for(StackTraceElement ste : throwable.getStackTrace()) {
54
			this.stackTrace.add(ste.toString());
55
		}
56
	}
57
	
58
	public Integer getStatus() {
59
		return status;
60
	}
61

    
62
	public void setStatus(Integer status) {
63
		this.status = status;
64
	}
65

    
66
	public String getMessage() {
67
		return message;
68
	}
69

    
70
	public void setMessage(String message) {
71
		this.message = message;
72
	}
73

    
74
	public String getResource() {
75
		return resource;
76
	}
77

    
78
	public void setResource(String resource) {
79
		this.resource = resource;
80
	}
81

    
82
	public String getCause() {
83
		return cause;
84
	}
85

    
86
	public void setCause(String cause) {
87
		this.cause = cause;
88
	}
89

    
90
	public String getCode() {
91
		return code;
92
	}
93

    
94
	public void setCode(String code) {
95
		this.code = code;
96
	}
97

    
98
	public List<String> getStackTrace() {
99
		return stackTrace;
100
	}
101

    
102
	public void setStackTrace(List<String> stackTrace) {
103
		this.stackTrace = stackTrace;
104
	} 
105
}
(8-8/17)