View Javadoc

1   /**
2    * Copyright 2005-2014 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.country;
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  /**
35   * <p>CountryService interface.</p>
36   *
37   * @author Kuali Rice Team (rice.collab@kuali.org)
38   */
39  @WebService(name = "CountryService", targetNamespace = LocationConstants.Namespaces.LOCATION_NAMESPACE_2_0)
40  @SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
41  public interface CountryService {
42  
43      /**
44       * Lookup a country object based on the given country code.
45       *
46       * @param code the given country code
47       * @return a country object with the given country code.  A null reference is returned if an invalid or
48       *         non-existant code is supplied.
49       * @throws RiceIllegalArgumentException if the code is blank or null
50       */
51      @WebMethod(operationName = "getCountry")
52      @WebResult(name = "country")
53      @Cacheable(value=Country.Cache.NAME, key="'code=' + #p0")
54      Country getCountry(@WebParam(name = "code") String code) throws RiceIllegalArgumentException;
55  
56      /**
57       * Get a country object based on an alternate country code
58       *
59       * @param alternateCode the given alternate country code
60       * @return A country object with the given alternate country code if a country with that alternate country code
61       *         exists.  Otherwise, null is returned.
62       * @throws RiceIllegalStateException if multiple Countries exist with the same passed in alternateCode
63       * @throws RiceIllegalArgumentException if alternateCode is null or is a whitespace only string.
64       */
65      @WebMethod(operationName = "getCountryByAlternateCode")
66      @WebResult(name = "country")
67      @Cacheable(value=Country.Cache.NAME, key="'alternateCode=' + #p0")
68      Country getCountryByAlternateCode(@WebParam(name = "alternateCode") String alternateCode)
69              throws RiceIllegalStateException, RiceIllegalArgumentException;
70  
71      /**
72       * Returns all Countries that are not restricted.
73       *
74       * @return all countries that are not restricted
75       */
76      @WebMethod(operationName = "findAllCountriesNotRestricted")
77      @XmlElementWrapper(name = "countriesNotRestricted", required = false)
78      @XmlElement(name = "countryNotRestricted", required = false)
79      @WebResult(name = "countriesNotRestricted")
80      @Cacheable(value=Country.Cache.NAME, key="'allRestricted'")
81      List<Country> findAllCountriesNotRestricted();
82  
83      /**
84       * Returns all Countries
85       *
86       * @return all countries
87       */
88      @WebMethod(operationName = "findAllCountries")
89      @XmlElementWrapper(name = "countries", required = false)
90      @XmlElement(name = "country", required = false)
91      @WebResult(name = "countries")
92      @Cacheable(value=Country.Cache.NAME, key="'all'")
93      List<Country> findAllCountries();
94  
95      /**
96       * Returns the system default country.  This is simply meant to be informational for applications which need the
97       * ability to utilize a default country (such as for defaulting of certain fields during data entry).  This method
98       * may return null in situations where no default country is configured.
99       *
100      * @return the default country, or null if no default country is defined
101      */
102     @WebMethod(operationName = "getDefaultCountry")
103     @WebResult(name = "country")
104     @Cacheable(value = Country.Cache.NAME,  key="'default'")
105     Country getDefaultCountry();
106 
107     /**
108      * This method find Countries based on a query criteria.  The criteria cannot be null.
109      *
110      * @since 2.0.1
111      * @param queryByCriteria the criteria.  Cannot be null.
112      * @return query results.  will never return null.
113      * @throws IllegalArgumentException if the queryByCriteria is null
114      */
115     @WebMethod(operationName = "findCountries")
116     @WebResult(name = "results")
117     CountryQueryResults findCountries(@WebParam(name = "query") QueryByCriteria queryByCriteria) throws RiceIllegalArgumentException;
118 
119 }