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.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.PortletServiceUtil;
025    
026    /**
027     * <p>
028     * This class provides a HTTP utility for the
029     * {@link com.liferay.portal.service.PortletServiceUtil} 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       PortletServiceSoap
052     * @see       com.liferay.portal.security.auth.HttpPrincipal
053     * @see       com.liferay.portal.service.PortletServiceUtil
054     * @generated
055     */
056    public class PortletServiceHttp {
057            public static com.liferay.portal.kernel.json.JSONArray getWARPortlets(
058                    HttpPrincipal httpPrincipal)
059                    throws com.liferay.portal.kernel.exception.SystemException {
060                    try {
061                            MethodWrapper methodWrapper = new MethodWrapper(PortletServiceUtil.class.getName(),
062                                            "getWARPortlets", new Object[0]);
063    
064                            Object returnObj = null;
065    
066                            try {
067                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
068                            }
069                            catch (Exception e) {
070                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
071                            }
072    
073                            return (com.liferay.portal.kernel.json.JSONArray)returnObj;
074                    }
075                    catch (com.liferay.portal.kernel.exception.SystemException se) {
076                            _log.error(se, se);
077    
078                            throw se;
079                    }
080            }
081    
082            public static com.liferay.portal.model.Portlet updatePortlet(
083                    HttpPrincipal httpPrincipal, long companyId,
084                    java.lang.String portletId, java.lang.String roles, boolean active)
085                    throws com.liferay.portal.kernel.exception.PortalException,
086                            com.liferay.portal.kernel.exception.SystemException {
087                    try {
088                            Object paramObj0 = new LongWrapper(companyId);
089    
090                            Object paramObj1 = portletId;
091    
092                            if (portletId == null) {
093                                    paramObj1 = new NullWrapper("java.lang.String");
094                            }
095    
096                            Object paramObj2 = roles;
097    
098                            if (roles == null) {
099                                    paramObj2 = new NullWrapper("java.lang.String");
100                            }
101    
102                            Object paramObj3 = new BooleanWrapper(active);
103    
104                            MethodWrapper methodWrapper = new MethodWrapper(PortletServiceUtil.class.getName(),
105                                            "updatePortlet",
106                                            new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
107    
108                            Object returnObj = null;
109    
110                            try {
111                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
112                            }
113                            catch (Exception e) {
114                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
115                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
116                                    }
117    
118                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
119                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
120                                    }
121    
122                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
123                            }
124    
125                            return (com.liferay.portal.model.Portlet)returnObj;
126                    }
127                    catch (com.liferay.portal.kernel.exception.SystemException se) {
128                            _log.error(se, se);
129    
130                            throw se;
131                    }
132            }
133    
134            private static Log _log = LogFactoryUtil.getLog(PortletServiceHttp.class);
135    }