001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.http;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogFactoryUtil;
019    import com.liferay.portal.kernel.util.MethodHandler;
020    import com.liferay.portal.kernel.util.MethodKey;
021    import com.liferay.portal.security.auth.HttpPrincipal;
022    import com.liferay.portal.service.PermissionServiceUtil;
023    
024    /**
025     * <p>
026     * This class provides a HTTP utility for the
027     * {@link com.liferay.portal.service.PermissionServiceUtil} service utility. The
028     * static methods of this class calls the same methods of the service utility.
029     * However, the signatures are different because it requires an additional
030     * {@link com.liferay.portal.security.auth.HttpPrincipal} parameter.
031     * </p>
032     *
033     * <p>
034     * The benefits of using the HTTP utility is that it is fast and allows for
035     * tunneling without the cost of serializing to text. The drawback is that it
036     * only works with Java.
037     * </p>
038     *
039     * <p>
040     * Set the property <b>tunnel.servlet.hosts.allowed</b> in portal.properties to
041     * configure security.
042     * </p>
043     *
044     * <p>
045     * The HTTP utility is only generated for remote services.
046     * </p>
047     *
048     * @author    Brian Wing Shun Chan
049     * @see       PermissionServiceSoap
050     * @see       com.liferay.portal.security.auth.HttpPrincipal
051     * @see       com.liferay.portal.service.PermissionServiceUtil
052     * @generated
053     */
054    public class PermissionServiceHttp {
055            public static void checkPermission(HttpPrincipal httpPrincipal,
056                    long groupId, long resourceId)
057                    throws com.liferay.portal.kernel.exception.PortalException,
058                            com.liferay.portal.kernel.exception.SystemException {
059                    try {
060                            MethodKey methodKey = new MethodKey(PermissionServiceUtil.class.getName(),
061                                            "checkPermission", long.class, long.class);
062    
063                            MethodHandler methodHandler = new MethodHandler(methodKey, groupId,
064                                            resourceId);
065    
066                            try {
067                                    TunnelUtil.invoke(httpPrincipal, methodHandler);
068                            }
069                            catch (Exception e) {
070                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
071                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
072                                    }
073    
074                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
075                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
076                                    }
077    
078                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
079                            }
080                    }
081                    catch (com.liferay.portal.kernel.exception.SystemException se) {
082                            _log.error(se, se);
083    
084                            throw se;
085                    }
086            }
087    
088            public static void checkPermission(HttpPrincipal httpPrincipal,
089                    long groupId, java.lang.String name, long primKey)
090                    throws com.liferay.portal.kernel.exception.PortalException,
091                            com.liferay.portal.kernel.exception.SystemException {
092                    try {
093                            MethodKey methodKey = new MethodKey(PermissionServiceUtil.class.getName(),
094                                            "checkPermission", long.class, java.lang.String.class,
095                                            long.class);
096    
097                            MethodHandler methodHandler = new MethodHandler(methodKey, groupId,
098                                            name, primKey);
099    
100                            try {
101                                    TunnelUtil.invoke(httpPrincipal, methodHandler);
102                            }
103                            catch (Exception e) {
104                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
105                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
106                                    }
107    
108                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
109                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
110                                    }
111    
112                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
113                            }
114                    }
115                    catch (com.liferay.portal.kernel.exception.SystemException se) {
116                            _log.error(se, se);
117    
118                            throw se;
119                    }
120            }
121    
122            public static void checkPermission(HttpPrincipal httpPrincipal,
123                    long groupId, java.lang.String name, java.lang.String primKey)
124                    throws com.liferay.portal.kernel.exception.PortalException,
125                            com.liferay.portal.kernel.exception.SystemException {
126                    try {
127                            MethodKey methodKey = new MethodKey(PermissionServiceUtil.class.getName(),
128                                            "checkPermission", long.class, java.lang.String.class,
129                                            java.lang.String.class);
130    
131                            MethodHandler methodHandler = new MethodHandler(methodKey, groupId,
132                                            name, primKey);
133    
134                            try {
135                                    TunnelUtil.invoke(httpPrincipal, methodHandler);
136                            }
137                            catch (Exception e) {
138                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
139                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
140                                    }
141    
142                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
143                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
144                                    }
145    
146                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
147                            }
148                    }
149                    catch (com.liferay.portal.kernel.exception.SystemException se) {
150                            _log.error(se, se);
151    
152                            throw se;
153                    }
154            }
155    
156            public static boolean hasGroupPermission(HttpPrincipal httpPrincipal,
157                    long groupId, java.lang.String actionId, long resourceId)
158                    throws com.liferay.portal.kernel.exception.SystemException {
159                    try {
160                            MethodKey methodKey = new MethodKey(PermissionServiceUtil.class.getName(),
161                                            "hasGroupPermission", long.class, java.lang.String.class,
162                                            long.class);
163    
164                            MethodHandler methodHandler = new MethodHandler(methodKey, groupId,
165                                            actionId, resourceId);
166    
167                            Object returnObj = null;
168    
169                            try {
170                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodHandler);
171                            }
172                            catch (Exception e) {
173                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
174                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
175                                    }
176    
177                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
178                            }
179    
180                            return ((Boolean)returnObj).booleanValue();
181                    }
182                    catch (com.liferay.portal.kernel.exception.SystemException se) {
183                            _log.error(se, se);
184    
185                            throw se;
186                    }
187            }
188    
189            public static boolean hasUserPermission(HttpPrincipal httpPrincipal,
190                    long userId, java.lang.String actionId, long resourceId)
191                    throws com.liferay.portal.kernel.exception.SystemException {
192                    try {
193                            MethodKey methodKey = new MethodKey(PermissionServiceUtil.class.getName(),
194                                            "hasUserPermission", long.class, java.lang.String.class,
195                                            long.class);
196    
197                            MethodHandler methodHandler = new MethodHandler(methodKey, userId,
198                                            actionId, resourceId);
199    
200                            Object returnObj = null;
201    
202                            try {
203                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodHandler);
204                            }
205                            catch (Exception e) {
206                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
207                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
208                                    }
209    
210                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
211                            }
212    
213                            return ((Boolean)returnObj).booleanValue();
214                    }
215                    catch (com.liferay.portal.kernel.exception.SystemException se) {
216                            _log.error(se, se);
217    
218                            throw se;
219                    }
220            }
221    
222            public static boolean hasUserPermissions(HttpPrincipal httpPrincipal,
223                    long userId, long groupId,
224                    java.util.List<com.liferay.portal.model.Resource> resources,
225                    java.lang.String actionId,
226                    com.liferay.portal.security.permission.PermissionCheckerBag permissionCheckerBag)
227                    throws com.liferay.portal.kernel.exception.PortalException,
228                            com.liferay.portal.kernel.exception.SystemException {
229                    try {
230                            MethodKey methodKey = new MethodKey(PermissionServiceUtil.class.getName(),
231                                            "hasUserPermissions", long.class, long.class,
232                                            java.util.List.class, java.lang.String.class,
233                                            com.liferay.portal.security.permission.PermissionCheckerBag.class);
234    
235                            MethodHandler methodHandler = new MethodHandler(methodKey, userId,
236                                            groupId, resources, actionId, permissionCheckerBag);
237    
238                            Object returnObj = null;
239    
240                            try {
241                                    returnObj = TunnelUtil.invoke(httpPrincipal, methodHandler);
242                            }
243                            catch (Exception e) {
244                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
245                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
246                                    }
247    
248                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
249                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
250                                    }
251    
252                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
253                            }
254    
255                            return ((Boolean)returnObj).booleanValue();
256                    }
257                    catch (com.liferay.portal.kernel.exception.SystemException se) {
258                            _log.error(se, se);
259    
260                            throw se;
261                    }
262            }
263    
264            public static void setGroupPermissions(HttpPrincipal httpPrincipal,
265                    long groupId, java.lang.String[] actionIds, long resourceId)
266                    throws com.liferay.portal.kernel.exception.PortalException,
267                            com.liferay.portal.kernel.exception.SystemException {
268                    try {
269                            MethodKey methodKey = new MethodKey(PermissionServiceUtil.class.getName(),
270                                            "setGroupPermissions", long.class,
271                                            java.lang.String[].class, long.class);
272    
273                            MethodHandler methodHandler = new MethodHandler(methodKey, groupId,
274                                            actionIds, resourceId);
275    
276                            try {
277                                    TunnelUtil.invoke(httpPrincipal, methodHandler);
278                            }
279                            catch (Exception e) {
280                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
281                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
282                                    }
283    
284                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
285                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
286                                    }
287    
288                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
289                            }
290                    }
291                    catch (com.liferay.portal.kernel.exception.SystemException se) {
292                            _log.error(se, se);
293    
294                            throw se;
295                    }
296            }
297    
298            public static void setGroupPermissions(HttpPrincipal httpPrincipal,
299                    java.lang.String className, java.lang.String classPK, long groupId,
300                    java.lang.String[] actionIds, long resourceId)
301                    throws com.liferay.portal.kernel.exception.PortalException,
302                            com.liferay.portal.kernel.exception.SystemException {
303                    try {
304                            MethodKey methodKey = new MethodKey(PermissionServiceUtil.class.getName(),
305                                            "setGroupPermissions", java.lang.String.class,
306                                            java.lang.String.class, long.class,
307                                            java.lang.String[].class, long.class);
308    
309                            MethodHandler methodHandler = new MethodHandler(methodKey,
310                                            className, classPK, groupId, actionIds, resourceId);
311    
312                            try {
313                                    TunnelUtil.invoke(httpPrincipal, methodHandler);
314                            }
315                            catch (Exception e) {
316                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
317                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
318                                    }
319    
320                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
321                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
322                                    }
323    
324                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
325                            }
326                    }
327                    catch (com.liferay.portal.kernel.exception.SystemException se) {
328                            _log.error(se, se);
329    
330                            throw se;
331                    }
332            }
333    
334            public static void setOrgGroupPermissions(HttpPrincipal httpPrincipal,
335                    long organizationId, long groupId, java.lang.String[] actionIds,
336                    long resourceId)
337                    throws com.liferay.portal.kernel.exception.PortalException,
338                            com.liferay.portal.kernel.exception.SystemException {
339                    try {
340                            MethodKey methodKey = new MethodKey(PermissionServiceUtil.class.getName(),
341                                            "setOrgGroupPermissions", long.class, long.class,
342                                            java.lang.String[].class, long.class);
343    
344                            MethodHandler methodHandler = new MethodHandler(methodKey,
345                                            organizationId, groupId, actionIds, resourceId);
346    
347                            try {
348                                    TunnelUtil.invoke(httpPrincipal, methodHandler);
349                            }
350                            catch (Exception e) {
351                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
352                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
353                                    }
354    
355                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
356                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
357                                    }
358    
359                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
360                            }
361                    }
362                    catch (com.liferay.portal.kernel.exception.SystemException se) {
363                            _log.error(se, se);
364    
365                            throw se;
366                    }
367            }
368    
369            public static void setRolePermission(HttpPrincipal httpPrincipal,
370                    long roleId, long groupId, java.lang.String name, int scope,
371                    java.lang.String primKey, java.lang.String actionId)
372                    throws com.liferay.portal.kernel.exception.PortalException,
373                            com.liferay.portal.kernel.exception.SystemException {
374                    try {
375                            MethodKey methodKey = new MethodKey(PermissionServiceUtil.class.getName(),
376                                            "setRolePermission", long.class, long.class,
377                                            java.lang.String.class, int.class, java.lang.String.class,
378                                            java.lang.String.class);
379    
380                            MethodHandler methodHandler = new MethodHandler(methodKey, roleId,
381                                            groupId, name, scope, primKey, actionId);
382    
383                            try {
384                                    TunnelUtil.invoke(httpPrincipal, methodHandler);
385                            }
386                            catch (Exception e) {
387                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
388                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
389                                    }
390    
391                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
392                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
393                                    }
394    
395                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
396                            }
397                    }
398                    catch (com.liferay.portal.kernel.exception.SystemException se) {
399                            _log.error(se, se);
400    
401                            throw se;
402                    }
403            }
404    
405            public static void setRolePermissions(HttpPrincipal httpPrincipal,
406                    long roleId, long groupId, java.lang.String[] actionIds, long resourceId)
407                    throws com.liferay.portal.kernel.exception.PortalException,
408                            com.liferay.portal.kernel.exception.SystemException {
409                    try {
410                            MethodKey methodKey = new MethodKey(PermissionServiceUtil.class.getName(),
411                                            "setRolePermissions", long.class, long.class,
412                                            java.lang.String[].class, long.class);
413    
414                            MethodHandler methodHandler = new MethodHandler(methodKey, roleId,
415                                            groupId, actionIds, resourceId);
416    
417                            try {
418                                    TunnelUtil.invoke(httpPrincipal, methodHandler);
419                            }
420                            catch (Exception e) {
421                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
422                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
423                                    }
424    
425                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
426                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
427                                    }
428    
429                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
430                            }
431                    }
432                    catch (com.liferay.portal.kernel.exception.SystemException se) {
433                            _log.error(se, se);
434    
435                            throw se;
436                    }
437            }
438    
439            public static void setUserPermissions(HttpPrincipal httpPrincipal,
440                    long userId, long groupId, java.lang.String[] actionIds, long resourceId)
441                    throws com.liferay.portal.kernel.exception.PortalException,
442                            com.liferay.portal.kernel.exception.SystemException {
443                    try {
444                            MethodKey methodKey = new MethodKey(PermissionServiceUtil.class.getName(),
445                                            "setUserPermissions", long.class, long.class,
446                                            java.lang.String[].class, long.class);
447    
448                            MethodHandler methodHandler = new MethodHandler(methodKey, userId,
449                                            groupId, actionIds, resourceId);
450    
451                            try {
452                                    TunnelUtil.invoke(httpPrincipal, methodHandler);
453                            }
454                            catch (Exception e) {
455                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
456                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
457                                    }
458    
459                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
460                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
461                                    }
462    
463                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
464                            }
465                    }
466                    catch (com.liferay.portal.kernel.exception.SystemException se) {
467                            _log.error(se, se);
468    
469                            throw se;
470                    }
471            }
472    
473            public static void unsetRolePermission(HttpPrincipal httpPrincipal,
474                    long roleId, long groupId, long permissionId)
475                    throws com.liferay.portal.kernel.exception.PortalException,
476                            com.liferay.portal.kernel.exception.SystemException {
477                    try {
478                            MethodKey methodKey = new MethodKey(PermissionServiceUtil.class.getName(),
479                                            "unsetRolePermission", long.class, long.class, long.class);
480    
481                            MethodHandler methodHandler = new MethodHandler(methodKey, roleId,
482                                            groupId, permissionId);
483    
484                            try {
485                                    TunnelUtil.invoke(httpPrincipal, methodHandler);
486                            }
487                            catch (Exception e) {
488                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
489                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
490                                    }
491    
492                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
493                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
494                                    }
495    
496                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
497                            }
498                    }
499                    catch (com.liferay.portal.kernel.exception.SystemException se) {
500                            _log.error(se, se);
501    
502                            throw se;
503                    }
504            }
505    
506            public static void unsetRolePermission(HttpPrincipal httpPrincipal,
507                    long roleId, long groupId, java.lang.String name, int scope,
508                    java.lang.String primKey, java.lang.String actionId)
509                    throws com.liferay.portal.kernel.exception.PortalException,
510                            com.liferay.portal.kernel.exception.SystemException {
511                    try {
512                            MethodKey methodKey = new MethodKey(PermissionServiceUtil.class.getName(),
513                                            "unsetRolePermission", long.class, long.class,
514                                            java.lang.String.class, int.class, java.lang.String.class,
515                                            java.lang.String.class);
516    
517                            MethodHandler methodHandler = new MethodHandler(methodKey, roleId,
518                                            groupId, name, scope, primKey, actionId);
519    
520                            try {
521                                    TunnelUtil.invoke(httpPrincipal, methodHandler);
522                            }
523                            catch (Exception e) {
524                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
525                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
526                                    }
527    
528                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
529                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
530                                    }
531    
532                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
533                            }
534                    }
535                    catch (com.liferay.portal.kernel.exception.SystemException se) {
536                            _log.error(se, se);
537    
538                            throw se;
539                    }
540            }
541    
542            public static void unsetRolePermissions(HttpPrincipal httpPrincipal,
543                    long roleId, long groupId, java.lang.String name, int scope,
544                    java.lang.String actionId)
545                    throws com.liferay.portal.kernel.exception.PortalException,
546                            com.liferay.portal.kernel.exception.SystemException {
547                    try {
548                            MethodKey methodKey = new MethodKey(PermissionServiceUtil.class.getName(),
549                                            "unsetRolePermissions", long.class, long.class,
550                                            java.lang.String.class, int.class, java.lang.String.class);
551    
552                            MethodHandler methodHandler = new MethodHandler(methodKey, roleId,
553                                            groupId, name, scope, actionId);
554    
555                            try {
556                                    TunnelUtil.invoke(httpPrincipal, methodHandler);
557                            }
558                            catch (Exception e) {
559                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
560                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
561                                    }
562    
563                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
564                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
565                                    }
566    
567                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
568                            }
569                    }
570                    catch (com.liferay.portal.kernel.exception.SystemException se) {
571                            _log.error(se, se);
572    
573                            throw se;
574                    }
575            }
576    
577            public static void unsetUserPermissions(HttpPrincipal httpPrincipal,
578                    long userId, long groupId, java.lang.String[] actionIds, long resourceId)
579                    throws com.liferay.portal.kernel.exception.PortalException,
580                            com.liferay.portal.kernel.exception.SystemException {
581                    try {
582                            MethodKey methodKey = new MethodKey(PermissionServiceUtil.class.getName(),
583                                            "unsetUserPermissions", long.class, long.class,
584                                            java.lang.String[].class, long.class);
585    
586                            MethodHandler methodHandler = new MethodHandler(methodKey, userId,
587                                            groupId, actionIds, resourceId);
588    
589                            try {
590                                    TunnelUtil.invoke(httpPrincipal, methodHandler);
591                            }
592                            catch (Exception e) {
593                                    if (e instanceof com.liferay.portal.kernel.exception.PortalException) {
594                                            throw (com.liferay.portal.kernel.exception.PortalException)e;
595                                    }
596    
597                                    if (e instanceof com.liferay.portal.kernel.exception.SystemException) {
598                                            throw (com.liferay.portal.kernel.exception.SystemException)e;
599                                    }
600    
601                                    throw new com.liferay.portal.kernel.exception.SystemException(e);
602                            }
603                    }
604                    catch (com.liferay.portal.kernel.exception.SystemException se) {
605                            _log.error(se, se);
606    
607                            throw se;
608                    }
609            }
610    
611            private static Log _log = LogFactoryUtil.getLog(PermissionServiceHttp.class);
612    }