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.MethodHandler;
020    import com.liferay.portal.kernel.util.MethodKey;
021    import com.liferay.portal.security.auth.HttpPrincipal;
022    import com.liferay.portal.service.ResourceServiceUtil;
023    
024    /**
025     * <p>
026     * This class provides a HTTP utility for the
027     * {@link com.liferay.portal.service.ResourceServiceUtil} service utility. The
028     * static methods of this class calls the same methods of the service utility.
029     * However, the signatures are different because it requires an additional
030     * {@link com.liferay.portal.security.auth.HttpPrincipal} parameter.
031     * </p>
032     *
033     * <p>
034     * The benefits of using the HTTP utility is that it is fast and allows for
035     * tunneling without the cost of serializing to text. The drawback is that it
036     * only works with Java.
037     * </p>
038     *
039     * <p>
040     * Set the property <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
041     * configure security.
042     * </p>
043     *
044     * <p>
045     * The HTTP utility is only generated for remote services.
046     * </p>
047     *
048     * @author    Brian Wing Shun Chan
049     * @see       ResourceServiceSoap
050     * @see       com.liferay.portal.security.auth.HttpPrincipal
051     * @see       com.liferay.portal.service.ResourceServiceUtil
052     * @generated
053     */
054    public class ResourceServiceHttp {
055            public static com.liferay.portal.model.Resource getResource(
056                    HttpPrincipal httpPrincipal, long companyId, java.lang.String name,
057                    int scope, java.lang.String primKey)
058                    throws com.liferay.portal.kernel.exception.PortalException,
059                            com.liferay.portal.kernel.exception.SystemException {
060                    try {
061                            MethodKey methodKey = new MethodKey(ResourceServiceUtil.class.getName(),
062                                            "getResource", long.class, java.lang.String.class,
063                                            int.class, java.lang.String.class);
064    
065                            MethodHandler methodHandler = new MethodHandler(methodKey,
066                                            companyId, name, scope, primKey);
067    
068                            Object returnObj = null;
069    
070                            try {
071                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodHandler);
072                            }
073                            catch (Exception e) {
074                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
075                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
076                                    }
077    
078                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
079                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
080                                    }
081    
082                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
083                            }
084    
085                            return (com.liferay.portal.model.Resource)returnObj;
086                    }
087                    catch (com.liferay.portal.kernel.exception.SystemException se) {
088                            _log.error(se, se);
089    
090                            throw se;
091                    }
092            }
093    
094            private static Log _log = LogFactoryUtil.getLog(ResourceServiceHttp.class);
095    }