Subversion Repositories XServices

Rev

Rev 65 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 65 Rev 85
1
/*
1
/*
2
 *   Copyright 2010 Brian Rosenberger (Brutex Network)
2
 *   Copyright 2010 Brian Rosenberger (Brutex Network)
3
 *
3
 *
4
 *   Licensed under the Apache License, Version 2.0 (the "License");
4
 *   Licensed under the Apache License, Version 2.0 (the "License");
5
 *   you may not use this file except in compliance with the License.
5
 *   you may not use this file except in compliance with the License.
6
 *   You may obtain a copy of the License at
6
 *   You may obtain a copy of the License at
7
 *
7
 *
8
 *       http://www.apache.org/licenses/LICENSE-2.0
8
 *       http://www.apache.org/licenses/LICENSE-2.0
9
 *
9
 *
10
 *   Unless required by applicable law or agreed to in writing, software
10
 *   Unless required by applicable law or agreed to in writing, software
11
 *   distributed under the License is distributed on an "AS IS" BASIS,
11
 *   distributed under the License is distributed on an "AS IS" BASIS,
12
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 *   See the License for the specific language governing permissions and
13
 *   See the License for the specific language governing permissions and
14
 *   limitations under the License.
14
 *   limitations under the License.
15
 */
15
 */
16
 
16
 
17
package net.brutex.xservices.ws;
17
package net.brutex.xservices.ws;
18
 
18
 
19
import java.util.GregorianCalendar;
19
import java.util.GregorianCalendar;
20
import javax.xml.bind.annotation.XmlElement;
20
import javax.xml.bind.annotation.XmlElement;
21
import javax.xml.bind.annotation.XmlRootElement;
21
import javax.xml.bind.annotation.XmlRootElement;
22
import javax.xml.bind.annotation.XmlType;
22
import javax.xml.bind.annotation.XmlType;
23
import javax.xml.datatype.DatatypeConfigurationException;
23
import javax.xml.datatype.DatatypeConfigurationException;
24
import javax.xml.datatype.DatatypeFactory;
24
import javax.xml.datatype.DatatypeFactory;
25
import javax.xml.datatype.XMLGregorianCalendar;
25
import javax.xml.datatype.XMLGregorianCalendar;
26
import javax.xml.ws.WebFault;
26
import javax.xml.ws.WebFault;
27
 
27
 
28
import net.brutex.xservices.util.BrutexNamespaces;
28
import net.brutex.xservices.util.BrutexNamespaces;
29
 
29
 
30
/**
30
/**
-
 
31
 * Generic web service fault.
31
 *
32
 *
32
 * @author Brian Rosenberger, bru@brutex.de
33
 * @author Brian Rosenberger, bru@brutex.de
-
 
34
 * since 0.4.0
33
 */
35
 */
34
@WebFault(targetNamespace=BrutexNamespaces.WS_XSERVICES)
36
@WebFault(targetNamespace=BrutexNamespaces.WS_XSERVICES)
35
public class XServicesFault extends Exception {
37
public class XServicesFault extends Exception {
36
 
38
 
37
    /**
39
    /**
38
	 * 
40
	 * 
39
	 */
41
	 */
40
	private static final long serialVersionUID = -6779279189376374820L;
42
	private static final long serialVersionUID = -6779279189376374820L;
41
 
43
 
42
	public XServicesFault(String message, Exception e) {
44
	public XServicesFault(String message, Exception e) {
43
        this(message, e.getCause());
45
        this(message, e.getCause());
44
    }
46
    }
45
 
47
 
46
    public XServicesFault(String string) {
48
    public XServicesFault(String string) {
47
        this(string, new Exception(string).getCause());
49
        this(string, new Exception(string).getCause());
48
    }
50
    }
49
 
51
 
50
    public XServicesFault(Exception e) {
52
    public XServicesFault(Exception e) {
51
        this(e.getMessage(), e.getCause());
53
        this(e.getMessage(), e.getCause());
52
    }
54
    }
53
 
55
 
54
    public XServicesFault(String message, Throwable cause) {
56
    public XServicesFault(String message, Throwable cause) {
55
        super(message, cause);
57
        super(message, cause);
56
        this.faultstring=message;
58
        this.faultstring=message;
57
 
59
 
58
       
60
       
59
        try {
61
        try {
60
            timestamp = DatatypeFactory.newInstance().newXMLGregorianCalendar(new GregorianCalendar());
62
            timestamp = DatatypeFactory.newInstance().newXMLGregorianCalendar(new GregorianCalendar());
61
        } catch (DatatypeConfigurationException ex) {
63
        } catch (DatatypeConfigurationException ex) {
62
            System.err.println(ex.getMessage());
64
            System.err.println(ex.getMessage());
63
        }
65
        }
64
 
66
 
65
 
67
 
66
    }
68
    }
67
    /**
69
    /**
68
     * The error message.
70
     * The error message.
69
     */
71
     */
70
    @XmlElement(name="faultstring", namespace=BrutexNamespaces.WS_XSERVICES)
72
    @XmlElement(name="faultstring", namespace=BrutexNamespaces.WS_XSERVICES)
71
    public String faultstring = "";
73
    public String faultstring = "";
72
 
74
 
73
    /**
75
    /**
74
     * Username under which the web service has been executed.
76
     * Username under which the web service has been executed.
75
     */
77
     */
76
    @XmlElement(name="username", namespace=BrutexNamespaces.WS_XSERVICES)
78
    @XmlElement(name="username", namespace=BrutexNamespaces.WS_XSERVICES)
77
    public String username = System.getProperty("user.name");
79
    public String username = System.getProperty("user.name");
78
 
80
 
79
    /**
81
    /**
80
     * Home directory of the user profile running the web service.
82
     * Home directory of the user profile running the web service.
81
     */
83
     */
82
    @XmlElement(name="homedir", namespace=BrutexNamespaces.WS_XSERVICES)
84
    @XmlElement(name="homedir", namespace=BrutexNamespaces.WS_XSERVICES)
83
    public String homedir = System.getProperty("user.home");
85
    public String homedir = System.getProperty("user.home");
84
 
86
 
85
    
87
    
86
    /**
88
    /**
87
     * Timestamp when the fault was thrown.
89
     * Timestamp when the fault was thrown.
88
     */
90
     */
89
    @XmlElement(name="timstamp", namespace=BrutexNamespaces.WS_XSERVICES)
91
    @XmlElement(name="timstamp", namespace=BrutexNamespaces.WS_XSERVICES)
90
    public XMLGregorianCalendar timestamp = null;
92
    public XMLGregorianCalendar timestamp = null;
91
    
93
    
92
    /**
94
    /**
93
     * Java runtime version.
95
     * Java runtime version.
94
     */
96
     */
95
    @XmlElement(name="jvmversion")
97
    @XmlElement(name="jvmversion")
96
    public String jvmruntime = System.getProperty("java.version");
98
    public String jvmruntime = System.getProperty("java.version");
97
}
99
}