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   * <code>com.liferay.portal.service.PortletPreferencesServiceUtil</code> service
44   * utility. The static methods of this class calls the same methods of the
45   * service utility. However, the signatures are different because it requires an
46   * additional <code>com.liferay.portal.security.auth.HttpPrincipal</code>
47   * parameter.
48   * </p>
49   *
50   * <p>
51   * The benefits of using the HTTP utility is that it is fast and allows for
52   * tunneling without the cost of serializing to text. The drawback is that it
53   * only works with Java.
54   * </p>
55   *
56   * <p>
57   * Set the property <code>tunnel.servlet.hosts.allowed</code> in
58   * portal.properties to configure security.
59   * </p>
60   *
61   * <p>
62   * The HTTP utility is only generated for remote services.
63   * </p>
64   *
65   * @author Brian Wing Shun Chan
66   *
67   * @see com.liferay.portal.security.auth.HttpPrincipal
68   * @see com.liferay.portal.service.PortletPreferencesServiceUtil
69   * @see com.liferay.portal.service.http.PortletPreferencesServiceSoap
70   *
71   */
72  public class PortletPreferencesServiceHttp {
73      public static void deleteArchivedPreferences(HttpPrincipal httpPrincipal,
74          long portletItemId)
75          throws com.liferay.portal.PortalException,
76              com.liferay.portal.SystemException {
77          try {
78              Object paramObj0 = new LongWrapper(portletItemId);
79  
80              MethodWrapper methodWrapper = new MethodWrapper(PortletPreferencesServiceUtil.class.getName(),
81                      "deleteArchivedPreferences", new Object[] { paramObj0 });
82  
83              try {
84                  TunnelUtil.invoke(httpPrincipal, methodWrapper);
85              }
86              catch (Exception e) {
87                  if (e instanceof com.liferay.portal.PortalException) {
88                      throw (com.liferay.portal.PortalException)e;
89                  }
90  
91                  if (e instanceof com.liferay.portal.SystemException) {
92                      throw (com.liferay.portal.SystemException)e;
93                  }
94  
95                  throw new com.liferay.portal.SystemException(e);
96              }
97          }
98          catch (com.liferay.portal.SystemException se) {
99              _log.error(se, se);
100 
101             throw se;
102         }
103     }
104 
105     public static void restoreArchivedPreferences(HttpPrincipal httpPrincipal,
106         long groupId, java.lang.String name, java.lang.String portletId,
107         javax.portlet.PortletPreferences preferences)
108         throws com.liferay.portal.PortalException,
109             com.liferay.portal.SystemException {
110         try {
111             Object paramObj0 = new LongWrapper(groupId);
112 
113             Object paramObj1 = name;
114 
115             if (name == null) {
116                 paramObj1 = new NullWrapper("java.lang.String");
117             }
118 
119             Object paramObj2 = portletId;
120 
121             if (portletId == null) {
122                 paramObj2 = new NullWrapper("java.lang.String");
123             }
124 
125             Object paramObj3 = preferences;
126 
127             if (preferences == null) {
128                 paramObj3 = new NullWrapper("javax.portlet.PortletPreferences");
129             }
130 
131             MethodWrapper methodWrapper = new MethodWrapper(PortletPreferencesServiceUtil.class.getName(),
132                     "restoreArchivedPreferences",
133                     new Object[] { paramObj0, paramObj1, paramObj2, paramObj3 });
134 
135             try {
136                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
137             }
138             catch (Exception e) {
139                 if (e instanceof com.liferay.portal.PortalException) {
140                     throw (com.liferay.portal.PortalException)e;
141                 }
142 
143                 if (e instanceof com.liferay.portal.SystemException) {
144                     throw (com.liferay.portal.SystemException)e;
145                 }
146 
147                 throw new com.liferay.portal.SystemException(e);
148             }
149         }
150         catch (com.liferay.portal.SystemException se) {
151             _log.error(se, se);
152 
153             throw se;
154         }
155     }
156 
157     public static void updateArchivePreferences(HttpPrincipal httpPrincipal,
158         long userId, long groupId, java.lang.String name,
159         java.lang.String portletId, javax.portlet.PortletPreferences preferences)
160         throws com.liferay.portal.PortalException,
161             com.liferay.portal.SystemException {
162         try {
163             Object paramObj0 = new LongWrapper(userId);
164 
165             Object paramObj1 = new LongWrapper(groupId);
166 
167             Object paramObj2 = name;
168 
169             if (name == null) {
170                 paramObj2 = new NullWrapper("java.lang.String");
171             }
172 
173             Object paramObj3 = portletId;
174 
175             if (portletId == null) {
176                 paramObj3 = new NullWrapper("java.lang.String");
177             }
178 
179             Object paramObj4 = preferences;
180 
181             if (preferences == null) {
182                 paramObj4 = new NullWrapper("javax.portlet.PortletPreferences");
183             }
184 
185             MethodWrapper methodWrapper = new MethodWrapper(PortletPreferencesServiceUtil.class.getName(),
186                     "updateArchivePreferences",
187                     new Object[] {
188                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4
189                     });
190 
191             try {
192                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
193             }
194             catch (Exception e) {
195                 if (e instanceof com.liferay.portal.PortalException) {
196                     throw (com.liferay.portal.PortalException)e;
197                 }
198 
199                 if (e instanceof com.liferay.portal.SystemException) {
200                     throw (com.liferay.portal.SystemException)e;
201                 }
202 
203                 throw new com.liferay.portal.SystemException(e);
204             }
205         }
206         catch (com.liferay.portal.SystemException se) {
207             _log.error(se, se);
208 
209             throw se;
210         }
211     }
212 
213     private static Log _log = LogFactoryUtil.getLog(PortletPreferencesServiceHttp.class);
214 }