Subversion Repositories XServices

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
66 brianR 1
/*
2
 *   Copyright 2011 Brian Rosenberger (Brutex Network)
3
 *
4
 *   Licensed under the Apache License, Version 2.0 (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
7
 *
8
 *       http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 *   Unless required by applicable law or agreed to in writing, software
11
 *   distributed under the License is distributed on an "AS IS" BASIS,
12
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 *   See the License for the specific language governing permissions and
14
 *   limitations under the License.
15
 */
16
 
17
package net.brutex.xservices.ws;
18
 
19
import java.math.BigInteger;
20
import java.util.GregorianCalendar;
21
 
22
import javax.jws.WebMethod;
23
import javax.jws.WebParam;
24
import javax.jws.WebService;
25
import javax.xml.bind.annotation.XmlElement;
26
 
27
import net.brutex.xservices.types.DateFormatType;
28
import net.brutex.xservices.types.DateTimeUnits;
29
import net.brutex.xservices.util.BrutexNamespaces;
30
 
31
import org.apache.cxf.annotations.WSDLDocumentation;
32
import org.apache.cxf.annotations.WSDLDocumentationCollection;
33
 
34
/**
35
 * Date and time related services.
36
 * @author Brian Rosenberger
37
 *
38
 */
39
@WebService(targetNamespace = BrutexNamespaces.WS_XSERVICES)
40
@WSDLDocumentationCollection(
41
    {
42
    	@WSDLDocumentation(value = BrutexNamespaces.BRUTEX_COPYRIGHT, placement = WSDLDocumentation.Placement.TOP)
43
    }
44
)
45
public interface DateService {
46
 
47
	public static final String SERVICE_NAME = "DateService";
48
	public static final String OPERATION_GETDATE = "getDate";
49
	public static final String OPERATION_GETTIMESTAMP = "getTimestamp";
50
	public static final String OPERATION_GETINTIMEZONE = "getInTimezone";
51
	public static final String OPERATION_FORMATDATE = "formatDate";
52
	public static final String OPERATION_FORMATDATEADVANCED = "formatDateAdvanced";
53
	public static final String OPERATION_PARSEDATE = "parseDate";
54
	public static final String OPERATION_PARSEDATEADVANCED = "parseDateAdvanced";
55
	public static final String OPERATION_DATETIMEDIFF = "dateTimeDiff";
56
	public static final String OPERATION_DATETIMEDIFF2 = "dateTimeDiff2";
57
 
58
	public static final String PARAM_TIMEZONE = "timezone";
59
	public static final String PARAM_DATETIME = "datetime";
60
	public static final String PARAM_FORMAT = "format";
61
 
62
	/**
63
	 * Get current date and time.
64
	 *
65
	 * @param timezone Optional timezone. Defaults to server timezone.
66
	 * @return Current date and time.
67
	 * @throws XServicesFault
68
	 */
69
	@WebMethod(operationName=OPERATION_GETDATE)
70
	@WSDLDocumentation(value="Get current date and time.")
71
	public abstract GregorianCalendar getDate(
72
			@WebParam(name=PARAM_TIMEZONE) String timezone) throws XServicesFault;
73
 
74
	/**
75
	 * Get milliseconds since 01.01.1970.
76
	 *
77
	 * @return timestamp milliseconds
78
	 */
79
	@WebMethod(operationName=OPERATION_GETTIMESTAMP)
80
	@WSDLDocumentation(value="Get milliseconds since 01.01.1970 (Unix timestap).")
81
	public abstract BigInteger getTimestamp();
82
 
83
	/**
84
	 * Display a date time with a different time zone.
85
	 * Changes representation only (no conversion).
86
	 *
87
	 * @param cal date time.
88
	 * @param timezone time zone
89
	 * @return date time
90
	 * @throws XServicesFault
91
	 */
92
	@WebMethod(operationName=OPERATION_GETINTIMEZONE)
93
	public abstract GregorianCalendar getInTimezone(
94
			@WebParam(name=PARAM_DATETIME) @XmlElement(required=true) GregorianCalendar cal,
95
			@WebParam(name=PARAM_TIMEZONE) @XmlElement(required=true) String timezone) throws XServicesFault;
96
 
97
	/**
98
	 * @param cal
99
	 * @param format
100
	 * @return formatted date/time string
101
	 * @throws XServicesFault
102
	 */
103
	@WebMethod(operationName=OPERATION_FORMATDATE)
104
	public abstract String formatDate(
105
			@WebParam(name=PARAM_DATETIME) @XmlElement(required=true) GregorianCalendar cal,
106
			@WebParam(name=PARAM_FORMAT) @XmlElement(required=true) DateFormatType format) throws XServicesFault;
107
 
108
	@WebMethod(operationName=OPERATION_FORMATDATEADVANCED)
109
	public abstract String formatDateAdvanced(
110
			@WebParam(name=PARAM_DATETIME) @XmlElement(required=true) GregorianCalendar cal,
111
			@WebParam(name=PARAM_FORMAT) @XmlElement(required=true) String format) throws XServicesFault;
112
 
113
	@WebMethod(operationName=OPERATION_PARSEDATE)
114
	public abstract GregorianCalendar parseDate(
115
			@WebParam(name=PARAM_DATETIME) @XmlElement(required=true) String s,
116
			@WebParam(name=PARAM_FORMAT) @XmlElement(required=true) DateFormatType format,
117
			@WebParam(name=PARAM_TIMEZONE) String timezone) throws XServicesFault;
118
 
119
	@WebMethod(operationName=OPERATION_PARSEDATEADVANCED)
120
	public abstract GregorianCalendar parseDateAdvanced(
121
			@WebParam(name=PARAM_DATETIME) @XmlElement(required=true) String s,
122
			@WebParam(name=PARAM_FORMAT) @XmlElement(required=true) String format,
123
			@WebParam(name=PARAM_TIMEZONE) String timezone) throws XServicesFault;
124
 
125
	@WebMethod(operationName=OPERATION_DATETIMEDIFF)
126
	public abstract BigInteger dateTimeDiff(
127
			@WebParam(name="fromDateTime") @XmlElement(required=true) GregorianCalendar fromCal,
128
			@WebParam(name="toDateTime") @XmlElement(required=true) GregorianCalendar toCal) throws XServicesFault;
129
 
130
	/**
131
	 * Fully elapsed units between two dates.
132
	 * 4:15:10-4:15:55 in minutes = 0 and in seconds = 45
133
	 *
134
	 * @param fromCal
135
	 * @param toCal
136
	 * @param unit
137
	 * @return Date/time difference in unit
138
	 * @throws XServicesFault
139
	 */
140
	@WebMethod(operationName=OPERATION_DATETIMEDIFF2)
141
	@WSDLDocumentation(value="Get elapsed time between to dates.")
142
	public abstract BigInteger dateTimeDiff2(
143
			@WebParam(name="fromDateTime") @XmlElement(required=true) GregorianCalendar fromCal,
144
			@WebParam(name="toDateTime") @XmlElement(required=true) GregorianCalendar toCal,
145
			@WebParam(name="unit") DateTimeUnits unit) throws XServicesFault;
146
}