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.ratings.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.DoubleWrapper;
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.ratings.service.RatingsEntryServiceUtil;
027    
028    /**
029     * <p>
030     * This class provides a HTTP utility for the
031     * {@link com.liferay.portlet.ratings.service.RatingsEntryServiceUtil} 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       RatingsEntryServiceSoap
054     * @see       com.liferay.portal.security.auth.HttpPrincipal
055     * @see       com.liferay.portlet.ratings.service.RatingsEntryServiceUtil
056     * @generated
057     */
058    public class RatingsEntryServiceHttp {
059            public static void deleteEntry(HttpPrincipal httpPrincipal,
060                    java.lang.String className, long classPK)
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                            MethodWrapper methodWrapper = new MethodWrapper(RatingsEntryServiceUtil.class.getName(),
073                                            "deleteEntry", new Object[] { paramObj0, paramObj1 });
074    
075                            try {
076                                    TunnelUtil.invoke(httpPrincipal, methodWrapper);
077                            }
078                            catch (Exception e) {
079                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
080                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
081                                    }
082    
083                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
084                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
085                                    }
086    
087                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
088                            }
089                    }
090                    catch (com.liferay.portal.kernel.exception.SystemException se) {
091                            _log.error(se, se);
092    
093                            throw se;
094                    }
095            }
096    
097            public static com.liferay.portlet.ratings.model.RatingsEntry updateEntry(
098                    HttpPrincipal httpPrincipal, java.lang.String className, long classPK,
099                    double score)
100                    throws com.liferay.portal.kernel.exception.PortalException,
101                            com.liferay.portal.kernel.exception.SystemException {
102                    try {
103                            Object paramObj0 = className;
104    
105                            if (className == null) {
106                                    paramObj0 = new NullWrapper("java.lang.String");
107                            }
108    
109                            Object paramObj1 = new LongWrapper(classPK);
110    
111                            Object paramObj2 = new DoubleWrapper(score);
112    
113                            MethodWrapper methodWrapper = new MethodWrapper(RatingsEntryServiceUtil.class.getName(),
114                                            "updateEntry",
115                                            new Object[] { paramObj0, paramObj1, paramObj2 });
116    
117                            Object returnObj = null;
118    
119                            try {
120                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
121                            }
122                            catch (Exception e) {
123                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
124                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
125                                    }
126    
127                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
128                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
129                                    }
130    
131                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
132                            }
133    
134                            return (com.liferay.portlet.ratings.model.RatingsEntry)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(RatingsEntryServiceHttp.class);
144    }