1 /**
2 * Copyright 2005-2013 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.postalcode;
17
18 import org.kuali.rice.core.api.criteria.QueryByCriteria;
19 import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
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 PostalCode PostalCodes}.
34 *
35 * @author Kuali Rice Team (rice.collab@kuali.org)
36 */
37 @WebService(name = "PostalCodeService", targetNamespace = LocationConstants.Namespaces.LOCATION_NAMESPACE_2_0)
38 @SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
39 public interface PostalCodeService {
40
41 /**
42 * Gets a {@link PostalCode} from a postal country code and postal code value.
43 *
44 * <p>
45 * This method will return null if the state does not exist.
46 * </p>
47 *
48 * <p>
49 * This method will return active or inactive postal codes.
50 * </p>
51 *
52 * @param countryCode country code. cannot be blank.
53 * @param code postal code value. cannot be blank.
54 * @return a {@link PostalCode} or null
55 * @throws RiceIllegalArgumentException country code or postal code value is blank
56 */
57 @WebMethod(operationName="getPostalCode")
58 @WebResult(name = "postalCode")
59 @Cacheable(value=PostalCode.Cache.NAME, key="'countryCode=' + #p0 + '|' + 'code=' + #p1")
60 PostalCode getPostalCode(@WebParam(name = "countryCode") String countryCode, @WebParam(name = "code") String code)
61 throws RiceIllegalArgumentException;
62
63 /**
64 * Gets all the {@link PostalCode PostalCode} for postal country code.
65 *
66 * <p>
67 * This method will always return an <b>immutable</b> Collection
68 * even when no values exist.
69 * </p>
70 *
71 * <p>
72 * This method will only return active postal codes.
73 * </p>
74 *
75 * @param countryCode state code. cannot be blank.
76 * @return an immutable collection of states
77 * @throws RiceIllegalArgumentException country code is blank
78 */
79 @WebMethod(operationName="findAllPostalCodesInCountry")
80 @XmlElementWrapper(name = "postalCodes", required = false)
81 @XmlElement(name = "postalCode", required = false)
82 @WebResult(name = "postalCodes")
83 @Cacheable(value=PostalCode.Cache.NAME, key="'countryCode=' + #p0")
84 List<PostalCode> findAllPostalCodesInCountry(@WebParam(name = "countryCode") String countryCode)
85 throws RiceIllegalArgumentException;
86
87 /**
88 * This method find PostalCodes based on a query criteria. The criteria cannot be null.
89 *
90 * @since 2.0.1
91 * @param queryByCriteria the criteria. Cannot be null.
92 * @return query results. will never return null.
93 * @throws IllegalArgumentException if the queryByCriteria is null
94 */
95 @WebMethod(operationName = "findPostalCodes")
96 @WebResult(name = "results")
97 PostalCodeQueryResults findPostalCodes(@WebParam(name = "query") QueryByCriteria queryByCriteria) throws RiceIllegalArgumentException;
98 }