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                     "FROM com.liferay.portlet.wiki.model.WikiPageResource WHERE ");
425 
426                 query.append("nodeId = ?");
427 
428                 query.append(" AND ");
429 
430                 if (title == null) {
431                     query.append("title IS NULL");
432                 }
433                 else {
434                     query.append("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                     "FROM com.liferay.portlet.wiki.model.WikiPageResource ");
564 
565                 if (obc != null) {
566                     query.append("ORDER BY ");
567                     query.append(obc.getOrderBy());
568                 }
569 
570                 Query q = session.createQuery(query.toString());
571 
572                 if (obc == null) {
573                     list = (List<WikiPageResource>)QueryUtil.list(q,
574                             getDialect(), start, end, false);
575 
576                     Collections.sort(list);
577                 }
578                 else {
579                     list = (List<WikiPageResource>)QueryUtil.list(q,
580                             getDialect(), start, end);
581                 }
582             }
583             catch (Exception e) {
584                 throw processException(e);
585             }
586             finally {
587                 if (list == null) {
588                     list = new ArrayList<WikiPageResource>();
589                 }
590 
591                 cacheResult(list);
592 
593                 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
594 
595                 closeSession(session);
596             }
597         }
598 
599         return list;
600     }
601 
602     public void removeByN_T(long nodeId, String title)
603         throws NoSuchPageResourceException, SystemException {
604         WikiPageResource wikiPageResource = findByN_T(nodeId, title);
605 
606         remove(wikiPageResource);
607     }
608 
609     public void removeAll() throws SystemException {
610         for (WikiPageResource wikiPageResource : findAll()) {
611             remove(wikiPageResource);
612         }
613     }
614 
615     public int countByN_T(long nodeId, String title) throws SystemException {
616         Object[] finderArgs = new Object[] { new Long(nodeId), title };
617 
618         Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_T,
619                 finderArgs, this);
620 
621         if (count == null) {
622             Session session = null;
623 
624             try {
625                 session = openSession();
626 
627                 StringBuilder query = new StringBuilder();
628 
629                 query.append("SELECT COUNT(*) ");
630                 query.append(
631                     "FROM com.liferay.portlet.wiki.model.WikiPageResource WHERE ");
632 
633                 query.append("nodeId = ?");
634 
635                 query.append(" AND ");
636 
637                 if (title == null) {
638                     query.append("title IS NULL");
639                 }
640                 else {
641                     query.append("title = ?");
642                 }
643 
644                 query.append(" ");
645 
646                 Query q = session.createQuery(query.toString());
647 
648                 QueryPos qPos = QueryPos.getInstance(q);
649 
650                 qPos.add(nodeId);
651 
652                 if (title != null) {
653                     qPos.add(title);
654                 }
655 
656                 count = (Long)q.uniqueResult();
657             }
658             catch (Exception e) {
659                 throw processException(e);
660             }
661             finally {
662                 if (count == null) {
663                     count = Long.valueOf(0);
664                 }
665 
666                 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_T, finderArgs,
667                     count);
668 
669                 closeSession(session);
670             }
671         }
672 
673         return count.intValue();
674     }
675 
676     public int countAll() throws SystemException {
677         Object[] finderArgs = new Object[0];
678 
679         Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
680                 finderArgs, this);
681 
682         if (count == null) {
683             Session session = null;
684 
685             try {
686                 session = openSession();
687 
688                 Query q = session.createQuery(
689                         "SELECT COUNT(*) FROM com.liferay.portlet.wiki.model.WikiPageResource");
690 
691                 count = (Long)q.uniqueResult();
692             }
693             catch (Exception e) {
694                 throw processException(e);
695             }
696             finally {
697                 if (count == null) {
698                     count = Long.valueOf(0);
699                 }
700 
701                 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
702                     count);
703 
704                 closeSession(session);
705             }
706         }
707 
708         return count.intValue();
709     }
710 
711     public void afterPropertiesSet() {
712         String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
713                     com.liferay.portal.util.PropsUtil.get(
714                         "value.object.listener.com.liferay.portlet.wiki.model.WikiPageResource")));
715 
716         if (listenerClassNames.length > 0) {
717             try {
718                 List<ModelListener<WikiPageResource>> listenersList = new ArrayList<ModelListener<WikiPageResource>>();
719 
720                 for (String listenerClassName : listenerClassNames) {
721                     listenersList.add((ModelListener<WikiPageResource>)Class.forName(
722                             listenerClassName).newInstance());
723                 }
724 
725                 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
726             }
727             catch (Exception e) {
728                 _log.error(e);
729             }
730         }
731     }
732 
733     @BeanReference(name = "com.liferay.portlet.wiki.service.persistence.WikiNodePersistence.impl")
734     protected com.liferay.portlet.wiki.service.persistence.WikiNodePersistence wikiNodePersistence;
735     @BeanReference(name = "com.liferay.portlet.wiki.service.persistence.WikiPagePersistence.impl")
736     protected com.liferay.portlet.wiki.service.persistence.WikiPagePersistence wikiPagePersistence;
737     @BeanReference(name = "com.liferay.portlet.wiki.service.persistence.WikiPageResourcePersistence.impl")
738     protected com.liferay.portlet.wiki.service.persistence.WikiPageResourcePersistence wikiPageResourcePersistence;
739     private static Log _log = LogFactoryUtil.getLog(WikiPageResourcePersistenceImpl.class);
740 }