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.IntegerWrapper;
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.ResourceServiceUtil;
025    
026    /**
027     * <p>
028     * This class provides a HTTP utility for the
029     * {@link com.liferay.portal.service.ResourceServiceUtil} service utility. The
030     * static methods of this class calls the same methods of the service utility.
031     * However, the signatures are different because it requires an additional
032     * {@link com.liferay.portal.security.auth.HttpPrincipal} parameter.
033     * </p>
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       ResourceServiceSoap
052     * @see       com.liferay.portal.security.auth.HttpPrincipal
053     * @see       com.liferay.portal.service.ResourceServiceUtil
054     * @generated
055     */
056    public class ResourceServiceHttp {
057            public static com.liferay.portal.model.Resource getResource(
058                    HttpPrincipal httpPrincipal, long companyId, java.lang.String name,
059                    int scope, java.lang.String primKey)
060                    throws com.liferay.portal.kernel.exception.PortalException,
061                            com.liferay.portal.kernel.exception.SystemException {
062                    try {
063                            Object paramObj0 = new LongWrapper(companyId);
064    
065                            Object paramObj1 = name;
066    
067                            if (name == null) {
068                                    paramObj1 = new NullWrapper("java.lang.String");
069                            }
070    
071                            Object paramObj2 = new IntegerWrapper(scope);
072    
073                            Object paramObj3 = primKey;
074    
075                            if (primKey == null) {
076                                    paramObj3 = new NullWrapper("java.lang.String");
077                            }
078    
079                            MethodWrapper methodWrapper = new MethodWrapper(ResourceServiceUtil.class.getName(),
080                                            "getResource",
081                                            new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
082    
083                            Object returnObj = null;
084    
085                            try {
086                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
087                            }
088                            catch (Exception e) {
089                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
090                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
091                                    }
092    
093                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
094                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
095                                    }
096    
097                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
098                            }
099    
100                            return (com.liferay.portal.model.Resource)returnObj;
101                    }
102                    catch (com.liferay.portal.kernel.exception.SystemException se) {
103                            _log.error(se, se);
104    
105                            throw se;
106                    }
107            }
108    
109            private static Log _log = LogFactoryUtil.getLog(ResourceServiceHttp.class);
110    }