1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights 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   * {@link com.liferay.portal.service.UserGroupRoleServiceUtil} 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       UserGroupRoleServiceSoap
66   * @see       com.liferay.portal.security.auth.HttpPrincipal
67   * @see       com.liferay.portal.service.UserGroupRoleServiceUtil
68   * @generated
69   */
70  public class UserGroupRoleServiceHttp {
71      public static void addUserGroupRoles(HttpPrincipal httpPrincipal,
72          long userId, long groupId, long[] roleIds)
73          throws com.liferay.portal.PortalException,
74              com.liferay.portal.SystemException {
75          try {
76              Object paramObj0 = new LongWrapper(userId);
77  
78              Object paramObj1 = new LongWrapper(groupId);
79  
80              Object paramObj2 = roleIds;
81  
82              if (roleIds == null) {
83                  paramObj2 = new NullWrapper("[J");
84              }
85  
86              MethodWrapper methodWrapper = new MethodWrapper(UserGroupRoleServiceUtil.class.getName(),
87                      "addUserGroupRoles",
88                      new Object[] { paramObj0, paramObj1, paramObj2 });
89  
90              try {
91                  TunnelUtil.invoke(httpPrincipal, methodWrapper);
92              }
93              catch (Exception e) {
94                  if (e instanceof com.liferay.portal.PortalException) {
95                      throw (com.liferay.portal.PortalException)e;
96                  }
97  
98                  if (e instanceof com.liferay.portal.SystemException) {
99                      throw (com.liferay.portal.SystemException)e;
100                 }
101 
102                 throw new com.liferay.portal.SystemException(e);
103             }
104         }
105         catch (com.liferay.portal.SystemException se) {
106             _log.error(se, se);
107 
108             throw se;
109         }
110     }
111 
112     public static void addUserGroupRoles(HttpPrincipal httpPrincipal,
113         long[] userIds, long groupId, long roleId)
114         throws com.liferay.portal.PortalException,
115             com.liferay.portal.SystemException {
116         try {
117             Object paramObj0 = userIds;
118 
119             if (userIds == null) {
120                 paramObj0 = new NullWrapper("[J");
121             }
122 
123             Object paramObj1 = new LongWrapper(groupId);
124 
125             Object paramObj2 = new LongWrapper(roleId);
126 
127             MethodWrapper methodWrapper = new MethodWrapper(UserGroupRoleServiceUtil.class.getName(),
128                     "addUserGroupRoles",
129                     new Object[] { paramObj0, paramObj1, paramObj2 });
130 
131             try {
132                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
133             }
134             catch (Exception e) {
135                 if (e instanceof com.liferay.portal.PortalException) {
136                     throw (com.liferay.portal.PortalException)e;
137                 }
138 
139                 if (e instanceof com.liferay.portal.SystemException) {
140                     throw (com.liferay.portal.SystemException)e;
141                 }
142 
143                 throw new com.liferay.portal.SystemException(e);
144             }
145         }
146         catch (com.liferay.portal.SystemException se) {
147             _log.error(se, se);
148 
149             throw se;
150         }
151     }
152 
153     public static void deleteUserGroupRoles(HttpPrincipal httpPrincipal,
154         long userId, long groupId, long[] roleIds)
155         throws com.liferay.portal.PortalException,
156             com.liferay.portal.SystemException {
157         try {
158             Object paramObj0 = new LongWrapper(userId);
159 
160             Object paramObj1 = new LongWrapper(groupId);
161 
162             Object paramObj2 = roleIds;
163 
164             if (roleIds == null) {
165                 paramObj2 = new NullWrapper("[J");
166             }
167 
168             MethodWrapper methodWrapper = new MethodWrapper(UserGroupRoleServiceUtil.class.getName(),
169                     "deleteUserGroupRoles",
170                     new Object[] { paramObj0, paramObj1, paramObj2 });
171 
172             try {
173                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
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     public static void deleteUserGroupRoles(HttpPrincipal httpPrincipal,
195         long[] userIds, long groupId, long roleId)
196         throws com.liferay.portal.PortalException,
197             com.liferay.portal.SystemException {
198         try {
199             Object paramObj0 = userIds;
200 
201             if (userIds == null) {
202                 paramObj0 = new NullWrapper("[J");
203             }
204 
205             Object paramObj1 = new LongWrapper(groupId);
206 
207             Object paramObj2 = new LongWrapper(roleId);
208 
209             MethodWrapper methodWrapper = new MethodWrapper(UserGroupRoleServiceUtil.class.getName(),
210                     "deleteUserGroupRoles",
211                     new Object[] { paramObj0, paramObj1, paramObj2 });
212 
213             try {
214                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
215             }
216             catch (Exception e) {
217                 if (e instanceof com.liferay.portal.PortalException) {
218                     throw (com.liferay.portal.PortalException)e;
219                 }
220 
221                 if (e instanceof com.liferay.portal.SystemException) {
222                     throw (com.liferay.portal.SystemException)e;
223                 }
224 
225                 throw new com.liferay.portal.SystemException(e);
226             }
227         }
228         catch (com.liferay.portal.SystemException se) {
229             _log.error(se, se);
230 
231             throw se;
232         }
233     }
234 
235     private static Log _log = LogFactoryUtil.getLog(UserGroupRoleServiceHttp.class);
236 }