Subversion Repositories XServices

Rev

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

Rev 66 Rev 68
1
/*
1
/*
2
 *   Copyright 2011 Brian Rosenberger (Brutex Network)
2
 *   Copyright 2011 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.math.BigInteger;
19
import java.math.BigInteger;
20
import java.util.GregorianCalendar;
20
import java.util.GregorianCalendar;
21
 
21
 
22
import javax.jws.WebMethod;
22
import javax.jws.WebMethod;
23
import javax.jws.WebParam;
23
import javax.jws.WebParam;
24
import javax.jws.WebService;
24
import javax.jws.WebService;
25
import javax.xml.bind.annotation.XmlElement;
25
import javax.xml.bind.annotation.XmlElement;
26
 
26
 
27
import net.brutex.xservices.types.DateFormatType;
27
import net.brutex.xservices.types.DateFormatType;
28
import net.brutex.xservices.types.DateTimeUnits;
28
import net.brutex.xservices.types.DateTimeUnits;
29
import net.brutex.xservices.util.BrutexNamespaces;
29
import net.brutex.xservices.util.BrutexNamespaces;
30
 
30
 
31
import org.apache.cxf.annotations.WSDLDocumentation;
31
import org.apache.cxf.annotations.WSDLDocumentation;
32
import org.apache.cxf.annotations.WSDLDocumentationCollection;
32
import org.apache.cxf.annotations.WSDLDocumentationCollection;
33
 
33
 
34
/**
34
/**
35
 * Date and time related services.
35
 * Date and time related services.
36
 * @author Brian Rosenberger
36
 * @author Brian Rosenberger
37
 *
37
 *
38
 */
38
 */
