1
22
23 package com.liferay.portal.service.persistence;
24
25 import com.liferay.portal.NoSuchResourceActionException;
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.orm.DynamicQuery;
30 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
31 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
32 import com.liferay.portal.kernel.dao.orm.FinderPath;
33 import com.liferay.portal.kernel.dao.orm.Query;
34 import com.liferay.portal.kernel.dao.orm.QueryPos;
35 import com.liferay.portal.kernel.dao.orm.QueryUtil;
36 import com.liferay.portal.kernel.dao.orm.Session;
37 import com.liferay.portal.kernel.log.Log;
38 import com.liferay.portal.kernel.log.LogFactoryUtil;
39 import com.liferay.portal.kernel.util.GetterUtil;
40 import com.liferay.portal.kernel.util.OrderByComparator;
41 import com.liferay.portal.kernel.util.StringPool;
42 import com.liferay.portal.kernel.util.StringUtil;
43 import com.liferay.portal.kernel.util.Validator;
44 import com.liferay.portal.model.ModelListener;
45 import com.liferay.portal.model.ResourceAction;
46 import com.liferay.portal.model.impl.ResourceActionImpl;
47 import com.liferay.portal.model.impl.ResourceActionModelImpl;
48 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
49
50 import java.util.ArrayList;
51 import java.util.Collections;
52 import java.util.List;
53
54
60 public class ResourceActionPersistenceImpl extends BasePersistenceImpl
61 implements ResourceActionPersistence {
62 public static final String FINDER_CLASS_NAME_ENTITY = ResourceActionImpl.class.getName();
63 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
64 ".List";
65 public static final FinderPath FINDER_PATH_FIND_BY_NAME = new FinderPath(ResourceActionModelImpl.ENTITY_CACHE_ENABLED,
66 ResourceActionModelImpl.FINDER_CACHE_ENABLED,
67 FINDER_CLASS_NAME_LIST, "findByName",
68 new String[] { String.class.getName() });
69 public static final FinderPath FINDER_PATH_FIND_BY_OBC_NAME = new FinderPath(ResourceActionModelImpl.ENTITY_CACHE_ENABLED,
70 ResourceActionModelImpl.FINDER_CACHE_ENABLED,
71 FINDER_CLASS_NAME_LIST, "findByName",
72 new String[] {
73 String.class.getName(),
74
75 "java.lang.Integer", "java.lang.Integer",
76 "com.liferay.portal.kernel.util.OrderByComparator"
77 });
78 public static final FinderPath FINDER_PATH_COUNT_BY_NAME = new FinderPath(ResourceActionModelImpl.ENTITY_CACHE_ENABLED,
79 ResourceActionModelImpl.FINDER_CACHE_ENABLED,
80 FINDER_CLASS_NAME_LIST, "countByName",
81 new String[] { String.class.getName() });
82 public static final FinderPath FINDER_PATH_FETCH_BY_N_A = new FinderPath(ResourceActionModelImpl.ENTITY_CACHE_ENABLED,
83 ResourceActionModelImpl.FINDER_CACHE_ENABLED,
84 FINDER_CLASS_NAME_ENTITY, "fetchByN_A",
85 new String[] { String.class.getName(), String.class.getName() });
86 public static final FinderPath FINDER_PATH_COUNT_BY_N_A = new FinderPath(ResourceActionModelImpl.ENTITY_CACHE_ENABLED,
87 ResourceActionModelImpl.FINDER_CACHE_ENABLED,
88 FINDER_CLASS_NAME_LIST, "countByN_A",
89 new String[] { String.class.getName(), String.class.getName() });
90 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(ResourceActionModelImpl.ENTITY_CACHE_ENABLED,
91 ResourceActionModelImpl.FINDER_CACHE_ENABLED,
92 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
93 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(ResourceActionModelImpl.ENTITY_CACHE_ENABLED,
94 ResourceActionModelImpl.FINDER_CACHE_ENABLED,
95 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
96
97 public void cacheResult(ResourceAction resourceAction) {
98 EntityCacheUtil.putResult(ResourceActionModelImpl.ENTITY_CACHE_ENABLED,
99 ResourceActionImpl.class, resourceAction.getPrimaryKey(),
100 resourceAction);
101
102 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_A,
103 new Object[] { resourceAction.getName(), resourceAction.getActionId() },
104 resourceAction);
105 }
106
107 public void cacheResult(List<ResourceAction> resourceActions) {
108 for (ResourceAction resourceAction : resourceActions) {
109 if (EntityCacheUtil.getResult(
110 ResourceActionModelImpl.ENTITY_CACHE_ENABLED,
111 ResourceActionImpl.class,
112 resourceAction.getPrimaryKey(), this) == null) {
113 cacheResult(resourceAction);
114 }
115 }
116 }
117
118 public void clearCache() {
119 CacheRegistry.clear(ResourceActionImpl.class.getName());
120 EntityCacheUtil.clearCache(ResourceActionImpl.class.getName());
121 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
122 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
123 }
124
125 public ResourceAction create(long resourceActionId) {
126 ResourceAction resourceAction = new ResourceActionImpl();
127
128 resourceAction.setNew(true);
129 resourceAction.setPrimaryKey(resourceActionId);
130
131 return resourceAction;
132 }
133
134 public ResourceAction remove(long resourceActionId)
135 throws NoSuchResourceActionException, SystemException {
136 Session session = null;
137
138 try {
139 session = openSession();
140
141 ResourceAction resourceAction = (ResourceAction)session.get(ResourceActionImpl.class,
142 new Long(resourceActionId));
143
144 if (resourceAction == null) {
145 if (_log.isWarnEnabled()) {
146 _log.warn("No ResourceAction exists with the primary key " +
147 resourceActionId);
148 }
149
150 throw new NoSuchResourceActionException(
151 "No ResourceAction exists with the primary key " +
152 resourceActionId);
153 }
154
155 return remove(resourceAction);
156 }
157 catch (NoSuchResourceActionException nsee) {
158 throw nsee;
159 }
160 catch (Exception e) {
161 throw processException(e);
162 }
163 finally {
164 closeSession(session);
165 }
166 }
167
168 public ResourceAction remove(ResourceAction resourceAction)
169 throws SystemException {
170 for (ModelListener<ResourceAction> listener : listeners) {
171 listener.onBeforeRemove(resourceAction);
172 }
173
174 resourceAction = removeImpl(resourceAction);
175
176 for (ModelListener<ResourceAction> listener : listeners) {
177 listener.onAfterRemove(resourceAction);
178 }
179
180 return resourceAction;
181 }
182
183 protected ResourceAction removeImpl(ResourceAction resourceAction)
184 throws SystemException {
185 Session session = null;
186
187 try {
188 session = openSession();
189
190 if (resourceAction.isCachedModel() || BatchSessionUtil.isEnabled()) {
191 Object staleObject = session.get(ResourceActionImpl.class,
192 resourceAction.getPrimaryKeyObj());
193
194 if (staleObject != null) {
195 session.evict(staleObject);
196 }
197 }
198
199 session.delete(resourceAction);
200
201 session.flush();
202 }
203 catch (Exception e) {
204 throw processException(e);
205 }
206 finally {
207 closeSession(session);
208 }
209
210 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
211
212 ResourceActionModelImpl resourceActionModelImpl = (ResourceActionModelImpl)resourceAction;
213
214 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_N_A,
215 new Object[] {
216 resourceActionModelImpl.getOriginalName(),
217
218 resourceActionModelImpl.getOriginalActionId()
219 });
220
221 EntityCacheUtil.removeResult(ResourceActionModelImpl.ENTITY_CACHE_ENABLED,
222 ResourceActionImpl.class, resourceAction.getPrimaryKey());
223
224 return resourceAction;
225 }
226
227
230 public ResourceAction update(ResourceAction resourceAction)
231 throws SystemException {
232 if (_log.isWarnEnabled()) {
233 _log.warn(
234 "Using the deprecated update(ResourceAction resourceAction) method. Use update(ResourceAction resourceAction, boolean merge) instead.");
235 }
236
237 return update(resourceAction, false);
238 }
239
240
253 public ResourceAction update(ResourceAction resourceAction, boolean merge)
254 throws SystemException {
255 boolean isNew = resourceAction.isNew();
256
257 for (ModelListener<ResourceAction> listener : listeners) {
258 if (isNew) {
259 listener.onBeforeCreate(resourceAction);
260 }
261 else {
262 listener.onBeforeUpdate(resourceAction);
263 }
264 }
265
266 resourceAction = updateImpl(resourceAction, merge);
267
268 for (ModelListener<ResourceAction> listener : listeners) {
269 if (isNew) {
270 listener.onAfterCreate(resourceAction);
271 }
272 else {
273 listener.onAfterUpdate(resourceAction);
274 }
275 }
276
277 return resourceAction;
278 }
279
280 public ResourceAction updateImpl(
281 com.liferay.portal.model.ResourceAction resourceAction, boolean merge)
282 throws SystemException {
283 boolean isNew = resourceAction.isNew();
284
285 ResourceActionModelImpl resourceActionModelImpl = (ResourceActionModelImpl)resourceAction;
286
287 Session session = null;
288
289 try {
290 session = openSession();
291
292 BatchSessionUtil.update(session, resourceAction, merge);
293
294 resourceAction.setNew(false);
295 }
296 catch (Exception e) {
297 throw processException(e);
298 }
299 finally {
300 closeSession(session);
301 }
302
303 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
304
305 EntityCacheUtil.putResult(ResourceActionModelImpl.ENTITY_CACHE_ENABLED,
306 ResourceActionImpl.class, resourceAction.getPrimaryKey(),
307 resourceAction);
308
309 if (!isNew &&
310 (!Validator.equals(resourceAction.getName(),
311 resourceActionModelImpl.getOriginalName()) ||
312 !Validator.equals(resourceAction.getActionId(),
313 resourceActionModelImpl.getOriginalActionId()))) {
314 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_N_A,
315 new Object[] {
316 resourceActionModelImpl.getOriginalName(),
317
318 resourceActionModelImpl.getOriginalActionId()
319 });
320 }
321
322 if (isNew ||
323 (!Validator.equals(resourceAction.getName(),
324 resourceActionModelImpl.getOriginalName()) ||
325 !Validator.equals(resourceAction.getActionId(),
326 resourceActionModelImpl.getOriginalActionId()))) {
327 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_A,
328 new Object[] {
329 resourceAction.getName(),
330
331 resourceAction.getActionId()
332 }, resourceAction);
333 }
334
335 return resourceAction;
336 }
337
338 public ResourceAction findByPrimaryKey(long resourceActionId)
339 throws NoSuchResourceActionException, SystemException {
340 ResourceAction resourceAction = fetchByPrimaryKey(resourceActionId);
341
342 if (resourceAction == null) {
343 if (_log.isWarnEnabled()) {
344 _log.warn("No ResourceAction exists with the primary key " +
345 resourceActionId);
346 }
347
348 throw new NoSuchResourceActionException(
349 "No ResourceAction exists with the primary key " +
350 resourceActionId);
351 }
352
353 return resourceAction;
354 }
355
356 public ResourceAction fetchByPrimaryKey(long resourceActionId)
357 throws SystemException {
358 ResourceAction resourceAction = (ResourceAction)EntityCacheUtil.getResult(ResourceActionModelImpl.ENTITY_CACHE_ENABLED,
359 ResourceActionImpl.class, resourceActionId, this);
360
361 if (resourceAction == null) {
362 Session session = null;
363
364 try {
365 session = openSession();
366
367 resourceAction = (ResourceAction)session.get(ResourceActionImpl.class,
368 new Long(resourceActionId));
369 }
370 catch (Exception e) {
371 throw processException(e);
372 }
373 finally {
374 if (resourceAction != null) {
375 cacheResult(resourceAction);
376 }
377
378 closeSession(session);
379 }
380 }
381
382 return resourceAction;
383 }
384
385 public List<ResourceAction> findByName(String name)
386 throws SystemException {
387 Object[] finderArgs = new Object[] { name };
388
389 List<ResourceAction> list = (List<ResourceAction>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_NAME,
390 finderArgs, this);
391
392 if (list == null) {
393 Session session = null;
394
395 try {
396 session = openSession();
397
398 StringBuilder query = new StringBuilder();
399
400 query.append(
401 "FROM com.liferay.portal.model.ResourceAction WHERE ");
402
403 if (name == null) {
404 query.append("name IS NULL");
405 }
406 else {
407 query.append("name = ?");
408 }
409
410 query.append(" ");
411
412 query.append("ORDER BY ");
413
414 query.append("name ASC, ");
415 query.append("bitwiseValue ASC");
416
417 Query q = session.createQuery(query.toString());
418
419 QueryPos qPos = QueryPos.getInstance(q);
420
421 if (name != null) {
422 qPos.add(name);
423 }
424
425 list = q.list();
426 }
427 catch (Exception e) {
428 throw processException(e);
429 }
430 finally {
431 if (list == null) {
432 list = new ArrayList<ResourceAction>();
433 }
434
435 cacheResult(list);
436
437 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_NAME, finderArgs,
438 list);
439
440 closeSession(session);
441 }
442 }
443
444 return list;
445 }
446
447 public List<ResourceAction> findByName(String name, int start, int end)
448 throws SystemException {
449 return findByName(name, start, end, null);
450 }
451
452 public List<ResourceAction> findByName(String name, int start, int end,
453 OrderByComparator obc) throws SystemException {
454 Object[] finderArgs = new Object[] {
455 name,
456
457 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
458 };
459
460 List<ResourceAction> list = (List<ResourceAction>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_NAME,
461 finderArgs, this);
462
463 if (list == null) {
464 Session session = null;
465
466 try {
467 session = openSession();
468
469 StringBuilder query = new StringBuilder();
470
471 query.append(
472 "FROM com.liferay.portal.model.ResourceAction WHERE ");
473
474 if (name == null) {
475 query.append("name IS NULL");
476 }
477 else {
478 query.append("name = ?");
479 }
480
481 query.append(" ");
482
483 if (obc != null) {
484 query.append("ORDER BY ");
485 query.append(obc.getOrderBy());
486 }
487
488 else {
489 query.append("ORDER BY ");
490
491 query.append("name ASC, ");
492 query.append("bitwiseValue ASC");
493 }
494
495 Query q = session.createQuery(query.toString());
496
497 QueryPos qPos = QueryPos.getInstance(q);
498
499 if (name != null) {
500 qPos.add(name);
501 }
502
503 list = (List<ResourceAction>)QueryUtil.list(q, getDialect(),
504 start, end);
505 }
506 catch (Exception e) {
507 throw processException(e);
508 }
509 finally {
510 if (list == null) {
511 list = new ArrayList<ResourceAction>();
512 }
513
514 cacheResult(list);
515
516 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_NAME,
517 finderArgs, list);
518
519 closeSession(session);
520 }
521 }
522
523 return list;
524 }
525
526 public ResourceAction findByName_First(String name, OrderByComparator obc)
527 throws NoSuchResourceActionException, SystemException {
528 List<ResourceAction> list = findByName(name, 0, 1, obc);
529
530 if (list.isEmpty()) {
531 StringBuilder msg = new StringBuilder();
532
533 msg.append("No ResourceAction exists with the key {");
534
535 msg.append("name=" + name);
536
537 msg.append(StringPool.CLOSE_CURLY_BRACE);
538
539 throw new NoSuchResourceActionException(msg.toString());
540 }
541 else {
542 return list.get(0);
543 }
544 }
545
546 public ResourceAction findByName_Last(String name, OrderByComparator obc)
547 throws NoSuchResourceActionException, SystemException {
548 int count = countByName(name);
549
550 List<ResourceAction> list = findByName(name, count - 1, count, obc);
551
552 if (list.isEmpty()) {
553 StringBuilder msg = new StringBuilder();
554
555 msg.append("No ResourceAction exists with the key {");
556
557 msg.append("name=" + name);
558
559 msg.append(StringPool.CLOSE_CURLY_BRACE);
560
561 throw new NoSuchResourceActionException(msg.toString());
562 }
563 else {
564 return list.get(0);
565 }
566 }
567
568 public ResourceAction[] findByName_PrevAndNext(long resourceActionId,
569 String name, OrderByComparator obc)
570 throws NoSuchResourceActionException, SystemException {
571 ResourceAction resourceAction = findByPrimaryKey(resourceActionId);
572
573 int count = countByName(name);
574
575 Session session = null;
576
577 try {
578 session = openSession();
579
580 StringBuilder query = new StringBuilder();
581
582 query.append("FROM com.liferay.portal.model.ResourceAction WHERE ");
583
584 if (name == null) {
585 query.append("name IS NULL");
586 }
587 else {
588 query.append("name = ?");
589 }
590
591 query.append(" ");
592
593 if (obc != null) {
594 query.append("ORDER BY ");
595 query.append(obc.getOrderBy());
596 }
597
598 else {
599 query.append("ORDER BY ");
600
601 query.append("name ASC, ");
602 query.append("bitwiseValue ASC");
603 }
604
605 Query q = session.createQuery(query.toString());
606
607 QueryPos qPos = QueryPos.getInstance(q);
608
609 if (name != null) {
610 qPos.add(name);
611 }
612
613 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
614 resourceAction);
615
616 ResourceAction[] array = new ResourceActionImpl[3];
617
618 array[0] = (ResourceAction)objArray[0];
619 array[1] = (ResourceAction)objArray[1];
620 array[2] = (ResourceAction)objArray[2];
621
622 return array;
623 }
624 catch (Exception e) {
625 throw processException(e);
626 }
627 finally {
628 closeSession(session);
629 }
630 }
631
632 public ResourceAction findByN_A(String name, String actionId)
633 throws NoSuchResourceActionException, SystemException {
634 ResourceAction resourceAction = fetchByN_A(name, actionId);
635
636 if (resourceAction == null) {
637 StringBuilder msg = new StringBuilder();
638
639 msg.append("No ResourceAction exists with the key {");
640
641 msg.append("name=" + name);
642
643 msg.append(", ");
644 msg.append("actionId=" + actionId);
645
646 msg.append(StringPool.CLOSE_CURLY_BRACE);
647
648 if (_log.isWarnEnabled()) {
649 _log.warn(msg.toString());
650 }
651
652 throw new NoSuchResourceActionException(msg.toString());
653 }
654
655 return resourceAction;
656 }
657
658 public ResourceAction fetchByN_A(String name, String actionId)
659 throws SystemException {
660 return fetchByN_A(name, actionId, true);
661 }
662
663 public ResourceAction fetchByN_A(String name, String actionId,
664 boolean retrieveFromCache) throws SystemException {
665 Object[] finderArgs = new Object[] { name, actionId };
666
667 Object result = null;
668
669 if (retrieveFromCache) {
670 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_N_A,
671 finderArgs, this);
672 }
673
674 if (result == null) {
675 Session session = null;
676
677 try {
678 session = openSession();
679
680 StringBuilder query = new StringBuilder();
681
682 query.append(
683 "FROM com.liferay.portal.model.ResourceAction WHERE ");
684
685 if (name == null) {
686 query.append("name IS NULL");
687 }
688 else {
689 query.append("name = ?");
690 }
691
692 query.append(" AND ");
693
694 if (actionId == null) {
695 query.append("actionId IS NULL");
696 }
697 else {
698 query.append("actionId = ?");
699 }
700
701 query.append(" ");
702
703 query.append("ORDER BY ");
704
705 query.append("name ASC, ");
706 query.append("bitwiseValue ASC");
707
708 Query q = session.createQuery(query.toString());
709
710 QueryPos qPos = QueryPos.getInstance(q);
711
712 if (name != null) {
713 qPos.add(name);
714 }
715
716 if (actionId != null) {
717 qPos.add(actionId);
718 }
719
720 List<ResourceAction> list = q.list();
721
722 result = list;
723
724 ResourceAction resourceAction = null;
725
726 if (list.isEmpty()) {
727 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_A,
728 finderArgs, list);
729 }
730 else {
731 resourceAction = list.get(0);
732
733 cacheResult(resourceAction);
734
735 if ((resourceAction.getName() == null) ||
736 !resourceAction.getName().equals(name) ||
737 (resourceAction.getActionId() == null) ||
738 !resourceAction.getActionId().equals(actionId)) {
739 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_A,
740 finderArgs, resourceAction);
741 }
742 }
743
744 return resourceAction;
745 }
746 catch (Exception e) {
747 throw processException(e);
748 }
749 finally {
750 if (result == null) {
751 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_A,
752 finderArgs, new ArrayList<ResourceAction>());
753 }
754
755 closeSession(session);
756 }
757 }
758 else {
759 if (result instanceof List) {
760 return null;
761 }
762 else {
763 return (ResourceAction)result;
764 }
765 }
766 }
767
768 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
769 throws SystemException {
770 Session session = null;
771
772 try {
773 session = openSession();
774
775 dynamicQuery.compile(session);
776
777 return dynamicQuery.list();
778 }
779 catch (Exception e) {
780 throw processException(e);
781 }
782 finally {
783 closeSession(session);
784 }
785 }
786
787 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
788 int start, int end) throws SystemException {
789 Session session = null;
790
791 try {
792 session = openSession();
793
794 dynamicQuery.setLimit(start, end);
795
796 dynamicQuery.compile(session);
797
798 return dynamicQuery.list();
799 }
800 catch (Exception e) {
801 throw processException(e);
802 }
803 finally {
804 closeSession(session);
805 }
806 }
807
808 public List<ResourceAction> findAll() throws SystemException {
809 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
810 }
811
812 public List<ResourceAction> findAll(int start, int end)
813 throws SystemException {
814 return findAll(start, end, null);
815 }
816
817 public List<ResourceAction> findAll(int start, int end,
818 OrderByComparator obc) throws SystemException {
819 Object[] finderArgs = new Object[] {
820 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
821 };
822
823 List<ResourceAction> list = (List<ResourceAction>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
824 finderArgs, this);
825
826 if (list == null) {
827 Session session = null;
828
829 try {
830 session = openSession();
831
832 StringBuilder query = new StringBuilder();
833
834 query.append("FROM com.liferay.portal.model.ResourceAction ");
835
836 if (obc != null) {
837 query.append("ORDER BY ");
838 query.append(obc.getOrderBy());
839 }
840
841 else {
842 query.append("ORDER BY ");
843
844 query.append("name ASC, ");
845 query.append("bitwiseValue ASC");
846 }
847
848 Query q = session.createQuery(query.toString());
849
850 if (obc == null) {
851 list = (List<ResourceAction>)QueryUtil.list(q,
852 getDialect(), start, end, false);
853
854 Collections.sort(list);
855 }
856 else {
857 list = (List<ResourceAction>)QueryUtil.list(q,
858 getDialect(), start, end);
859 }
860 }
861 catch (Exception e) {
862 throw processException(e);
863 }
864 finally {
865 if (list == null) {
866 list = new ArrayList<ResourceAction>();
867 }
868
869 cacheResult(list);
870
871 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
872
873 closeSession(session);
874 }
875 }
876
877 return list;
878 }
879
880 public void removeByName(String name) throws SystemException {
881 for (ResourceAction resourceAction : findByName(name)) {
882 remove(resourceAction);
883 }
884 }
885
886 public void removeByN_A(String name, String actionId)
887 throws NoSuchResourceActionException, SystemException {
888 ResourceAction resourceAction = findByN_A(name, actionId);
889
890 remove(resourceAction);
891 }
892
893 public void removeAll() throws SystemException {
894 for (ResourceAction resourceAction : findAll()) {
895 remove(resourceAction);
896 }
897 }
898
899 public int countByName(String name) throws SystemException {
900 Object[] finderArgs = new Object[] { name };
901
902 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_NAME,
903 finderArgs, this);
904
905 if (count == null) {
906 Session session = null;
907
908 try {
909 session = openSession();
910
911 StringBuilder query = new StringBuilder();
912
913 query.append("SELECT COUNT(*) ");
914 query.append(
915 "FROM com.liferay.portal.model.ResourceAction WHERE ");
916
917 if (name == null) {
918 query.append("name IS NULL");
919 }
920 else {
921 query.append("name = ?");
922 }
923
924 query.append(" ");
925
926 Query q = session.createQuery(query.toString());
927
928 QueryPos qPos = QueryPos.getInstance(q);
929
930 if (name != null) {
931 qPos.add(name);
932 }
933
934 count = (Long)q.uniqueResult();
935 }
936 catch (Exception e) {
937 throw processException(e);
938 }
939 finally {
940 if (count == null) {
941 count = Long.valueOf(0);
942 }
943
944 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_NAME,
945 finderArgs, count);
946
947 closeSession(session);
948 }
949 }
950
951 return count.intValue();
952 }
953
954 public int countByN_A(String name, String actionId)
955 throws SystemException {
956 Object[] finderArgs = new Object[] { name, actionId };
957
958 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_A,
959 finderArgs, this);
960
961 if (count == null) {
962 Session session = null;
963
964 try {
965 session = openSession();
966
967 StringBuilder query = new StringBuilder();
968
969 query.append("SELECT COUNT(*) ");
970 query.append(
971 "FROM com.liferay.portal.model.ResourceAction WHERE ");
972
973 if (name == null) {
974 query.append("name IS NULL");
975 }
976 else {
977 query.append("name = ?");
978 }
979
980 query.append(" AND ");
981
982 if (actionId == null) {
983 query.append("actionId IS NULL");
984 }
985 else {
986 query.append("actionId = ?");
987 }
988
989 query.append(" ");
990
991 Query q = session.createQuery(query.toString());
992
993 QueryPos qPos = QueryPos.getInstance(q);
994
995 if (name != null) {
996 qPos.add(name);
997 }
998
999 if (actionId != null) {
1000 qPos.add(actionId);
1001 }
1002
1003 count = (Long)q.uniqueResult();
1004 }
1005 catch (Exception e) {
1006 throw processException(e);
1007 }
1008 finally {
1009 if (count == null) {
1010 count = Long.valueOf(0);
1011 }
1012
1013 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_A, finderArgs,
1014 count);
1015
1016 closeSession(session);
1017 }
1018 }
1019
1020 return count.intValue();
1021 }
1022
1023 public int countAll() throws SystemException {
1024 Object[] finderArgs = new Object[0];
1025
1026 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1027 finderArgs, this);
1028
1029 if (count == null) {
1030 Session session = null;
1031
1032 try {
1033 session = openSession();
1034
1035 Query q = session.createQuery(
1036 "SELECT COUNT(*) FROM com.liferay.portal.model.ResourceAction");
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_ALL, finderArgs,
1049 count);
1050
1051 closeSession(session);
1052 }
1053 }
1054
1055 return count.intValue();
1056 }
1057
1058 public void afterPropertiesSet() {
1059 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1060 com.liferay.portal.util.PropsUtil.get(
1061 "value.object.listener.com.liferay.portal.model.ResourceAction")));
1062
1063 if (listenerClassNames.length > 0) {
1064 try {
1065 List<ModelListener<ResourceAction>> listenersList = new ArrayList<ModelListener<ResourceAction>>();
1066
1067 for (String listenerClassName : listenerClassNames) {
1068 listenersList.add((ModelListener<ResourceAction>)Class.forName(
1069 listenerClassName).newInstance());
1070 }
1071
1072 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1073 }
1074 catch (Exception e) {
1075 _log.error(e);
1076 }
1077 }
1078 }
1079
1080 @BeanReference(name = "com.liferay.portal.service.persistence.AccountPersistence.impl")
1081 protected com.liferay.portal.service.persistence.AccountPersistence accountPersistence;
1082 @BeanReference(name = "com.liferay.portal.service.persistence.AddressPersistence.impl")
1083 protected com.liferay.portal.service.persistence.AddressPersistence addressPersistence;
1084 @BeanReference(name = "com.liferay.portal.service.persistence.BrowserTrackerPersistence.impl")
1085 protected com.liferay.portal.service.persistence.BrowserTrackerPersistence browserTrackerPersistence;
1086 @BeanReference(name = "com.liferay.portal.service.persistence.ClassNamePersistence.impl")
1087 protected com.liferay.portal.service.persistence.ClassNamePersistence classNamePersistence;
1088 @BeanReference(name = "com.liferay.portal.service.persistence.CompanyPersistence.impl")
1089 protected com.liferay.portal.service.persistence.CompanyPersistence companyPersistence;
1090 @BeanReference(name = "com.liferay.portal.service.persistence.ContactPersistence.impl")
1091 protected com.liferay.portal.service.persistence.ContactPersistence contactPersistence;
1092 @BeanReference(name = "com.liferay.portal.service.persistence.CountryPersistence.impl")
1093 protected com.liferay.portal.service.persistence.CountryPersistence countryPersistence;
1094 @BeanReference(name = "com.liferay.portal.service.persistence.EmailAddressPersistence.impl")
1095 protected com.liferay.portal.service.persistence.EmailAddressPersistence emailAddressPersistence;
1096 @BeanReference(name = "com.liferay.portal.service.persistence.GroupPersistence.impl")
1097 protected com.liferay.portal.service.persistence.GroupPersistence groupPersistence;
1098 @BeanReference(name = "com.liferay.portal.service.persistence.ImagePersistence.impl")
1099 protected com.liferay.portal.service.persistence.ImagePersistence imagePersistence;
1100 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutPersistence.impl")
1101 protected com.liferay.portal.service.persistence.LayoutPersistence layoutPersistence;
1102 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutSetPersistence.impl")
1103 protected com.liferay.portal.service.persistence.LayoutSetPersistence layoutSetPersistence;
1104 @BeanReference(name = "com.liferay.portal.service.persistence.ListTypePersistence.impl")
1105 protected com.liferay.portal.service.persistence.ListTypePersistence listTypePersistence;
1106 @BeanReference(name = "com.liferay.portal.service.persistence.MembershipRequestPersistence.impl")
1107 protected com.liferay.portal.service.persistence.MembershipRequestPersistence membershipRequestPersistence;
1108 @BeanReference(name = "com.liferay.portal.service.persistence.OrganizationPersistence.impl")
1109 protected com.liferay.portal.service.persistence.OrganizationPersistence organizationPersistence;
1110 @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupPermissionPersistence.impl")
1111 protected com.liferay.portal.service.persistence.OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1112 @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupRolePersistence.impl")
1113 protected com.liferay.portal.service.persistence.OrgGroupRolePersistence orgGroupRolePersistence;
1114 @BeanReference(name = "com.liferay.portal.service.persistence.OrgLaborPersistence.impl")
1115 protected com.liferay.portal.service.persistence.OrgLaborPersistence orgLaborPersistence;
1116 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyPersistence.impl")
1117 protected com.liferay.portal.service.persistence.PasswordPolicyPersistence passwordPolicyPersistence;
1118 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyRelPersistence.impl")
1119 protected com.liferay.portal.service.persistence.PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1120 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordTrackerPersistence.impl")
1121 protected com.liferay.portal.service.persistence.PasswordTrackerPersistence passwordTrackerPersistence;
1122 @BeanReference(name = "com.liferay.portal.service.persistence.PermissionPersistence.impl")
1123 protected com.liferay.portal.service.persistence.PermissionPersistence permissionPersistence;
1124 @BeanReference(name = "com.liferay.portal.service.persistence.PhonePersistence.impl")
1125 protected com.liferay.portal.service.persistence.PhonePersistence phonePersistence;
1126 @BeanReference(name = "com.liferay.portal.service.persistence.PluginSettingPersistence.impl")
1127 protected com.liferay.portal.service.persistence.PluginSettingPersistence pluginSettingPersistence;
1128 @BeanReference(name = "com.liferay.portal.service.persistence.PortletPersistence.impl")
1129 protected com.liferay.portal.service.persistence.PortletPersistence portletPersistence;
1130 @BeanReference(name = "com.liferay.portal.service.persistence.PortletItemPersistence.impl")
1131 protected com.liferay.portal.service.persistence.PortletItemPersistence portletItemPersistence;
1132 @BeanReference(name = "com.liferay.portal.service.persistence.PortletPreferencesPersistence.impl")
1133 protected com.liferay.portal.service.persistence.PortletPreferencesPersistence portletPreferencesPersistence;
1134 @BeanReference(name = "com.liferay.portal.service.persistence.RegionPersistence.impl")
1135 protected com.liferay.portal.service.persistence.RegionPersistence regionPersistence;
1136 @BeanReference(name = "com.liferay.portal.service.persistence.ReleasePersistence.impl")
1137 protected com.liferay.portal.service.persistence.ReleasePersistence releasePersistence;
1138 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
1139 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
1140 @BeanReference(name = "com.liferay.portal.service.persistence.ResourceActionPersistence.impl")
1141 protected com.liferay.portal.service.persistence.ResourceActionPersistence resourceActionPersistence;
1142 @BeanReference(name = "com.liferay.portal.service.persistence.ResourceCodePersistence.impl")
1143 protected com.liferay.portal.service.persistence.ResourceCodePersistence resourceCodePersistence;
1144 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePermissionPersistence.impl")
1145 protected com.liferay.portal.service.persistence.ResourcePermissionPersistence resourcePermissionPersistence;
1146 @BeanReference(name = "com.liferay.portal.service.persistence.RolePersistence.impl")
1147 protected com.liferay.portal.service.persistence.RolePersistence rolePersistence;
1148 @BeanReference(name = "com.liferay.portal.service.persistence.ServiceComponentPersistence.impl")
1149 protected com.liferay.portal.service.persistence.ServiceComponentPersistence serviceComponentPersistence;
1150 @BeanReference(name = "com.liferay.portal.service.persistence.ShardPersistence.impl")
1151 protected com.liferay.portal.service.persistence.ShardPersistence shardPersistence;
1152 @BeanReference(name = "com.liferay.portal.service.persistence.SubscriptionPersistence.impl")
1153 protected com.liferay.portal.service.persistence.SubscriptionPersistence subscriptionPersistence;
1154 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
1155 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
1156 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupPersistence.impl")
1157 protected com.liferay.portal.service.persistence.UserGroupPersistence userGroupPersistence;
1158 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupRolePersistence.impl")
1159 protected com.liferay.portal.service.persistence.UserGroupRolePersistence userGroupRolePersistence;
1160 @BeanReference(name = "com.liferay.portal.service.persistence.UserIdMapperPersistence.impl")
1161 protected com.liferay.portal.service.persistence.UserIdMapperPersistence userIdMapperPersistence;
1162 @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPersistence.impl")
1163 protected com.liferay.portal.service.persistence.UserTrackerPersistence userTrackerPersistence;
1164 @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPathPersistence.impl")
1165 protected com.liferay.portal.service.persistence.UserTrackerPathPersistence userTrackerPathPersistence;
1166 @BeanReference(name = "com.liferay.portal.service.persistence.WebDAVPropsPersistence.impl")
1167 protected com.liferay.portal.service.persistence.WebDAVPropsPersistence webDAVPropsPersistence;
1168 @BeanReference(name = "com.liferay.portal.service.persistence.WebsitePersistence.impl")
1169 protected com.liferay.portal.service.persistence.WebsitePersistence websitePersistence;
1170 private static Log _log = LogFactoryUtil.getLog(ResourceActionPersistenceImpl.class);
1171}