1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions 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.portlet.wiki.service.persistence;
24  
25  import com.liferay.portal.SystemException;
26  import com.liferay.portal.kernel.annotation.BeanReference;
27  import com.liferay.portal.kernel.cache.CacheRegistry;
28  import com.liferay.portal.kernel.dao.orm.DynamicQuery;
29  import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
30  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
31  import com.liferay.portal.kernel.dao.orm.FinderPath;
32  import com.liferay.portal.kernel.dao.orm.Query;
33  import com.liferay.portal.kernel.dao.orm.QueryPos;
34  import com.liferay.portal.kernel.dao.orm.QueryUtil;
35  import com.liferay.portal.kernel.dao.orm.Session;
36  import com.liferay.portal.kernel.log.Log;
37  import com.liferay.portal.kernel.log.LogFactoryUtil;
38  import com.liferay.portal.kernel.util.GetterUtil;
39  import com.liferay.portal.kernel.util.OrderByComparator;
40  import com.liferay.portal.kernel.util.StringPool;
41  import com.liferay.portal.kernel.util.StringUtil;
42  import com.liferay.portal.kernel.util.Validator;
43  import com.liferay.portal.model.ModelListener;
44  import com.liferay.portal.service.persistence.BatchSessionUtil;
45  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
46  
47  import com.liferay.portlet.wiki.NoSuchPageResourceException;
48  import com.liferay.portlet.wiki.model.WikiPageResource;
49  import com.liferay.portlet.wiki.model.impl.WikiPageResourceImpl;
50  import com.liferay.portlet.wiki.model.impl.WikiPageResourceModelImpl;
51  
52  import java.util.ArrayList;
53  import java.util.Collections;
54  import java.util.List;
55  
56  /**
57   * <a href="WikiPageResourcePersistenceImpl.java.html"><b><i>View Source</i></b></a>
58   *
59   * @author Brian Wing Shun Chan
60   *
61   */
62  public class WikiPageResourcePersistenceImpl extends BasePersistenceImpl
63      implements WikiPageResourcePersistence {
64      public static final String FINDER_CLASS_NAME_ENTITY = WikiPageResourceImpl.class.getName();
65      public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
66          ".List";
67      public static final FinderPath FINDER_PATH_FETCH_BY_N_T = new FinderPath(WikiPageResourceModelImpl.ENTITY_CACHE_ENABLED,
68              WikiPageResourceModelImpl.FINDER_CACHE_ENABLED,
69              FINDER_CLASS_NAME_ENTITY, "fetchByN_T",
70              new String[] { Long.class.getName(), String.class.getName() });
71      public static final FinderPath FINDER_PATH_COUNT_BY_N_T = new FinderPath(WikiPageResourceModelImpl.ENTITY_CACHE_ENABLED,
72              WikiPageResourceModelImpl.FINDER_CACHE_ENABLED,
73              FINDER_CLASS_NAME_LIST, "countByN_T",
74              new String[] { Long.class.getName(), String.class.getName() });
75      public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(WikiPageResourceModelImpl.ENTITY_CACHE_ENABLED,
76              WikiPageResourceModelImpl.FINDER_CACHE_ENABLED,
77              FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
78      public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(WikiPageResourceModelImpl.ENTITY_CACHE_ENABLED,
79              WikiPageResourceModelImpl.FINDER_CACHE_ENABLED,
80              FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
81  
82      public void cacheResult(WikiPageResource wikiPageResource) {
83          EntityCacheUtil.putResult(WikiPageResourceModelImpl.ENTITY_CACHE_ENABLED,
84              WikiPageResourceImpl.class, wikiPageResource.getPrimaryKey(),
85              wikiPageResource);
86  
87          FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T,
88              new Object[] {
89                  new Long(wikiPageResource.getNodeId()),
90                  
91              wikiPageResource.getTitle()
92              }, wikiPageResource);
93      }
94  
95      public void cacheResult(List<WikiPageResource> wikiPageResources) {
96          for (WikiPageResource wikiPageResource : wikiPageResources) {
97              if (EntityCacheUtil.getResult(
98                          WikiPageResourceModelImpl.ENTITY_CACHE_ENABLED,
99                          WikiPageResourceImpl.class,
100                         wikiPageResource.getPrimaryKey(), this) == null) {
101                 cacheResult(wikiPageResource);
102             }
103         }
104     }
105 
106     public void clearCache() {
107         CacheRegistry.clear(WikiPageResourceImpl.class.getName());
108         EntityCacheUtil.clearCache(WikiPageResourceImpl.class.getName());
109         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
110         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
111     }
112 
113     public WikiPageResource create(long resourcePrimKey) {
114         WikiPageResource wikiPageResource = new WikiPageResourceImpl();
115 
116         wikiPageResource.setNew(true);
117         wikiPageResource.setPrimaryKey(resourcePrimKey);
118 
119         return wikiPageResource;
120     }
121 
122     public WikiPageResource remove(long resourcePrimKey)
123         throws NoSuchPageResourceException, SystemException {
124         Session session = null;
125 
126         try {
127             session = openSession();
128 
129             WikiPageResource wikiPageResource = (WikiPageResource)session.get(WikiPageResourceImpl.class,
130                     new Long(resourcePrimKey));
131 
132             if (wikiPageResource == null) {
133                 if (_log.isWarnEnabled()) {
134                     _log.warn(
135                         "No WikiPageResource exists with the primary key " +
136                         resourcePrimKey);
137                 }
138 
139                 throw new NoSuchPageResourceException(
140                     "No WikiPageResource exists with the primary key " +
141                     resourcePrimKey);
142             }
143 
144             return remove(wikiPageResource);
145         }
146         catch (NoSuchPageResourceException nsee) {
147             throw nsee;
148         }
149         catch (Exception e) {
150             throw processException(e);
151         }
152         finally {
153             closeSession(session);
154         }
155     }
156 
157     public WikiPageResource remove(WikiPageResource wikiPageResource)
158         throws SystemException {
159         for (ModelListener<WikiPageResource> listener : listeners) {
160             listener.onBeforeRemove(wikiPageResource);
161         }
162 
163         wikiPageResource = removeImpl(wikiPageResource);
164 
165         for (ModelListener<WikiPageResource> listener : listeners) {
166             listener.onAfterRemove(wikiPageResource);
167         }
168 
169         return wikiPageResource;
170     }
171 
172     protected WikiPageResource removeImpl(WikiPageResource wikiPageResource)
173         throws SystemException {
174         Session session = null;
175 
176         try {
177             session = openSession();
178 
179             if (wikiPageResource.isCachedModel() ||
180                     BatchSessionUtil.isEnabled()) {
181                 Object staleObject = session.get(WikiPageResourceImpl.class,
182                         wikiPageResource.getPrimaryKeyObj());
183 
184                 if (staleObject != null) {
185                     session.evict(staleObject);
186                 }
187             }
188 
189             session.delete(wikiPageResource);
190 
191             session.flush();
192         }
193         catch (Exception e) {
194             throw processException(e);
195         }
196         finally {
197             closeSession(session);
198         }
199 
200         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
201 
202         WikiPageResourceModelImpl wikiPageResourceModelImpl = (WikiPageResourceModelImpl)wikiPageResource;
203 
204         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_N_T,
205             new Object[] {
206                 new Long(wikiPageResourceModelImpl.getOriginalNodeId()),
207                 
208             wikiPageResourceModelImpl.getOriginalTitle()
209             });
210 
211         EntityCacheUtil.removeResult(WikiPageResourceModelImpl.ENTITY_CACHE_ENABLED,
212             WikiPageResourceImpl.class, wikiPageResource.getPrimaryKey());
213 
214         return wikiPageResource;
215     }
216 
217     /**
218      * @deprecated Use <code>update(WikiPageResource wikiPageResource, boolean merge)</code>.
219      */
220     public WikiPageResource update(WikiPageResource wikiPageResource)
221         throws SystemException {
222         if (_log.isWarnEnabled()) {
223             _log.warn(
224                 "Using the deprecated update(WikiPageResource wikiPageResource) method. Use update(WikiPageResource wikiPageResource, boolean merge) instead.");
225         }
226 
227         return update(wikiPageResource, false);
228     }
229 
230     /**
231      * Add, update, or merge, the entity. This method also calls the model
232      * listeners to trigger the proper events associated with adding, deleting,
233      * or updating an entity.
234      *
235      * @param        wikiPageResource the entity to add, update, or merge
236      * @param        merge boolean value for whether to merge the entity. The
237      *                default value is false. Setting merge to true is more
238      *                expensive and should only be true when wikiPageResource is
239      *                transient. See LEP-5473 for a detailed discussion of this
240      *                method.
241      * @return        true if the portlet can be displayed via Ajax
242      */
243     public WikiPageResource update(WikiPageResource wikiPageResource,
244         boolean merge) throws SystemException {
245         boolean isNew = wikiPageResource.isNew();
246 
247         for (ModelListener<WikiPageResource> listener : listeners) {
248             if (isNew) {
249                 listener.onBeforeCreate(wikiPageResource);
250             }
251             else {
252                 listener.onBeforeUpdate(wikiPageResource);
253             }
254         }
255 
256         wikiPageResource = updateImpl(wikiPageResource, merge);
257 
258         for (ModelListener<WikiPageResource> listener : listeners) {
259             if (isNew) {
260                 listener.onAfterCreate(wikiPageResource);
261             }
262             else {
263                 listener.onAfterUpdate(wikiPageResource);
264             }
265         }
266 
267         return wikiPageResource;
268     }
269 
270     public WikiPageResource updateImpl(
271         com.liferay.portlet.wiki.model.WikiPageResource wikiPageResource,
272         boolean merge) throws SystemException {
273         boolean isNew = wikiPageResource.isNew();
274 
275         WikiPageResourceModelImpl wikiPageResourceModelImpl = (WikiPageResourceModelImpl)wikiPageResource;
276 
277         Session session = null;
278 
279         try {
280             session = openSession();
281 
282             BatchSessionUtil.update(session, wikiPageResource, merge);
283 
284             wikiPageResource.setNew(false);
285         }
286         catch (Exception e) {
287             throw processException(e);
288         }
289         finally {
290             closeSession(session);
291         }
292 
293         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
294 
295         EntityCacheUtil.putResult(WikiPageResourceModelImpl.ENTITY_CACHE_ENABLED,
296             WikiPageResourceImpl.class, wikiPageResource.getPrimaryKey(),
297             wikiPageResource);
298 
299         if (!isNew &&
300                 ((wikiPageResource.getNodeId() != wikiPageResourceModelImpl.getOriginalNodeId()) ||
301                 !Validator.equals(wikiPageResource.getTitle(),
302                     wikiPageResourceModelImpl.getOriginalTitle()))) {
303             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_N_T,
304                 new Object[] {
305                     new Long(wikiPageResourceModelImpl.getOriginalNodeId()),
306                     
307                 wikiPageResourceModelImpl.getOriginalTitle()
308                 });
309         }
310 
311         if (isNew ||
312                 ((wikiPageResource.getNodeId() != wikiPageResourceModelImpl.getOriginalNodeId()) ||
313                 !Validator.equals(wikiPageResource.getTitle(),
314                     wikiPageResourceModelImpl.getOriginalTitle()))) {
315             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T,
316                 new Object[] {
317                     new Long(wikiPageResource.getNodeId()),
318                     
319                 wikiPageResource.getTitle()
320                 }, wikiPageResource);
321         }
322 
323         return wikiPageResource;
324     }
325 
326     public WikiPageResource findByPrimaryKey(long resourcePrimKey)
327         throws NoSuchPageResourceException, SystemException {
328         WikiPageResource wikiPageResource = fetchByPrimaryKey(resourcePrimKey);
329 
330         if (wikiPageResource == null) {
331             if (_log.isWarnEnabled()) {
332                 _log.warn("No WikiPageResource exists with the primary key " +
333                     resourcePrimKey);
334             }
335 
336             throw new NoSuchPageResourceException(
337                 "No WikiPageResource exists with the primary key " +
338                 resourcePrimKey);
339         }
340 
341         return wikiPageResource;
342     }
343 
344     public WikiPageResource fetchByPrimaryKey(long resourcePrimKey)
345         throws SystemException {
346         WikiPageResource wikiPageResource = (WikiPageResource)EntityCacheUtil.getResult(WikiPageResourceModelImpl.ENTITY_CACHE_ENABLED,
347                 WikiPageResourceImpl.class, resourcePrimKey, this);
348 
349         if (wikiPageResource == null) {
350             Session session = null;
351 
352             try {
353                 session = openSession();
354 
355                 wikiPageResource = (WikiPageResource)session.get(WikiPageResourceImpl.class,
356                         new Long(resourcePrimKey));
357             }
358             catch (Exception e) {
359                 throw processException(e);
360             }
361             finally {
362                 if (wikiPageResource != null) {
363                     cacheResult(wikiPageResource);
364                 }
365 
366                 closeSession(session);
367             }
368         }
369 
370         return wikiPageResource;
371     }
372 
373     public WikiPageResource findByN_T(long nodeId, String title)
374         throws NoSuchPageResourceException, SystemException {
375         WikiPageResource wikiPageResource = fetchByN_T(nodeId, title);
376 
377         if (wikiPageResource == null) {
378             StringBuilder msg = new StringBuilder();
379 
380             msg.append("No WikiPageResource exists with the key {");
381 
382             msg.append("nodeId=" + nodeId);
383 
384             msg.append(", ");
385             msg.append("title=" + title);
386 
387             msg.append(StringPool.CLOSE_CURLY_BRACE);
388 
389             if (_log.isWarnEnabled()) {
390                 _log.warn(msg.toString());
391             }
392 
393             throw new NoSuchPageResourceException(msg.toString());
394         }
395 
396         return wikiPageResource;
397     }
398 
399     public WikiPageResource fetchByN_T(long nodeId, String title)
400         throws SystemException {
401         return fetchByN_T(nodeId, title, true);
402     }
403 
404     public WikiPageResource fetchByN_T(long nodeId, String title,
405         boolean retrieveFromCache) throws SystemException {
406         Object[] finderArgs = new Object[] { new Long(nodeId), title };
407 
408         Object result = null;
409 
410         if (retrieveFromCache) {
411             result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_N_T,
412                     finderArgs, this);
413         }
414 
415         if (result == null) {
416             Session session = null;
417 
418             try {
419                 session = openSession();
420 
421                 StringBuilder query = new StringBuilder();
422 
423                 query.append(
424                     "SELECT wikiPageResource FROM WikiPageResource wikiPageResource WHERE ");
425 
426                 query.append("wikiPageResource.nodeId = ?");
427 
428                 query.append(" AND ");
429 
430                 if (title == null) {
431                     query.append("wikiPageResource.title IS NULL");
432                 }
433                 else {
434                     query.append("wikiPageResource.title = ?");
435                 }
436 
437                 query.append(" ");
438 
439                 Query q = session.createQuery(query.toString());
440 
441                 QueryPos qPos = QueryPos.getInstance(q);
442 
443                 qPos.add(nodeId);
444 
445                 if (title != null) {
446                     qPos.add(title);
447                 }
448 
449                 List<WikiPageResource> list = q.list();
450 
451                 result = list;
452 
453                 WikiPageResource wikiPageResource = null;
454 
455                 if (list.isEmpty()) {
456                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T,
457                         finderArgs, list);
458                 }
459                 else {
460                     wikiPageResource = list.get(0);
461 
462                     cacheResult(wikiPageResource);
463 
464                     if ((wikiPageResource.getNodeId() != nodeId) ||
465                             (wikiPageResource.getTitle() == null) ||
466                             !wikiPageResource.getTitle().equals(title)) {
467                         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T,
468                             finderArgs, wikiPageResource);
469                     }
470                 }
471 
472                 return wikiPageResource;
473             }
474             catch (Exception e) {
475                 throw processException(e);
476             }
477             finally {
478                 if (result == null) {
479                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T,
480                         finderArgs, new ArrayList<WikiPageResource>());
481                 }
482 
483                 closeSession(session);
484             }
485         }
486         else {
487             if (result instanceof List) {
488                 return null;
489             }
490             else {
491                 return (WikiPageResource)result;
492             }
493         }
494     }
495 
496     public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
497         throws SystemException {
498         Session session = null;
499 
500         try {
501             session = openSession();
502 
503             dynamicQuery.compile(session);
504 
505             return dynamicQuery.list();
506         }
507         catch (Exception e) {
508             throw processException(e);
509         }
510         finally {
511             closeSession(session);
512         }
513     }
514 
515     public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
516         int start, int end) throws SystemException {
517         Session session = null;
518 
519         try {
520             session = openSession();
521 
522             dynamicQuery.setLimit(start, end);
523 
524             dynamicQuery.compile(session);
525 
526             return dynamicQuery.list();
527         }
528         catch (Exception e) {
529             throw processException(e);
530         }
531         finally {
532             closeSession(session);
533         }
534     }
535 
536     public List<WikiPageResource> findAll() throws SystemException {
537         return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
538     }
539 
540     public List<WikiPageResource> findAll(int start, int end)
541         throws SystemException {
542         return findAll(start, end, null);
543     }
544 
545     public List<WikiPageResource> findAll(int start, int end,
546         OrderByComparator obc) throws SystemException {
547         Object[] finderArgs = new Object[] {
548                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
549             };
550 
551         List<WikiPageResource> list = (List<WikiPageResource>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
552                 finderArgs, this);
553 
554         if (list == null) {
555             Session session = null;
556 
557             try {
558                 session = openSession();
559 
560                 StringBuilder query = new StringBuilder();
561 
562                 query.append(
563                     "SELECT wikiPageResource FROM WikiPageResource wikiPageResource ");
564 
565                 if (obc != null) {
566                     query.append("ORDER BY ");
567 
568                     String[] orderByFields = obc.getOrderByFields();
569 
570                     for (int i = 0; i < orderByFields.length; i++) {
571                         query.append("wikiPageResource.");
572                         query.append(orderByFields[i]);
573 
574                         if (obc.isAscending()) {
575                             query.append(" ASC");
576                         }
577                         else {
578                             query.append(" DESC");
579                         }
580 
581                         if ((i + 1) < orderByFields.length) {
582                             query.append(", ");
583                         }
584                     }
585                 }
586 
587                 Query q = session.createQuery(query.toString());
588 
589                 if (obc == null) {
590                     list = (List<WikiPageResource>)QueryUtil.list(q,
591                             getDialect(), start, end, false);
592 
593                     Collections.sort(list);
594                 }
595                 else {
596                     list = (List<WikiPageResource>)QueryUtil.list(q,
597                             getDialect(), start, end);
598                 }
599             }
600             catch (Exception e) {
601                 throw processException(e);
602             }
603             finally {
604                 if (list == null) {
605                     list = new ArrayList<WikiPageResource>();
606                 }
607 
608                 cacheResult(list);
609 
610                 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
611 
612                 closeSession(session);
613             }
614         }
615 
616         return list;
617     }
618 
619     public void removeByN_T(long nodeId, String title)
620         throws NoSuchPageResourceException, SystemException {
621         WikiPageResource wikiPageResource = findByN_T(nodeId, title);
622 
623         remove(wikiPageResource);
624     }
625 
626     public void removeAll() throws SystemException {
627         for (WikiPageResource wikiPageResource : findAll()) {
628             remove(wikiPageResource);
629         }
630     }
631 
632     public int countByN_T(long nodeId, String title) throws SystemException {
633         Object[] finderArgs = new Object[] { new Long(nodeId), title };
634 
635         Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_T,
636                 finderArgs, this);
637 
638         if (count == null) {
639             Session session = null;
640 
641             try {
642                 session = openSession();
643 
644                 StringBuilder query = new StringBuilder();
645 
646                 query.append("SELECT COUNT(wikiPageResource) ");
647                 query.append("FROM WikiPageResource wikiPageResource WHERE ");
648 
649                 query.append("wikiPageResource.nodeId = ?");
650 
651                 query.append(" AND ");
652 
653                 if (title == null) {
654                     query.append("wikiPageResource.title IS NULL");
655                 }
656                 else {
657                     query.append("wikiPageResource.title = ?");
658                 }
659 
660                 query.append(" ");
661 
662                 Query q = session.createQuery(query.toString());
663 
664                 QueryPos qPos = QueryPos.getInstance(q);
665 
666                 qPos.add(nodeId);
667 
668                 if (title != null) {
669                     qPos.add(title);
670                 }
671 
672                 count = (Long)q.uniqueResult();
673             }
674             catch (Exception e) {
675                 throw processException(e);
676             }
677             finally {
678                 if (count == null) {
679                     count = Long.valueOf(0);
680                 }
681 
682                 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_T, finderArgs,
683                     count);
684 
685                 closeSession(session);
686             }
687         }
688 
689         return count.intValue();
690     }
691 
692     public int countAll() throws SystemException {
693         Object[] finderArgs = new Object[0];
694 
695         Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
696                 finderArgs, this);
697 
698         if (count == null) {
699             Session session = null;
700 
701             try {
702                 session = openSession();
703 
704                 Query q = session.createQuery(
705                         "SELECT COUNT(wikiPageResource) FROM WikiPageResource wikiPageResource");
706 
707                 count = (Long)q.uniqueResult();
708             }
709             catch (Exception e) {
710                 throw processException(e);
711             }
712             finally {
713                 if (count == null) {
714                     count = Long.valueOf(0);
715                 }
716 
717                 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
718                     count);
719 
720                 closeSession(session);
721             }
722         }
723 
724         return count.intValue();
725     }
726 
727     public void afterPropertiesSet() {
728         String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
729                     com.liferay.portal.util.PropsUtil.get(
730                         "value.object.listener.com.liferay.portlet.wiki.model.WikiPageResource")));
731 
732         if (listenerClassNames.length > 0) {
733             try {
734                 List<ModelListener<WikiPageResource>> listenersList = new ArrayList<ModelListener<WikiPageResource>>();
735 
736                 for (String listenerClassName : listenerClassNames) {
737                     listenersList.add((ModelListener<WikiPageResource>)Class.forName(
738                             listenerClassName).newInstance());
739                 }
740 
741                 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
742             }
743             catch (Exception e) {
744                 _log.error(e);
745             }
746         }
747     }
748 
749     @BeanReference(name = "com.liferay.portlet.wiki.service.persistence.WikiNodePersistence.impl")
750     protected com.liferay.portlet.wiki.service.persistence.WikiNodePersistence wikiNodePersistence;
751     @BeanReference(name = "com.liferay.portlet.wiki.service.persistence.WikiPagePersistence.impl")
752     protected com.liferay.portlet.wiki.service.persistence.WikiPagePersistence wikiPagePersistence;
753     @BeanReference(name = "com.liferay.portlet.wiki.service.persistence.WikiPageResourcePersistence.impl")
754     protected com.liferay.portlet.wiki.service.persistence.WikiPageResourcePersistence wikiPageResourcePersistence;
755     private static Log _log = LogFactoryUtil.getLog(WikiPageResourcePersistenceImpl.class);
756 }