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