1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights 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   * {@link com.liferay.portal.service.WebsiteServiceUtil} service utility. The
46   * static methods of this class calls the same methods of the service utility.
47   * However, the signatures are different because it requires an additional
48   * {@link com.liferay.portal.security.auth.HttpPrincipal} 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 <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
59   * 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   * @see       WebsiteServiceSoap
68   * @see       com.liferay.portal.security.auth.HttpPrincipal
69   * @see       com.liferay.portal.service.WebsiteServiceUtil
70   * @generated
71   */
72  public class WebsiteServiceHttp {
73      public static com.liferay.portal.model.Website addWebsite(
74          HttpPrincipal httpPrincipal, java.lang.String className, long classPK,
75          java.lang.String url, int typeId, boolean primary)
76          throws com.liferay.portal.PortalException,
77              com.liferay.portal.SystemException {
78          try {
79              Object paramObj0 = className;
80  
81              if (className == null) {
82                  paramObj0 = new NullWrapper("java.lang.String");
83              }
84  
85              Object paramObj1 = new LongWrapper(classPK);
86  
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  
95              Object paramObj4 = new BooleanWrapper(primary);
96  
97              MethodWrapper methodWrapper = new MethodWrapper(WebsiteServiceUtil.class.getName(),
98                      "addWebsite",
99                      new Object[] {
100                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
101                     });
102 
103             Object returnObj = null;
104 
105             try {
106                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
107             }
108             catch (Exception e) {
109                 if (e instanceof com.liferay.portal.PortalException) {
110                     throw (com.liferay.portal.PortalException)e;
111                 }
112 
113                 if (e instanceof com.liferay.portal.SystemException) {
114                     throw (com.liferay.portal.SystemException)e;
115                 }
116 
117                 throw new com.liferay.portal.SystemException(e);
118             }
119 
120             return (com.liferay.portal.model.Website)returnObj;
121         }
122         catch (com.liferay.portal.SystemException se) {
123             _log.error(se, se);
124 
125             throw se;
126         }
127     }
128 
129     public static void deleteWebsite(HttpPrincipal httpPrincipal, long websiteId)
130         throws com.liferay.portal.PortalException,
131             com.liferay.portal.SystemException {
132         try {
133             Object paramObj0 = new LongWrapper(websiteId);
134 
135             MethodWrapper methodWrapper = new MethodWrapper(WebsiteServiceUtil.class.getName(),
136                     "deleteWebsite", new Object[] { paramObj0 });
137 
138             try {
139                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
140             }
141             catch (Exception e) {
142                 if (e instanceof com.liferay.portal.PortalException) {
143                     throw (com.liferay.portal.PortalException)e;
144                 }
145 
146                 if (e instanceof com.liferay.portal.SystemException) {
147                     throw (com.liferay.portal.SystemException)e;
148                 }
149 
150                 throw new com.liferay.portal.SystemException(e);
151             }
152         }
153         catch (com.liferay.portal.SystemException se) {
154             _log.error(se, se);
155 
156             throw se;
157         }
158     }
159 
160     public static com.liferay.portal.model.Website getWebsite(
161         HttpPrincipal httpPrincipal, long websiteId)
162         throws com.liferay.portal.PortalException,
163             com.liferay.portal.SystemException {
164         try {
165             Object paramObj0 = new LongWrapper(websiteId);
166 
167             MethodWrapper methodWrapper = new MethodWrapper(WebsiteServiceUtil.class.getName(),
168                     "getWebsite", new Object[] { paramObj0 });
169 
170             Object returnObj = null;
171 
172             try {
173                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
174             }
175             catch (Exception e) {
176                 if (e instanceof com.liferay.portal.PortalException) {
177                     throw (com.liferay.portal.PortalException)e;
178                 }
179 
180                 if (e instanceof com.liferay.portal.SystemException) {
181                     throw (com.liferay.portal.SystemException)e;
182                 }
183 
184                 throw new com.liferay.portal.SystemException(e);
185             }
186 
187             return (com.liferay.portal.model.Website)returnObj;
188         }
189         catch (com.liferay.portal.SystemException se) {
190             _log.error(se, se);
191 
192             throw se;
193         }
194     }
195 
196     public static java.util.List<com.liferay.portal.model.Website> getWebsites(
197         HttpPrincipal httpPrincipal, java.lang.String className, long classPK)
198         throws com.liferay.portal.PortalException,
199             com.liferay.portal.SystemException {
200         try {
201             Object paramObj0 = className;
202 
203             if (className == null) {
204                 paramObj0 = new NullWrapper("java.lang.String");
205             }
206 
207             Object paramObj1 = new LongWrapper(classPK);
208 
209             MethodWrapper methodWrapper = new MethodWrapper(WebsiteServiceUtil.class.getName(),
210                     "getWebsites", new Object[] { paramObj0, paramObj1 });
211 
212             Object returnObj = null;
213 
214             try {
215                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
216             }
217             catch (Exception e) {
218                 if (e instanceof com.liferay.portal.PortalException) {
219                     throw (com.liferay.portal.PortalException)e;
220                 }
221 
222                 if (e instanceof com.liferay.portal.SystemException) {
223                     throw (com.liferay.portal.SystemException)e;
224                 }
225 
226                 throw new com.liferay.portal.SystemException(e);
227             }
228 
229             return (java.util.List<com.liferay.portal.model.Website>)returnObj;
230         }
231         catch (com.liferay.portal.SystemException se) {
232             _log.error(se, se);
233 
234             throw se;
235         }
236     }
237 
238     public static com.liferay.portal.model.Website updateWebsite(
239         HttpPrincipal httpPrincipal, long websiteId, java.lang.String url,
240         int typeId, boolean primary)
241         throws com.liferay.portal.PortalException,
242             com.liferay.portal.SystemException {
243         try {
244             Object paramObj0 = new LongWrapper(websiteId);
245 
246             Object paramObj1 = url;
247 
248             if (url == null) {
249                 paramObj1 = new NullWrapper("java.lang.String");
250             }
251 
252             Object paramObj2 = new IntegerWrapper(typeId);
253 
254             Object paramObj3 = new BooleanWrapper(primary);
255 
256             MethodWrapper methodWrapper = new MethodWrapper(WebsiteServiceUtil.class.getName(),
257                     "updateWebsite",
258                     new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
259 
260             Object returnObj = null;
261 
262             try {
263                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
264             }
265             catch (Exception e) {
266                 if (e instanceof com.liferay.portal.PortalException) {
267                     throw (com.liferay.portal.PortalException)e;
268                 }
269 
270                 if (e instanceof com.liferay.portal.SystemException) {
271                     throw (com.liferay.portal.SystemException)e;
272                 }
273 
274                 throw new com.liferay.portal.SystemException(e);
275             }
276 
277             return (com.liferay.portal.model.Website)returnObj;
278         }
279         catch (com.liferay.portal.SystemException se) {
280             _log.error(se, se);
281 
282             throw se;
283         }
284     }
285 
286     private static Log _log = LogFactoryUtil.getLog(WebsiteServiceHttp.class);
287 }