1   /**
2    * Copyright (c) 2000-2007 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.service.http;
24  
25  import com.liferay.portal.kernel.log.Log;
26  import com.liferay.portal.kernel.log.LogFactoryUtil;
27  import com.liferay.portal.kernel.util.BooleanWrapper;
28  import com.liferay.portal.kernel.util.LongWrapper;
29  import com.liferay.portal.kernel.util.MethodWrapper;
30  import com.liferay.portal.security.auth.HttpPrincipal;
31  import com.liferay.portal.service.RegionServiceUtil;
32  import com.liferay.portal.service.http.TunnelUtil;
33  
34  /**
35   * <a href="RegionServiceHttp.java.html"><b><i>View Source</i></b></a>
36   *
37   * <p>
38   * ServiceBuilder generated this class. Modifications in this class will be overwritten
39   * the next time is generated.
40   * </p>
41   *
42   * <p>
43   * This class provides a HTTP utility for the <code>com.liferay.portal.service.RegionServiceUtil</code>
44   * service utility. The static methods of this class calls the same methods of the
45   * service utility. However, the signatures are different because it requires an
46   * additional <code>com.liferay.portal.security.auth.HttpPrincipal</code> parameter.
47   * </p>
48   *
49   * <p>
50   * The benefits of using the HTTP utility is that it is fast and allows for tunneling
51   * without the cost of serializing to text. The drawback is that it only works with
52   * Java.
53   * </p>
54   *
55   * <p>
56   * Set the property <code>tunnel.servlet.hosts.allowed</code> in portal.properties
57   * to configure security.
58   * </p>
59   *
60   * <p>
61   * The HTTP utility is only generated for remote services.
62   * </p>
63   *
64   * @author Brian Wing Shun Chan
65   *
66   * @see com.liferay.portal.security.auth.HttpPrincipal
67   * @see com.liferay.portal.service.RegionServiceUtil
68   * @see com.liferay.portal.service.http.RegionServiceSoap
69   *
70   */
71  public class RegionServiceHttp {
72      public static java.util.List getRegions(HttpPrincipal httpPrincipal)
73          throws com.liferay.portal.SystemException {
74          try {
75              MethodWrapper methodWrapper = new MethodWrapper(RegionServiceUtil.class.getName(),
76                      "getRegions", new Object[0]);
77              Object returnObj = null;
78  
79              try {
80                  returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
81              }
82              catch (Exception e) {
83                  if (e instanceof com.liferay.portal.SystemException) {
84                      throw (com.liferay.portal.SystemException)e;
85                  }
86  
87                  throw new com.liferay.portal.SystemException(e);
88              }
89  
90              return (java.util.List)returnObj;
91          }
92          catch (com.liferay.portal.SystemException se) {
93              _log.error(se, se);
94              throw se;
95          }
96      }
97  
98      public static java.util.List getRegions(HttpPrincipal httpPrincipal,
99          long countryId) throws com.liferay.portal.SystemException {
100         try {
101             Object paramObj0 = new LongWrapper(countryId);
102             MethodWrapper methodWrapper = new MethodWrapper(RegionServiceUtil.class.getName(),
103                     "getRegions", new Object[] { paramObj0 });
104             Object returnObj = null;
105 
106             try {
107                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
108             }
109             catch (Exception e) {
110                 if (e instanceof com.liferay.portal.SystemException) {
111                     throw (com.liferay.portal.SystemException)e;
112                 }
113 
114                 throw new com.liferay.portal.SystemException(e);
115             }
116 
117             return (java.util.List)returnObj;
118         }
119         catch (com.liferay.portal.SystemException se) {
120             _log.error(se, se);
121             throw se;
122         }
123     }
124 
125     public static java.util.List getRegions(HttpPrincipal httpPrincipal,
126         boolean active) throws com.liferay.portal.SystemException {
127         try {
128             Object paramObj0 = new BooleanWrapper(active);
129             MethodWrapper methodWrapper = new MethodWrapper(RegionServiceUtil.class.getName(),
130                     "getRegions", new Object[] { paramObj0 });
131             Object returnObj = null;
132 
133             try {
134                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
135             }
136             catch (Exception e) {
137                 if (e instanceof com.liferay.portal.SystemException) {
138                     throw (com.liferay.portal.SystemException)e;
139                 }
140 
141                 throw new com.liferay.portal.SystemException(e);
142             }
143 
144             return (java.util.List)returnObj;
145         }
146         catch (com.liferay.portal.SystemException se) {
147             _log.error(se, se);
148             throw se;
149         }
150     }
151 
152     public static java.util.List getRegions(HttpPrincipal httpPrincipal,
153         long countryId, boolean active)
154         throws com.liferay.portal.SystemException {
155         try {
156             Object paramObj0 = new LongWrapper(countryId);
157             Object paramObj1 = new BooleanWrapper(active);
158             MethodWrapper methodWrapper = new MethodWrapper(RegionServiceUtil.class.getName(),
159                     "getRegions", new Object[] { paramObj0, paramObj1 });
160             Object returnObj = null;
161 
162             try {
163                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
164             }
165             catch (Exception e) {
166                 if (e instanceof com.liferay.portal.SystemException) {
167                     throw (com.liferay.portal.SystemException)e;
168                 }
169 
170                 throw new com.liferay.portal.SystemException(e);
171             }
172 
173             return (java.util.List)returnObj;
174         }
175         catch (com.liferay.portal.SystemException se) {
176             _log.error(se, se);
177             throw se;
178         }
179     }
180 
181     public static com.liferay.portal.model.Region getRegion(
182         HttpPrincipal httpPrincipal, long regionId)
183         throws com.liferay.portal.SystemException, 
184             com.liferay.portal.PortalException {
185         try {
186             Object paramObj0 = new LongWrapper(regionId);
187             MethodWrapper methodWrapper = new MethodWrapper(RegionServiceUtil.class.getName(),
188                     "getRegion", new Object[] { paramObj0 });
189             Object returnObj = null;
190 
191             try {
192                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
193             }
194             catch (Exception e) {
195                 if (e instanceof com.liferay.portal.SystemException) {
196                     throw (com.liferay.portal.SystemException)e;
197                 }
198 
199                 if (e instanceof com.liferay.portal.PortalException) {
200                     throw (com.liferay.portal.PortalException)e;
201                 }
202 
203                 throw new com.liferay.portal.SystemException(e);
204             }
205 
206             return (com.liferay.portal.model.Region)returnObj;
207         }
208         catch (com.liferay.portal.SystemException se) {
209             _log.error(se, se);
210             throw se;
211         }
212     }
213 
214     private static Log _log = LogFactoryUtil.getLog(RegionServiceHttp.class);
215 }