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