001 /** 002 * Copyright 2005-2012 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.rice.location.api.state; 017 018 import org.kuali.rice.core.api.exception.RiceIllegalArgumentException; 019 import org.kuali.rice.core.api.exception.RiceIllegalStateException; 020 import org.kuali.rice.location.api.LocationConstants; 021 import org.springframework.cache.annotation.Cacheable; 022 023 import javax.jws.WebMethod; 024 import javax.jws.WebParam; 025 import javax.jws.WebResult; 026 import javax.jws.WebService; 027 import javax.jws.soap.SOAPBinding; 028 import javax.xml.bind.annotation.XmlElement; 029 import javax.xml.bind.annotation.XmlElementWrapper; 030 import java.util.List; 031 032 /** 033 * Service for interacting with {@link State States}. 034 * 035 * @author Kuali Rice Team (rice.collab@kuali.org) 036 */ 037 @WebService(name = "StateService", targetNamespace = LocationConstants.Namespaces.LOCATION_NAMESPACE_2_0) 038 @SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED) 039 public interface StateService { 040 041 /** 042 * Gets a {@link State} from a postal country code and postal state code. 043 * <p/> 044 * <p> 045 * This method will return null if the state does not exist. 046 * </p> 047 * <p/> 048 * <p> 049 * This method will return active or inactive states. 050 * </p> 051 * 052 * @param countryCode country code. cannot be blank. 053 * @param code state code. cannot be blank. 054 * @return a {@link State} or null 055 * @throws IllegalArgumentException country code or state code is blank 056 */ 057 @WebMethod(operationName = "getState") 058 @WebResult(name = "state") 059 @Cacheable(value=State.Cache.NAME, key="'countryCode=' + #countryCode + '|' + 'code=' + #code") 060 State getState(@WebParam(name = "countryCode") String countryCode, @WebParam(name = "code") String code) 061 throws RiceIllegalArgumentException; 062 063 /** 064 * Finds all the {@link State States} for postal country code. 065 * <p/> 066 * <p> 067 * This method will always return an <b>immutable</b> Collection 068 * even when no values exist. 069 * </p> 070 * <p/> 071 * <p> 072 * This method will only return active states. 073 * </p> 074 * 075 * @param countryCode state code. cannot be blank. 076 * @return an immutable collection of states 077 * @throws IllegalArgumentException country code is blank 078 */ 079 @WebMethod(operationName = "findAllStatesInCountry") 080 @XmlElementWrapper(name = "states", required = true) 081 @XmlElement(name = "state", required = false) 082 @WebResult(name = "states") 083 @Cacheable(value=State.Cache.NAME, key="'countryCode=' + #countryCode") 084 List<State> findAllStatesInCountry(@WebParam(name = "countryCode") String countryCode) 085 throws RiceIllegalArgumentException; 086 087 /** 088 * Finds all the {@link State States} for alternate postal country code. 089 * <p/> 090 * <p> 091 * This method will always return an <b>immutable</b> Collection 092 * even when no values exist. 093 * </p> 094 * <p/> 095 * <p> 096 * This method will only return active states. 097 * </p> 098 * 099 * @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 }