1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.service.http;
16  
17  import com.liferay.portal.kernel.log.Log;
18  import com.liferay.portal.kernel.log.LogFactoryUtil;
19  import com.liferay.portal.kernel.util.BooleanWrapper;
20  import com.liferay.portal.kernel.util.LongWrapper;
21  import com.liferay.portal.kernel.util.MethodWrapper;
22  import com.liferay.portal.kernel.util.NullWrapper;
23  import com.liferay.portal.security.auth.HttpPrincipal;
24  import com.liferay.portal.service.RegionServiceUtil;
25  
26  /**
27   * <a href="RegionServiceHttp.java.html"><b><i>View Source</i></b></a>
28   *
29   * <p>
30   * ServiceBuilder generated this class. Modifications in this class will be
31   * overwritten the next time is generated.
32   * </p>
33   *
34   * <p>
35   * This class provides a HTTP utility for the
36   * {@link com.liferay.portal.service.RegionServiceUtil} service utility. The
37   * static methods of this class calls the same methods of the service utility.
38   * However, the signatures are different because it requires an additional
39   * {@link com.liferay.portal.security.auth.HttpPrincipal} parameter.
40   * </p>
41   *
42   * <p>
43   * The benefits of using the HTTP utility is that it is fast and allows for
44   * tunneling without the cost of serializing to text. The drawback is that it
45   * only works with Java.
46   * </p>
47   *
48   * <p>
49   * Set the property <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
50   * configure security.
51   * </p>
52   *
53   * <p>
54   * The HTTP utility is only generated for remote services.
55   * </p>
56   *
57   * @author    Brian Wing Shun Chan
58   * @see       RegionServiceSoap
59   * @see       com.liferay.portal.security.auth.HttpPrincipal
60   * @see       com.liferay.portal.service.RegionServiceUtil
61   * @generated
62   */
63  public class RegionServiceHttp {
64      public static com.liferay.portal.model.Region addRegion(
65          HttpPrincipal httpPrincipal, long countryId,
66          java.lang.String regionCode, java.lang.String name, boolean active)
67          throws com.liferay.portal.kernel.exception.PortalException,
68              com.liferay.portal.kernel.exception.SystemException {
69          try {
70              Object paramObj0 = new LongWrapper(countryId);
71  
72              Object paramObj1 = regionCode;
73  
74              if (regionCode == null) {
75                  paramObj1 = new NullWrapper("java.lang.String");
76              }
77  
78              Object paramObj2 = name;
79  
80              if (name == null) {
81                  paramObj2 = new NullWrapper("java.lang.String");
82              }
83  
84              Object paramObj3 = new BooleanWrapper(active);
85  
86              MethodWrapper methodWrapper = new MethodWrapper(RegionServiceUtil.class.getName(),
87                      "addRegion",
88                      new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
89  
90              Object returnObj = null;
91  
92              try {
93                  returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
94              }
95              catch (Exception e) {
96                  if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
97                      throw (com.liferay.portal.kernel.exception.PortalException)e;
98                  }
99  
100                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
101                     throw (com.liferay.portal.kernel.exception.SystemException)e;
102                 }
103 
104                 throw new com.liferay.portal.kernel.exception.SystemException(e);
105             }
106 
107             return (com.liferay.portal.model.Region)returnObj;
108         }
109         catch (com.liferay.portal.kernel.exception.SystemException se) {
110             _log.error(se, se);
111 
112             throw se;
113         }
114     }
115 
116     public static java.util.List<com.liferay.portal.model.Region> getRegions(
117         HttpPrincipal httpPrincipal)
118         throws com.liferay.portal.kernel.exception.SystemException {
119         try {
120             MethodWrapper methodWrapper = new MethodWrapper(RegionServiceUtil.class.getName(),
121                     "getRegions", new Object[0]);
122 
123             Object returnObj = null;
124 
125             try {
126                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
127             }
128             catch (Exception e) {
129                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
130                     throw (com.liferay.portal.kernel.exception.SystemException)e;
131                 }
132 
133                 throw new com.liferay.portal.kernel.exception.SystemException(e);
134             }
135 
136             return (java.util.List<com.liferay.portal.model.Region>)returnObj;
137         }
138         catch (com.liferay.portal.kernel.exception.SystemException se) {
139             _log.error(se, se);
140 
141             throw se;
142         }
143     }
144 
145     public static java.util.List<com.liferay.portal.model.Region> getRegions(
146         HttpPrincipal httpPrincipal, long countryId)
147         throws com.liferay.portal.kernel.exception.SystemException {
148         try {
149             Object paramObj0 = new LongWrapper(countryId);
150 
151             MethodWrapper methodWrapper = new MethodWrapper(RegionServiceUtil.class.getName(),
152                     "getRegions", new Object[] { paramObj0 });
153 
154             Object returnObj = null;
155 
156             try {
157                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
158             }
159             catch (Exception e) {
160                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
161                     throw (com.liferay.portal.kernel.exception.SystemException)e;
162                 }
163 
164                 throw new com.liferay.portal.kernel.exception.SystemException(e);
165             }
166 
167             return (java.util.List<com.liferay.portal.model.Region>)returnObj;
168         }
169         catch (com.liferay.portal.kernel.exception.SystemException se) {
170             _log.error(se, se);
171 
172             throw se;
173         }
174     }
175 
176     public static java.util.List<com.liferay.portal.model.Region> getRegions(
177         HttpPrincipal httpPrincipal, boolean active)
178         throws com.liferay.portal.kernel.exception.SystemException {
179         try {
180             Object paramObj0 = new BooleanWrapper(active);
181 
182             MethodWrapper methodWrapper = new MethodWrapper(RegionServiceUtil.class.getName(),
183                     "getRegions", new Object[] { paramObj0 });
184 
185             Object returnObj = null;
186 
187             try {
188                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
189             }
190             catch (Exception e) {
191                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
192                     throw (com.liferay.portal.kernel.exception.SystemException)e;
193                 }
194 
195                 throw new com.liferay.portal.kernel.exception.SystemException(e);
196             }
197 
198             return (java.util.List<com.liferay.portal.model.Region>)returnObj;
199         }
200         catch (com.liferay.portal.kernel.exception.SystemException se) {
201             _log.error(se, se);
202 
203             throw se;
204         }
205     }
206 
207     public static java.util.List<com.liferay.portal.model.Region> getRegions(
208         HttpPrincipal httpPrincipal, long countryId, boolean active)
209         throws com.liferay.portal.kernel.exception.SystemException {
210         try {
211             Object paramObj0 = new LongWrapper(countryId);
212 
213             Object paramObj1 = new BooleanWrapper(active);
214 
215             MethodWrapper methodWrapper = new MethodWrapper(RegionServiceUtil.class.getName(),
216                     "getRegions", new Object[] { paramObj0, paramObj1 });
217 
218             Object returnObj = null;
219 
220             try {
221                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
222             }
223             catch (Exception e) {
224                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
225                     throw (com.liferay.portal.kernel.exception.SystemException)e;
226                 }
227 
228                 throw new com.liferay.portal.kernel.exception.SystemException(e);
229             }
230 
231             return (java.util.List<com.liferay.portal.model.Region>)returnObj;
232         }
233         catch (com.liferay.portal.kernel.exception.SystemException se) {
234             _log.error(se, se);
235 
236             throw se;
237         }
238     }
239 
240     public static com.liferay.portal.model.Region getRegion(
241         HttpPrincipal httpPrincipal, long regionId)
242         throws com.liferay.portal.kernel.exception.PortalException,
243             com.liferay.portal.kernel.exception.SystemException {
244         try {
245             Object paramObj0 = new LongWrapper(regionId);
246 
247             MethodWrapper methodWrapper = new MethodWrapper(RegionServiceUtil.class.getName(),
248                     "getRegion", new Object[] { paramObj0 });
249 
250             Object returnObj = null;
251 
252             try {
253                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
254             }
255             catch (Exception e) {
256                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
257                     throw (com.liferay.portal.kernel.exception.PortalException)e;
258                 }
259 
260                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
261                     throw (com.liferay.portal.kernel.exception.SystemException)e;
262                 }
263 
264                 throw new com.liferay.portal.kernel.exception.SystemException(e);
265             }
266 
267             return (com.liferay.portal.model.Region)returnObj;
268         }
269         catch (com.liferay.portal.kernel.exception.SystemException se) {
270             _log.error(se, se);
271 
272             throw se;
273         }
274     }
275 
276     private static Log _log = LogFactoryUtil.getLog(RegionServiceHttp.class);
277 }