1 /**
2 * Copyright 2005-2012 The Kuali Foundation
3 *
4 * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
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 package org.kuali.rice.location.api.state;
17
18 import org.kuali.rice.core.api.criteria.QueryByCriteria;
19 import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
20 import org.kuali.rice.core.api.exception.RiceIllegalStateException;
21 import org.kuali.rice.location.api.LocationConstants;
22 import org.springframework.cache.annotation.Cacheable;
23
24 import javax.jws.WebMethod;
25 import javax.jws.WebParam;
26 import javax.jws.WebResult;
27 import javax.jws.WebService;
28 import javax.jws.soap.SOAPBinding;
29 import javax.xml.bind.annotation.XmlElement;
30 import javax.xml.bind.annotation.XmlElementWrapper;
31 import java.util.List;
32
33 /**
34 * Service for interacting with {@link State States}.
35 *
36 * @author Kuali Rice Team (rice.collab@kuali.org)
37 */
38 @WebService(name = "StateService", targetNamespace = LocationConstants.Namespaces.LOCATION_NAMESPACE_2_0)
39 @SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
40 public interface StateService {
41
42 /**
43 * Gets a {@link State} from a postal country code and postal state code.
44 * <p/>
45 * <p>
46 * This method will return null if the state does not exist.
47 * </p>
48 * <p/>
49 * <p>
50 * This method will return active or inactive states.
51 * </p>
52 *
53 * @param countryCode country code. cannot be blank.
54 * @param code state code. cannot be blank.
55 * @return a {@link State} or null
56 * @throws RiceIllegalArgumentException country code or state code is blank
57 */
58 @WebMethod(operationName = "getState")
59 @WebResult(name = "state")
60 @Cacheable(value=State.Cache.NAME, key="'countryCode=' + #p0 + '|' + 'code=' + #p1")
61 State getState(@WebParam(name = "countryCode") String countryCode, @WebParam(name = "code") String code)
62 throws RiceIllegalArgumentException;
63
64 /**
65 * Finds all the {@link State States} for postal country code.
66 * <p/>
67 * <p>
68 * This method will always return an <b>immutable</b> Collection
69 * even when no values exist.
70 * </p>
71 * <p/>
72 * <p>
73 * This method will only return active states.
74 * </p>
75 *
76 * @param countryCode state code. cannot be blank.
77 * @return an immutable collection of states
78 * @throws RiceIllegalArgumentException country code is blank
79 */
80 @WebMethod(operationName = "findAllStatesInCountry")
81 @XmlElementWrapper(name = "states", required = true)
82 @XmlElement(name = "state", required = false)
83 @WebResult(name = "states")
84 @Cacheable(value=State.Cache.NAME, key="'countryCode=' + #p0")
85 List<State> findAllStatesInCountry(@WebParam(name = "countryCode") String countryCode)
86 throws RiceIllegalArgumentException;
87
88 /**
89 * Finds all the {@link State States} for alternate postal country code.
90 * <p/>
91 * <p>
92 * This method will always return an <b>immutable</b> Collection
93 * even when no values exist.
94 * </p>
95 * <p/>
96 * <p>
97 * This method will only return active states.
98 * </p>
99 *
100 * @param alternateCode cannot be blank.
101 * @return an immutable collection of states
102 * @throws RiceIllegalArgumentException alternate country code is null
103 * @throws RiceIllegalStateException when no countries are found for alternate country code
104 */
105 @WebMethod(operationName = "findAllStatesInCountryByAltCode")
106 @XmlElementWrapper(name = "states", required = true)
107 @XmlElement(name = "state", required = false)
108 @WebResult(name = "states")
109 @Cacheable(value=State.Cache.NAME, key="'alternateCode=' + #p0")
110 List<State> findAllStatesInCountryByAltCode(@WebParam(name = "alternateCode") String alternateCode)
111 throws RiceIllegalArgumentException, RiceIllegalStateException;
112
113 /**
114 * This method find States based on a query criteria. The criteria cannot be null.
115 *
116 * @since 2.0.1
117 * @param queryByCriteria the criteria. Cannot be null.
118 * @return query results. will never return null.
119 * @throws IllegalArgumentException if the queryByCriteria is null
120 */
121 @WebMethod(operationName = "findStates")
122 @WebResult(name = "results")
123 StateQueryResults findStates(@WebParam(name = "query") QueryByCriteria queryByCriteria) throws RiceIllegalArgumentException;
124 }