001    /**
002     * Copyright (c) 2000-present 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 aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.log.Log;
020    import com.liferay.portal.kernel.log.LogFactoryUtil;
021    import com.liferay.portal.kernel.util.MethodHandler;
022    import com.liferay.portal.kernel.util.MethodKey;
023    import com.liferay.portal.security.auth.HttpPrincipal;
024    import com.liferay.portal.service.http.TunnelUtil;
025    
026    import com.liferay.portlet.announcements.service.AnnouncementsFlagServiceUtil;
027    
028    /**
029     * Provides the HTTP utility for the
030     * {@link AnnouncementsFlagServiceUtil} 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 HttpPrincipal} parameter.
034     *
035     * <p>
036     * The benefits of using the HTTP utility is that it is fast and allows for
037     * tunneling without the cost of serializing to text. The drawback is that it
038     * only works with Java.
039     * </p>
040     *
041     * <p>
042     * Set the property <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
043     * configure security.
044     * </p>
045     *
046     * <p>
047     * The HTTP utility is only generated for remote services.
048     * </p>
049     *
050     * @author Brian Wing Shun Chan
051     * @see AnnouncementsFlagServiceSoap
052     * @see HttpPrincipal
053     * @see AnnouncementsFlagServiceUtil
054     * @generated
055     */
056    @ProviderType
057    public class AnnouncementsFlagServiceHttp {
058            public static void addFlag(HttpPrincipal httpPrincipal, long entryId,
059                    int value) throws com.liferay.portal.kernel.exception.PortalException {
060                    try {
061                            MethodKey methodKey = new MethodKey(AnnouncementsFlagServiceUtil.class,
062                                            "addFlag", _addFlagParameterTypes0);
063    
064                            MethodHandler methodHandler = new MethodHandler(methodKey, entryId,
065                                            value);
066    
067                            try {
068                                    TunnelUtil.invoke(httpPrincipal, methodHandler);
069                            }
070                            catch (Exception e) {
071                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
072                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
073                                    }
074    
075                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
076                            }
077                    }
078                    catch (com.liferay.portal.kernel.exception.SystemException se) {
079                            _log.error(se, se);
080    
081                            throw se;
082                    }
083            }
084    
085            public static void deleteFlag(HttpPrincipal httpPrincipal, long flagId)
086                    throws com.liferay.portal.kernel.exception.PortalException {
087                    try {
088                            MethodKey methodKey = new MethodKey(AnnouncementsFlagServiceUtil.class,
089                                            "deleteFlag", _deleteFlagParameterTypes1);
090    
091                            MethodHandler methodHandler = new MethodHandler(methodKey, flagId);
092    
093                            try {
094                                    TunnelUtil.invoke(httpPrincipal, methodHandler);
095                            }
096                            catch (Exception e) {
097                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
098                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
099                                    }
100    
101                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
102                            }
103                    }
104                    catch (com.liferay.portal.kernel.exception.SystemException se) {
105                            _log.error(se, se);
106    
107                            throw se;
108                    }
109            }
110    
111            public static com.liferay.portlet.announcements.model.AnnouncementsFlag getFlag(
112                    HttpPrincipal httpPrincipal, long entryId, int value)
113                    throws com.liferay.portal.kernel.exception.PortalException {
114                    try {
115                            MethodKey methodKey = new MethodKey(AnnouncementsFlagServiceUtil.class,
116                                            "getFlag", _getFlagParameterTypes2);
117    
118                            MethodHandler methodHandler = new MethodHandler(methodKey, entryId,
119                                            value);
120    
121                            Object returnObj = null;
122    
123                            try {
124                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodHandler);
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                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
132                            }
133    
134                            return (com.liferay.portlet.announcements.model.AnnouncementsFlag)returnObj;
135                    }
136                    catch (com.liferay.portal.kernel.exception.SystemException se) {
137                            _log.error(se, se);
138    
139                            throw se;
140                    }
141            }
142    
143            private static Log _log = LogFactoryUtil.getLog(AnnouncementsFlagServiceHttp.class);
144            private static final Class<?>[] _addFlagParameterTypes0 = new Class[] {
145                            long.class, int.class
146                    };
147            private static final Class<?>[] _deleteFlagParameterTypes1 = new Class[] {
148                            long.class
149                    };
150            private static final Class<?>[] _getFlagParameterTypes2 = new Class[] {
151                            long.class, int.class
152                    };
153    }