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