39
@WebService(targetNamespace = BrutexNamespaces.WS_XSERVICES)
39
@WebService(targetNamespace = BrutexNamespaces.WS_XSERVICES)
40
@WSDLDocumentationCollection(
40
@WSDLDocumentationCollection(
41
    {
41
    {
42
    	@WSDLDocumentation(value = BrutexNamespaces.BRUTEX_COPYRIGHT, placement = WSDLDocumentation.Placement.TOP)
42
    	@WSDLDocumentation(value = BrutexNamespaces.BRUTEX_COPYRIGHT, placement = WSDLDocumentation.Placement.TOP)
43
    }
43
    }
44
)
44
)
45
public interface DateService {
45
public interface DateService {
46
	
46
	
47
	public static final String SERVICE_NAME = "DateService";
47
	public static final String SERVICE_NAME = "DateService";
48
	public static final String OPERATION_GETDATE = "getDate";
48
	public static final String OPERATION_GETDATE = "getDate";
49
	public static final String OPERATION_GETTIMESTAMP = "getTimestamp";
49
	public static final String OPERATION_GETTIMESTAMP = "getTimestamp";
50
	public static final String OPERATION_GETINTIMEZONE = "getInTimezone";
50
	public static final String OPERATION_GETINTIMEZONE = "getInTimezone";
51
	public static final String OPERATION_FORMATDATE = "formatDate";
51
	public static final String OPERATION_FORMATDATE = "formatDate";
52
	public static final String OPERATION_FORMATDATEADVANCED = "formatDateAdvanced";	
52
	public static final String OPERATION_FORMATDATEADVANCED = "formatDateAdvanced";	
53
	public static final String OPERATION_PARSEDATE = "parseDate";
53
	public static final String OPERATION_PARSEDATE = "parseDate";
54
	public static final String OPERATION_PARSEDATEADVANCED = "parseDateAdvanced";
54
	public static final String OPERATION_PARSEDATEADVANCED = "parseDateAdvanced";
55
	public static final String OPERATION_DATETIMEDIFF = "dateTimeDiff";
55
	public static final String OPERATION_DATETIMEDIFF = "dateTimeDiff";
56
	public static final String OPERATION_DATETIMEDIFF2 = "dateTimeDiff2";
56
	public static final String OPERATION_DATETIMEDIFF2 = "dateTimeDiff2";
-
 
57
	public static final String OPERATION_DATEADD = "dateAdd";
57
	
58
	
58
	public static final String PARAM_TIMEZONE = "timezone";
59
	public static final String PARAM_TIMEZONE = "timezone";
59
	public static final String PARAM_DATETIME = "datetime";
60
	public static final String PARAM_DATETIME = "datetime";
60
	public static final String PARAM_FORMAT = "format";
61
	public static final String PARAM_FORMAT = "format";
-
 
62
	public static final String PARAM_UNIT = "unit";
61
	
63
	
62
	/**
64
	/**
63
	 * Get current date and time.
65
	 * Get current date and time.
64
	 * 
66
	 * 
65
	 * @param timezone Optional timezone. Defaults to server timezone.
67
	 * @param timezone Optional timezone. Defaults to server timezone.
66
	 * @return Current date and time.
68
	 * @return Current date and time.
67
	 * @throws XServicesFault 
69
	 * @throws XServicesFault 
68
	 */
70
	 */
69
	@WebMethod(operationName=OPERATION_GETDATE)
71
	@WebMethod(operationName=OPERATION_GETDATE)
70
	@WSDLDocumentation(value="Get current date and time.")
72
	@WSDLDocumentation(value="Get current date and time.")
71
	public abstract GregorianCalendar getDate(
73
	public abstract GregorianCalendar getDate(
72
			@WebParam(name=PARAM_TIMEZONE) String timezone) throws XServicesFault;
74
			@WebParam(name=PARAM_TIMEZONE) String timezone) throws XServicesFault;
73
	
75
	
74
	/**
76
	/**
75
	 * Get milliseconds since 01.01.1970.
77
	 * Get milliseconds since 01.01.1970.
76
	 * 
78
	 * 
77
	 * @return timestamp milliseconds
79
	 * @return timestamp milliseconds
78
	 */
80
	 */
79
	@WebMethod(operationName=OPERATION_GETTIMESTAMP)
81
	@WebMethod(operationName=OPERATION_GETTIMESTAMP)
80
	@WSDLDocumentation(value="Get milliseconds since 01.01.1970 (Unix timestap).")
82
	@WSDLDocumentation(value="Get milliseconds since 01.01.1970 (Unix timestap).")
81
	public abstract BigInteger getTimestamp();
83
	public abstract BigInteger getTimestamp();
82
	
84
	
83
	/**
85
	/**
84
	 * Display a date time with a different time zone. 
86
	 * Display a date time with a different time zone. 
85
	 * Changes representation only (no conversion).
87
	 * Changes representation only (no conversion).
86
	 * 
88
	 * 
87
	 * @param cal date time.
89
	 * @param cal date time.
88
	 * @param timezone time zone
90
	 * @param timezone time zone
89
	 * @return date time
91
	 * @return date time
90
	 * @throws XServicesFault
92
	 * @throws XServicesFault
91
	 */
93
	 */
92
	@WebMethod(operationName=OPERATION_GETINTIMEZONE)
94
	@WebMethod(operationName=OPERATION_GETINTIMEZONE)
93
	public abstract GregorianCalendar getInTimezone(
95
	public abstract GregorianCalendar getInTimezone(
94
			@WebParam(name=PARAM_DATETIME) @XmlElement(required=true) GregorianCalendar cal,
96
			@WebParam(name=PARAM_DATETIME) @XmlElement(required=true) GregorianCalendar cal,
95
			@WebParam(name=PARAM_TIMEZONE) @XmlElement(required=true) String timezone) throws XServicesFault;
97
			@WebParam(name=PARAM_TIMEZONE) @XmlElement(required=true) String timezone) throws XServicesFault;
96
	
98
	
97
	/**
99
	/**
98
	 * @param cal
100
	 * @param cal
99
	 * @param format
101
	 * @param format
100
	 * @return formatted date/time string
102
	 * @return formatted date/time string
101
	 * @throws XServicesFault
103
	 * @throws XServicesFault
102
	 */
104
	 */
103
	@WebMethod(operationName=OPERATION_FORMATDATE)
105
	@WebMethod(operationName=OPERATION_FORMATDATE)
104
	public abstract String formatDate(
106
	public abstract String formatDate(
105
			@WebParam(name=PARAM_DATETIME) @XmlElement(required=true) GregorianCalendar cal,
107
			@WebParam(name=PARAM_DATETIME) @XmlElement(required=true) GregorianCalendar cal,
106
			@WebParam(name=PARAM_FORMAT) @XmlElement(required=true) DateFormatType format) throws XServicesFault;
108
			@WebParam(name=PARAM_FORMAT) @XmlElement(required=true) DateFormatType format) throws XServicesFault;
107
	
109
	
108
	@WebMethod(operationName=OPERATION_FORMATDATEADVANCED)
110
	@WebMethod(operationName=OPERATION_FORMATDATEADVANCED)
109
	public abstract String formatDateAdvanced(
111
	public abstract String formatDateAdvanced(
110
			@WebParam(name=PARAM_DATETIME) @XmlElement(required=true) GregorianCalendar cal,
112
			@WebParam(name=PARAM_DATETIME) @XmlElement(required=true) GregorianCalendar cal,
111
			@WebParam(name=PARAM_FORMAT) @XmlElement(required=true) String format) throws XServicesFault;
113
			@WebParam(name=PARAM_FORMAT) @XmlElement(required=true) String format) throws XServicesFault;
112
	
114
	
113
	@WebMethod(operationName=OPERATION_PARSEDATE)
115
	@WebMethod(operationName=OPERATION_PARSEDATE)
114
	public abstract GregorianCalendar parseDate(
116
	public abstract GregorianCalendar parseDate(
115
			@WebParam(name=PARAM_DATETIME) @XmlElement(required=true) String s,
117
			@WebParam(name=PARAM_DATETIME) @XmlElement(required=true) String s,
116
			@WebParam(name=PARAM_FORMAT) @XmlElement(required=true) DateFormatType format,
118
			@WebParam(name=PARAM_FORMAT) @XmlElement(required=true) DateFormatType format,
117
			@WebParam(name=PARAM_TIMEZONE) String timezone) throws XServicesFault;
119
			@WebParam(name=PARAM_TIMEZONE) String timezone) throws XServicesFault;
118
	
120
	
119
	@WebMethod(operationName=OPERATION_PARSEDATEADVANCED)
121
	@WebMethod(operationName=OPERATION_PARSEDATEADVANCED)
120
	public abstract GregorianCalendar parseDateAdvanced(
122
	public abstract GregorianCalendar parseDateAdvanced(
121
			@WebParam(name=PARAM_DATETIME) @XmlElement(required=true) String s,
123
			@WebParam(name=PARAM_DATETIME) @XmlElement(required=true) String s,
122
			@WebParam(name=PARAM_FORMAT) @XmlElement(required=true) String format,
124
			@WebParam(name=PARAM_FORMAT) @XmlElement(required=true) String format,
123
			@WebParam(name=PARAM_TIMEZONE) String timezone) throws XServicesFault;
125
			@WebParam(name=PARAM_TIMEZONE) String timezone) throws XServicesFault;
124
	
126
	
125
	@WebMethod(operationName=OPERATION_DATETIMEDIFF)
127
	@WebMethod(operationName=OPERATION_DATETIMEDIFF)
126
	public abstract BigInteger dateTimeDiff(
128
	public abstract BigInteger dateTimeDiff(
127
			@WebParam(name="fromDateTime") @XmlElement(required=true) GregorianCalendar fromCal,
129
			@WebParam(name="fromDateTime") @XmlElement(required=true) GregorianCalendar fromCal,
128
			@WebParam(name="toDateTime") @XmlElement(required=true) GregorianCalendar toCal) throws XServicesFault;
130
			@WebParam(name="toDateTime") @XmlElement(required=true) GregorianCalendar toCal) throws XServicesFault;
129
	
131
	
130
	/**
132
	/**
131
	 * Fully elapsed units between two dates.
133
	 * Fully elapsed units between two dates.
132
	 * 4:15:10-4:15:55 in minutes = 0 and in seconds = 45
134
	 * 4:15:10-4:15:55 in minutes = 0 and in seconds = 45
133
	 * 
135
	 * 
134
	 * @param fromCal
136
	 * @param fromCal
135
	 * @param toCal
137
	 * @param toCal
136
	 * @param unit
138
	 * @param unit
137
	 * @return Date/time difference in unit
139
	 * @return Date/time difference in unit
138
	 * @throws XServicesFault
140
	 * @throws XServicesFault
139
	 */
141
	 */
140
	@WebMethod(operationName=OPERATION_DATETIMEDIFF2)
142
	@WebMethod(operationName=OPERATION_DATETIMEDIFF2)
141
	@WSDLDocumentation(value="Get elapsed time between to dates.")
143
	@WSDLDocumentation(value="Get elapsed time between to dates.")
142
	public abstract BigInteger dateTimeDiff2(
144
	public abstract BigInteger dateTimeDiff2(
143
			@WebParam(name="fromDateTime") @XmlElement(required=true) GregorianCalendar fromCal,
145
			@WebParam(name="fromDateTime") @XmlElement(required=true) GregorianCalendar fromCal,
144
			@WebParam(name="toDateTime") @XmlElement(required=true) GregorianCalendar toCal,
146
			@WebParam(name="toDateTime") @XmlElement(required=true) GregorianCalendar toCal,
145
			@WebParam(name="unit") DateTimeUnits unit) throws XServicesFault;
147
			@WebParam(name="PARAM_UNIT") DateTimeUnits unit) throws XServicesFault;
-
 
148
	
-
 
149
	/**
-
 
150
	 * Add or substract a time span from a date.
-
 
151
	 * 
-
 
152
	 * @param cal
-
 
153
	 * @param unit 
-
 
154
	 * @return New date and time.
-
 
155
	 * @throws XServicesFault
-
 
156
	 */
-
 
157
	@WebMethod(operationName=OPERATION_DATEADD)
-
 
158
	@WSDLDocumentation(value="Add or substract a time span from a date.")
-
 
159
	public abstract GregorianCalendar dateAdd(
-
 
160
			@WebParam(name=PARAM_DATETIME) @XmlElement(required=true) GregorianCalendar cal,
-
 
161
			@WebParam(name="value") @XmlElement(required=true) BigInteger value,
-
 
162
			@WebParam(name=PARAM_UNIT) @XmlElement(required=true) DateTimeUnits unit) throws XServicesFault;
-
 
163
	
146
}
164
}