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