1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.service.http;
16  
17  import com.liferay.portal.kernel.log.Log;
18  import com.liferay.portal.kernel.log.LogFactoryUtil;
19  import com.liferay.portal.kernel.util.LongWrapper;
20  import com.liferay.portal.kernel.util.MethodWrapper;
21  import com.liferay.portal.kernel.util.NullWrapper;
22  import com.liferay.portal.security.auth.HttpPrincipal;
23  import com.liferay.portal.service.PortletPreferencesServiceUtil;
24  
25  /**
26   * <a href="PortletPreferencesServiceHttp.java.html"><b><i>View Source</i></b></a>
27   *
28   * <p>
29   * ServiceBuilder generated this class. Modifications in this class will be
30   * overwritten the next time is generated.
31   * </p>
32   *
33   * <p>
34   * This class provides a HTTP utility for the
35   * {@link com.liferay.portal.service.PortletPreferencesServiceUtil} service utility. The
36   * static methods of this class calls the same methods of the service utility.
37   * However, the signatures are different because it requires an additional
38   * {@link com.liferay.portal.security.auth.HttpPrincipal} parameter.
39   * </p>
40   *
41   * <p>
42   * The benefits of using the HTTP utility is that it is fast and allows for
43   * tunneling without the cost of serializing to text. The drawback is that it
44   * only works with Java.
45   * </p>
46   *
47   * <p>
48   * Set the property <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
49   * configure security.
50   * </p>
51   *
52   * <p>
53   * The HTTP utility is only generated for remote services.
54   * </p>
55   *
56   * @author    Brian Wing Shun Chan
57   * @see       PortletPreferencesServiceSoap
58   * @see       com.liferay.portal.security.auth.HttpPrincipal
59   * @see       com.liferay.portal.service.PortletPreferencesServiceUtil
60   * @generated
61   */
62  public class PortletPreferencesServiceHttp {
63      public static void deleteArchivedPreferences(HttpPrincipal httpPrincipal,
64          long portletItemId)
65          throws com.liferay.portal.kernel.exception.PortalException,
66              com.liferay.portal.kernel.exception.SystemException {
67          try {
68              Object paramObj0 = new LongWrapper(portletItemId);
69  
70              MethodWrapper methodWrapper = new MethodWrapper(PortletPreferencesServiceUtil.class.getName(),
71                      "deleteArchivedPreferences", new Object[] { paramObj0 });
72  
73              try {
74                  TunnelUtil.invoke(httpPrincipal, methodWrapper);
75              }
76              catch (Exception e) {
77                  if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
78                      throw (com.liferay.portal.kernel.exception.PortalException)e;
79                  }
80  
81                  if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
82                      throw (com.liferay.portal.kernel.exception.SystemException)e;
83                  }
84  
85                  throw new com.liferay.portal.kernel.exception.SystemException(e);
86              }
87          }
88          catch (com.liferay.portal.kernel.exception.SystemException se) {
89              _log.error(se, se);
90  
91              throw se;
92          }
93      }
94  
95      public static void restoreArchivedPreferences(HttpPrincipal httpPrincipal,
96          long groupId, java.lang.String name, java.lang.String portletId,
97          javax.portlet.PortletPreferences preferences)
98          throws com.liferay.portal.kernel.exception.PortalException,
99              com.liferay.portal.kernel.exception.SystemException {
100         try {
101             Object paramObj0 = new LongWrapper(groupId);
102 
103             Object paramObj1 = name;
104 
105             if (name == null) {
106                 paramObj1 = new NullWrapper("java.lang.String");
107             }
108 
109             Object paramObj2 = portletId;
110 
111             if (portletId == null) {
112                 paramObj2 = new NullWrapper("java.lang.String");
113             }
114 
115             Object paramObj3 = preferences;
116 
117             if (preferences == null) {
118                 paramObj3 = new NullWrapper("javax.portlet.PortletPreferences");
119             }
120 
121             MethodWrapper methodWrapper = new MethodWrapper(PortletPreferencesServiceUtil.class.getName(),
122                     "restoreArchivedPreferences",
123                     new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
124 
125             try {
126                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
127             }
128             catch (Exception e) {
129                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
130                     throw (com.liferay.portal.kernel.exception.PortalException)e;
131                 }
132 
133                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
134                     throw (com.liferay.portal.kernel.exception.SystemException)e;
135                 }
136 
137                 throw new com.liferay.portal.kernel.exception.SystemException(e);
138             }
139         }
140         catch (com.liferay.portal.kernel.exception.SystemException se) {
141             _log.error(se, se);
142 
143             throw se;
144         }
145     }
146 
147     public static void updateArchivePreferences(HttpPrincipal httpPrincipal,
148         long userId, long groupId, java.lang.String name,
149         java.lang.String portletId, javax.portlet.PortletPreferences preferences)
150         throws com.liferay.portal.kernel.exception.PortalException,
151             com.liferay.portal.kernel.exception.SystemException {
152         try {
153             Object paramObj0 = new LongWrapper(userId);
154 
155             Object paramObj1 = new LongWrapper(groupId);
156 
157             Object paramObj2 = name;
158 
159             if (name == null) {
160                 paramObj2 = new NullWrapper("java.lang.String");
161             }
162 
163             Object paramObj3 = portletId;
164 
165             if (portletId == null) {
166                 paramObj3 = new NullWrapper("java.lang.String");
167             }
168 
169             Object paramObj4 = preferences;
170 
171             if (preferences == null) {
172                 paramObj4 = new NullWrapper("javax.portlet.PortletPreferences");
173             }
174 
175             MethodWrapper methodWrapper = new MethodWrapper(PortletPreferencesServiceUtil.class.getName(),
176                     "updateArchivePreferences",
177                     new Object[] {
178                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
179                     });
180 
181             try {
182                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
183             }
184             catch (Exception e) {
185                 if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
186                     throw (com.liferay.portal.kernel.exception.PortalException)e;
187                 }
188 
189                 if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
190                     throw (com.liferay.portal.kernel.exception.SystemException)e;
191                 }
192 
193                 throw new com.liferay.portal.kernel.exception.SystemException(e);
194             }
195         }
196         catch (com.liferay.portal.kernel.exception.SystemException se) {
197             _log.error(se, se);
198 
199             throw se;
200         }
201     }
202 
203     private static Log _log = LogFactoryUtil.getLog(PortletPreferencesServiceHttp.class);
204 }