View Javadoc

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