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.portlet.announcements.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.LongWrapper;
021    import com.liferay.portal.kernel.util.MethodWrapper;
022    import com.liferay.portal.kernel.util.NullWrapper;
023    import com.liferay.portal.security.auth.HttpPrincipal;
024    import com.liferay.portal.service.http.TunnelUtil;
025    
026    import com.liferay.portlet.announcements.service.AnnouncementsDeliveryServiceUtil;
027    
028    /**
029     * <p>
030     * This class provides a HTTP utility for the
031     * {@link com.liferay.portlet.announcements.service.AnnouncementsDeliveryServiceUtil} service utility. The
032     * static methods of this class calls the same methods of the service utility.
033     * However, the signatures are different because it requires an additional
034     * {@link com.liferay.portal.security.auth.HttpPrincipal} parameter.
035     * </p>
036     *
037     * <p>
038     * The benefits of using the HTTP utility is that it is fast and allows for
039     * tunneling without the cost of serializing to text. The drawback is that it
040     * only works with Java.
041     * </p>
042     *
043     * <p>
044     * Set the property <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
045     * configure security.
046     * </p>
047     *
048     * <p>
049     * The HTTP utility is only generated for remote services.
050     * </p>
051     *
052     * @author    Brian Wing Shun Chan
053     * @see       AnnouncementsDeliveryServiceSoap
054     * @see       com.liferay.portal.security.auth.HttpPrincipal
055     * @see       com.liferay.portlet.announcements.service.AnnouncementsDeliveryServiceUtil
056     * @generated
057     */
058    public class AnnouncementsDeliveryServiceHttp {
059            public static com.liferay.portlet.announcements.model.AnnouncementsDelivery updateDelivery(
060                    HttpPrincipal httpPrincipal, long userId, java.lang.String type,
061                    boolean email, boolean sms, boolean website)
062                    throws com.liferay.portal.kernel.exception.PortalException,
063                            com.liferay.portal.kernel.exception.SystemException {
064                    try {
065                            Object paramObj0 = new LongWrapper(userId);
066    
067                            Object paramObj1 = type;
068    
069                            if (type == null) {
070                                    paramObj1 = new NullWrapper("java.lang.String");
071                            }
072    
073                            Object paramObj2 = new BooleanWrapper(email);
074    
075                            Object paramObj3 = new BooleanWrapper(sms);
076    
077                            Object paramObj4 = new BooleanWrapper(website);
078    
079                            MethodWrapper methodWrapper = new MethodWrapper(AnnouncementsDeliveryServiceUtil.class.getName(),
080                                            "updateDelivery",
081                                            new Object[] {
082                                                    paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
083                                            });
084    
085                            Object returnObj = null;
086    
087                            try {
088                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
089                            }
090                            catch (Exception e) {
091                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
092                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
093                                    }
094    
095                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
096                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
097                                    }
098    
099                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
100                            }
101    
102                            return (com.liferay.portlet.announcements.model.AnnouncementsDelivery)returnObj;
103                    }
104                    catch (com.liferay.portal.kernel.exception.SystemException se) {
105                            _log.error(se, se);
106    
107                            throw se;
108                    }
109            }
110    
111            private static Log _log = LogFactoryUtil.getLog(AnnouncementsDeliveryServiceHttp.class);
112    }