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