1   /**
2    * Copyright (c) 2000-2009 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.kernel.util.NullWrapper;
31  import com.liferay.portal.security.auth.HttpPrincipal;
32  import com.liferay.portal.service.RegionServiceUtil;
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
39   * overwritten the next time is generated.
40   * </p>
41   *
42   * <p>
43   * This class provides a HTTP utility for the
44   * <code>com.liferay.portal.service.RegionServiceUtil</code> service
45   * utility. The static methods of this class calls the same methods of the
46   * service utility. However, the signatures are different because it requires an
47   * additional <code>com.liferay.portal.security.auth.HttpPrincipal</code>
48   * parameter.
49   * </p>
50   *
51   * <p>
52   * The benefits of using the HTTP utility is that it is fast and allows for
53   * tunneling without the cost of serializing to text. The drawback is that it
54   * only works with Java.
55   * </p>
56   *
57   * <p>
58   * Set the property <code>tunnel.servlet.hosts.allowed</code> in
59   * portal.properties to configure security.
60   * </p>
61   *
62   * <p>
63   * The HTTP utility is only generated for remote services.
64   * </p>
65   *
66   * @author Brian Wing Shun Chan
67   *
68   * @see com.liferay.portal.security.auth.HttpPrincipal
69   * @see com.liferay.portal.service.RegionServiceUtil
70   * @see com.liferay.portal.service.http.RegionServiceSoap
71   *
72   */
73  public class RegionServiceHttp {
74      public static com.liferay.portal.model.Region addRegion(
75          HttpPrincipal httpPrincipal, long countryId,
76          java.lang.String regionCode, java.lang.String name, boolean active)
77          throws com.liferay.portal.PortalException,
78              com.liferay.portal.SystemException {
79          try {
80              Object paramObj0 = new LongWrapper(countryId);
81  
82              Object paramObj1 = regionCode;
83  
84              if (regionCode == null) {
85                  paramObj1 = new NullWrapper("java.lang.String");
86              }
87  
88              Object paramObj2 = name;
89  
90              if (name == null) {
91                  paramObj2 = new NullWrapper("java.lang.String");
92              }
93  
94              Object paramObj3 = new BooleanWrapper(active);
95  
96              MethodWrapper methodWrapper = new MethodWrapper(RegionServiceUtil.class.getName(),
97                      "addRegion",
98                      new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
99  
100             Object returnObj = null;
101 
102             try {
103                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
104             }
105             catch (Exception e) {
106                 if (e instanceof com.liferay.portal.PortalException) {
107                     throw (com.liferay.portal.PortalException)e;
108                 }
109 
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 (com.liferay.portal.model.Region)returnObj;
118         }
119         catch (com.liferay.portal.SystemException se) {
120             _log.error(se, se);
121 
122             throw se;
123         }
124     }
125 
126     public static java.util.List<com.liferay.portal.model.Region> getRegions(
127         HttpPrincipal httpPrincipal) throws com.liferay.portal.SystemException {
128         try {
129             MethodWrapper methodWrapper = new MethodWrapper(RegionServiceUtil.class.getName(),
130                     "getRegions", new Object[0]);
131 
132             Object returnObj = null;
133 
134             try {
135                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
136             }
137             catch (Exception e) {
138                 if (e instanceof com.liferay.portal.SystemException) {
139                     throw (com.liferay.portal.SystemException)e;
140                 }
141 
142                 throw new com.liferay.portal.SystemException(e);
143             }
144 
145             return (java.util.List<com.liferay.portal.model.Region>)returnObj;
146         }
147         catch (com.liferay.portal.SystemException se) {
148             _log.error(se, se);
149 
150             throw se;
151         }
152     }
153 
154     public static java.util.List<com.liferay.portal.model.Region> getRegions(
155         HttpPrincipal httpPrincipal, long countryId)
156         throws com.liferay.portal.SystemException {
157         try {
158             Object paramObj0 = new LongWrapper(countryId);
159 
160             MethodWrapper methodWrapper = new MethodWrapper(RegionServiceUtil.class.getName(),
161                     "getRegions", new Object[] { paramObj0 });
162 
163             Object returnObj = null;
164 
165             try {
166                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
167             }
168             catch (Exception e) {
169                 if (e instanceof com.liferay.portal.SystemException) {
170                     throw (com.liferay.portal.SystemException)e;
171                 }
172 
173                 throw new com.liferay.portal.SystemException(e);
174             }
175 
176             return (java.util.List<com.liferay.portal.model.Region>)returnObj;
177         }
178         catch (com.liferay.portal.SystemException se) {
179             _log.error(se, se);
180 
181             throw se;
182         }
183     }
184 
185     public static java.util.List<com.liferay.portal.model.Region> getRegions(
186         HttpPrincipal httpPrincipal, boolean active)
187         throws com.liferay.portal.SystemException {
188         try {
189             Object paramObj0 = new BooleanWrapper(active);
190 
191             MethodWrapper methodWrapper = new MethodWrapper(RegionServiceUtil.class.getName(),
192                     "getRegions", new Object[] { paramObj0 });
193 
194             Object returnObj = null;
195 
196             try {
197                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
198             }
199             catch (Exception e) {
200                 if (e instanceof com.liferay.portal.SystemException) {
201                     throw (com.liferay.portal.SystemException)e;
202                 }
203 
204                 throw new com.liferay.portal.SystemException(e);
205             }
206 
207             return (java.util.List<com.liferay.portal.model.Region>)returnObj;
208         }
209         catch (com.liferay.portal.SystemException se) {
210             _log.error(se, se);
211 
212             throw se;
213         }
214     }
215 
216     public static java.util.List<com.liferay.portal.model.Region> getRegions(
217         HttpPrincipal httpPrincipal, long countryId, boolean active)
218         throws com.liferay.portal.SystemException {
219         try {
220             Object paramObj0 = new LongWrapper(countryId);
221 
222             Object paramObj1 = new BooleanWrapper(active);
223 
224             MethodWrapper methodWrapper = new MethodWrapper(RegionServiceUtil.class.getName(),
225                     "getRegions", new Object[] { paramObj0, paramObj1 });
226 
227             Object returnObj = null;
228 
229             try {
230                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
231             }
232             catch (Exception e) {
233                 if (e instanceof com.liferay.portal.SystemException) {
234                     throw (com.liferay.portal.SystemException)e;
235                 }
236 
237                 throw new com.liferay.portal.SystemException(e);
238             }
239 
240             return (java.util.List<com.liferay.portal.model.Region>)returnObj;
241         }
242         catch (com.liferay.portal.SystemException se) {
243             _log.error(se, se);
244 
245             throw se;
246         }
247     }
248 
249     public static com.liferay.portal.model.Region getRegion(
250         HttpPrincipal httpPrincipal, long regionId)
251         throws com.liferay.portal.PortalException,
252             com.liferay.portal.SystemException {
253         try {
254             Object paramObj0 = new LongWrapper(regionId);
255 
256             MethodWrapper methodWrapper = new MethodWrapper(RegionServiceUtil.class.getName(),
257                     "getRegion", new Object[] { paramObj0 });
258 
259             Object returnObj = null;
260 
261             try {
262                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
263             }
264             catch (Exception e) {
265                 if (e instanceof com.liferay.portal.PortalException) {
266                     throw (com.liferay.portal.PortalException)e;
267                 }
268 
269                 if (e instanceof com.liferay.portal.SystemException) {
270                     throw (com.liferay.portal.SystemException)e;
271                 }
272 
273                 throw new com.liferay.portal.SystemException(e);
274             }
275 
276             return (com.liferay.portal.model.Region)returnObj;
277         }
278         catch (com.liferay.portal.SystemException se) {
279             _log.error(se, se);
280 
281             throw se;
282         }
283     }
284 
285     private static Log _log = LogFactoryUtil.getLog(RegionServiceHttp.class);
286 }