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.BooleanWrapper;
026: import com.liferay.portal.kernel.util.IntegerWrapper;
027: import com.liferay.portal.kernel.util.LongWrapper;
028: import com.liferay.portal.kernel.util.MethodWrapper;
029: import com.liferay.portal.kernel.util.NullWrapper;
030: import com.liferay.portal.security.auth.HttpPrincipal;
031: import com.liferay.portal.service.RoleServiceUtil;
032:
033: /**
034: * <a href="RoleServiceHttp.java.html"><b><i>View Source</i></b></a>
035: *
036: * <p>
037: * ServiceBuilder generated this class. Modifications in this class will be
038: * overwritten the next time is generated.
039: * </p>
040: *
041: * <p>
042: * This class provides a HTTP utility for the
043: * <code>com.liferay.portal.service.RoleServiceUtil</code> service
044: * utility. The static methods of this class calls the same methods of the
045: * service utility. However, the signatures are different because it requires an
046: * additional <code>com.liferay.portal.security.auth.HttpPrincipal</code>
047: * parameter.
048: * </p>
049: *
050: * <p>
051: * The benefits of using the HTTP utility is that it is fast and allows for
052: * tunneling without the cost of serializing to text. The drawback is that it
053: * only works with Java.
054: * </p>
055: *
056: * <p>
057: * Set the property <code>tunnel.servlet.hosts.allowed</code> in
058: * portal.properties to configure security.
059: * </p>
060: *
061: * <p>
062: * The HTTP utility is only generated for remote services.
063: * </p>
064: *
065: * @author Brian Wing Shun Chan
066: *
067: * @see com.liferay.portal.security.auth.HttpPrincipal
068: * @see com.liferay.portal.service.RoleServiceUtil
069: * @see com.liferay.portal.service.http.RoleServiceSoap
070: *
071: */
072: public class RoleServiceHttp {
073: public static com.liferay.portal.model.Role addRole(
074: HttpPrincipal httpPrincipal, java.lang.String name,
075: java.lang.String description, int type)
076: throws com.liferay.portal.SystemException,
077: com.liferay.portal.PortalException {
078: try {
079: Object paramObj0 = name;
080:
081: if (name == null) {
082: paramObj0 = new NullWrapper("java.lang.String");
083: }
084:
085: Object paramObj1 = description;
086:
087: if (description == null) {
088: paramObj1 = new NullWrapper("java.lang.String");
089: }
090:
091: Object paramObj2 = new IntegerWrapper(type);
092:
093: MethodWrapper methodWrapper = new MethodWrapper(
094: RoleServiceUtil.class.getName(), "addRole",
095: new Object[] { paramObj0, paramObj1, paramObj2 });
096:
097: Object returnObj = null;
098:
099: try {
100: returnObj = TunnelUtil.invoke(httpPrincipal,
101: methodWrapper);
102: } catch (Exception e) {
103: if (e instanceof com.liferay.portal.SystemException) {
104: throw (com.liferay.portal.SystemException) e;
105: }
106:
107: if (e instanceof com.liferay.portal.PortalException) {
108: throw (com.liferay.portal.PortalException) e;
109: }
110:
111: throw new com.liferay.portal.SystemException(e);
112: }
113:
114: return (com.liferay.portal.model.Role) returnObj;
115: } catch (com.liferay.portal.SystemException se) {
116: _log.error(se, se);
117:
118: throw se;
119: }
120: }
121:
122: public static void addUserRoles(HttpPrincipal httpPrincipal,
123: long userId, long[] roleIds)
124: throws com.liferay.portal.SystemException,
125: com.liferay.portal.PortalException {
126: try {
127: Object paramObj0 = new LongWrapper(userId);
128:
129: Object paramObj1 = roleIds;
130:
131: if (roleIds == null) {
132: paramObj1 = new NullWrapper("[J");
133: }
134:
135: MethodWrapper methodWrapper = new MethodWrapper(
136: RoleServiceUtil.class.getName(), "addUserRoles",
137: new Object[] { paramObj0, paramObj1 });
138:
139: try {
140: TunnelUtil.invoke(httpPrincipal, methodWrapper);
141: } catch (Exception e) {
142: if (e instanceof com.liferay.portal.SystemException) {
143: throw (com.liferay.portal.SystemException) e;
144: }
145:
146: if (e instanceof com.liferay.portal.PortalException) {
147: throw (com.liferay.portal.PortalException) e;
148: }
149:
150: throw new com.liferay.portal.SystemException(e);
151: }
152: } catch (com.liferay.portal.SystemException se) {
153: _log.error(se, se);
154:
155: throw se;
156: }
157: }
158:
159: public static void deleteRole(HttpPrincipal httpPrincipal,
160: long roleId) throws com.liferay.portal.SystemException,
161: com.liferay.portal.PortalException {
162: try {
163: Object paramObj0 = new LongWrapper(roleId);
164:
165: MethodWrapper methodWrapper = new MethodWrapper(
166: RoleServiceUtil.class.getName(), "deleteRole",
167: new Object[] { paramObj0 });
168:
169: try {
170: TunnelUtil.invoke(httpPrincipal, methodWrapper);
171: } catch (Exception e) {
172: if (e instanceof com.liferay.portal.SystemException) {
173: throw (com.liferay.portal.SystemException) e;
174: }
175:
176: if (e instanceof com.liferay.portal.PortalException) {
177: throw (com.liferay.portal.PortalException) e;
178: }
179:
180: throw new com.liferay.portal.SystemException(e);
181: }
182: } catch (com.liferay.portal.SystemException se) {
183: _log.error(se, se);
184:
185: throw se;
186: }
187: }
188:
189: public static com.liferay.portal.model.Role getGroupRole(
190: HttpPrincipal httpPrincipal, long companyId, long groupId)
191: throws com.liferay.portal.SystemException,
192: com.liferay.portal.PortalException {
193: try {
194: Object paramObj0 = new LongWrapper(companyId);
195:
196: Object paramObj1 = new LongWrapper(groupId);
197:
198: MethodWrapper methodWrapper = new MethodWrapper(
199: RoleServiceUtil.class.getName(), "getGroupRole",
200: new Object[] { paramObj0, paramObj1 });
201:
202: Object returnObj = null;
203:
204: try {
205: returnObj = TunnelUtil.invoke(httpPrincipal,
206: methodWrapper);
207: } catch (Exception e) {
208: if (e instanceof com.liferay.portal.SystemException) {
209: throw (com.liferay.portal.SystemException) e;
210: }
211:
212: if (e instanceof com.liferay.portal.PortalException) {
213: throw (com.liferay.portal.PortalException) e;
214: }
215:
216: throw new com.liferay.portal.SystemException(e);
217: }
218:
219: return (com.liferay.portal.model.Role) returnObj;
220: } catch (com.liferay.portal.SystemException se) {
221: _log.error(se, se);
222:
223: throw se;
224: }
225: }
226:
227: public static java.util.List getGroupRoles(
228: HttpPrincipal httpPrincipal, long groupId)
229: throws com.liferay.portal.SystemException,
230: com.liferay.portal.PortalException {
231: try {
232: Object paramObj0 = new LongWrapper(groupId);
233:
234: MethodWrapper methodWrapper = new MethodWrapper(
235: RoleServiceUtil.class.getName(), "getGroupRoles",
236: new Object[] { paramObj0 });
237:
238: Object returnObj = null;
239:
240: try {
241: returnObj = TunnelUtil.invoke(httpPrincipal,
242: methodWrapper);
243: } catch (Exception e) {
244: if (e instanceof com.liferay.portal.SystemException) {
245: throw (com.liferay.portal.SystemException) e;
246: }
247:
248: if (e instanceof com.liferay.portal.PortalException) {
249: throw (com.liferay.portal.PortalException) e;
250: }
251:
252: throw new com.liferay.portal.SystemException(e);
253: }
254:
255: return (java.util.List) returnObj;
256: } catch (com.liferay.portal.SystemException se) {
257: _log.error(se, se);
258:
259: throw se;
260: }
261: }
262:
263: public static com.liferay.portal.model.Role getRole(
264: HttpPrincipal httpPrincipal, long roleId)
265: throws com.liferay.portal.SystemException,
266: com.liferay.portal.PortalException {
267: try {
268: Object paramObj0 = new LongWrapper(roleId);
269:
270: MethodWrapper methodWrapper = new MethodWrapper(
271: RoleServiceUtil.class.getName(), "getRole",
272: new Object[] { paramObj0 });
273:
274: Object returnObj = null;
275:
276: try {
277: returnObj = TunnelUtil.invoke(httpPrincipal,
278: methodWrapper);
279: } catch (Exception e) {
280: if (e instanceof com.liferay.portal.SystemException) {
281: throw (com.liferay.portal.SystemException) e;
282: }
283:
284: if (e instanceof com.liferay.portal.PortalException) {
285: throw (com.liferay.portal.PortalException) e;
286: }
287:
288: throw new com.liferay.portal.SystemException(e);
289: }
290:
291: return (com.liferay.portal.model.Role) returnObj;
292: } catch (com.liferay.portal.SystemException se) {
293: _log.error(se, se);
294:
295: throw se;
296: }
297: }
298:
299: public static com.liferay.portal.model.Role getRole(
300: HttpPrincipal httpPrincipal, long companyId,
301: java.lang.String name)
302: throws com.liferay.portal.SystemException,
303: com.liferay.portal.PortalException {
304: try {
305: Object paramObj0 = new LongWrapper(companyId);
306:
307: Object paramObj1 = name;
308:
309: if (name == null) {
310: paramObj1 = new NullWrapper("java.lang.String");
311: }
312:
313: MethodWrapper methodWrapper = new MethodWrapper(
314: RoleServiceUtil.class.getName(), "getRole",
315: new Object[] { paramObj0, paramObj1 });
316:
317: Object returnObj = null;
318:
319: try {
320: returnObj = TunnelUtil.invoke(httpPrincipal,
321: methodWrapper);
322: } catch (Exception e) {
323: if (e instanceof com.liferay.portal.SystemException) {
324: throw (com.liferay.portal.SystemException) e;
325: }
326:
327: if (e instanceof com.liferay.portal.PortalException) {
328: throw (com.liferay.portal.PortalException) e;
329: }
330:
331: throw new com.liferay.portal.SystemException(e);
332: }
333:
334: return (com.liferay.portal.model.Role) returnObj;
335: } catch (com.liferay.portal.SystemException se) {
336: _log.error(se, se);
337:
338: throw se;
339: }
340: }
341:
342: public static java.util.List getUserGroupRoles(
343: HttpPrincipal httpPrincipal, long userId, long groupId)
344: throws com.liferay.portal.SystemException,
345: com.liferay.portal.PortalException {
346: try {
347: Object paramObj0 = new LongWrapper(userId);
348:
349: Object paramObj1 = new LongWrapper(groupId);
350:
351: MethodWrapper methodWrapper = new MethodWrapper(
352: RoleServiceUtil.class.getName(),
353: "getUserGroupRoles", new Object[] { paramObj0,
354: paramObj1 });
355:
356: Object returnObj = null;
357:
358: try {
359: returnObj = TunnelUtil.invoke(httpPrincipal,
360: methodWrapper);
361: } catch (Exception e) {
362: if (e instanceof com.liferay.portal.SystemException) {
363: throw (com.liferay.portal.SystemException) e;
364: }
365:
366: if (e instanceof com.liferay.portal.PortalException) {
367: throw (com.liferay.portal.PortalException) e;
368: }
369:
370: throw new com.liferay.portal.SystemException(e);
371: }
372:
373: return (java.util.List) returnObj;
374: } catch (com.liferay.portal.SystemException se) {
375: _log.error(se, se);
376:
377: throw se;
378: }
379: }
380:
381: public static java.util.List getUserRelatedRoles(
382: HttpPrincipal httpPrincipal, long userId,
383: java.util.List groups)
384: throws com.liferay.portal.SystemException,
385: com.liferay.portal.PortalException {
386: try {
387: Object paramObj0 = new LongWrapper(userId);
388:
389: Object paramObj1 = groups;
390:
391: if (groups == null) {
392: paramObj1 = new NullWrapper("java.util.List");
393: }
394:
395: MethodWrapper methodWrapper = new MethodWrapper(
396: RoleServiceUtil.class.getName(),
397: "getUserRelatedRoles", new Object[] { paramObj0,
398: paramObj1 });
399:
400: Object returnObj = null;
401:
402: try {
403: returnObj = TunnelUtil.invoke(httpPrincipal,
404: methodWrapper);
405: } catch (Exception e) {
406: if (e instanceof com.liferay.portal.SystemException) {
407: throw (com.liferay.portal.SystemException) e;
408: }
409:
410: if (e instanceof com.liferay.portal.PortalException) {
411: throw (com.liferay.portal.PortalException) e;
412: }
413:
414: throw new com.liferay.portal.SystemException(e);
415: }
416:
417: return (java.util.List) returnObj;
418: } catch (com.liferay.portal.SystemException se) {
419: _log.error(se, se);
420:
421: throw se;
422: }
423: }
424:
425: public static java.util.List getUserRoles(
426: HttpPrincipal httpPrincipal, long userId)
427: throws com.liferay.portal.SystemException,
428: com.liferay.portal.PortalException {
429: try {
430: Object paramObj0 = new LongWrapper(userId);
431:
432: MethodWrapper methodWrapper = new MethodWrapper(
433: RoleServiceUtil.class.getName(), "getUserRoles",
434: new Object[] { paramObj0 });
435:
436: Object returnObj = null;
437:
438: try {
439: returnObj = TunnelUtil.invoke(httpPrincipal,
440: methodWrapper);
441: } catch (Exception e) {
442: if (e instanceof com.liferay.portal.SystemException) {
443: throw (com.liferay.portal.SystemException) e;
444: }
445:
446: if (e instanceof com.liferay.portal.PortalException) {
447: throw (com.liferay.portal.PortalException) e;
448: }
449:
450: throw new com.liferay.portal.SystemException(e);
451: }
452:
453: return (java.util.List) returnObj;
454: } catch (com.liferay.portal.SystemException se) {
455: _log.error(se, se);
456:
457: throw se;
458: }
459: }
460:
461: public static boolean hasUserRole(HttpPrincipal httpPrincipal,
462: long userId, long companyId, java.lang.String name,
463: boolean inherited)
464: throws com.liferay.portal.SystemException,
465: com.liferay.portal.PortalException {
466: try {
467: Object paramObj0 = new LongWrapper(userId);
468:
469: Object paramObj1 = new LongWrapper(companyId);
470:
471: Object paramObj2 = name;
472:
473: if (name == null) {
474: paramObj2 = new NullWrapper("java.lang.String");
475: }
476:
477: Object paramObj3 = new BooleanWrapper(inherited);
478:
479: MethodWrapper methodWrapper = new MethodWrapper(
480: RoleServiceUtil.class.getName(), "hasUserRole",
481: new Object[] { paramObj0, paramObj1, paramObj2,
482: paramObj3 });
483:
484: Object returnObj = null;
485:
486: try {
487: returnObj = TunnelUtil.invoke(httpPrincipal,
488: methodWrapper);
489: } catch (Exception e) {
490: if (e instanceof com.liferay.portal.SystemException) {
491: throw (com.liferay.portal.SystemException) e;
492: }
493:
494: if (e instanceof com.liferay.portal.PortalException) {
495: throw (com.liferay.portal.PortalException) e;
496: }
497:
498: throw new com.liferay.portal.SystemException(e);
499: }
500:
501: return ((Boolean) returnObj).booleanValue();
502: } catch (com.liferay.portal.SystemException se) {
503: _log.error(se, se);
504:
505: throw se;
506: }
507: }
508:
509: public static boolean hasUserRoles(HttpPrincipal httpPrincipal,
510: long userId, long companyId, java.lang.String[] names,
511: boolean inherited)
512: throws com.liferay.portal.SystemException,
513: com.liferay.portal.PortalException {
514: try {
515: Object paramObj0 = new LongWrapper(userId);
516:
517: Object paramObj1 = new LongWrapper(companyId);
518:
519: Object paramObj2 = names;
520:
521: if (names == null) {
522: paramObj2 = new NullWrapper("[Ljava.lang.String;");
523: }
524:
525: Object paramObj3 = new BooleanWrapper(inherited);
526:
527: MethodWrapper methodWrapper = new MethodWrapper(
528: RoleServiceUtil.class.getName(), "hasUserRoles",
529: new Object[] { paramObj0, paramObj1, paramObj2,
530: paramObj3 });
531:
532: Object returnObj = null;
533:
534: try {
535: returnObj = TunnelUtil.invoke(httpPrincipal,
536: methodWrapper);
537: } catch (Exception e) {
538: if (e instanceof com.liferay.portal.SystemException) {
539: throw (com.liferay.portal.SystemException) e;
540: }
541:
542: if (e instanceof com.liferay.portal.PortalException) {
543: throw (com.liferay.portal.PortalException) e;
544: }
545:
546: throw new com.liferay.portal.SystemException(e);
547: }
548:
549: return ((Boolean) returnObj).booleanValue();
550: } catch (com.liferay.portal.SystemException se) {
551: _log.error(se, se);
552:
553: throw se;
554: }
555: }
556:
557: public static void unsetUserRoles(HttpPrincipal httpPrincipal,
558: long userId, long[] roleIds)
559: throws com.liferay.portal.SystemException,
560: com.liferay.portal.PortalException {
561: try {
562: Object paramObj0 = new LongWrapper(userId);
563:
564: Object paramObj1 = roleIds;
565:
566: if (roleIds == null) {
567: paramObj1 = new NullWrapper("[J");
568: }
569:
570: MethodWrapper methodWrapper = new MethodWrapper(
571: RoleServiceUtil.class.getName(), "unsetUserRoles",
572: new Object[] { paramObj0, paramObj1 });
573:
574: try {
575: TunnelUtil.invoke(httpPrincipal, methodWrapper);
576: } catch (Exception e) {
577: if (e instanceof com.liferay.portal.SystemException) {
578: throw (com.liferay.portal.SystemException) e;
579: }
580:
581: if (e instanceof com.liferay.portal.PortalException) {
582: throw (com.liferay.portal.PortalException) e;
583: }
584:
585: throw new com.liferay.portal.SystemException(e);
586: }
587: } catch (com.liferay.portal.SystemException se) {
588: _log.error(se, se);
589:
590: throw se;
591: }
592: }
593:
594: public static com.liferay.portal.model.Role updateRole(
595: HttpPrincipal httpPrincipal, long roleId,
596: java.lang.String name, java.lang.String description)
597: throws com.liferay.portal.SystemException,
598: com.liferay.portal.PortalException {
599: try {
600: Object paramObj0 = new LongWrapper(roleId);
601:
602: Object paramObj1 = name;
603:
604: if (name == null) {
605: paramObj1 = new NullWrapper("java.lang.String");
606: }
607:
608: Object paramObj2 = description;
609:
610: if (description == null) {
611: paramObj2 = new NullWrapper("java.lang.String");
612: }
613:
614: MethodWrapper methodWrapper = new MethodWrapper(
615: RoleServiceUtil.class.getName(), "updateRole",
616: new Object[] { paramObj0, paramObj1, paramObj2 });
617:
618: Object returnObj = null;
619:
620: try {
621: returnObj = TunnelUtil.invoke(httpPrincipal,
622: methodWrapper);
623: } catch (Exception e) {
624: if (e instanceof com.liferay.portal.SystemException) {
625: throw (com.liferay.portal.SystemException) e;
626: }
627:
628: if (e instanceof com.liferay.portal.PortalException) {
629: throw (com.liferay.portal.PortalException) e;
630: }
631:
632: throw new com.liferay.portal.SystemException(e);
633: }
634:
635: return (com.liferay.portal.model.Role) returnObj;
636: } catch (com.liferay.portal.SystemException se) {
637: _log.error(se, se);
638:
639: throw se;
640: }
641: }
642:
643: private static Log _log = LogFactoryUtil
644: .getLog(RoleServiceHttp.class);
645: }
|