001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.http;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogFactoryUtil;
019    import com.liferay.portal.kernel.util.BooleanWrapper;
020    import com.liferay.portal.kernel.util.IntegerWrapper;
021    import com.liferay.portal.kernel.util.LongWrapper;
022    import com.liferay.portal.kernel.util.MethodWrapper;
023    import com.liferay.portal.kernel.util.NullWrapper;
024    import com.liferay.portal.security.auth.HttpPrincipal;
025    import com.liferay.portal.service.WebsiteServiceUtil;
026    
027    /**
028     * <p>
029     * This class provides a HTTP utility for the
030     * {@link com.liferay.portal.service.WebsiteServiceUtil} service utility. The
031     * static methods of this class calls the same methods of the service utility.
032     * However, the signatures are different because it requires an additional
033     * {@link com.liferay.portal.security.auth.HttpPrincipal} parameter.
034     * </p>
035     *
036     * <p>
037     * The benefits of using the HTTP utility is that it is fast and allows for
038     * tunneling without the cost of serializing to text. The drawback is that it
039     * only works with Java.
040     * </p>
041     *
042     * <p>
043     * Set the property <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
044     * configure security.
045     * </p>
046     *
047     * <p>
048     * The HTTP utility is only generated for remote services.
049     * </p>
050     *
051     * @author    Brian Wing Shun Chan
052     * @see       WebsiteServiceSoap
053     * @see       com.liferay.portal.security.auth.HttpPrincipal
054     * @see       com.liferay.portal.service.WebsiteServiceUtil
055     * @generated
056     */
057    public class WebsiteServiceHttp {
058            public static com.liferay.portal.model.Website addWebsite(
059                    HttpPrincipal httpPrincipal, java.lang.String className, long classPK,
060                    java.lang.String url, int typeId, boolean primary)
061                    throws com.liferay.portal.kernel.exception.PortalException,
062                            com.liferay.portal.kernel.exception.SystemException {
063                    try {
064                            Object paramObj0 = className;
065    
066                            if (className == null) {
067                                    paramObj0 = new NullWrapper("java.lang.String");
068                            }
069    
070                            Object paramObj1 = new LongWrapper(classPK);
071    
072                            Object paramObj2 = url;
073    
074                            if (url == null) {
075                                    paramObj2 = new NullWrapper("java.lang.String");
076                            }
077    
078                            Object paramObj3 = new IntegerWrapper(typeId);
079    
080                            Object paramObj4 = new BooleanWrapper(primary);
081    
082                            MethodWrapper methodWrapper = new MethodWrapper(WebsiteServiceUtil.class.getName(),
083                                            "addWebsite",
084                                            new Object[] {
085                                                    paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
086                                            });
087    
088                            Object returnObj = null;
089    
090                            try {
091                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
092                            }
093                            catch (Exception e) {
094                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
095                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
096                                    }
097    
098                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
099                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
100                                    }
101    
102                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
103                            }
104    
105                            return (com.liferay.portal.model.Website)returnObj;
106                    }
107                    catch (com.liferay.portal.kernel.exception.SystemException se) {
108                            _log.error(se, se);
109    
110                            throw se;
111                    }
112            }
113    
114            public static void deleteWebsite(HttpPrincipal httpPrincipal, long websiteId)
115                    throws com.liferay.portal.kernel.exception.PortalException,
116                            com.liferay.portal.kernel.exception.SystemException {
117                    try {
118                            Object paramObj0 = new LongWrapper(websiteId);
119    
120                            MethodWrapper methodWrapper = new MethodWrapper(WebsiteServiceUtil.class.getName(),
121                                            "deleteWebsite", new Object[] { paramObj0 });
122    
123                            try {
124                                    TunnelUtil.invoke(httpPrincipal, methodWrapper);
125                            }
126                            catch (Exception e) {
127                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
128                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
129                                    }
130    
131                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
132                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
133                                    }
134    
135                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
136                            }
137                    }
138                    catch (com.liferay.portal.kernel.exception.SystemException se) {
139                            _log.error(se, se);
140    
141                            throw se;
142                    }
143            }
144    
145            public static com.liferay.portal.model.Website getWebsite(
146                    HttpPrincipal httpPrincipal, long websiteId)
147                    throws com.liferay.portal.kernel.exception.PortalException,
148                            com.liferay.portal.kernel.exception.SystemException {
149                    try {
150                            Object paramObj0 = new LongWrapper(websiteId);
151    
152                            MethodWrapper methodWrapper = new MethodWrapper(WebsiteServiceUtil.class.getName(),
153                                            "getWebsite", new Object[] { paramObj0 });
154    
155                            Object returnObj = null;
156    
157                            try {
158                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
159                            }
160                            catch (Exception e) {
161                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
162                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
163                                    }
164    
165                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
166                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
167                                    }
168    
169                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
170                            }
171    
172                            return (com.liferay.portal.model.Website)returnObj;
173                    }
174                    catch (com.liferay.portal.kernel.exception.SystemException se) {
175                            _log.error(se, se);
176    
177                            throw se;
178                    }
179            }
180    
181            public static java.util.List<com.liferay.portal.model.Website> getWebsites(
182                    HttpPrincipal httpPrincipal, java.lang.String className, long classPK)
183                    throws com.liferay.portal.kernel.exception.PortalException,
184                            com.liferay.portal.kernel.exception.SystemException {
185                    try {
186                            Object paramObj0 = className;
187    
188                            if (className == null) {
189                                    paramObj0 = new NullWrapper("java.lang.String");
190                            }
191    
192                            Object paramObj1 = new LongWrapper(classPK);
193    
194                            MethodWrapper methodWrapper = new MethodWrapper(WebsiteServiceUtil.class.getName(),
195                                            "getWebsites", new Object[] { paramObj0, paramObj1 });
196    
197                            Object returnObj = null;
198    
199                            try {
200                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
201                            }
202                            catch (Exception e) {
203                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
204                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
205                                    }
206    
207                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
208                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
209                                    }
210    
211                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
212                            }
213    
214                            return (java.util.List<com.liferay.portal.model.Website>)returnObj;
215                    }
216                    catch (com.liferay.portal.kernel.exception.SystemException se) {
217                            _log.error(se, se);
218    
219                            throw se;
220                    }
221            }
222    
223            public static com.liferay.portal.model.Website updateWebsite(
224                    HttpPrincipal httpPrincipal, long websiteId, java.lang.String url,
225                    int typeId, boolean primary)
226                    throws com.liferay.portal.kernel.exception.PortalException,
227                            com.liferay.portal.kernel.exception.SystemException {
228                    try {
229                            Object paramObj0 = new LongWrapper(websiteId);
230    
231                            Object paramObj1 = url;
232    
233                            if (url == null) {
234                                    paramObj1 = new NullWrapper("java.lang.String");
235                            }
236    
237                            Object paramObj2 = new IntegerWrapper(typeId);
238    
239                            Object paramObj3 = new BooleanWrapper(primary);
240    
241                            MethodWrapper methodWrapper = new MethodWrapper(WebsiteServiceUtil.class.getName(),
242                                            "updateWebsite",
243                                            new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
244    
245                            Object returnObj = null;
246    
247                            try {
248                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
249                            }
250                            catch (Exception e) {
251                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
252                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
253                                    }
254    
255                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
256                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
257                                    }
258    
259                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
260                            }
261    
262                            return (com.liferay.portal.model.Website)returnObj;
263                    }
264                    catch (com.liferay.portal.kernel.exception.SystemException se) {
265                            _log.error(se, se);
266    
267                            throw se;
268                    }
269            }
270    
271            private static Log _log = LogFactoryUtil.getLog(WebsiteServiceHttp.class);
272    }