1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portal.service.http;
21  
22  import com.liferay.portal.kernel.log.Log;
23  import com.liferay.portal.kernel.log.LogFactoryUtil;
24  import com.liferay.portal.kernel.util.BooleanWrapper;
25  import com.liferay.portal.kernel.util.LongWrapper;
26  import com.liferay.portal.kernel.util.MethodWrapper;
27  import com.liferay.portal.kernel.util.NullWrapper;
28  import com.liferay.portal.security.auth.HttpPrincipal;
29  import com.liferay.portal.service.RegionServiceUtil;
30  
31  /**
32   * <a href="RegionServiceHttp.java.html"><b><i>View Source</i></b></a>
33   *
34   * <p>
35   * ServiceBuilder generated this class. Modifications in this class will be
36   * overwritten the next time is generated.
37   * </p>
38   *
39   * <p>
40   * This class provides a HTTP utility for the
41   * <code>com.liferay.portal.service.RegionServiceUtil</code> service
42   * utility. The static methods of this class calls the same methods of the
43   * service utility. However, the signatures are different because it requires an
44   * additional <code>com.liferay.portal.security.auth.HttpPrincipal</code>
45   * parameter.
46   * </p>
47   *
48   * <p>
49   * The benefits of using the HTTP utility is that it is fast and allows for
50   * tunneling without the cost of serializing to text. The drawback is that it
51   * only works with Java.
52   * </p>
53   *
54   * <p>
55   * Set the property <code>tunnel.servlet.hosts.allowed</code> in
56   * portal.properties to configure security.
57   * </p>
58   *
59   * <p>
60   * The HTTP utility is only generated for remote services.
61   * </p>
62   *
63   * @author Brian Wing Shun Chan
64   *
65   * @see com.liferay.portal.security.auth.HttpPrincipal
66   * @see com.liferay.portal.service.RegionServiceUtil
67   * @see com.liferay.portal.service.http.RegionServiceSoap
68   *
69   */
70  public class RegionServiceHttp {
71      public static com.liferay.portal.model.Region addRegion(
72          HttpPrincipal httpPrincipal, long countryId,
73          java.lang.String regionCode, java.lang.String name, boolean active)
74          throws com.liferay.portal.PortalException,
75              com.liferay.portal.SystemException {
76          try {
77              Object paramObj0 = new LongWrapper(countryId);
78  
79              Object paramObj1 = regionCode;
80  
81              if (regionCode == null) {
82                  paramObj1 = new NullWrapper("java.lang.String");
83              }
84  
85              Object paramObj2 = name;
86  
87              if (name == null) {
88                  paramObj2 = new NullWrapper("java.lang.String");
89              }
90  
91              Object paramObj3 = new BooleanWrapper(active);
92  
93              MethodWrapper methodWrapper = new MethodWrapper(RegionServiceUtil.class.getName(),
94                      "addRegion",
95                      new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
96  
97              Object returnObj = null;
98  
99              try {
100                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
101             }
102             catch (Exception e) {
103                 if (e instanceof com.liferay.portal.PortalException) {
104                     throw (com.liferay.portal.PortalException)e;
105                 }
106 
107                 if (e instanceof com.liferay.portal.SystemException) {
108                     throw (com.liferay.portal.SystemException)e;
109                 }
110 
111                 throw new com.liferay.portal.SystemException(e);
112             }
113 
114             return (com.liferay.portal.model.Region)returnObj;
115         }
116         catch (com.liferay.portal.SystemException se) {
117             _log.error(se, se);
118 
119             throw se;
120         }
121     }
122 
123     public static java.util.List<com.liferay.portal.model.Region> getRegions(
124         HttpPrincipal httpPrincipal) throws com.liferay.portal.SystemException {
125         try {
126             MethodWrapper methodWrapper = new MethodWrapper(RegionServiceUtil.class.getName(),
127                     "getRegions", new Object[0]);
128 
129             Object returnObj = null;
130 
131             try {
132                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
133             }
134             catch (Exception e) {
135                 if (e instanceof com.liferay.portal.SystemException) {
136                     throw (com.liferay.portal.SystemException)e;
137                 }
138 
139                 throw new com.liferay.portal.SystemException(e);
140             }
141 
142             return (java.util.List<com.liferay.portal.model.Region>)returnObj;
143         }
144         catch (com.liferay.portal.SystemException se) {
145             _log.error(se, se);
146 
147             throw se;
148         }
149     }
150 
151     public static java.util.List<com.liferay.portal.model.Region> getRegions(
152         HttpPrincipal httpPrincipal, long countryId)
153         throws com.liferay.portal.SystemException {
154         try {
155             Object paramObj0 = new LongWrapper(countryId);
156 
157             MethodWrapper methodWrapper = new MethodWrapper(RegionServiceUtil.class.getName(),
158                     "getRegions", new Object[] { paramObj0 });
159 
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<com.liferay.portal.model.Region>)returnObj;
174         }
175         catch (com.liferay.portal.SystemException se) {
176             _log.error(se, se);
177 
178             throw se;
179         }
180     }
181 
182     public static java.util.List<com.liferay.portal.model.Region> getRegions(
183         HttpPrincipal httpPrincipal, boolean active)
184         throws com.liferay.portal.SystemException {
185         try {
186             Object paramObj0 = new BooleanWrapper(active);
187 
188             MethodWrapper methodWrapper = new MethodWrapper(RegionServiceUtil.class.getName(),
189                     "getRegions", new Object[] { paramObj0 });
190 
191             Object returnObj = null;
192 
193             try {
194                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
195             }
196             catch (Exception e) {
197                 if (e instanceof com.liferay.portal.SystemException) {
198                     throw (com.liferay.portal.SystemException)e;
199                 }
200 
201                 throw new com.liferay.portal.SystemException(e);
202             }
203 
204             return (java.util.List<com.liferay.portal.model.Region>)returnObj;
205         }
206         catch (com.liferay.portal.SystemException se) {
207             _log.error(se, se);
208 
209             throw se;
210         }
211     }
212 
213     public static java.util.List<com.liferay.portal.model.Region> getRegions(
214         HttpPrincipal httpPrincipal, long countryId, boolean active)
215         throws com.liferay.portal.SystemException {
216         try {
217             Object paramObj0 = new LongWrapper(countryId);
218 
219             Object paramObj1 = new BooleanWrapper(active);
220 
221             MethodWrapper methodWrapper = new MethodWrapper(RegionServiceUtil.class.getName(),
222                     "getRegions", new Object[] { paramObj0, paramObj1 });
223 
224             Object returnObj = null;
225 
226             try {
227                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
228             }
229             catch (Exception e) {
230                 if (e instanceof com.liferay.portal.SystemException) {
231                     throw (com.liferay.portal.SystemException)e;
232                 }
233 
234                 throw new com.liferay.portal.SystemException(e);
235             }
236 
237             return (java.util.List<com.liferay.portal.model.Region>)returnObj;
238         }
239         catch (com.liferay.portal.SystemException se) {
240             _log.error(se, se);
241 
242             throw se;
243         }
244     }
245 
246     public static com.liferay.portal.model.Region getRegion(
247         HttpPrincipal httpPrincipal, long regionId)
248         throws com.liferay.portal.PortalException,
249             com.liferay.portal.SystemException {
250         try {
251             Object paramObj0 = new LongWrapper(regionId);
252 
253             MethodWrapper methodWrapper = new MethodWrapper(RegionServiceUtil.class.getName(),
254                     "getRegion", new Object[] { paramObj0 });
255 
256             Object returnObj = null;
257 
258             try {
259                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
260             }
261             catch (Exception e) {
262                 if (e instanceof com.liferay.portal.PortalException) {
263                     throw (com.liferay.portal.PortalException)e;
264                 }
265 
266                 if (e instanceof com.liferay.portal.SystemException) {
267                     throw (com.liferay.portal.SystemException)e;
268                 }
269 
270                 throw new com.liferay.portal.SystemException(e);
271             }
272 
273             return (com.liferay.portal.model.Region)returnObj;
274         }
275         catch (com.liferay.portal.SystemException se) {
276             _log.error(se, se);
277 
278             throw se;
279         }
280     }
281 
282     private static Log _log = LogFactoryUtil.getLog(RegionServiceHttp.class);
283 }