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.LongWrapper;
020    import com.liferay.portal.kernel.util.MethodWrapper;
021    import com.liferay.portal.kernel.util.NullWrapper;
022    import com.liferay.portal.security.auth.HttpPrincipal;
023    import com.liferay.portal.service.PortletPreferencesServiceUtil;
024    
025    /**
026     * <p>
027     * This class provides a HTTP utility for the
028     * {@link com.liferay.portal.service.PortletPreferencesServiceUtil} service utility. The
029     * static methods of this class calls the same methods of the service utility.
030     * However, the signatures are different because it requires an additional
031     * {@link com.liferay.portal.security.auth.HttpPrincipal} parameter.
032     * </p>
033     *
034     * <p>
035     * The benefits of using the HTTP utility is that it is fast and allows for
036     * tunneling without the cost of serializing to text. The drawback is that it
037     * only works with Java.
038     * </p>
039     *
040     * <p>
041     * Set the property <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
042     * configure security.
043     * </p>
044     *
045     * <p>
046     * The HTTP utility is only generated for remote services.
047     * </p>
048     *
049     * @author    Brian Wing Shun Chan
050     * @see       PortletPreferencesServiceSoap
051     * @see       com.liferay.portal.security.auth.HttpPrincipal
052     * @see       com.liferay.portal.service.PortletPreferencesServiceUtil
053     * @generated
054     */
055    public class PortletPreferencesServiceHttp {
056            public static void deleteArchivedPreferences(HttpPrincipal httpPrincipal,
057                    long portletItemId)
058                    throws com.liferay.portal.kernel.exception.PortalException,
059                            com.liferay.portal.kernel.exception.SystemException {
060                    try {
061                            Object paramObj0 = new LongWrapper(portletItemId);
062    
063                            MethodWrapper methodWrapper = new MethodWrapper(PortletPreferencesServiceUtil.class.getName(),
064                                            "deleteArchivedPreferences", new Object[] { paramObj0 });
065    
066                            try {
067                                    TunnelUtil.invoke(httpPrincipal, methodWrapper);
068                            }
069                            catch (Exception e) {
070                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
071                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
072                                    }
073    
074                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
075                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
076                                    }
077    
078                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
079                            }
080                    }
081                    catch (com.liferay.portal.kernel.exception.SystemException se) {
082                            _log.error(se, se);
083    
084                            throw se;
085                    }
086            }
087    
088            public static void restoreArchivedPreferences(HttpPrincipal httpPrincipal,
089                    long groupId, java.lang.String name, java.lang.String portletId,
090                    javax.portlet.PortletPreferences preferences)
091                    throws com.liferay.portal.kernel.exception.PortalException,
092                            com.liferay.portal.kernel.exception.SystemException {
093                    try {
094                            Object paramObj0 = new LongWrapper(groupId);
095    
096                            Object paramObj1 = name;
097    
098                            if (name == null) {
099                                    paramObj1 = new NullWrapper("java.lang.String");
100                            }
101    
102                            Object paramObj2 = portletId;
103    
104                            if (portletId == null) {
105                                    paramObj2 = new NullWrapper("java.lang.String");
106                            }
107    
108                            Object paramObj3 = preferences;
109    
110                            if (preferences == null) {
111                                    paramObj3 = new NullWrapper("javax.portlet.PortletPreferences");
112                            }
113    
114                            MethodWrapper methodWrapper = new MethodWrapper(PortletPreferencesServiceUtil.class.getName(),
115                                            "restoreArchivedPreferences",
116                                            new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
117    
118                            try {
119                                    TunnelUtil.invoke(httpPrincipal, methodWrapper);
120                            }
121                            catch (Exception e) {
122                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
123                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
124                                    }
125    
126                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
127                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
128                                    }
129    
130                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
131                            }
132                    }
133                    catch (com.liferay.portal.kernel.exception.SystemException se) {
134                            _log.error(se, se);
135    
136                            throw se;
137                    }
138            }
139    
140            public static void updateArchivePreferences(HttpPrincipal httpPrincipal,
141                    long userId, long groupId, java.lang.String name,
142                    java.lang.String portletId, javax.portlet.PortletPreferences preferences)
143                    throws com.liferay.portal.kernel.exception.PortalException,
144                            com.liferay.portal.kernel.exception.SystemException {
145                    try {
146                            Object paramObj0 = new LongWrapper(userId);
147    
148                            Object paramObj1 = new LongWrapper(groupId);
149    
150                            Object paramObj2 = name;
151    
152                            if (name == null) {
153                                    paramObj2 = new NullWrapper("java.lang.String");
154                            }
155    
156                            Object paramObj3 = portletId;
157    
158                            if (portletId == null) {
159                                    paramObj3 = new NullWrapper("java.lang.String");
160                            }
161    
162                            Object paramObj4 = preferences;
163    
164                            if (preferences == null) {
165                                    paramObj4 = new NullWrapper("javax.portlet.PortletPreferences");
166                            }
167    
168                            MethodWrapper methodWrapper = new MethodWrapper(PortletPreferencesServiceUtil.class.getName(),
169                                            "updateArchivePreferences",
170                                            new Object[] {
171                                                    paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
172                                            });
173    
174                            try {
175                                    TunnelUtil.invoke(httpPrincipal, methodWrapper);
176                            }
177                            catch (Exception e) {
178                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
179                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
180                                    }
181    
182                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
183                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
184                                    }
185    
186                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
187                            }
188                    }
189                    catch (com.liferay.portal.kernel.exception.SystemException se) {
190                            _log.error(se, se);
191    
192                            throw se;
193                    }
194            }
195    
196            private static Log _log = LogFactoryUtil.getLog(PortletPreferencesServiceHttp.class);
197    }