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.UserGroupRoleServiceUtil;
23  
24  /**
25   * <a href="UserGroupRoleServiceHttp.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.UserGroupRoleServiceUtil} 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       UserGroupRoleServiceSoap
57   * @see       com.liferay.portal.security.auth.HttpPrincipal
58   * @see       com.liferay.portal.service.UserGroupRoleServiceUtil
59   * @generated
60   */
61  public class UserGroupRoleServiceHttp {
62      public static void addUserGroupRoles(HttpPrincipal httpPrincipal,
63          long userId, long groupId, long[] roleIds)
64          throws com.liferay.portal.PortalException,
65              com.liferay.portal.SystemException {
66          try {
67              MethodKey methodKey = new MethodKey(UserGroupRoleServiceUtil.class.getName(),
68                      "addUserGroupRoles", _addUserGroupRolesParameterTypes0);
69  
70              MethodHandler methodHandler = new MethodHandler(methodKey, userId,
71                      groupId, roleIds);
72  
73              try {
74                  TunnelUtil.invoke(httpPrincipal, methodHandler);
75              }
76              catch (Exception e) {
77                  if (e instanceof com.liferay.portal.PortalException) {
78                      throw (com.liferay.portal.PortalException)e;
79                  }
80  
81                  if (e instanceof com.liferay.portal.SystemException) {
82                      throw (com.liferay.portal.SystemException)e;
83                  }
84  
85                  throw new com.liferay.portal.SystemException(e);
86              }
87          }
88          catch (com.liferay.portal.SystemException se) {
89              _log.error(se, se);
90  
91              throw se;
92          }
93      }
94  
95      public static void addUserGroupRoles(HttpPrincipal httpPrincipal,
96          long[] userIds, long groupId, long roleId)
97          throws com.liferay.portal.PortalException,
98              com.liferay.portal.SystemException {
99          try {
100             MethodKey methodKey = new MethodKey(UserGroupRoleServiceUtil.class.getName(),
101                     "addUserGroupRoles", _addUserGroupRolesParameterTypes1);
102 
103             MethodHandler methodHandler = new MethodHandler(methodKey, userIds,
104                     groupId, roleId);
105 
106             try {
107                 TunnelUtil.invoke(httpPrincipal, methodHandler);
108             }
109             catch (Exception e) {
110                 if (e instanceof com.liferay.portal.PortalException) {
111                     throw (com.liferay.portal.PortalException)e;
112                 }
113 
114                 if (e instanceof com.liferay.portal.SystemException) {
115                     throw (com.liferay.portal.SystemException)e;
116                 }
117 
118                 throw new com.liferay.portal.SystemException(e);
119             }
120         }
121         catch (com.liferay.portal.SystemException se) {
122             _log.error(se, se);
123 
124             throw se;
125         }
126     }
127 
128     public static void deleteUserGroupRoles(HttpPrincipal httpPrincipal,
129         long userId, long groupId, long[] roleIds)
130         throws com.liferay.portal.PortalException,
131             com.liferay.portal.SystemException {
132         try {
133             MethodKey methodKey = new MethodKey(UserGroupRoleServiceUtil.class.getName(),
134                     "deleteUserGroupRoles", _deleteUserGroupRolesParameterTypes2);
135 
136             MethodHandler methodHandler = new MethodHandler(methodKey, userId,
137                     groupId, roleIds);
138 
139             try {
140                 TunnelUtil.invoke(httpPrincipal, methodHandler);
141             }
142             catch (Exception e) {
143                 if (e instanceof com.liferay.portal.PortalException) {
144                     throw (com.liferay.portal.PortalException)e;
145                 }
146 
147                 if (e instanceof com.liferay.portal.SystemException) {
148                     throw (com.liferay.portal.SystemException)e;
149                 }
150 
151                 throw new com.liferay.portal.SystemException(e);
152             }
153         }
154         catch (com.liferay.portal.SystemException se) {
155             _log.error(se, se);
156 
157             throw se;
158         }
159     }
160 
161     public static void deleteUserGroupRoles(HttpPrincipal httpPrincipal,
162         long[] userIds, long groupId, long roleId)
163         throws com.liferay.portal.PortalException,
164             com.liferay.portal.SystemException {
165         try {
166             MethodKey methodKey = new MethodKey(UserGroupRoleServiceUtil.class.getName(),
167                     "deleteUserGroupRoles", _deleteUserGroupRolesParameterTypes3);
168 
169             MethodHandler methodHandler = new MethodHandler(methodKey, userIds,
170                     groupId, roleId);
171 
172             try {
173                 TunnelUtil.invoke(httpPrincipal, methodHandler);
174             }
175             catch (Exception e) {
176                 if (e instanceof com.liferay.portal.PortalException) {
177                     throw (com.liferay.portal.PortalException)e;
178                 }
179 
180                 if (e instanceof com.liferay.portal.SystemException) {
181                     throw (com.liferay.portal.SystemException)e;
182                 }
183 
184                 throw new com.liferay.portal.SystemException(e);
185             }
186         }
187         catch (com.liferay.portal.SystemException se) {
188             _log.error(se, se);
189 
190             throw se;
191         }
192     }
193 
194     private static Log _log = LogFactoryUtil.getLog(UserGroupRoleServiceHttp.class);
195     private static final Class<?>[] _addUserGroupRolesParameterTypes0 = new Class[] {
196             long.class, long.class, long[].class
197         };
198     private static final Class<?>[] _addUserGroupRolesParameterTypes1 = new Class[] {
199             long[].class, long.class, long.class
200         };
201     private static final Class<?>[] _deleteUserGroupRolesParameterTypes2 = new Class[] {
202             long.class, long.class, long[].class
203         };
204     private static final Class<?>[] _deleteUserGroupRolesParameterTypes3 = new Class[] {
205             long[].class, long.class, long.class
206         };
207 }