1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.service.http;
24  
25  import com.liferay.portal.kernel.log.Log;
26  import com.liferay.portal.kernel.log.LogFactoryUtil;
27  import com.liferay.portal.kernel.util.LongWrapper;
28  import com.liferay.portal.kernel.util.MethodWrapper;
29  import com.liferay.portal.kernel.util.NullWrapper;
30  import com.liferay.portal.security.auth.HttpPrincipal;
31  import com.liferay.portal.service.PortletPreferencesServiceUtil;
32  
33  /**
34   * <a href="PortletPreferencesServiceHttp.java.html"><b><i>View Source</i></b></a>
35   *
36   * <p>
37   * ServiceBuilder generated this class. Modifications in this class will be
38   * overwritten the next time is generated.
39   * </p>
40   *
41   * <p>
42   * This class provides a HTTP utility for the
43   * {@link com.liferay.portal.service.PortletPreferencesServiceUtil} service utility. The
44   * static methods of this class calls the same methods of the service utility.
45   * However, the signatures are different because it requires an additional
46   * {@link com.liferay.portal.security.auth.HttpPrincipal} parameter.
47   * </p>
48   *
49   * <p>
50   * The benefits of using the HTTP utility is that it is fast and allows for
51   * tunneling without the cost of serializing to text. The drawback is that it
52   * only works with Java.
53   * </p>
54   *
55   * <p>
56   * Set the property <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
57   * configure security.
58   * </p>
59   *
60   * <p>
61   * The HTTP utility is only generated for remote services.
62   * </p>
63   *
64   * @author    Brian Wing Shun Chan
65   * @see       PortletPreferencesServiceSoap
66   * @see       com.liferay.portal.security.auth.HttpPrincipal
67   * @see       com.liferay.portal.service.PortletPreferencesServiceUtil
68   * @generated
69   */
70  public class PortletPreferencesServiceHttp {
71      public static void deleteArchivedPreferences(HttpPrincipal httpPrincipal,
72          long portletItemId)
73          throws com.liferay.portal.PortalException,
74              com.liferay.portal.SystemException {
75          try {
76              Object paramObj0 = new LongWrapper(portletItemId);
77  
78              MethodWrapper methodWrapper = new MethodWrapper(PortletPreferencesServiceUtil.class.getName(),
79                      "deleteArchivedPreferences", new Object[] { paramObj0 });
80  
81              try {
82                  TunnelUtil.invoke(httpPrincipal, methodWrapper);
83              }
84              catch (Exception e) {
85                  if (e instanceof com.liferay.portal.PortalException) {
86                      throw (com.liferay.portal.PortalException)e;
87                  }
88  
89                  if (e instanceof com.liferay.portal.SystemException) {
90                      throw (com.liferay.portal.SystemException)e;
91                  }
92  
93                  throw new com.liferay.portal.SystemException(e);
94              }
95          }
96          catch (com.liferay.portal.SystemException se) {
97              _log.error(se, se);
98  
99              throw se;
100         }
101     }
102 
103     public static void restoreArchivedPreferences(HttpPrincipal httpPrincipal,
104         long groupId, java.lang.String name, java.lang.String portletId,
105         javax.portlet.PortletPreferences prefs)
106         throws com.liferay.portal.PortalException,
107             com.liferay.portal.SystemException {
108         try {
109             Object paramObj0 = new LongWrapper(groupId);
110 
111             Object paramObj1 = name;
112 
113             if (name == null) {
114                 paramObj1 = new NullWrapper("java.lang.String");
115             }
116 
117             Object paramObj2 = portletId;
118 
119             if (portletId == null) {
120                 paramObj2 = new NullWrapper("java.lang.String");
121             }
122 
123             Object paramObj3 = prefs;
124 
125             if (prefs == null) {
126                 paramObj3 = new NullWrapper("javax.portlet.PortletPreferences");
127             }
128 
129             MethodWrapper methodWrapper = new MethodWrapper(PortletPreferencesServiceUtil.class.getName(),
130                     "restoreArchivedPreferences",
131                     new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
132 
133             try {
134                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
135             }
136             catch (Exception e) {
137                 if (e instanceof com.liferay.portal.PortalException) {
138                     throw (com.liferay.portal.PortalException)e;
139                 }
140 
141                 if (e instanceof com.liferay.portal.SystemException) {
142                     throw (com.liferay.portal.SystemException)e;
143                 }
144 
145                 throw new com.liferay.portal.SystemException(e);
146             }
147         }
148         catch (com.liferay.portal.SystemException se) {
149             _log.error(se, se);
150 
151             throw se;
152         }
153     }
154 
155     public static void updateArchivePreferences(HttpPrincipal httpPrincipal,
156         long userId, long groupId, java.lang.String name,
157         java.lang.String portletId, javax.portlet.PortletPreferences prefs)
158         throws com.liferay.portal.PortalException,
159             com.liferay.portal.SystemException {
160         try {
161             Object paramObj0 = new LongWrapper(userId);
162 
163             Object paramObj1 = new LongWrapper(groupId);
164 
165             Object paramObj2 = name;
166 
167             if (name == null) {
168                 paramObj2 = new NullWrapper("java.lang.String");
169             }
170 
171             Object paramObj3 = portletId;
172 
173             if (portletId == null) {
174                 paramObj3 = new NullWrapper("java.lang.String");
175             }
176 
177             Object paramObj4 = prefs;
178 
179             if (prefs == null) {
180                 paramObj4 = new NullWrapper("javax.portlet.PortletPreferences");
181             }
182 
183             MethodWrapper methodWrapper = new MethodWrapper(PortletPreferencesServiceUtil.class.getName(),
184                     "updateArchivePreferences",
185                     new Object[] {
186                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
187                     });
188 
189             try {
190                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
191             }
192             catch (Exception e) {
193                 if (e instanceof com.liferay.portal.PortalException) {
194                     throw (com.liferay.portal.PortalException)e;
195                 }
196 
197                 if (e instanceof com.liferay.portal.SystemException) {
198                     throw (com.liferay.portal.SystemException)e;
199                 }
200 
201                 throw new com.liferay.portal.SystemException(e);
202             }
203         }
204         catch (com.liferay.portal.SystemException se) {
205             _log.error(se, se);
206 
207             throw se;
208         }
209     }
210 
211     private static Log _log = LogFactoryUtil.getLog(PortletPreferencesServiceHttp.class);
212 }