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.persistence;
24  
25  import com.liferay.portal.NoSuchPermissionException;
26  import com.liferay.portal.SystemException;
27  import com.liferay.portal.kernel.annotation.BeanReference;
28  import com.liferay.portal.kernel.cache.CacheRegistry;
29  import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
30  import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
31  import com.liferay.portal.kernel.dao.jdbc.RowMapper;
32  import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
33  import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
34  import com.liferay.portal.kernel.dao.orm.DynamicQuery;
35  import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
36  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
37  import com.liferay.portal.kernel.dao.orm.FinderPath;
38  import com.liferay.portal.kernel.dao.orm.Query;
39  import com.liferay.portal.kernel.dao.orm.QueryPos;
40  import com.liferay.portal.kernel.dao.orm.QueryUtil;
41  import com.liferay.portal.kernel.dao.orm.SQLQuery;
42  import com.liferay.portal.kernel.dao.orm.Session;
43  import com.liferay.portal.kernel.dao.orm.Type;
44  import com.liferay.portal.kernel.log.Log;
45  import com.liferay.portal.kernel.log.LogFactoryUtil;
46  import com.liferay.portal.kernel.util.GetterUtil;
47  import com.liferay.portal.kernel.util.OrderByComparator;
48  import com.liferay.portal.kernel.util.SetUtil;
49  import com.liferay.portal.kernel.util.StringPool;
50  import com.liferay.portal.kernel.util.StringUtil;
51  import com.liferay.portal.kernel.util.Validator;
52  import com.liferay.portal.model.ModelListener;
53  import com.liferay.portal.model.Permission;
54  import com.liferay.portal.model.impl.PermissionImpl;
55  import com.liferay.portal.model.impl.PermissionModelImpl;
56  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
57  
58  import java.sql.Types;
59  
60  import java.util.ArrayList;
61  import java.util.Collections;
62  import java.util.List;
63  import java.util.Set;
64  
65  /**
66   * <a href="PermissionPersistenceImpl.java.html"><b><i>View Source</i></b></a>
67   *
68   * <p>
69   * ServiceBuilder generated this class. Modifications in this class will be
70   * overwritten the next time is generated.
71   * </p>
72   *
73   * @author    Brian Wing Shun Chan
74   * @see       PermissionPersistence
75   * @see       PermissionUtil
76   * @generated
77   */
78  public class PermissionPersistenceImpl extends BasePersistenceImpl
79      implements PermissionPersistence {
80      public static final String FINDER_CLASS_NAME_ENTITY = PermissionImpl.class.getName();
81      public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
82          ".List";
83      public static final FinderPath FINDER_PATH_FIND_BY_RESOURCEID = new FinderPath(PermissionModelImpl.ENTITY_CACHE_ENABLED,
84              PermissionModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
85              "findByResourceId", new String[] { Long.class.getName() });
86      public static final FinderPath FINDER_PATH_FIND_BY_OBC_RESOURCEID = new FinderPath(PermissionModelImpl.ENTITY_CACHE_ENABLED,
87              PermissionModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
88              "findByResourceId",
89              new String[] {
90                  Long.class.getName(),
91                  
92              "java.lang.Integer", "java.lang.Integer",
93                  "com.liferay.portal.kernel.util.OrderByComparator"
94              });
95      public static final FinderPath FINDER_PATH_COUNT_BY_RESOURCEID = new FinderPath(PermissionModelImpl.ENTITY_CACHE_ENABLED,
96              PermissionModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
97              "countByResourceId", new String[] { Long.class.getName() });
98      public static final FinderPath FINDER_PATH_FETCH_BY_A_R = new FinderPath(PermissionModelImpl.ENTITY_CACHE_ENABLED,
99              PermissionModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
100             "fetchByA_R",
101             new String[] { String.class.getName(), Long.class.getName() });
102     public static final FinderPath FINDER_PATH_COUNT_BY_A_R = new FinderPath(PermissionModelImpl.ENTITY_CACHE_ENABLED,
103             PermissionModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
104             "countByA_R",
105             new String[] { String.class.getName(), Long.class.getName() });
106     public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(PermissionModelImpl.ENTITY_CACHE_ENABLED,
107             PermissionModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
108             "findAll", new String[0]);
109     public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(PermissionModelImpl.ENTITY_CACHE_ENABLED,
110             PermissionModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
111             "countAll", new String[0]);
112 
113     public void cacheResult(Permission permission) {
114         EntityCacheUtil.putResult(PermissionModelImpl.ENTITY_CACHE_ENABLED,
115             PermissionImpl.class, permission.getPrimaryKey(), permission);
116 
117         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_A_R,
118             new Object[] {
119                 permission.getActionId(), new Long(permission.getResourceId())
120             }, permission);
121     }
122 
123     public void cacheResult(List<Permission> permissions) {
124         for (Permission permission : permissions) {
125             if (EntityCacheUtil.getResult(
126                         PermissionModelImpl.ENTITY_CACHE_ENABLED,
127                         PermissionImpl.class, permission.getPrimaryKey(), this) == null) {
128                 cacheResult(permission);
129             }
130         }
131     }
132 
133     public void clearCache() {
134         CacheRegistry.clear(PermissionImpl.class.getName());
135         EntityCacheUtil.clearCache(PermissionImpl.class.getName());
136         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
137         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
138     }
139 
140     public Permission create(long permissionId) {
141         Permission permission = new PermissionImpl();
142 
143         permission.setNew(true);
144         permission.setPrimaryKey(permissionId);
145 
146         return permission;
147     }
148 
149     public Permission remove(long permissionId)
150         throws NoSuchPermissionException, SystemException {
151         Session session = null;
152 
153         try {
154             session = openSession();
155 
156             Permission permission = (Permission)session.get(PermissionImpl.class,
157                     new Long(permissionId));
158 
159             if (permission == null) {
160                 if (_log.isWarnEnabled()) {
161                     _log.warn("No Permission exists with the primary key " +
162                         permissionId);
163                 }
164 
165                 throw new NoSuchPermissionException(
166                     "No Permission exists with the primary key " +
167                     permissionId);
168             }
169 
170             return remove(permission);
171         }
172         catch (NoSuchPermissionException nsee) {
173             throw nsee;
174         }
175         catch (Exception e) {
176             throw processException(e);
177         }
178         finally {
179             closeSession(session);
180         }
181     }
182 
183     public Permission remove(Permission permission) throws SystemException {
184         for (ModelListener<Permission> listener : listeners) {
185             listener.onBeforeRemove(permission);
186         }
187 
188         permission = removeImpl(permission);
189 
190         for (ModelListener<Permission> listener : listeners) {
191             listener.onAfterRemove(permission);
192         }
193 
194         return permission;
195     }
196 
197     protected Permission removeImpl(Permission permission)
198         throws SystemException {
199         permission = toUnwrappedModel(permission);
200 
201         try {
202             clearGroups.clear(permission.getPrimaryKey());
203         }
204         catch (Exception e) {
205             throw processException(e);
206         }
207         finally {
208             FinderCacheUtil.clearCache("Groups_Permissions");
209         }
210 
211         try {
212             clearRoles.clear(permission.getPrimaryKey());
213         }
214         catch (Exception e) {
215             throw processException(e);
216         }
217         finally {
218             FinderCacheUtil.clearCache("Roles_Permissions");
219         }
220 
221         try {
222             clearUsers.clear(permission.getPrimaryKey());
223         }
224         catch (Exception e) {
225             throw processException(e);
226         }
227         finally {
228             FinderCacheUtil.clearCache("Users_Permissions");
229         }
230 
231         Session session = null;
232 
233         try {
234             session = openSession();
235 
236             if (permission.isCachedModel() || BatchSessionUtil.isEnabled()) {
237                 Object staleObject = session.get(PermissionImpl.class,
238                         permission.getPrimaryKeyObj());
239 
240                 if (staleObject != null) {
241                     session.evict(staleObject);
242                 }
243             }
244 
245             session.delete(permission);
246 
247             session.flush();
248         }
249         catch (Exception e) {
250             throw processException(e);
251         }
252         finally {
253             closeSession(session);
254         }
255 
256         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
257 
258         PermissionModelImpl permissionModelImpl = (PermissionModelImpl)permission;
259 
260         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_A_R,
261             new Object[] {
262                 permissionModelImpl.getOriginalActionId(),
263                 new Long(permissionModelImpl.getOriginalResourceId())
264             });
265 
266         EntityCacheUtil.removeResult(PermissionModelImpl.ENTITY_CACHE_ENABLED,
267             PermissionImpl.class, permission.getPrimaryKey());
268 
269         return permission;
270     }
271 
272     /**
273      * @deprecated Use {@link #update(Permission, boolean merge)}.
274      */
275     public Permission update(Permission permission) throws SystemException {
276         if (_log.isWarnEnabled()) {
277             _log.warn(
278                 "Using the deprecated update(Permission permission) method. Use update(Permission permission, boolean merge) instead.");
279         }
280 
281         return update(permission, false);
282     }
283 
284     /**
285      * Add, update, or merge, the entity. This method also calls the model
286      * listeners to trigger the proper events associated with adding, deleting,
287      * or updating an entity.
288      *
289      * @param  permission the entity to add, update, or merge
290      * @param  merge boolean value for whether to merge the entity. The default
291      *         value is false. Setting merge to true is more expensive and
292      *         should only be true when permission is transient. See
293      *         LEP-5473 for a detailed discussion of this method.
294      * @return the entity that was added, updated, or merged
295      */
296     public Permission update(Permission permission, boolean merge)
297         throws SystemException {
298         boolean isNew = permission.isNew();
299 
300         for (ModelListener<Permission> listener : listeners) {
301             if (isNew) {
302                 listener.onBeforeCreate(permission);
303             }
304             else {
305                 listener.onBeforeUpdate(permission);
306             }
307         }
308 
309         permission = updateImpl(permission, merge);
310 
311         for (ModelListener<Permission> listener : listeners) {
312             if (isNew) {
313                 listener.onAfterCreate(permission);
314             }
315             else {
316                 listener.onAfterUpdate(permission);
317             }
318         }
319 
320         return permission;
321     }
322 
323     public Permission updateImpl(
324         com.liferay.portal.model.Permission permission, boolean merge)
325         throws SystemException {
326         permission = toUnwrappedModel(permission);
327 
328         boolean isNew = permission.isNew();
329 
330         PermissionModelImpl permissionModelImpl = (PermissionModelImpl)permission;
331 
332         Session session = null;
333 
334         try {
335             session = openSession();
336 
337             BatchSessionUtil.update(session, permission, merge);
338 
339             permission.setNew(false);
340         }
341         catch (Exception e) {
342             throw processException(e);
343         }
344         finally {
345             closeSession(session);
346         }
347 
348         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
349 
350         EntityCacheUtil.putResult(PermissionModelImpl.ENTITY_CACHE_ENABLED,
351             PermissionImpl.class, permission.getPrimaryKey(), permission);
352 
353         if (!isNew &&
354                 (!Validator.equals(permission.getActionId(),
355                     permissionModelImpl.getOriginalActionId()) ||
356                 (permission.getResourceId() != permissionModelImpl.getOriginalResourceId()))) {
357             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_A_R,
358                 new Object[] {
359                     permissionModelImpl.getOriginalActionId(),
360                     new Long(permissionModelImpl.getOriginalResourceId())
361                 });
362         }
363 
364         if (isNew ||
365                 (!Validator.equals(permission.getActionId(),
366                     permissionModelImpl.getOriginalActionId()) ||
367                 (permission.getResourceId() != permissionModelImpl.getOriginalResourceId()))) {
368             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_A_R,
369                 new Object[] {
370                     permission.getActionId(),
371                     new Long(permission.getResourceId())
372                 }, permission);
373         }
374 
375         return permission;
376     }
377 
378     protected Permission toUnwrappedModel(Permission permission) {
379         if (permission instanceof PermissionImpl) {
380             return permission;
381         }
382 
383         PermissionImpl permissionImpl = new PermissionImpl();
384 
385         permissionImpl.setNew(permission.isNew());
386         permissionImpl.setPrimaryKey(permission.getPrimaryKey());
387 
388         permissionImpl.setPermissionId(permission.getPermissionId());
389         permissionImpl.setCompanyId(permission.getCompanyId());
390         permissionImpl.setActionId(permission.getActionId());
391         permissionImpl.setResourceId(permission.getResourceId());
392 
393         return permissionImpl;
394     }
395 
396     public Permission findByPrimaryKey(long permissionId)
397         throws NoSuchPermissionException, SystemException {
398         Permission permission = fetchByPrimaryKey(permissionId);
399 
400         if (permission == null) {
401             if (_log.isWarnEnabled()) {
402                 _log.warn("No Permission exists with the primary key " +
403                     permissionId);
404             }
405 
406             throw new NoSuchPermissionException(
407                 "No Permission exists with the primary key " + permissionId);
408         }
409 
410         return permission;
411     }
412 
413     public Permission fetchByPrimaryKey(long permissionId)
414         throws SystemException {
415         Permission permission = (Permission)EntityCacheUtil.getResult(PermissionModelImpl.ENTITY_CACHE_ENABLED,
416                 PermissionImpl.class, permissionId, this);
417 
418         if (permission == null) {
419             Session session = null;
420 
421             try {
422                 session = openSession();
423 
424                 permission = (Permission)session.get(PermissionImpl.class,
425                         new Long(permissionId));
426             }
427             catch (Exception e) {
428                 throw processException(e);
429             }
430             finally {
431                 if (permission != null) {
432                     cacheResult(permission);
433                 }
434 
435                 closeSession(session);
436             }
437         }
438 
439         return permission;
440     }
441 
442     public List<Permission> findByResourceId(long resourceId)
443         throws SystemException {
444         Object[] finderArgs = new Object[] { new Long(resourceId) };
445 
446         List<Permission> list = (List<Permission>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_RESOURCEID,
447                 finderArgs, this);
448 
449         if (list == null) {
450             Session session = null;
451 
452             try {
453                 session = openSession();
454 
455                 StringBuilder query = new StringBuilder();
456 
457                 query.append(
458                     "SELECT permission FROM Permission permission WHERE ");
459 
460                 query.append("permission.resourceId = ?");
461 
462                 query.append(" ");
463 
464                 Query q = session.createQuery(query.toString());
465 
466                 QueryPos qPos = QueryPos.getInstance(q);
467 
468                 qPos.add(resourceId);
469 
470                 list = q.list();
471             }
472             catch (Exception e) {
473                 throw processException(e);
474             }
475             finally {
476                 if (list == null) {
477                     list = new ArrayList<Permission>();
478                 }
479 
480                 cacheResult(list);
481 
482                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_RESOURCEID,
483                     finderArgs, list);
484 
485                 closeSession(session);
486             }
487         }
488 
489         return list;
490     }
491 
492     public List<Permission> findByResourceId(long resourceId, int start, int end)
493         throws SystemException {
494         return findByResourceId(resourceId, start, end, null);
495     }
496 
497     public List<Permission> findByResourceId(long resourceId, int start,
498         int end, OrderByComparator obc) throws SystemException {
499         Object[] finderArgs = new Object[] {
500                 new Long(resourceId),
501                 
502                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
503             };
504 
505         List<Permission> list = (List<Permission>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_RESOURCEID,
506                 finderArgs, this);
507 
508         if (list == null) {
509             Session session = null;
510 
511             try {
512                 session = openSession();
513 
514                 StringBuilder query = new StringBuilder();
515 
516                 query.append(
517                     "SELECT permission FROM Permission permission WHERE ");
518 
519                 query.append("permission.resourceId = ?");
520 
521                 query.append(" ");
522 
523                 if (obc != null) {
524                     query.append("ORDER BY ");
525 
526                     String[] orderByFields = obc.getOrderByFields();
527 
528                     for (int i = 0; i < orderByFields.length; i++) {
529                         query.append("permission.");
530                         query.append(orderByFields[i]);
531 
532                         if (obc.isAscending()) {
533                             query.append(" ASC");
534                         }
535                         else {
536                             query.append(" DESC");
537                         }
538 
539                         if ((i + 1) < orderByFields.length) {
540                             query.append(", ");
541                         }
542                     }
543                 }
544 
545                 Query q = session.createQuery(query.toString());
546 
547                 QueryPos qPos = QueryPos.getInstance(q);
548 
549                 qPos.add(resourceId);
550 
551                 list = (List<Permission>)QueryUtil.list(q, getDialect(), start,
552                         end);
553             }
554             catch (Exception e) {
555                 throw processException(e);
556             }
557             finally {
558                 if (list == null) {
559                     list = new ArrayList<Permission>();
560                 }
561 
562                 cacheResult(list);
563 
564                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_RESOURCEID,
565                     finderArgs, list);
566 
567                 closeSession(session);
568             }
569         }
570 
571         return list;
572     }
573 
574     public Permission findByResourceId_First(long resourceId,
575         OrderByComparator obc)
576         throws NoSuchPermissionException, SystemException {
577         List<Permission> list = findByResourceId(resourceId, 0, 1, obc);
578 
579         if (list.isEmpty()) {
580             StringBuilder msg = new StringBuilder();
581 
582             msg.append("No Permission exists with the key {");
583 
584             msg.append("resourceId=" + resourceId);
585 
586             msg.append(StringPool.CLOSE_CURLY_BRACE);
587 
588             throw new NoSuchPermissionException(msg.toString());
589         }
590         else {
591             return list.get(0);
592         }
593     }
594 
595     public Permission findByResourceId_Last(long resourceId,
596         OrderByComparator obc)
597         throws NoSuchPermissionException, SystemException {
598         int count = countByResourceId(resourceId);
599 
600         List<Permission> list = findByResourceId(resourceId, count - 1, count,
601                 obc);
602 
603         if (list.isEmpty()) {
604             StringBuilder msg = new StringBuilder();
605 
606             msg.append("No Permission exists with the key {");
607 
608             msg.append("resourceId=" + resourceId);
609 
610             msg.append(StringPool.CLOSE_CURLY_BRACE);
611 
612             throw new NoSuchPermissionException(msg.toString());
613         }
614         else {
615             return list.get(0);
616         }
617     }
618 
619     public Permission[] findByResourceId_PrevAndNext(long permissionId,
620         long resourceId, OrderByComparator obc)
621         throws NoSuchPermissionException, SystemException {
622         Permission permission = findByPrimaryKey(permissionId);
623 
624         int count = countByResourceId(resourceId);
625 
626         Session session = null;
627 
628         try {
629             session = openSession();
630 
631             StringBuilder query = new StringBuilder();
632 
633             query.append("SELECT permission FROM Permission permission WHERE ");
634 
635             query.append("permission.resourceId = ?");
636 
637             query.append(" ");
638 
639             if (obc != null) {
640                 query.append("ORDER BY ");
641 
642                 String[] orderByFields = obc.getOrderByFields();
643 
644                 for (int i = 0; i < orderByFields.length; i++) {
645                     query.append("permission.");
646                     query.append(orderByFields[i]);
647 
648                     if (obc.isAscending()) {
649                         query.append(" ASC");
650                     }
651                     else {
652                         query.append(" DESC");
653                     }
654 
655                     if ((i + 1) < orderByFields.length) {
656                         query.append(", ");
657                     }
658                 }
659             }
660 
661             Query q = session.createQuery(query.toString());
662 
663             QueryPos qPos = QueryPos.getInstance(q);
664 
665             qPos.add(resourceId);
666 
667             Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
668                     permission);
669 
670             Permission[] array = new PermissionImpl[3];
671 
672             array[0] = (Permission)objArray[0];
673             array[1] = (Permission)objArray[1];
674             array[2] = (Permission)objArray[2];
675 
676             return array;
677         }
678         catch (Exception e) {
679             throw processException(e);
680         }
681         finally {
682             closeSession(session);
683         }
684     }
685 
686     public Permission findByA_R(String actionId, long resourceId)
687         throws NoSuchPermissionException, SystemException {
688         Permission permission = fetchByA_R(actionId, resourceId);
689 
690         if (permission == null) {
691             StringBuilder msg = new StringBuilder();
692 
693             msg.append("No Permission exists with the key {");
694 
695             msg.append("actionId=" + actionId);
696 
697             msg.append(", ");
698             msg.append("resourceId=" + resourceId);
699 
700             msg.append(StringPool.CLOSE_CURLY_BRACE);
701 
702             if (_log.isWarnEnabled()) {
703                 _log.warn(msg.toString());
704             }
705 
706             throw new NoSuchPermissionException(msg.toString());
707         }
708 
709         return permission;
710     }
711 
712     public Permission fetchByA_R(String actionId, long resourceId)
713         throws SystemException {
714         return fetchByA_R(actionId, resourceId, true);
715     }
716 
717     public Permission fetchByA_R(String actionId, long resourceId,
718         boolean retrieveFromCache) throws SystemException {
719         Object[] finderArgs = new Object[] { actionId, new Long(resourceId) };
720 
721         Object result = null;
722 
723         if (retrieveFromCache) {
724             result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_A_R,
725                     finderArgs, this);
726         }
727 
728         if (result == null) {
729             Session session = null;
730 
731             try {
732                 session = openSession();
733 
734                 StringBuilder query = new StringBuilder();
735 
736                 query.append(
737                     "SELECT permission FROM Permission permission WHERE ");
738 
739                 if (actionId == null) {
740                     query.append("permission.actionId IS NULL");
741                 }
742                 else {
743                     query.append("permission.actionId = ?");
744                 }
745 
746                 query.append(" AND ");
747 
748                 query.append("permission.resourceId = ?");
749 
750                 query.append(" ");
751 
752                 Query q = session.createQuery(query.toString());
753 
754                 QueryPos qPos = QueryPos.getInstance(q);
755 
756                 if (actionId != null) {
757                     qPos.add(actionId);
758                 }
759 
760                 qPos.add(resourceId);
761 
762                 List<Permission> list = q.list();
763 
764                 result = list;
765 
766                 Permission permission = null;
767 
768                 if (list.isEmpty()) {
769                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_A_R,
770                         finderArgs, list);
771                 }
772                 else {
773                     permission = list.get(0);
774 
775                     cacheResult(permission);
776 
777                     if ((permission.getActionId() == null) ||
778                             !permission.getActionId().equals(actionId) ||
779                             (permission.getResourceId() != resourceId)) {
780                         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_A_R,
781                             finderArgs, permission);
782                     }
783                 }
784 
785                 return permission;
786             }
787             catch (Exception e) {
788                 throw processException(e);
789             }
790             finally {
791                 if (result == null) {
792                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_A_R,
793                         finderArgs, new ArrayList<Permission>());
794                 }
795 
796                 closeSession(session);
797             }
798         }
799         else {
800             if (result instanceof List<?>) {
801                 return null;
802             }
803             else {
804                 return (Permission)result;
805             }
806         }
807     }
808 
809     public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
810         throws SystemException {
811         Session session = null;
812 
813         try {
814             session = openSession();
815 
816             dynamicQuery.compile(session);
817 
818             return dynamicQuery.list();
819         }
820         catch (Exception e) {
821             throw processException(e);
822         }
823         finally {
824             closeSession(session);
825         }
826     }
827 
828     public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
829         int start, int end) throws SystemException {
830         Session session = null;
831 
832         try {
833             session = openSession();
834 
835             dynamicQuery.setLimit(start, end);
836 
837             dynamicQuery.compile(session);
838 
839             return dynamicQuery.list();
840         }
841         catch (Exception e) {
842             throw processException(e);
843         }
844         finally {
845             closeSession(session);
846         }
847     }
848 
849     public List<Permission> findAll() throws SystemException {
850         return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
851     }
852 
853     public List<Permission> findAll(int start, int end)
854         throws SystemException {
855         return findAll(start, end, null);
856     }
857 
858     public List<Permission> findAll(int start, int end, OrderByComparator obc)
859         throws SystemException {
860         Object[] finderArgs = new Object[] {
861                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
862             };
863 
864         List<Permission> list = (List<Permission>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
865                 finderArgs, this);
866 
867         if (list == null) {
868             Session session = null;
869 
870             try {
871                 session = openSession();
872 
873                 StringBuilder query = new StringBuilder();
874 
875                 query.append("SELECT permission FROM Permission permission ");
876 
877                 if (obc != null) {
878                     query.append("ORDER BY ");
879 
880                     String[] orderByFields = obc.getOrderByFields();
881 
882                     for (int i = 0; i < orderByFields.length; i++) {
883                         query.append("permission.");
884                         query.append(orderByFields[i]);
885 
886                         if (obc.isAscending()) {
887                             query.append(" ASC");
888                         }
889                         else {
890                             query.append(" DESC");
891                         }
892 
893                         if ((i + 1) < orderByFields.length) {
894                             query.append(", ");
895                         }
896                     }
897                 }
898 
899                 Query q = session.createQuery(query.toString());
900 
901                 if (obc == null) {
902                     list = (List<Permission>)QueryUtil.list(q, getDialect(),
903                             start, end, false);
904 
905                     Collections.sort(list);
906                 }
907                 else {
908                     list = (List<Permission>)QueryUtil.list(q, getDialect(),
909                             start, end);
910                 }
911             }
912             catch (Exception e) {
913                 throw processException(e);
914             }
915             finally {
916                 if (list == null) {
917                     list = new ArrayList<Permission>();
918                 }
919 
920                 cacheResult(list);
921 
922                 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
923 
924                 closeSession(session);
925             }
926         }
927 
928         return list;
929     }
930 
931     public void removeByResourceId(long resourceId) throws SystemException {
932         for (Permission permission : findByResourceId(resourceId)) {
933             remove(permission);
934         }
935     }
936 
937     public void removeByA_R(String actionId, long resourceId)
938         throws NoSuchPermissionException, SystemException {
939         Permission permission = findByA_R(actionId, resourceId);
940 
941         remove(permission);
942     }
943 
944     public void removeAll() throws SystemException {
945         for (Permission permission : findAll()) {
946             remove(permission);
947         }
948     }
949 
950     public int countByResourceId(long resourceId) throws SystemException {
951         Object[] finderArgs = new Object[] { new Long(resourceId) };
952 
953         Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RESOURCEID,
954                 finderArgs, this);
955 
956         if (count == null) {
957             Session session = null;
958 
959             try {
960                 session = openSession();
961 
962                 StringBuilder query = new StringBuilder();
963 
964                 query.append("SELECT COUNT(permission) ");
965                 query.append("FROM Permission permission WHERE ");
966 
967                 query.append("permission.resourceId = ?");
968 
969                 query.append(" ");
970 
971                 Query q = session.createQuery(query.toString());
972 
973                 QueryPos qPos = QueryPos.getInstance(q);
974 
975                 qPos.add(resourceId);
976 
977                 count = (Long)q.uniqueResult();
978             }
979             catch (Exception e) {
980                 throw processException(e);
981             }
982             finally {
983                 if (count == null) {
984                     count = Long.valueOf(0);
985                 }
986 
987                 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RESOURCEID,
988                     finderArgs, count);
989 
990                 closeSession(session);
991             }
992         }
993 
994         return count.intValue();
995     }
996 
997     public int countByA_R(String actionId, long resourceId)
998         throws SystemException {
999         Object[] finderArgs = new Object[] { actionId, new Long(resourceId) };
1000
1001        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_A_R,
1002                finderArgs, this);
1003
1004        if (count == null) {
1005            Session session = null;
1006
1007            try {
1008                session = openSession();
1009
1010                StringBuilder query = new StringBuilder();
1011
1012                query.append("SELECT COUNT(permission) ");
1013                query.append("FROM Permission permission WHERE ");
1014
1015                if (actionId == null) {
1016                    query.append("permission.actionId IS NULL");
1017                }
1018                else {
1019                    query.append("permission.actionId = ?");
1020                }
1021
1022                query.append(" AND ");
1023
1024                query.append("permission.resourceId = ?");
1025
1026                query.append(" ");
1027
1028                Query q = session.createQuery(query.toString());
1029
1030                QueryPos qPos = QueryPos.getInstance(q);
1031
1032                if (actionId != null) {
1033                    qPos.add(actionId);
1034                }
1035
1036                qPos.add(resourceId);
1037
1038                count = (Long)q.uniqueResult();
1039            }
1040            catch (Exception e) {
1041                throw processException(e);
1042            }
1043            finally {
1044                if (count == null) {
1045                    count = Long.valueOf(0);
1046                }
1047
1048                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_A_R, finderArgs,
1049                    count);
1050
1051                closeSession(session);
1052            }
1053        }
1054
1055        return count.intValue();
1056    }
1057
1058    public int countAll() throws SystemException {
1059        Object[] finderArgs = new Object[0];
1060
1061        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1062                finderArgs, this);
1063
1064        if (count == null) {
1065            Session session = null;
1066
1067            try {
1068                session = openSession();
1069
1070                Query q = session.createQuery(
1071                        "SELECT COUNT(permission) FROM Permission permission");
1072
1073                count = (Long)q.uniqueResult();
1074            }
1075            catch (Exception e) {
1076                throw processException(e);
1077            }
1078            finally {
1079                if (count == null) {
1080                    count = Long.valueOf(0);
1081                }
1082
1083                FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1084                    count);
1085
1086                closeSession(session);
1087            }
1088        }
1089
1090        return count.intValue();
1091    }
1092
1093    public List<com.liferay.portal.model.Group> getGroups(long pk)
1094        throws SystemException {
1095        return getGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1096    }
1097
1098    public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
1099        int end) throws SystemException {
1100        return getGroups(pk, start, end, null);
1101    }
1102
1103    public static final FinderPath FINDER_PATH_GET_GROUPS = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
1104            PermissionModelImpl.FINDER_CACHE_ENABLED_GROUPS_PERMISSIONS,
1105            "Groups_Permissions", "getGroups",
1106            new String[] {
1107                Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1108                "com.liferay.portal.kernel.util.OrderByComparator"
1109            });
1110
1111    public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
1112        int end, OrderByComparator obc) throws SystemException {
1113        Object[] finderArgs = new Object[] {
1114                new Long(pk), String.valueOf(start), String.valueOf(end),
1115                String.valueOf(obc)
1116            };
1117
1118        List<com.liferay.portal.model.Group> list = (List<com.liferay.portal.model.Group>)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS,
1119                finderArgs, this);
1120
1121        if (list == null) {
1122            Session session = null;
1123
1124            try {
1125                session = openSession();
1126
1127                StringBuilder sb = new StringBuilder();
1128
1129                sb.append(_SQL_GETGROUPS);
1130
1131                if (obc != null) {
1132                    sb.append("ORDER BY ");
1133                    sb.append(obc.getOrderBy());
1134                }
1135
1136                else {
1137                    sb.append("ORDER BY ");
1138
1139                    sb.append("Group_.name ASC");
1140                }
1141
1142                String sql = sb.toString();
1143
1144                SQLQuery q = session.createSQLQuery(sql);
1145
1146                q.addEntity("Group_",
1147                    com.liferay.portal.model.impl.GroupImpl.class);
1148
1149                QueryPos qPos = QueryPos.getInstance(q);
1150
1151                qPos.add(pk);
1152
1153                list = (List<com.liferay.portal.model.Group>)QueryUtil.list(q,
1154                        getDialect(), start, end);
1155            }
1156            catch (Exception e) {
1157                throw processException(e);
1158            }
1159            finally {
1160                if (list == null) {
1161                    list = new ArrayList<com.liferay.portal.model.Group>();
1162                }
1163
1164                groupPersistence.cacheResult(list);
1165
1166                FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS, finderArgs,
1167                    list);
1168
1169                closeSession(session);
1170            }
1171        }
1172
1173        return list;
1174    }
1175
1176    public static final FinderPath FINDER_PATH_GET_GROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
1177            PermissionModelImpl.FINDER_CACHE_ENABLED_GROUPS_PERMISSIONS,
1178            "Groups_Permissions", "getGroupsSize",
1179            new String[] { Long.class.getName() });
1180
1181    public int getGroupsSize(long pk) throws SystemException {
1182        Object[] finderArgs = new Object[] { new Long(pk) };
1183
1184        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS_SIZE,
1185                finderArgs, this);
1186
1187        if (count == null) {
1188            Session session = null;
1189
1190            try {
1191                session = openSession();
1192
1193                SQLQuery q = session.createSQLQuery(_SQL_GETGROUPSSIZE);
1194
1195                q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
1196
1197                QueryPos qPos = QueryPos.getInstance(q);
1198
1199                qPos.add(pk);
1200
1201                count = (Long)q.uniqueResult();
1202            }
1203            catch (Exception e) {
1204                throw processException(e);
1205            }
1206            finally {
1207                if (count == null) {
1208                    count = Long.valueOf(0);
1209                }
1210
1211                FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS_SIZE,
1212                    finderArgs, count);
1213
1214                closeSession(session);
1215            }
1216        }
1217
1218        return count.intValue();
1219    }
1220
1221    public static final FinderPath FINDER_PATH_CONTAINS_GROUP = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
1222            PermissionModelImpl.FINDER_CACHE_ENABLED_GROUPS_PERMISSIONS,
1223            "Groups_Permissions", "containsGroup",
1224            new String[] { Long.class.getName(), Long.class.getName() });
1225
1226    public boolean containsGroup(long pk, long groupPK)
1227        throws SystemException {
1228        Object[] finderArgs = new Object[] { new Long(pk), new Long(groupPK) };
1229
1230        Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_GROUP,
1231                finderArgs, this);
1232
1233        if (value == null) {
1234            try {
1235                value = Boolean.valueOf(containsGroup.contains(pk, groupPK));
1236            }
1237            catch (Exception e) {
1238                throw processException(e);
1239            }
1240            finally {
1241                if (value == null) {
1242                    value = Boolean.FALSE;
1243                }
1244
1245                FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_GROUP,
1246                    finderArgs, value);
1247            }
1248        }
1249
1250        return value.booleanValue();
1251    }
1252
1253    public boolean containsGroups(long pk) throws SystemException {
1254        if (getGroupsSize(pk) > 0) {
1255            return true;
1256        }
1257        else {
1258            return false;
1259        }
1260    }
1261
1262    public void addGroup(long pk, long groupPK) throws SystemException {
1263        try {
1264            addGroup.add(pk, groupPK);
1265        }
1266        catch (Exception e) {
1267            throw processException(e);
1268        }
1269        finally {
1270            FinderCacheUtil.clearCache("Groups_Permissions");
1271        }
1272    }
1273
1274    public void addGroup(long pk, com.liferay.portal.model.Group group)
1275        throws SystemException {
1276        try {
1277            addGroup.add(pk, group.getPrimaryKey());
1278        }
1279        catch (Exception e) {
1280            throw processException(e);
1281        }
1282        finally {
1283            FinderCacheUtil.clearCache("Groups_Permissions");
1284        }
1285    }
1286
1287    public void addGroups(long pk, long[] groupPKs) throws SystemException {
1288        try {
1289            for (long groupPK : groupPKs) {
1290                addGroup.add(pk, groupPK);
1291            }
1292        }
1293        catch (Exception e) {
1294            throw processException(e);
1295        }
1296        finally {
1297            FinderCacheUtil.clearCache("Groups_Permissions");
1298        }
1299    }
1300
1301    public void addGroups(long pk, List<com.liferay.portal.model.Group> groups)
1302        throws SystemException {
1303        try {
1304            for (com.liferay.portal.model.Group group : groups) {
1305                addGroup.add(pk, group.getPrimaryKey());
1306            }
1307        }
1308        catch (Exception e) {
1309            throw processException(e);
1310        }
1311        finally {
1312            FinderCacheUtil.clearCache("Groups_Permissions");
1313        }
1314    }
1315
1316    public void clearGroups(long pk) throws SystemException {
1317        try {
1318            clearGroups.clear(pk);
1319        }
1320        catch (Exception e) {
1321            throw processException(e);
1322        }
1323        finally {
1324            FinderCacheUtil.clearCache("Groups_Permissions");
1325        }
1326    }
1327
1328    public void removeGroup(long pk, long groupPK) throws SystemException {
1329        try {
1330            removeGroup.remove(pk, groupPK);
1331        }
1332        catch (Exception e) {
1333            throw processException(e);
1334        }
1335        finally {
1336            FinderCacheUtil.clearCache("Groups_Permissions");
1337        }
1338    }
1339
1340    public void removeGroup(long pk, com.liferay.portal.model.Group group)
1341        throws SystemException {
1342        try {
1343            removeGroup.remove(pk, group.getPrimaryKey());
1344        }
1345        catch (Exception e) {
1346            throw processException(e);
1347        }
1348        finally {
1349            FinderCacheUtil.clearCache("Groups_Permissions");
1350        }
1351    }
1352
1353    public void removeGroups(long pk, long[] groupPKs)
1354        throws SystemException {
1355        try {
1356            for (long groupPK : groupPKs) {
1357                removeGroup.remove(pk, groupPK);
1358            }
1359        }
1360        catch (Exception e) {
1361            throw processException(e);
1362        }
1363        finally {
1364            FinderCacheUtil.clearCache("Groups_Permissions");
1365        }
1366    }
1367
1368    public void removeGroups(long pk,
1369        List<com.liferay.portal.model.Group> groups) throws SystemException {
1370        try {
1371            for (com.liferay.portal.model.Group group : groups) {
1372                removeGroup.remove(pk, group.getPrimaryKey());
1373            }
1374        }
1375        catch (Exception e) {
1376            throw processException(e);
1377        }
1378        finally {
1379            FinderCacheUtil.clearCache("Groups_Permissions");
1380        }
1381    }
1382
1383    public void setGroups(long pk, long[] groupPKs) throws SystemException {
1384        try {
1385            Set<Long> groupPKSet = SetUtil.fromArray(groupPKs);
1386
1387            List<com.liferay.portal.model.Group> groups = getGroups(pk);
1388
1389            for (com.liferay.portal.model.Group group : groups) {
1390                if (!groupPKSet.contains(group.getPrimaryKey())) {
1391                    removeGroup.remove(pk, group.getPrimaryKey());
1392                }
1393                else {
1394                    groupPKSet.remove(group.getPrimaryKey());
1395                }
1396            }
1397
1398            for (Long groupPK : groupPKSet) {
1399                addGroup.add(pk, groupPK);
1400            }
1401        }
1402        catch (Exception e) {
1403            throw processException(e);
1404        }
1405        finally {
1406            FinderCacheUtil.clearCache("Groups_Permissions");
1407        }
1408    }
1409
1410    public void setGroups(long pk, List<com.liferay.portal.model.Group> groups)
1411        throws SystemException {
1412        try {
1413            long[] groupPKs = new long[groups.size()];
1414
1415            for (int i = 0; i < groups.size(); i++) {
1416                com.liferay.portal.model.Group group = groups.get(i);
1417
1418                groupPKs[i] = group.getPrimaryKey();
1419            }
1420
1421            setGroups(pk, groupPKs);
1422        }
1423        catch (Exception e) {
1424            throw processException(e);
1425        }
1426        finally {
1427            FinderCacheUtil.clearCache("Groups_Permissions");
1428        }
1429    }
1430
1431    public List<com.liferay.portal.model.Role> getRoles(long pk)
1432        throws SystemException {
1433        return getRoles(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1434    }
1435
1436    public List<com.liferay.portal.model.Role> getRoles(long pk, int start,
1437        int end) throws SystemException {
1438        return getRoles(pk, start, end, null);
1439    }
1440
1441    public static final FinderPath FINDER_PATH_GET_ROLES = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
1442            PermissionModelImpl.FINDER_CACHE_ENABLED_ROLES_PERMISSIONS,
1443            "Roles_Permissions", "getRoles",
1444            new String[] {
1445                Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1446                "com.liferay.portal.kernel.util.OrderByComparator"
1447            });
1448
1449    public List<com.liferay.portal.model.Role> getRoles(long pk, int start,
1450        int end, OrderByComparator obc) throws SystemException {
1451        Object[] finderArgs = new Object[] {
1452                new Long(pk), String.valueOf(start), String.valueOf(end),
1453                String.valueOf(obc)
1454            };
1455
1456        List<com.liferay.portal.model.Role> list = (List<com.liferay.portal.model.Role>)FinderCacheUtil.getResult(FINDER_PATH_GET_ROLES,
1457                finderArgs, this);
1458
1459        if (list == null) {
1460            Session session = null;
1461
1462            try {
1463                session = openSession();
1464
1465                StringBuilder sb = new StringBuilder();
1466
1467                sb.append(_SQL_GETROLES);
1468
1469                if (obc != null) {
1470                    sb.append("ORDER BY ");
1471                    sb.append(obc.getOrderBy());
1472                }
1473
1474                else {
1475                    sb.append("ORDER BY ");
1476
1477                    sb.append("Role_.name ASC");
1478                }
1479
1480                String sql = sb.toString();
1481
1482                SQLQuery q = session.createSQLQuery(sql);
1483
1484                q.addEntity("Role_",
1485                    com.liferay.portal.model.impl.RoleImpl.class);
1486
1487                QueryPos qPos = QueryPos.getInstance(q);
1488
1489                qPos.add(pk);
1490
1491                list = (List<com.liferay.portal.model.Role>)QueryUtil.list(q,
1492                        getDialect(), start, end);
1493            }
1494            catch (Exception e) {
1495                throw processException(e);
1496            }
1497            finally {
1498                if (list == null) {
1499                    list = new ArrayList<com.liferay.portal.model.Role>();
1500                }
1501
1502                rolePersistence.cacheResult(list);
1503
1504                FinderCacheUtil.putResult(FINDER_PATH_GET_ROLES, finderArgs,
1505                    list);
1506
1507                closeSession(session);
1508            }
1509        }
1510
1511        return list;
1512    }
1513
1514    public static final FinderPath FINDER_PATH_GET_ROLES_SIZE = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
1515            PermissionModelImpl.FINDER_CACHE_ENABLED_ROLES_PERMISSIONS,
1516            "Roles_Permissions", "getRolesSize",
1517            new String[] { Long.class.getName() });
1518
1519    public int getRolesSize(long pk) throws SystemException {
1520        Object[] finderArgs = new Object[] { new Long(pk) };
1521
1522        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ROLES_SIZE,
1523                finderArgs, this);
1524
1525        if (count == null) {
1526            Session session = null;
1527
1528            try {
1529                session = openSession();
1530
1531                SQLQuery q = session.createSQLQuery(_SQL_GETROLESSIZE);
1532
1533                q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
1534
1535                QueryPos qPos = QueryPos.getInstance(q);
1536
1537                qPos.add(pk);
1538
1539                count = (Long)q.uniqueResult();
1540            }
1541            catch (Exception e) {
1542                throw processException(e);
1543            }
1544            finally {
1545                if (count == null) {
1546                    count = Long.valueOf(0);
1547                }
1548
1549                FinderCacheUtil.putResult(FINDER_PATH_GET_ROLES_SIZE,
1550                    finderArgs, count);
1551
1552                closeSession(session);
1553            }
1554        }
1555
1556        return count.intValue();
1557    }
1558
1559    public static final FinderPath FINDER_PATH_CONTAINS_ROLE = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
1560            PermissionModelImpl.FINDER_CACHE_ENABLED_ROLES_PERMISSIONS,
1561            "Roles_Permissions", "containsRole",
1562            new String[] { Long.class.getName(), Long.class.getName() });
1563
1564    public boolean containsRole(long pk, long rolePK) throws SystemException {
1565        Object[] finderArgs = new Object[] { new Long(pk), new Long(rolePK) };
1566
1567        Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ROLE,
1568                finderArgs, this);
1569
1570        if (value == null) {
1571            try {
1572                value = Boolean.valueOf(containsRole.contains(pk, rolePK));
1573            }
1574            catch (Exception e) {
1575                throw processException(e);
1576            }
1577            finally {
1578                if (value == null) {
1579                    value = Boolean.FALSE;
1580                }
1581
1582                FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ROLE,
1583                    finderArgs, value);
1584            }
1585        }
1586
1587        return value.booleanValue();
1588    }
1589
1590    public boolean containsRoles(long pk) throws SystemException {
1591        if (getRolesSize(pk) > 0) {
1592            return true;
1593        }
1594        else {
1595            return false;
1596        }
1597    }
1598
1599    public void addRole(long pk, long rolePK) throws SystemException {
1600        try {
1601            addRole.add(pk, rolePK);
1602        }
1603        catch (Exception e) {
1604            throw processException(e);
1605        }
1606        finally {
1607            FinderCacheUtil.clearCache("Roles_Permissions");
1608        }
1609    }
1610
1611    public void addRole(long pk, com.liferay.portal.model.Role role)
1612        throws SystemException {
1613        try {
1614            addRole.add(pk, role.getPrimaryKey());
1615        }
1616        catch (Exception e) {
1617            throw processException(e);
1618        }
1619        finally {
1620            FinderCacheUtil.clearCache("Roles_Permissions");
1621        }
1622    }
1623
1624    public void addRoles(long pk, long[] rolePKs) throws SystemException {
1625        try {
1626            for (long rolePK : rolePKs) {
1627                addRole.add(pk, rolePK);
1628            }
1629        }
1630        catch (Exception e) {
1631            throw processException(e);
1632        }
1633        finally {
1634            FinderCacheUtil.clearCache("Roles_Permissions");
1635        }
1636    }
1637
1638    public void addRoles(long pk, List<com.liferay.portal.model.Role> roles)
1639        throws SystemException {
1640        try {
1641            for (com.liferay.portal.model.Role role : roles) {
1642                addRole.add(pk, role.getPrimaryKey());
1643            }
1644        }
1645        catch (Exception e) {
1646            throw processException(e);
1647        }
1648        finally {
1649            FinderCacheUtil.clearCache("Roles_Permissions");
1650        }
1651    }
1652
1653    public void clearRoles(long pk) throws SystemException {
1654        try {
1655            clearRoles.clear(pk);
1656        }
1657        catch (Exception e) {
1658            throw processException(e);
1659        }
1660        finally {
1661            FinderCacheUtil.clearCache("Roles_Permissions");
1662        }
1663    }
1664
1665    public void removeRole(long pk, long rolePK) throws SystemException {
1666        try {
1667            removeRole.remove(pk, rolePK);
1668        }
1669        catch (Exception e) {
1670            throw processException(e);
1671        }
1672        finally {
1673            FinderCacheUtil.clearCache("Roles_Permissions");
1674        }
1675    }
1676
1677    public void removeRole(long pk, com.liferay.portal.model.Role role)
1678        throws SystemException {
1679        try {
1680            removeRole.remove(pk, role.getPrimaryKey());
1681        }
1682        catch (Exception e) {
1683            throw processException(e);
1684        }
1685        finally {
1686            FinderCacheUtil.clearCache("Roles_Permissions");
1687        }
1688    }
1689
1690    public void removeRoles(long pk, long[] rolePKs) throws SystemException {
1691        try {
1692            for (long rolePK : rolePKs) {
1693                removeRole.remove(pk, rolePK);
1694            }
1695        }
1696        catch (Exception e) {
1697            throw processException(e);
1698        }
1699        finally {
1700            FinderCacheUtil.clearCache("Roles_Permissions");
1701        }
1702    }
1703
1704    public void removeRoles(long pk, List<com.liferay.portal.model.Role> roles)
1705        throws SystemException {
1706        try {
1707            for (com.liferay.portal.model.Role role : roles) {
1708                removeRole.remove(pk, role.getPrimaryKey());
1709            }
1710        }
1711        catch (Exception e) {
1712            throw processException(e);
1713        }
1714        finally {
1715            FinderCacheUtil.clearCache("Roles_Permissions");
1716        }
1717    }
1718
1719    public void setRoles(long pk, long[] rolePKs) throws SystemException {
1720        try {
1721            Set<Long> rolePKSet = SetUtil.fromArray(rolePKs);
1722
1723            List<com.liferay.portal.model.Role> roles = getRoles(pk);
1724
1725            for (com.liferay.portal.model.Role role : roles) {
1726                if (!rolePKSet.contains(role.getPrimaryKey())) {
1727                    removeRole.remove(pk, role.getPrimaryKey());
1728                }
1729                else {
1730                    rolePKSet.remove(role.getPrimaryKey());
1731                }
1732            }
1733
1734            for (Long rolePK : rolePKSet) {
1735                addRole.add(pk, rolePK);
1736            }
1737        }
1738        catch (Exception e) {
1739            throw processException(e);
1740        }
1741        finally {
1742            FinderCacheUtil.clearCache("Roles_Permissions");
1743        }
1744    }
1745
1746    public void setRoles(long pk, List<com.liferay.portal.model.Role> roles)
1747        throws SystemException {
1748        try {
1749            long[] rolePKs = new long[roles.size()];
1750
1751            for (int i = 0; i < roles.size(); i++) {
1752                com.liferay.portal.model.Role role = roles.get(i);
1753
1754                rolePKs[i] = role.getPrimaryKey();
1755            }
1756
1757            setRoles(pk, rolePKs);
1758        }
1759        catch (Exception e) {
1760            throw processException(e);
1761        }
1762        finally {
1763            FinderCacheUtil.clearCache("Roles_Permissions");
1764        }
1765    }
1766
1767    public List<com.liferay.portal.model.User> getUsers(long pk)
1768        throws SystemException {
1769        return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1770    }
1771
1772    public List<com.liferay.portal.model.User> getUsers(long pk, int start,
1773        int end) throws SystemException {
1774        return getUsers(pk, start, end, null);
1775    }
1776
1777    public static final FinderPath FINDER_PATH_GET_USERS = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
1778            PermissionModelImpl.FINDER_CACHE_ENABLED_USERS_PERMISSIONS,
1779            "Users_Permissions", "getUsers",
1780            new String[] {
1781                Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1782                "com.liferay.portal.kernel.util.OrderByComparator"
1783            });
1784
1785    public List<com.liferay.portal.model.User> getUsers(long pk, int start,
1786        int end, OrderByComparator obc) throws SystemException {
1787        Object[] finderArgs = new Object[] {
1788                new Long(pk), String.valueOf(start), String.valueOf(end),
1789                String.valueOf(obc)
1790            };
1791
1792        List<com.liferay.portal.model.User> list = (List<com.liferay.portal.model.User>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS,
1793                finderArgs, this);
1794
1795        if (list == null) {
1796            Session session = null;
1797
1798            try {
1799                session = openSession();
1800
1801                StringBuilder sb = new StringBuilder();
1802
1803                sb.append(_SQL_GETUSERS);
1804
1805                if (obc != null) {
1806                    sb.append("ORDER BY ");
1807                    sb.append(obc.getOrderBy());
1808                }
1809
1810                String sql = sb.toString();
1811
1812                SQLQuery q = session.createSQLQuery(sql);
1813
1814                q.addEntity("User_",
1815                    com.liferay.portal.model.impl.UserImpl.class);
1816
1817                QueryPos qPos = QueryPos.getInstance(q);
1818
1819                qPos.add(pk);
1820
1821                list = (List<com.liferay.portal.model.User>)QueryUtil.list(q,
1822                        getDialect(), start, end);
1823            }
1824            catch (Exception e) {
1825                throw processException(e);
1826            }
1827            finally {
1828                if (list == null) {
1829                    list = new ArrayList<com.liferay.portal.model.User>();
1830                }
1831
1832                userPersistence.cacheResult(list);
1833
1834                FinderCacheUtil.putResult(FINDER_PATH_GET_USERS, finderArgs,
1835                    list);
1836
1837                closeSession(session);
1838            }
1839        }
1840
1841        return list;
1842    }
1843
1844    public static final FinderPath FINDER_PATH_GET_USERS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
1845            PermissionModelImpl.FINDER_CACHE_ENABLED_USERS_PERMISSIONS,
1846            "Users_Permissions", "getUsersSize",
1847            new String[] { Long.class.getName() });
1848
1849    public int getUsersSize(long pk) throws SystemException {
1850        Object[] finderArgs = new Object[] { new Long(pk) };
1851
1852        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS_SIZE,
1853                finderArgs, this);
1854
1855        if (count == null) {
1856            Session session = null;
1857
1858            try {
1859                session = openSession();
1860
1861                SQLQuery q = session.createSQLQuery(_SQL_GETUSERSSIZE);
1862
1863                q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
1864
1865                QueryPos qPos = QueryPos.getInstance(q);
1866
1867                qPos.add(pk);
1868
1869                count = (Long)q.uniqueResult();
1870            }
1871            catch (Exception e) {
1872                throw processException(e);
1873            }
1874            finally {
1875                if (count == null) {
1876                    count = Long.valueOf(0);
1877                }
1878
1879                FinderCacheUtil.putResult(FINDER_PATH_GET_USERS_SIZE,
1880                    finderArgs, count);
1881
1882                closeSession(session);
1883            }
1884        }
1885
1886        return count.intValue();
1887    }
1888
1889    public static final FinderPath FINDER_PATH_CONTAINS_USER = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
1890            PermissionModelImpl.FINDER_CACHE_ENABLED_USERS_PERMISSIONS,
1891            "Users_Permissions", "containsUser",
1892            new String[] { Long.class.getName(), Long.class.getName() });
1893
1894    public boolean containsUser(long pk, long userPK) throws SystemException {
1895        Object[] finderArgs = new Object[] { new Long(pk), new Long(userPK) };
1896
1897        Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USER,
1898                finderArgs, this);
1899
1900        if (value == null) {
1901            try {
1902                value = Boolean.valueOf(containsUser.contains(pk, userPK));
1903            }
1904            catch (Exception e) {
1905                throw processException(e);
1906            }
1907            finally {
1908                if (value == null) {
1909                    value = Boolean.FALSE;
1910                }
1911
1912                FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USER,
1913                    finderArgs, value);
1914            }
1915        }
1916
1917        return value.booleanValue();
1918    }
1919
1920    public boolean containsUsers(long pk) throws SystemException {
1921        if (getUsersSize(pk) > 0) {
1922            return true;
1923        }
1924        else {
1925            return false;
1926        }
1927    }
1928
1929    public void addUser(long pk, long userPK) throws SystemException {
1930        try {
1931            addUser.add(pk, userPK);
1932        }
1933        catch (Exception e) {
1934            throw processException(e);
1935        }
1936        finally {
1937            FinderCacheUtil.clearCache("Users_Permissions");
1938        }
1939    }
1940
1941    public void addUser(long pk, com.liferay.portal.model.User user)
1942        throws SystemException {
1943        try {
1944            addUser.add(pk, user.getPrimaryKey());
1945        }
1946        catch (Exception e) {
1947            throw processException(e);
1948        }
1949        finally {
1950            FinderCacheUtil.clearCache("Users_Permissions");
1951        }
1952    }
1953
1954    public void addUsers(long pk, long[] userPKs) throws SystemException {
1955        try {
1956            for (long userPK : userPKs) {
1957                addUser.add(pk, userPK);
1958            }
1959        }
1960        catch (Exception e) {
1961            throw processException(e);
1962        }
1963        finally {
1964            FinderCacheUtil.clearCache("Users_Permissions");
1965        }
1966    }
1967
1968    public void addUsers(long pk, List<com.liferay.portal.model.User> users)
1969        throws SystemException {
1970        try {
1971            for (com.liferay.portal.model.User user : users) {
1972                addUser.add(pk, user.getPrimaryKey());
1973            }
1974        }
1975        catch (Exception e) {
1976            throw processException(e);
1977        }
1978        finally {
1979            FinderCacheUtil.clearCache("Users_Permissions");
1980        }
1981    }
1982
1983    public void clearUsers(long pk) throws SystemException {
1984        try {
1985            clearUsers.clear(pk);
1986        }
1987        catch (Exception e) {
1988            throw processException(e);
1989        }
1990        finally {
1991            FinderCacheUtil.clearCache("Users_Permissions");
1992        }
1993    }
1994
1995    public void removeUser(long pk, long userPK) throws SystemException {
1996        try {
1997            removeUser.remove(pk, userPK);
1998        }
1999        catch (Exception e) {
2000            throw processException(e);
2001        }
2002        finally {
2003            FinderCacheUtil.clearCache("Users_Permissions");
2004        }
2005    }
2006
2007    public void removeUser(long pk, com.liferay.portal.model.User user)
2008        throws SystemException {
2009        try {
2010            removeUser.remove(pk, user.getPrimaryKey());
2011        }
2012        catch (Exception e) {
2013            throw processException(e);
2014        }
2015        finally {
2016            FinderCacheUtil.clearCache("Users_Permissions");
2017        }
2018    }
2019
2020    public void removeUsers(long pk, long[] userPKs) throws SystemException {
2021        try {
2022            for (long userPK : userPKs) {
2023                removeUser.remove(pk, userPK);
2024            }
2025        }
2026        catch (Exception e) {
2027            throw processException(e);
2028        }
2029        finally {
2030            FinderCacheUtil.clearCache("Users_Permissions");
2031        }
2032    }
2033
2034    public void removeUsers(long pk, List<com.liferay.portal.model.User> users)
2035        throws SystemException {
2036        try {
2037            for (com.liferay.portal.model.User user : users) {
2038                removeUser.remove(pk, user.getPrimaryKey());
2039            }
2040        }
2041        catch (Exception e) {
2042            throw processException(e);
2043        }
2044        finally {
2045            FinderCacheUtil.clearCache("Users_Permissions");
2046        }
2047    }
2048
2049    public void setUsers(long pk, long[] userPKs) throws SystemException {
2050        try {
2051            Set<Long> userPKSet = SetUtil.fromArray(userPKs);
2052
2053            List<com.liferay.portal.model.User> users = getUsers(pk);
2054
2055            for (com.liferay.portal.model.User user : users) {
2056                if (!userPKSet.contains(user.getPrimaryKey())) {
2057                    removeUser.remove(pk, user.getPrimaryKey());
2058                }
2059                else {
2060                    userPKSet.remove(user.getPrimaryKey());
2061                }
2062            }
2063
2064            for (Long userPK : userPKSet) {
2065                addUser.add(pk, userPK);
2066            }
2067        }
2068        catch (Exception e) {
2069            throw processException(e);
2070        }
2071        finally {
2072            FinderCacheUtil.clearCache("Users_Permissions");
2073        }
2074    }
2075
2076    public void setUsers(long pk, List<com.liferay.portal.model.User> users)
2077        throws SystemException {
2078        try {
2079            long[] userPKs = new long[users.size()];
2080
2081            for (int i = 0; i < users.size(); i++) {
2082                com.liferay.portal.model.User user = users.get(i);
2083
2084                userPKs[i] = user.getPrimaryKey();
2085            }
2086
2087            setUsers(pk, userPKs);
2088        }
2089        catch (Exception e) {
2090            throw processException(e);
2091        }
2092        finally {
2093            FinderCacheUtil.clearCache("Users_Permissions");
2094        }
2095    }
2096
2097    public void afterPropertiesSet() {
2098        String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2099                    com.liferay.portal.util.PropsUtil.get(
2100                        "value.object.listener.com.liferay.portal.model.Permission")));
2101
2102        if (listenerClassNames.length > 0) {
2103            try {
2104                List<ModelListener<Permission>> listenersList = new ArrayList<ModelListener<Permission>>();
2105
2106                for (String listenerClassName : listenerClassNames) {
2107                    listenersList.add((ModelListener<Permission>)Class.forName(
2108                            listenerClassName).newInstance());
2109                }
2110
2111                listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2112            }
2113            catch (Exception e) {
2114                _log.error(e);
2115            }
2116        }
2117
2118        containsGroup = new ContainsGroup(this);
2119
2120        addGroup = new AddGroup(this);
2121        clearGroups = new ClearGroups(this);
2122        removeGroup = new RemoveGroup(this);
2123
2124        containsRole = new ContainsRole(this);
2125
2126        addRole = new AddRole(this);
2127        clearRoles = new ClearRoles(this);
2128        removeRole = new RemoveRole(this);
2129
2130        containsUser = new ContainsUser(this);
2131
2132        addUser = new AddUser(this);
2133        clearUsers = new ClearUsers(this);
2134        removeUser = new RemoveUser(this);
2135    }
2136
2137    @BeanReference(name = "com.liferay.portal.service.persistence.AccountPersistence.impl")
2138    protected com.liferay.portal.service.persistence.AccountPersistence accountPersistence;
2139    @BeanReference(name = "com.liferay.portal.service.persistence.AddressPersistence.impl")
2140    protected com.liferay.portal.service.persistence.AddressPersistence addressPersistence;
2141    @BeanReference(name = "com.liferay.portal.service.persistence.BrowserTrackerPersistence.impl")
2142    protected com.liferay.portal.service.persistence.BrowserTrackerPersistence browserTrackerPersistence;
2143    @BeanReference(name = "com.liferay.portal.service.persistence.ClassNamePersistence.impl")
2144    protected com.liferay.portal.service.persistence.ClassNamePersistence classNamePersistence;
2145    @BeanReference(name = "com.liferay.portal.service.persistence.CompanyPersistence.impl")
2146    protected com.liferay.portal.service.persistence.CompanyPersistence companyPersistence;
2147    @BeanReference(name = "com.liferay.portal.service.persistence.ContactPersistence.impl")
2148    protected com.liferay.portal.service.persistence.ContactPersistence contactPersistence;
2149    @BeanReference(name = "com.liferay.portal.service.persistence.CountryPersistence.impl")
2150    protected com.liferay.portal.service.persistence.CountryPersistence countryPersistence;
2151    @BeanReference(name = "com.liferay.portal.service.persistence.EmailAddressPersistence.impl")
2152    protected com.liferay.portal.service.persistence.EmailAddressPersistence emailAddressPersistence;
2153    @BeanReference(name = "com.liferay.portal.service.persistence.GroupPersistence.impl")
2154    protected com.liferay.portal.service.persistence.GroupPersistence groupPersistence;
2155    @BeanReference(name = "com.liferay.portal.service.persistence.ImagePersistence.impl")
2156    protected com.liferay.portal.service.persistence.ImagePersistence imagePersistence;
2157    @BeanReference(name = "com.liferay.portal.service.persistence.LayoutPersistence.impl")
2158    protected com.liferay.portal.service.persistence.LayoutPersistence layoutPersistence;
2159    @BeanReference(name = "com.liferay.portal.service.persistence.LayoutSetPersistence.impl")
2160    protected com.liferay.portal.service.persistence.LayoutSetPersistence layoutSetPersistence;
2161    @BeanReference(name = "com.liferay.portal.service.persistence.ListTypePersistence.impl")
2162    protected com.liferay.portal.service.persistence.ListTypePersistence listTypePersistence;
2163    @BeanReference(name = "com.liferay.portal.service.persistence.LockPersistence.impl")
2164    protected com.liferay.portal.service.persistence.LockPersistence lockPersistence;
2165    @BeanReference(name = "com.liferay.portal.service.persistence.MembershipRequestPersistence.impl")
2166    protected com.liferay.portal.service.persistence.MembershipRequestPersistence membershipRequestPersistence;
2167    @BeanReference(name = "com.liferay.portal.service.persistence.OrganizationPersistence.impl")
2168    protected com.liferay.portal.service.persistence.OrganizationPersistence organizationPersistence;
2169    @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupPermissionPersistence.impl")
2170    protected com.liferay.portal.service.persistence.OrgGroupPermissionPersistence orgGroupPermissionPersistence;
2171    @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupRolePersistence.impl")
2172    protected com.liferay.portal.service.persistence.OrgGroupRolePersistence orgGroupRolePersistence;
2173    @BeanReference(name = "com.liferay.portal.service.persistence.OrgLaborPersistence.impl")
2174    protected com.liferay.portal.service.persistence.OrgLaborPersistence orgLaborPersistence;
2175    @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyPersistence.impl")
2176    protected com.liferay.portal.service.persistence.PasswordPolicyPersistence passwordPolicyPersistence;
2177    @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyRelPersistence.impl")
2178    protected com.liferay.portal.service.persistence.PasswordPolicyRelPersistence passwordPolicyRelPersistence;
2179    @BeanReference(name = "com.liferay.portal.service.persistence.PasswordTrackerPersistence.impl")
2180    protected com.liferay.portal.service.persistence.PasswordTrackerPersistence passwordTrackerPersistence;
2181    @BeanReference(name = "com.liferay.portal.service.persistence.PermissionPersistence.impl")
2182    protected com.liferay.portal.service.persistence.PermissionPersistence permissionPersistence;
2183    @BeanReference(name = "com.liferay.portal.service.persistence.PhonePersistence.impl")
2184    protected com.liferay.portal.service.persistence.PhonePersistence phonePersistence;
2185    @BeanReference(name = "com.liferay.portal.service.persistence.PluginSettingPersistence.impl")
2186    protected com.liferay.portal.service.persistence.PluginSettingPersistence pluginSettingPersistence;
2187    @BeanReference(name = "com.liferay.portal.service.persistence.PortletPersistence.impl")
2188    protected com.liferay.portal.service.persistence.PortletPersistence portletPersistence;
2189    @BeanReference(name = "com.liferay.portal.service.persistence.PortletItemPersistence.impl")
2190    protected com.liferay.portal.service.persistence.PortletItemPersistence portletItemPersistence;
2191    @BeanReference(name = "com.liferay.portal.service.persistence.PortletPreferencesPersistence.impl")
2192    protected com.liferay.portal.service.persistence.PortletPreferencesPersistence portletPreferencesPersistence;
2193    @BeanReference(name = "com.liferay.portal.service.persistence.RegionPersistence.impl")
2194    protected com.liferay.portal.service.persistence.RegionPersistence regionPersistence;
2195    @BeanReference(name = "com.liferay.portal.service.persistence.ReleasePersistence.impl")
2196    protected com.liferay.portal.service.persistence.ReleasePersistence releasePersistence;
2197    @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
2198    protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
2199    @BeanReference(name = "com.liferay.portal.service.persistence.ResourceActionPersistence.impl")
2200    protected com.liferay.portal.service.persistence.ResourceActionPersistence resourceActionPersistence;
2201    @BeanReference(name = "com.liferay.portal.service.persistence.ResourceCodePersistence.impl")
2202    protected com.liferay.portal.service.persistence.ResourceCodePersistence resourceCodePersistence;
2203    @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePermissionPersistence.impl")
2204    protected com.liferay.portal.service.persistence.ResourcePermissionPersistence resourcePermissionPersistence;
2205    @BeanReference(name = "com.liferay.portal.service.persistence.RolePersistence.impl")
2206    protected com.liferay.portal.service.persistence.RolePersistence rolePersistence;
2207    @BeanReference(name = "com.liferay.portal.service.persistence.ServiceComponentPersistence.impl")
2208    protected com.liferay.portal.service.persistence.ServiceComponentPersistence serviceComponentPersistence;
2209    @BeanReference(name = "com.liferay.portal.service.persistence.ShardPersistence.impl")
2210    protected com.liferay.portal.service.persistence.ShardPersistence shardPersistence;
2211    @BeanReference(name = "com.liferay.portal.service.persistence.SubscriptionPersistence.impl")
2212    protected com.liferay.portal.service.persistence.SubscriptionPersistence subscriptionPersistence;
2213    @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
2214    protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
2215    @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupPersistence.impl")
2216    protected com.liferay.portal.service.persistence.UserGroupPersistence userGroupPersistence;
2217    @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupGroupRolePersistence.impl")
2218    protected com.liferay.portal.service.persistence.UserGroupGroupRolePersistence userGroupGroupRolePersistence;
2219    @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupRolePersistence.impl")
2220    protected com.liferay.portal.service.persistence.UserGroupRolePersistence userGroupRolePersistence;
2221    @BeanReference(name = "com.liferay.portal.service.persistence.UserIdMapperPersistence.impl")
2222    protected com.liferay.portal.service.persistence.UserIdMapperPersistence userIdMapperPersistence;
2223    @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPersistence.impl")
2224    protected com.liferay.portal.service.persistence.UserTrackerPersistence userTrackerPersistence;
2225    @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPathPersistence.impl")
2226    protected com.liferay.portal.service.persistence.UserTrackerPathPersistence userTrackerPathPersistence;
2227    @BeanReference(name = "com.liferay.portal.service.persistence.WebDAVPropsPersistence.impl")
2228    protected com.liferay.portal.service.persistence.WebDAVPropsPersistence webDAVPropsPersistence;
2229    @BeanReference(name = "com.liferay.portal.service.persistence.WebsitePersistence.impl")
2230    protected com.liferay.portal.service.persistence.WebsitePersistence websitePersistence;
2231    protected ContainsGroup containsGroup;
2232    protected AddGroup addGroup;
2233    protected ClearGroups clearGroups;
2234    protected RemoveGroup removeGroup;
2235    protected ContainsRole containsRole;
2236    protected AddRole addRole;
2237    protected ClearRoles clearRoles;
2238    protected RemoveRole removeRole;
2239    protected ContainsUser containsUser;
2240    protected AddUser addUser;
2241    protected ClearUsers clearUsers;
2242    protected RemoveUser removeUser;
2243
2244    protected class ContainsGroup {
2245        protected ContainsGroup(PermissionPersistenceImpl persistenceImpl) {
2246            super();
2247
2248            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2249                    _SQL_CONTAINSGROUP,
2250                    new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
2251        }
2252
2253        protected boolean contains(long permissionId, long groupId) {
2254            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2255                        new Long(permissionId), new Long(groupId)
2256                    });
2257
2258            if (results.size() > 0) {
2259                Integer count = results.get(0);
2260
2261                if (count.intValue() > 0) {
2262                    return true;
2263                }
2264            }
2265
2266            return false;
2267        }
2268
2269        private MappingSqlQuery _mappingSqlQuery;
2270    }
2271
2272    protected class AddGroup {
2273        protected AddGroup(PermissionPersistenceImpl persistenceImpl) {
2274            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2275                    "INSERT INTO Groups_Permissions (permissionId, groupId) VALUES (?, ?)",
2276                    new int[] { Types.BIGINT, Types.BIGINT });
2277            _persistenceImpl = persistenceImpl;
2278        }
2279
2280        protected void add(long permissionId, long groupId)
2281            throws SystemException {
2282            if (!_persistenceImpl.containsGroup.contains(permissionId, groupId)) {
2283                ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
2284
2285                for (ModelListener<Permission> listener : listeners) {
2286                    listener.onBeforeAddAssociation(permissionId,
2287                        com.liferay.portal.model.Group.class.getName(), groupId);
2288                }
2289
2290                for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
2291                    listener.onBeforeAddAssociation(groupId,
2292                        Permission.class.getName(), permissionId);
2293                }
2294
2295                _sqlUpdate.update(new Object[] {
2296                        new Long(permissionId), new Long(groupId)
2297                    });
2298
2299                for (ModelListener<Permission> listener : listeners) {
2300                    listener.onAfterAddAssociation(permissionId,
2301                        com.liferay.portal.model.Group.class.getName(), groupId);
2302                }
2303
2304                for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
2305                    listener.onAfterAddAssociation(groupId,
2306                        Permission.class.getName(), permissionId);
2307                }
2308            }
2309        }
2310
2311        private SqlUpdate _sqlUpdate;
2312        private PermissionPersistenceImpl _persistenceImpl;
2313    }
2314
2315    protected class ClearGroups {
2316        protected ClearGroups(PermissionPersistenceImpl persistenceImpl) {
2317            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2318                    "DELETE FROM Groups_Permissions WHERE permissionId = ?",
2319                    new int[] { Types.BIGINT });
2320        }
2321
2322        protected void clear(long permissionId) throws SystemException {
2323            ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
2324
2325            List<com.liferay.portal.model.Group> groups = null;
2326
2327            if ((listeners.length > 0) || (groupListeners.length > 0)) {
2328                groups = getGroups(permissionId);
2329
2330                for (com.liferay.portal.model.Group group : groups) {
2331                    for (ModelListener<Permission> listener : listeners) {
2332                        listener.onBeforeRemoveAssociation(permissionId,
2333                            com.liferay.portal.model.Group.class.getName(),
2334                            group.getPrimaryKey());
2335                    }
2336
2337                    for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
2338                        listener.onBeforeRemoveAssociation(group.getPrimaryKey(),
2339                            Permission.class.getName(), permissionId);
2340                    }
2341                }
2342            }
2343
2344            _sqlUpdate.update(new Object[] { new Long(permissionId) });
2345
2346            if ((listeners.length > 0) || (groupListeners.length > 0)) {
2347                for (com.liferay.portal.model.Group group : groups) {
2348                    for (ModelListener<Permission> listener : listeners) {
2349                        listener.onAfterRemoveAssociation(permissionId,
2350                            com.liferay.portal.model.Group.class.getName(),
2351                            group.getPrimaryKey());
2352                    }
2353
2354                    for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
2355                        listener.onAfterRemoveAssociation(group.getPrimaryKey(),
2356                            Permission.class.getName(), permissionId);
2357                    }
2358                }
2359            }
2360        }
2361
2362        private SqlUpdate _sqlUpdate;
2363    }
2364
2365    protected class RemoveGroup {
2366        protected RemoveGroup(PermissionPersistenceImpl persistenceImpl) {
2367            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2368                    "DELETE FROM Groups_Permissions WHERE permissionId = ? AND groupId = ?",
2369                    new int[] { Types.BIGINT, Types.BIGINT });
2370            _persistenceImpl = persistenceImpl;
2371        }
2372
2373        protected void remove(long permissionId, long groupId)
2374            throws SystemException {
2375            if (_persistenceImpl.containsGroup.contains(permissionId, groupId)) {
2376                ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
2377
2378                for (ModelListener<Permission> listener : listeners) {
2379                    listener.onBeforeRemoveAssociation(permissionId,
2380                        com.liferay.portal.model.Group.class.getName(), groupId);
2381                }
2382
2383                for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
2384                    listener.onBeforeRemoveAssociation(groupId,
2385                        Permission.class.getName(), permissionId);
2386                }
2387
2388                _sqlUpdate.update(new Object[] {
2389                        new Long(permissionId), new Long(groupId)
2390                    });
2391
2392                for (ModelListener<Permission> listener : listeners) {
2393                    listener.onAfterRemoveAssociation(permissionId,
2394                        com.liferay.portal.model.Group.class.getName(), groupId);
2395                }
2396
2397                for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
2398                    listener.onAfterRemoveAssociation(groupId,
2399                        Permission.class.getName(), permissionId);
2400                }
2401            }
2402        }
2403
2404        private SqlUpdate _sqlUpdate;
2405        private PermissionPersistenceImpl _persistenceImpl;
2406    }
2407
2408    protected class ContainsRole {
2409        protected ContainsRole(PermissionPersistenceImpl persistenceImpl) {
2410            super();
2411
2412            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2413                    _SQL_CONTAINSROLE,
2414                    new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
2415        }
2416
2417        protected boolean contains(long permissionId, long roleId) {
2418            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2419                        new Long(permissionId), new Long(roleId)
2420                    });
2421
2422            if (results.size() > 0) {
2423                Integer count = results.get(0);
2424
2425                if (count.intValue() > 0) {
2426                    return true;
2427                }
2428            }
2429
2430            return false;
2431        }
2432
2433        private MappingSqlQuery _mappingSqlQuery;
2434    }
2435
2436    protected class AddRole {
2437        protected AddRole(PermissionPersistenceImpl persistenceImpl) {
2438            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2439                    "INSERT INTO Roles_Permissions (permissionId, roleId) VALUES (?, ?)",
2440                    new int[] { Types.BIGINT, Types.BIGINT });
2441            _persistenceImpl = persistenceImpl;
2442        }
2443
2444        protected void add(long permissionId, long roleId)
2445            throws SystemException {
2446            if (!_persistenceImpl.containsRole.contains(permissionId, roleId)) {
2447                ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
2448
2449                for (ModelListener<Permission> listener : listeners) {
2450                    listener.onBeforeAddAssociation(permissionId,
2451                        com.liferay.portal.model.Role.class.getName(), roleId);
2452                }
2453
2454                for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
2455                    listener.onBeforeAddAssociation(roleId,
2456                        Permission.class.getName(), permissionId);
2457                }
2458
2459                _sqlUpdate.update(new Object[] {
2460                        new Long(permissionId), new Long(roleId)
2461                    });
2462
2463                for (ModelListener<Permission> listener : listeners) {
2464                    listener.onAfterAddAssociation(permissionId,
2465                        com.liferay.portal.model.Role.class.getName(), roleId);
2466                }
2467
2468                for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
2469                    listener.onAfterAddAssociation(roleId,
2470                        Permission.class.getName(), permissionId);
2471                }
2472            }
2473        }
2474
2475        private SqlUpdate _sqlUpdate;
2476        private PermissionPersistenceImpl _persistenceImpl;
2477    }
2478
2479    protected class ClearRoles {
2480        protected ClearRoles(PermissionPersistenceImpl persistenceImpl) {
2481            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2482                    "DELETE FROM Roles_Permissions WHERE permissionId = ?",
2483                    new int[] { Types.BIGINT });
2484        }
2485
2486        protected void clear(long permissionId) throws SystemException {
2487            ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
2488
2489            List<com.liferay.portal.model.Role> roles = null;
2490
2491            if ((listeners.length > 0) || (roleListeners.length > 0)) {
2492                roles = getRoles(permissionId);
2493
2494                for (com.liferay.portal.model.Role role : roles) {
2495                    for (ModelListener<Permission> listener : listeners) {
2496                        listener.onBeforeRemoveAssociation(permissionId,
2497                            com.liferay.portal.model.Role.class.getName(),
2498                            role.getPrimaryKey());
2499                    }
2500
2501                    for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
2502                        listener.onBeforeRemoveAssociation(role.getPrimaryKey(),
2503                            Permission.class.getName(), permissionId);
2504                    }
2505                }
2506            }
2507
2508            _sqlUpdate.update(new Object[] { new Long(permissionId) });
2509
2510            if ((listeners.length > 0) || (roleListeners.length > 0)) {
2511                for (com.liferay.portal.model.Role role : roles) {
2512                    for (ModelListener<Permission> listener : listeners) {
2513                        listener.onAfterRemoveAssociation(permissionId,
2514                            com.liferay.portal.model.Role.class.getName(),
2515                            role.getPrimaryKey());
2516                    }
2517
2518                    for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
2519                        listener.onAfterRemoveAssociation(role.getPrimaryKey(),
2520                            Permission.class.getName(), permissionId);
2521                    }
2522                }
2523            }
2524        }
2525
2526        private SqlUpdate _sqlUpdate;
2527    }
2528
2529    protected class RemoveRole {
2530        protected RemoveRole(PermissionPersistenceImpl persistenceImpl) {
2531            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2532                    "DELETE FROM Roles_Permissions WHERE permissionId = ? AND roleId = ?",
2533                    new int[] { Types.BIGINT, Types.BIGINT });
2534            _persistenceImpl = persistenceImpl;
2535        }
2536
2537        protected void remove(long permissionId, long roleId)
2538            throws SystemException {
2539            if (_persistenceImpl.containsRole.contains(permissionId, roleId)) {
2540                ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
2541
2542                for (ModelListener<Permission> listener : listeners) {
2543                    listener.onBeforeRemoveAssociation(permissionId,
2544                        com.liferay.portal.model.Role.class.getName(), roleId);
2545                }
2546
2547                for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
2548                    listener.onBeforeRemoveAssociation(roleId,
2549                        Permission.class.getName(), permissionId);
2550                }
2551
2552                _sqlUpdate.update(new Object[] {
2553                        new Long(permissionId), new Long(roleId)
2554                    });
2555
2556                for (ModelListener<Permission> listener : listeners) {
2557                    listener.onAfterRemoveAssociation(permissionId,
2558                        com.liferay.portal.model.Role.class.getName(), roleId);
2559                }
2560
2561                for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
2562                    listener.onAfterRemoveAssociation(roleId,
2563                        Permission.class.getName(), permissionId);
2564                }
2565            }
2566        }
2567
2568        private SqlUpdate _sqlUpdate;
2569        private PermissionPersistenceImpl _persistenceImpl;
2570    }
2571
2572    protected class ContainsUser {
2573        protected ContainsUser(PermissionPersistenceImpl persistenceImpl) {
2574            super();
2575
2576            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2577                    _SQL_CONTAINSUSER,
2578                    new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
2579        }
2580
2581        protected boolean contains(long permissionId, long userId) {
2582            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2583                        new Long(permissionId), new Long(userId)
2584                    });
2585
2586            if (results.size() > 0) {
2587                Integer count = results.get(0);
2588
2589                if (count.intValue() > 0) {
2590                    return true;
2591                }
2592            }
2593
2594            return false;
2595        }
2596
2597        private MappingSqlQuery _mappingSqlQuery;
2598    }
2599
2600    protected class AddUser {
2601        protected AddUser(PermissionPersistenceImpl persistenceImpl) {
2602            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2603                    "INSERT INTO Users_Permissions (permissionId, userId) VALUES (?, ?)",
2604                    new int[] { Types.BIGINT, Types.BIGINT });
2605            _persistenceImpl = persistenceImpl;
2606        }
2607
2608        protected void add(long permissionId, long userId)
2609            throws SystemException {
2610            if (!_persistenceImpl.containsUser.contains(permissionId, userId)) {
2611                ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
2612
2613                for (ModelListener<Permission> listener : listeners) {
2614                    listener.onBeforeAddAssociation(permissionId,
2615                        com.liferay.portal.model.User.class.getName(), userId);
2616                }
2617
2618                for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2619                    listener.onBeforeAddAssociation(userId,
2620                        Permission.class.getName(), permissionId);
2621                }
2622
2623                _sqlUpdate.update(new Object[] {
2624                        new Long(permissionId), new Long(userId)
2625                    });
2626
2627                for (ModelListener<Permission> listener : listeners) {
2628                    listener.onAfterAddAssociation(permissionId,
2629                        com.liferay.portal.model.User.class.getName(), userId);
2630                }
2631
2632                for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2633                    listener.onAfterAddAssociation(userId,
2634                        Permission.class.getName(), permissionId);
2635                }
2636            }
2637        }
2638
2639        private SqlUpdate _sqlUpdate;
2640        private PermissionPersistenceImpl _persistenceImpl;
2641    }
2642
2643    protected class ClearUsers {
2644        protected ClearUsers(PermissionPersistenceImpl persistenceImpl) {
2645            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2646                    "DELETE FROM Users_Permissions WHERE permissionId = ?",
2647                    new int[] { Types.BIGINT });
2648        }
2649
2650        protected void clear(long permissionId) throws SystemException {
2651            ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
2652
2653            List<com.liferay.portal.model.User> users = null;
2654
2655            if ((listeners.length > 0) || (userListeners.length > 0)) {
2656                users = getUsers(permissionId);
2657
2658                for (com.liferay.portal.model.User user : users) {
2659                    for (ModelListener<Permission> listener : listeners) {
2660                        listener.onBeforeRemoveAssociation(permissionId,
2661                            com.liferay.portal.model.User.class.getName(),
2662                            user.getPrimaryKey());
2663                    }
2664
2665                    for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2666                        listener.onBeforeRemoveAssociation(user.getPrimaryKey(),
2667                            Permission.class.getName(), permissionId);
2668                    }
2669                }
2670            }
2671
2672            _sqlUpdate.update(new Object[] { new Long(permissionId) });
2673
2674            if ((listeners.length > 0) || (userListeners.length > 0)) {
2675                for (com.liferay.portal.model.User user : users) {
2676                    for (ModelListener<Permission> listener : listeners) {
2677                        listener.onAfterRemoveAssociation(permissionId,
2678                            com.liferay.portal.model.User.class.getName(),
2679                            user.getPrimaryKey());
2680                    }
2681
2682                    for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2683                        listener.onAfterRemoveAssociation(user.getPrimaryKey(),
2684                            Permission.class.getName(), permissionId);
2685                    }
2686                }
2687            }
2688        }
2689
2690        private SqlUpdate _sqlUpdate;
2691    }
2692
2693    protected class RemoveUser {
2694        protected RemoveUser(PermissionPersistenceImpl persistenceImpl) {
2695            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2696                    "DELETE FROM Users_Permissions WHERE permissionId = ? AND userId = ?",
2697                    new int[] { Types.BIGINT, Types.BIGINT });
2698            _persistenceImpl = persistenceImpl;
2699        }
2700
2701        protected void remove(long permissionId, long userId)
2702            throws SystemException {
2703            if (_persistenceImpl.containsUser.contains(permissionId, userId)) {
2704                ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
2705
2706                for (ModelListener<Permission> listener : listeners) {
2707                    listener.onBeforeRemoveAssociation(permissionId,
2708                        com.liferay.portal.model.User.class.getName(), userId);
2709                }
2710
2711                for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2712                    listener.onBeforeRemoveAssociation(userId,
2713                        Permission.class.getName(), permissionId);
2714                }
2715
2716                _sqlUpdate.update(new Object[] {
2717                        new Long(permissionId), new Long(userId)
2718                    });
2719
2720                for (ModelListener<Permission> listener : listeners) {
2721                    listener.onAfterRemoveAssociation(permissionId,
2722                        com.liferay.portal.model.User.class.getName(), userId);
2723                }
2724
2725                for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2726                    listener.onAfterRemoveAssociation(userId,
2727                        Permission.class.getName(), permissionId);
2728                }
2729            }
2730        }
2731
2732        private SqlUpdate _sqlUpdate;
2733        private PermissionPersistenceImpl _persistenceImpl;
2734    }
2735
2736    private static final String _SQL_GETGROUPS = "SELECT {Group_.*} FROM Group_ INNER JOIN Groups_Permissions ON (Groups_Permissions.groupId = Group_.groupId) WHERE (Groups_Permissions.permissionId = ?)";
2737    private static final String _SQL_GETGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Permissions WHERE permissionId = ?";
2738    private static final String _SQL_CONTAINSGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Permissions WHERE permissionId = ? AND groupId = ?";
2739    private static final String _SQL_GETROLES = "SELECT {Role_.*} FROM Role_ INNER JOIN Roles_Permissions ON (Roles_Permissions.roleId = Role_.roleId) WHERE (Roles_Permissions.permissionId = ?)";
2740    private static final String _SQL_GETROLESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Roles_Permissions WHERE permissionId = ?";
2741    private static final String _SQL_CONTAINSROLE = "SELECT COUNT(*) AS COUNT_VALUE FROM Roles_Permissions WHERE permissionId = ? AND roleId = ?";
2742    private static final String _SQL_GETUSERS = "SELECT {User_.*} FROM User_ INNER JOIN Users_Permissions ON (Users_Permissions.userId = User_.userId) WHERE (Users_Permissions.permissionId = ?)";
2743    private static final String _SQL_GETUSERSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Permissions WHERE permissionId = ?";
2744    private static final String _SQL_CONTAINSUSER = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Permissions WHERE permissionId = ? AND userId = ?";
2745    private static Log _log = LogFactoryUtil.getLog(PermissionPersistenceImpl.class);
2746}