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