001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portal.service.http;
022:
023: import com.liferay.portal.kernel.log.Log;
024: import com.liferay.portal.kernel.log.LogFactoryUtil;
025: import com.liferay.portal.kernel.util.LongWrapper;
026: import com.liferay.portal.kernel.util.MethodWrapper;
027: import com.liferay.portal.kernel.util.NullWrapper;
028: import com.liferay.portal.security.auth.HttpPrincipal;
029: import com.liferay.portal.service.UserGroupRoleServiceUtil;
030:
031: /**
032: * <a href="UserGroupRoleServiceHttp.java.html"><b><i>View Source</i></b></a>
033: *
034: * <p>
035: * ServiceBuilder generated this class. Modifications in this class will be
036: * overwritten the next time is generated.
037: * </p>
038: *
039: * <p>
040: * This class provides a HTTP utility for the
041: * <code>com.liferay.portal.service.UserGroupRoleServiceUtil</code> service
042: * utility. The static methods of this class calls the same methods of the
043: * service utility. However, the signatures are different because it requires an
044: * additional <code>com.liferay.portal.security.auth.HttpPrincipal</code>
045: * parameter.
046: * </p>
047: *
048: * <p>
049: * The benefits of using the HTTP utility is that it is fast and allows for
050: * tunneling without the cost of serializing to text. The drawback is that it
051: * only works with Java.
052: * </p>
053: *
054: * <p>
055: * Set the property <code>tunnel.servlet.hosts.allowed</code> in
056: * portal.properties to configure security.
057: * </p>
058: *
059: * <p>
060: * The HTTP utility is only generated for remote services.
061: * </p>
062: *
063: * @author Brian Wing Shun Chan
064: *
065: * @see com.liferay.portal.security.auth.HttpPrincipal
066: * @see com.liferay.portal.service.UserGroupRoleServiceUtil
067: * @see com.liferay.portal.service.http.UserGroupRoleServiceSoap
068: *
069: */
070: public class UserGroupRoleServiceHttp {
071: public static void addUserGroupRoles(HttpPrincipal httpPrincipal,
072: long userId, long groupId, long[] roleIds)
073: throws com.liferay.portal.SystemException,
074: com.liferay.portal.PortalException {
075: try {
076: Object paramObj0 = new LongWrapper(userId);
077:
078: Object paramObj1 = new LongWrapper(groupId);
079:
080: Object paramObj2 = roleIds;
081:
082: if (roleIds == null) {
083: paramObj2 = new NullWrapper("[J");
084: }
085:
086: MethodWrapper methodWrapper = new MethodWrapper(
087: UserGroupRoleServiceUtil.class.getName(),
088: "addUserGroupRoles", new Object[] { paramObj0,
089: paramObj1, paramObj2 });
090:
091: try {
092: TunnelUtil.invoke(httpPrincipal, methodWrapper);
093: } catch (Exception e) {
094: if (e instanceof com.liferay.portal.SystemException) {
095: throw (com.liferay.portal.SystemException) e;
096: }
097:
098: if (e instanceof com.liferay.portal.PortalException) {
099: throw (com.liferay.portal.PortalException) e;
100: }
101:
102: throw new com.liferay.portal.SystemException(e);
103: }
104: } catch (com.liferay.portal.SystemException se) {
105: _log.error(se, se);
106:
107: throw se;
108: }
109: }
110:
111: public static void addUserGroupRoles(HttpPrincipal httpPrincipal,
112: long[] userIds, long groupId, long roleId)
113: throws com.liferay.portal.SystemException,
114: com.liferay.portal.PortalException {
115: try {
116: Object paramObj0 = userIds;
117:
118: if (userIds == null) {
119: paramObj0 = new NullWrapper("[J");
120: }
121:
122: Object paramObj1 = new LongWrapper(groupId);
123:
124: Object paramObj2 = new LongWrapper(roleId);
125:
126: MethodWrapper methodWrapper = new MethodWrapper(
127: UserGroupRoleServiceUtil.class.getName(),
128: "addUserGroupRoles", new Object[] { paramObj0,
129: paramObj1, paramObj2 });
130:
131: try {
132: TunnelUtil.invoke(httpPrincipal, methodWrapper);
133: } catch (Exception e) {
134: if (e instanceof com.liferay.portal.SystemException) {
135: throw (com.liferay.portal.SystemException) e;
136: }
137:
138: if (e instanceof com.liferay.portal.PortalException) {
139: throw (com.liferay.portal.PortalException) e;
140: }
141:
142: throw new com.liferay.portal.SystemException(e);
143: }
144: } catch (com.liferay.portal.SystemException se) {
145: _log.error(se, se);
146:
147: throw se;
148: }
149: }
150:
151: public static void deleteUserGroupRoles(
152: HttpPrincipal httpPrincipal, long userId, long groupId,
153: long[] roleIds) throws com.liferay.portal.SystemException,
154: com.liferay.portal.PortalException {
155: try {
156: Object paramObj0 = new LongWrapper(userId);
157:
158: Object paramObj1 = new LongWrapper(groupId);
159:
160: Object paramObj2 = roleIds;
161:
162: if (roleIds == null) {
163: paramObj2 = new NullWrapper("[J");
164: }
165:
166: MethodWrapper methodWrapper = new MethodWrapper(
167: UserGroupRoleServiceUtil.class.getName(),
168: "deleteUserGroupRoles", new Object[] { paramObj0,
169: paramObj1, paramObj2 });
170:
171: try {
172: TunnelUtil.invoke(httpPrincipal, methodWrapper);
173: } catch (Exception e) {
174: if (e instanceof com.liferay.portal.SystemException) {
175: throw (com.liferay.portal.SystemException) e;
176: }
177:
178: if (e instanceof com.liferay.portal.PortalException) {
179: throw (com.liferay.portal.PortalException) e;
180: }
181:
182: throw new com.liferay.portal.SystemException(e);
183: }
184: } catch (com.liferay.portal.SystemException se) {
185: _log.error(se, se);
186:
187: throw se;
188: }
189: }
190:
191: public static void deleteUserGroupRoles(
192: HttpPrincipal httpPrincipal, long[] userIds, long groupId,
193: long roleId) throws com.liferay.portal.SystemException,
194: com.liferay.portal.PortalException {
195: try {
196: Object paramObj0 = userIds;
197:
198: if (userIds == null) {
199: paramObj0 = new NullWrapper("[J");
200: }
201:
202: Object paramObj1 = new LongWrapper(groupId);
203:
204: Object paramObj2 = new LongWrapper(roleId);
205:
206: MethodWrapper methodWrapper = new MethodWrapper(
207: UserGroupRoleServiceUtil.class.getName(),
208: "deleteUserGroupRoles", new Object[] { paramObj0,
209: paramObj1, paramObj2 });
210:
211: try {
212: TunnelUtil.invoke(httpPrincipal, methodWrapper);
213: } catch (Exception e) {
214: if (e instanceof com.liferay.portal.SystemException) {
215: throw (com.liferay.portal.SystemException) e;
216: }
217:
218: if (e instanceof com.liferay.portal.PortalException) {
219: throw (com.liferay.portal.PortalException) e;
220: }
221:
222: throw new com.liferay.portal.SystemException(e);
223: }
224: } catch (com.liferay.portal.SystemException se) {
225: _log.error(se, se);
226:
227: throw se;
228: }
229: }
230:
231: private static Log _log = LogFactoryUtil
232: .getLog(UserGroupRoleServiceHttp.class);
233: }
|