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.UserGroupRoleServiceUtil;
32  
33  /**
34   * <a href="UserGroupRoleServiceHttp.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.UserGroupRoleServiceUtil</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.UserGroupRoleServiceUtil
69   * @see com.liferay.portal.service.http.UserGroupRoleServiceSoap
70   *
71   */
72  public class UserGroupRoleServiceHttp {
73      public static void addUserGroupRoles(HttpPrincipal httpPrincipal,
74          long userId, long groupId, long[] roleIds)
75          throws com.liferay.portal.PortalException,
76              com.liferay.portal.SystemException {
77          try {
78              Object paramObj0 = new LongWrapper(userId);
79  
80              Object paramObj1 = new LongWrapper(groupId);
81  
82              Object paramObj2 = roleIds;
83  
84              if (roleIds == null) {
85                  paramObj2 = new NullWrapper("[J");
86              }
87  
88              MethodWrapper methodWrapper = new MethodWrapper(UserGroupRoleServiceUtil.class.getName(),
89                      "addUserGroupRoles",
90                      new Object[] { paramObj0, paramObj1, paramObj2 });
91  
92              try {
93                  TunnelUtil.invoke(httpPrincipal, methodWrapper);
94              }
95              catch (Exception e) {
96                  if (e instanceof com.liferay.portal.PortalException) {
97                      throw (com.liferay.portal.PortalException)e;
98                  }
99  
100                 if (e instanceof com.liferay.portal.SystemException) {
101                     throw (com.liferay.portal.SystemException)e;
102                 }
103 
104                 throw new com.liferay.portal.SystemException(e);
105             }
106         }
107         catch (com.liferay.portal.SystemException se) {
108             _log.error(se, se);
109 
110             throw se;
111         }
112     }
113 
114     public static void addUserGroupRoles(HttpPrincipal httpPrincipal,
115         long[] userIds, long groupId, long roleId)
116         throws com.liferay.portal.PortalException,
117             com.liferay.portal.SystemException {
118         try {
119             Object paramObj0 = userIds;
120 
121             if (userIds == null) {
122                 paramObj0 = new NullWrapper("[J");
123             }
124 
125             Object paramObj1 = new LongWrapper(groupId);
126 
127             Object paramObj2 = new LongWrapper(roleId);
128 
129             MethodWrapper methodWrapper = new MethodWrapper(UserGroupRoleServiceUtil.class.getName(),
130                     "addUserGroupRoles",
131                     new Object[] { paramObj0, paramObj1, paramObj2 });
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 deleteUserGroupRoles(HttpPrincipal httpPrincipal,
156         long userId, long groupId, long[] roleIds)
157         throws com.liferay.portal.PortalException,
158             com.liferay.portal.SystemException {
159         try {
160             Object paramObj0 = new LongWrapper(userId);
161 
162             Object paramObj1 = new LongWrapper(groupId);
163 
164             Object paramObj2 = roleIds;
165 
166             if (roleIds == null) {
167                 paramObj2 = new NullWrapper("[J");
168             }
169 
170             MethodWrapper methodWrapper = new MethodWrapper(UserGroupRoleServiceUtil.class.getName(),
171                     "deleteUserGroupRoles",
172                     new Object[] { paramObj0, paramObj1, paramObj2 });
173 
174             try {
175                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
176             }
177             catch (Exception e) {
178                 if (e instanceof com.liferay.portal.PortalException) {
179                     throw (com.liferay.portal.PortalException)e;
180                 }
181 
182                 if (e instanceof com.liferay.portal.SystemException) {
183                     throw (com.liferay.portal.SystemException)e;
184                 }
185 
186                 throw new com.liferay.portal.SystemException(e);
187             }
188         }
189         catch (com.liferay.portal.SystemException se) {
190             _log.error(se, se);
191 
192             throw se;
193         }
194     }
195 
196     public static void deleteUserGroupRoles(HttpPrincipal httpPrincipal,
197         long[] userIds, long groupId, long roleId)
198         throws com.liferay.portal.PortalException,
199             com.liferay.portal.SystemException {
200         try {
201             Object paramObj0 = userIds;
202 
203             if (userIds == null) {
204                 paramObj0 = new NullWrapper("[J");
205             }
206 
207             Object paramObj1 = new LongWrapper(groupId);
208 
209             Object paramObj2 = new LongWrapper(roleId);
210 
211             MethodWrapper methodWrapper = new MethodWrapper(UserGroupRoleServiceUtil.class.getName(),
212                     "deleteUserGroupRoles",
213                     new Object[] { paramObj0, paramObj1, paramObj2 });
214 
215             try {
216                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
217             }
218             catch (Exception e) {
219                 if (e instanceof com.liferay.portal.PortalException) {
220                     throw (com.liferay.portal.PortalException)e;
221                 }
222 
223                 if (e instanceof com.liferay.portal.SystemException) {
224                     throw (com.liferay.portal.SystemException)e;
225                 }
226 
227                 throw new com.liferay.portal.SystemException(e);
228             }
229         }
230         catch (com.liferay.portal.SystemException se) {
231             _log.error(se, se);
232 
233             throw se;
234         }
235     }
236 
237     private static Log _log = LogFactoryUtil.getLog(UserGroupRoleServiceHttp.class);
238 }