1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
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.MethodHandler;
20  import com.liferay.portal.kernel.util.MethodKey;
21  import com.liferay.portal.security.auth.HttpPrincipal;
22  import com.liferay.portal.service.PortletPreferencesServiceUtil;
23  
24  /**
25   * <a href="PortletPreferencesServiceHttp.java.html"><b><i>View Source</i></b></a>
26   *
27   * <p>
28   * ServiceBuilder generated this class. Modifications in this class will be
29   * overwritten the next time is generated.
30   * </p>
31   *
32   * <p>
33   * This class provides a HTTP utility for the
34   * {@link com.liferay.portal.service.PortletPreferencesServiceUtil} service utility. The
35   * static methods of this class calls the same methods of the service utility.
36   * However, the signatures are different because it requires an additional
37   * {@link com.liferay.portal.security.auth.HttpPrincipal} parameter.
38   * </p>
39   *
40   * <p>
41   * The benefits of using the HTTP utility is that it is fast and allows for
42   * tunneling without the cost of serializing to text. The drawback is that it
43   * only works with Java.
44   * </p>
45   *
46   * <p>
47   * Set the property <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
48   * configure security.
49   * </p>
50   *
51   * <p>
52   * The HTTP utility is only generated for remote services.
53   * </p>
54   *
55   * @author    Brian Wing Shun Chan
56   * @see       PortletPreferencesServiceSoap
57   * @see       com.liferay.portal.security.auth.HttpPrincipal
58   * @see       com.liferay.portal.service.PortletPreferencesServiceUtil
59   * @generated
60   */
61  public class PortletPreferencesServiceHttp {
62      public static void deleteArchivedPreferences(HttpPrincipal httpPrincipal,
63          long portletItemId)
64          throws com.liferay.portal.PortalException,
65              com.liferay.portal.SystemException {
66          try {
67              MethodKey methodKey = new MethodKey(PortletPreferencesServiceUtil.class.getName(),
68                      "deleteArchivedPreferences",
69                      _deleteArchivedPreferencesParameterTypes0);
70  
71              MethodHandler methodHandler = new MethodHandler(methodKey,
72                      portletItemId);
73  
74              try {
75                  TunnelUtil.invoke(httpPrincipal, methodHandler);
76              }
77              catch (Exception e) {
78                  if (e instanceof com.liferay.portal.PortalException) {
79                      throw (com.liferay.portal.PortalException)e;
80                  }
81  
82                  if (e instanceof com.liferay.portal.SystemException) {
83                      throw (com.liferay.portal.SystemException)e;
84                  }
85  
86                  throw new com.liferay.portal.SystemException(e);
87              }
88          }
89          catch (com.liferay.portal.SystemException se) {
90              _log.error(se, se);
91  
92              throw se;
93          }
94      }
95  
96      public static void restoreArchivedPreferences(HttpPrincipal httpPrincipal,
97          long groupId, java.lang.String name, java.lang.String portletId,
98          javax.portlet.PortletPreferences preferences)
99          throws com.liferay.portal.PortalException,
100             com.liferay.portal.SystemException {
101         try {
102             MethodKey methodKey = new MethodKey(PortletPreferencesServiceUtil.class.getName(),
103                     "restoreArchivedPreferences",
104                     _restoreArchivedPreferencesParameterTypes1);
105 
106             MethodHandler methodHandler = new MethodHandler(methodKey, groupId,
107                     name, portletId, preferences);
108 
109             try {
110                 TunnelUtil.invoke(httpPrincipal, methodHandler);
111             }
112             catch (Exception e) {
113                 if (e instanceof com.liferay.portal.PortalException) {
114                     throw (com.liferay.portal.PortalException)e;
115                 }
116 
117                 if (e instanceof com.liferay.portal.SystemException) {
118                     throw (com.liferay.portal.SystemException)e;
119                 }
120 
121                 throw new com.liferay.portal.SystemException(e);
122             }
123         }
124         catch (com.liferay.portal.SystemException se) {
125             _log.error(se, se);
126 
127             throw se;
128         }
129     }
130 
131     public static void updateArchivePreferences(HttpPrincipal httpPrincipal,
132         long userId, long groupId, java.lang.String name,
133         java.lang.String portletId, javax.portlet.PortletPreferences preferences)
134         throws com.liferay.portal.PortalException,
135             com.liferay.portal.SystemException {
136         try {
137             MethodKey methodKey = new MethodKey(PortletPreferencesServiceUtil.class.getName(),
138                     "updateArchivePreferences",
139                     _updateArchivePreferencesParameterTypes2);
140 
141             MethodHandler methodHandler = new MethodHandler(methodKey, userId,
142                     groupId, name, portletId, preferences);
143 
144             try {
145                 TunnelUtil.invoke(httpPrincipal, methodHandler);
146             }
147             catch (Exception e) {
148                 if (e instanceof com.liferay.portal.PortalException) {
149                     throw (com.liferay.portal.PortalException)e;
150                 }
151 
152                 if (e instanceof com.liferay.portal.SystemException) {
153                     throw (com.liferay.portal.SystemException)e;
154                 }
155 
156                 throw new com.liferay.portal.SystemException(e);
157             }
158         }
159         catch (com.liferay.portal.SystemException se) {
160             _log.error(se, se);
161 
162             throw se;
163         }
164     }
165 
166     private static Log _log = LogFactoryUtil.getLog(PortletPreferencesServiceHttp.class);
167     private static final Class<?>[] _deleteArchivedPreferencesParameterTypes0 = new Class[] {
168             long.class
169         };
170     private static final Class<?>[] _restoreArchivedPreferencesParameterTypes1 = new Class[] {
171             long.class, java.lang.String.class, java.lang.String.class,
172             javax.portlet.PortletPreferences.class
173         };
174     private static final Class<?>[] _updateArchivePreferencesParameterTypes2 = new Class[] {
175             long.class, long.class, java.lang.String.class,
176             java.lang.String.class, javax.portlet.PortletPreferences.class
177         };
178 }