KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > cms > controllers > kernel > impl > simple > SiteNodeVersionController


1 /* ===============================================================================
2  *
3  * Part of the InfoGlue Content Management Platform (www.infoglue.org)
4  *
5  * ===============================================================================
6  *
7  * Copyright (C)
8  *
9  * This program is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License version 2, as published by the
11  * Free Software Foundation. See the file LICENSE.html for more information.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
19  * Place, Suite 330 / Boston, MA 02111-1307 / USA.
20  *
21  * ===============================================================================
22  */

23
24 package org.infoglue.cms.controllers.kernel.impl.simple;
25
26 import java.util.ArrayList JavaDoc;
27 import java.util.Collection JavaDoc;
28 import java.util.Collections JavaDoc;
29 import java.util.Iterator JavaDoc;
30 import java.util.List JavaDoc;
31
32 import org.apache.log4j.Logger;
33 import org.exolab.castor.jdo.Database;
34 import org.exolab.castor.jdo.OQLQuery;
35 import org.exolab.castor.jdo.QueryResults;
36 import org.infoglue.cms.entities.content.Content;
37 import org.infoglue.cms.entities.content.ContentVO;
38 import org.infoglue.cms.entities.content.ContentVersion;
39 import org.infoglue.cms.entities.kernel.BaseEntityVO;
40 import org.infoglue.cms.entities.management.AvailableServiceBinding;
41 import org.infoglue.cms.entities.management.Language;
42 import org.infoglue.cms.entities.management.RegistryVO;
43 import org.infoglue.cms.entities.structure.ServiceBinding;
44 import org.infoglue.cms.entities.structure.SiteNode;
45 import org.infoglue.cms.entities.structure.SiteNodeVO;
46 import org.infoglue.cms.entities.structure.SiteNodeVersion;
47 import org.infoglue.cms.entities.structure.SiteNodeVersionVO;
48 import org.infoglue.cms.entities.structure.impl.simple.SiteNodeImpl;
49 import org.infoglue.cms.entities.structure.impl.simple.SiteNodeVersionImpl;
50 import org.infoglue.cms.exception.Bug;
51 import org.infoglue.cms.exception.ConstraintException;
52 import org.infoglue.cms.exception.SystemException;
53 import org.infoglue.cms.security.InfoGluePrincipal;
54 import org.infoglue.cms.util.ConstraintExceptionBuffer;
55 import org.infoglue.cms.util.DateHelper;
56
57 public class SiteNodeVersionController extends BaseController
58 {
59     private final static Logger logger = Logger.getLogger(SiteNodeVersionController.class.getName());
60
61     private final RegistryController registryController = RegistryController.getController();
62
63     /**
64      * Factory method
65      */

66
67     public static SiteNodeVersionController getController()
68     {
69         return new SiteNodeVersionController();
70     }
71     
72     public SiteNodeVersionVO getSiteNodeVersionVOWithId(Integer JavaDoc siteNodeVersionId) throws SystemException, Bug
73     {
74         return (SiteNodeVersionVO) getVOWithId(SiteNodeVersionImpl.class, siteNodeVersionId);
75     }
76     
77     public SiteNodeVersion getSiteNodeVersionWithId(Integer JavaDoc siteNodeVersionId, Database db) throws SystemException, Bug
78     {
79         return (SiteNodeVersion) getObjectWithId(SiteNodeVersionImpl.class, siteNodeVersionId, db);
80     }
81
82     public static SiteNodeVersion getSiteNodeVersionWithIdAsReadOnly(Integer JavaDoc siteNodeVersionId, Database db) throws SystemException, Bug
83     {
84         return (SiteNodeVersion) getObjectWithIdAsReadOnly(SiteNodeVersionImpl.class, siteNodeVersionId, db);
85     }
86
87     public List JavaDoc getSiteNodeVersionVOList() throws SystemException, Bug
88     {
89         return getAllVOObjects(SiteNodeVersionImpl.class, "siteNodeVersionId");
90     }
91
92     public static void delete(SiteNodeVersionVO siteNodeVersionVO) throws ConstraintException, SystemException
93     {
94         deleteEntity(SiteNodeVersionImpl.class, siteNodeVersionVO.getSiteNodeVersionId());
95     }
96
97     /**
98      * This method removes the siteNodeVersion and also all associated bindings.
99      * @param siteNodeVersion
100      * @param db
101      * @throws ConstraintException
102      * @throws SystemException
103      */

104     public void delete(SiteNodeVersion siteNodeVersion, Database db) throws ConstraintException, SystemException
105     {
106         ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();
107
108         try
109         {
110             SiteNode siteNode = siteNodeVersion.getOwningSiteNode();
111             Collection JavaDoc serviceBindings = siteNodeVersion.getServiceBindings();
112             Iterator JavaDoc serviceBindingsIterator = serviceBindings.iterator();
113             while(serviceBindingsIterator.hasNext())
114             {
115                 ServiceBinding serviceBinding = (ServiceBinding)serviceBindingsIterator.next();
116                 serviceBindingsIterator.remove();
117                 db.remove(serviceBinding);
118             }
119             
120             if(siteNode != null)
121                 siteNode.getSiteNodeVersions().remove(siteNodeVersion);
122             
123             db.remove(siteNodeVersion);
124         }
125         catch(Exception JavaDoc e)
126         {
127             logger.error("An error occurred so we should not completes the transaction:" + e, e);
128             throw new SystemException(e.getMessage());
129         }
130     }
131     
132
133     /**
134      * This method creates an initial siteNodeVersion for the siteNode sent in and within the transaction sent in.
135      */

136     
137     public static SiteNodeVersion createInitialSiteNodeVersion(Database db, SiteNode siteNode, InfoGluePrincipal infoGluePrincipal) throws SystemException, Bug
138     {
139         ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();
140
141         SiteNodeVersion siteNodeVersion = null;
142
143         try
144         {
145             //SiteNode siteNode = SiteNodeController.getSiteNodeWithId(siteNodeId, db);
146

147             siteNodeVersion = new SiteNodeVersionImpl();
148             siteNodeVersion.setIsCheckedOut(new Boolean JavaDoc(false));
149             siteNodeVersion.setModifiedDateTime(DateHelper.getSecondPreciseDate());
150             siteNodeVersion.setOwningSiteNode((SiteNodeImpl)siteNode);
151             siteNodeVersion.setStateId(new Integer JavaDoc(0));
152             siteNodeVersion.setVersionComment("Initial version");
153             siteNodeVersion.setVersionModifier(infoGluePrincipal.getName());
154             siteNodeVersion.setVersionNumber(new Integer JavaDoc(1));
155             
156             db.create((SiteNodeVersion)siteNodeVersion);
157             
158             List JavaDoc siteNodeVersions = new ArrayList JavaDoc();
159             siteNodeVersions.add(siteNodeVersion);
160             siteNode.setSiteNodeVersions(siteNodeVersions);
161         }
162         catch(Exception JavaDoc e)
163         {
164             logger.error("An error occurred so we should not completes the transaction:" + e, e);
165             throw new SystemException(e.getMessage());
166         }
167         
168         return siteNodeVersion;
169     }
170
171     /**
172      * This method creates a new siteNodeVersion for the siteNode sent in.
173      */

174     
175     public static SiteNodeVersion create(Integer JavaDoc siteNodeId, InfoGluePrincipal infoGluePrincipal, SiteNodeVersionVO siteNodeVersionVO) throws SystemException, Bug
176     {
177         Database db = CastorDatabaseService.getDatabase();
178         ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();
179
180         SiteNodeVersion siteNodeVersion = null;
181
182         beginTransaction(db);
183
184         try
185         {
186             SiteNode siteNode = SiteNodeController.getController().getSiteNodeWithId(siteNodeId, db);
187             
188             siteNodeVersion = new SiteNodeVersionImpl();
189             siteNodeVersion.setOwningSiteNode((SiteNodeImpl)siteNode);
190             siteNodeVersion.setVersionModifier(infoGluePrincipal.getName());
191             siteNodeVersion.setValueObject(siteNodeVersionVO);
192             
193             //Remove later and use a lookup....
194
siteNodeVersion.setVersionNumber(new Integer JavaDoc(1));
195             
196             siteNodeVersion = (SiteNodeVersion)createEntity(siteNodeVersion, db);
197             //commitTransaction(db);
198
}
199         catch(Exception JavaDoc e)
200         {
201             logger.error("An error occurred so we should not completes the transaction:" + e, e);
202             //rollbackTransaction(db);
203
throw new SystemException(e.getMessage());
204         }
205         
206         return siteNodeVersion;
207     }
208
209
210     /**
211      * This method creates a new siteNodeVersion for the siteNode sent in.
212      */

213     
214     public static SiteNodeVersion create(Integer JavaDoc siteNodeId, InfoGluePrincipal infoGluePrincipal, SiteNodeVersionVO siteNodeVersionVO, Database db) throws SystemException, Bug, Exception JavaDoc
215     {
216         SiteNodeVersion siteNodeVersion = null;
217
218         SiteNode siteNode = SiteNodeController.getController().getSiteNodeWithId(siteNodeId, db);
219         
220         siteNodeVersion = new SiteNodeVersionImpl();
221         siteNodeVersion.setOwningSiteNode((SiteNodeImpl)siteNode);
222         siteNodeVersion.setVersionModifier(infoGluePrincipal.getName());
223         siteNodeVersion.setValueObject(siteNodeVersionVO);
224         //Remove later and use a lookup....
225
siteNodeVersion.setVersionNumber(new Integer JavaDoc(1));
226         
227         db.create(siteNodeVersion);
228         
229         return siteNodeVersion;
230     }
231
232
233     public SiteNodeVersionVO getLatestActiveSiteNodeVersionVO(Integer JavaDoc siteNodeId) throws SystemException, Bug
234     {
235         Database db = CastorDatabaseService.getDatabase();
236         ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();
237
238         SiteNodeVersionVO siteNodeVersionVO = null;
239
240         beginTransaction(db);
241
242         try
243         {
244             SiteNodeVersion siteNodeVersion = getLatestActiveSiteNodeVersion(db, siteNodeId);
245             if(siteNodeVersion != null)
246                 siteNodeVersionVO = siteNodeVersion.getValueObject();
247             
248             commitTransaction(db);
249         }
250         catch(Exception JavaDoc e)
251         {
252             logger.error("An error occurred so we should not completes the transaction:" + e, e);
253             rollbackTransaction(db);
254             throw new SystemException(e.getMessage());
255         }
256         
257         return siteNodeVersionVO;
258     }
259
260     public SiteNodeVersion getLatestActiveSiteNodeVersion(Database db, Integer JavaDoc siteNodeId) throws SystemException, Bug, Exception JavaDoc
261     {
262         SiteNodeVersion siteNodeVersion = null;
263         
264         OQLQuery oql = db.getOQLQuery( "SELECT cv FROM org.infoglue.cms.entities.structure.impl.simple.SiteNodeVersionImpl cv WHERE cv.owningSiteNode.siteNodeId = $1 AND cv.isActive = $2 ORDER BY cv.siteNodeVersionId desc");
265         oql.bind(siteNodeId);
266         oql.bind(new Boolean JavaDoc(true));
267         
268         QueryResults results = oql.execute(Database.ReadOnly);
269         
270         if (results.hasMore())
271         {
272             siteNodeVersion = (SiteNodeVersion)results.next();
273         }
274
275         results.close();
276         oql.close();
277
278         return siteNodeVersion;
279     }
280
281     public SiteNodeVersionVO getLatestActiveSiteNodeVersionVO(Database db, Integer JavaDoc siteNodeId) throws SystemException, Bug, Exception JavaDoc
282     {
283         SiteNodeVersionVO siteNodeVersionVO = null;
284         
285         SiteNodeVersion siteNodeVersion = getLatestActiveSiteNodeVersion(db, siteNodeId);
286         if(siteNodeVersion != null)
287             siteNodeVersionVO = siteNodeVersion.getValueObject();
288         else
289             logger.warn("The siteNode " + siteNodeId + " did not have a latest active siteNodeVersion - very strange.");
290         
291         return siteNodeVersionVO;
292     }
293
294     public SiteNodeVersionVO getLatestSiteNodeVersionVO(Integer JavaDoc siteNodeId) throws SystemException, Bug
295     {
296         Database db = CastorDatabaseService.getDatabase();
297         ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();
298
299         SiteNodeVersionVO siteNodeVersionVO = null;
300
301         beginTransaction(db);
302
303         try
304         {
305             OQLQuery oql = db.getOQLQuery( "SELECT cv FROM org.infoglue.cms.entities.structure.impl.simple.SiteNodeVersionImpl cv WHERE cv.owningSiteNode.siteNodeId = $1 ORDER BY cv.siteNodeVersionId desc");
306             oql.bind(siteNodeId);
307             
308             QueryResults results = oql.execute(Database.ReadOnly);
309             
310             if (results.hasMore())
311             {
312                 SiteNodeVersion siteNodeVersion = (SiteNodeVersion)results.next();
313                 logger.info("found one:" + siteNodeVersion.getValueObject());
314                 siteNodeVersionVO = siteNodeVersion.getValueObject();
315             }
316             
317             results.close();
318             oql.close();
319
320             commitTransaction(db);
321         }
322         catch(Exception JavaDoc e)
323         {
324             logger.error("An error occurred so we should not completes the transaction:" + e, e);
325             rollbackTransaction(db);
326             throw new SystemException(e.getMessage());
327         }
328         
329         return siteNodeVersionVO;
330     }
331     
332     
333     public SiteNodeVersionVO getLatestSiteNodeVersionVO(Database db, Integer JavaDoc siteNodeId) throws SystemException, Bug, Exception JavaDoc
334     {
335         SiteNodeVersionVO siteNodeVersionVO = null;
336
337         OQLQuery oql = db.getOQLQuery( "SELECT cv FROM org.infoglue.cms.entities.structure.impl.simple.SiteNodeVersionImpl cv WHERE cv.owningSiteNode.siteNodeId = $1 ORDER BY cv.siteNodeVersionId desc");
338         oql.bind(siteNodeId);
339         
340         QueryResults results = oql.execute(Database.ReadOnly);
341         
342         if (results.hasMore())
343         {
344             SiteNodeVersion siteNodeVersion = (SiteNodeVersion)results.next();
345             logger.info("found one:" + siteNodeVersion.getValueObject());
346             siteNodeVersionVO = siteNodeVersion.getValueObject();
347         }
348         
349         results.close();
350         oql.close();
351
352         return siteNodeVersionVO;
353     }
354
355     /**
356      * This is a method used to get the latest site node version of a sitenode within a given transaction.
357      */

358
359     public SiteNodeVersion getLatestSiteNodeVersion(Database db, Integer JavaDoc siteNodeId, boolean readOnly) throws SystemException, Bug
360     {
361         ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();
362
363         SiteNodeVersion siteNodeVersion = null;
364
365         try
366         {
367             OQLQuery oql = db.getOQLQuery( "SELECT cv FROM org.infoglue.cms.entities.structure.impl.simple.SiteNodeVersionImpl cv WHERE cv.owningSiteNode.siteNodeId = $1 ORDER BY cv.siteNodeVersionId desc");
368             oql.bind(siteNodeId);
369             
370             QueryResults results = null;
371             if(readOnly)
372                 results = oql.execute(Database.ReadOnly);
373             else
374             {
375                 this.logger.info("Fetching entity in read/write mode");
376                 results = oql.execute();
377             }
378             
379             if (results.hasMore())
380             {
381                 siteNodeVersion = (SiteNodeVersion)results.next();
382             }
383
384             results.close();
385             oql.close();
386         }
387         catch(Exception JavaDoc e)
388         {
389             logger.error("An error occurred so we should not completes the transaction:" + e, e);
390             throw new SystemException(e.getMessage());
391         }
392         
393         return siteNodeVersion;
394     }
395
396     
397     public SiteNodeVersionVO updateStateId(Integer JavaDoc siteNodeVersionId, Integer JavaDoc stateId, String JavaDoc versionComment, InfoGluePrincipal infoGluePrincipal, Integer JavaDoc siteNodeId) throws ConstraintException, SystemException
398     {
399         SiteNodeVersionVO siteNodeVersionVO = getSiteNodeVersionVOWithId(siteNodeVersionId);
400         SiteNodeVersionVO returnVO = null;
401         
402         //Here we just updates the state if it's a publish-state-change.
403
if(stateId.intValue() == 2)
404         {
405             siteNodeVersionVO.setStateId(stateId);
406             siteNodeVersionVO.setVersionComment(versionComment);
407             returnVO = (SiteNodeVersionVO) updateEntity(SiteNodeVersionImpl.class, siteNodeVersionVO);
408         }
409                 
410         //Here we create a new version if it was a state-change back to working
411
if(stateId.intValue() == 0)
412         {
413             siteNodeVersionVO.setStateId(stateId);
414             siteNodeVersionVO.setVersionComment("");
415             create(siteNodeId, infoGluePrincipal, siteNodeVersionVO);
416             returnVO = getLatestSiteNodeVersionVO(siteNodeId);
417         }
418         
419         return returnVO;
420     }
421
422     public SiteNodeVersionVO updateStateId(Integer JavaDoc siteNodeVersionId, Integer JavaDoc stateId, String JavaDoc versionComment, InfoGluePrincipal infoGluePrincipal, Integer JavaDoc siteNodeId, Database db) throws ConstraintException, SystemException, Exception JavaDoc
423     {
424         SiteNodeVersionVO siteNodeVersionVO = getSiteNodeVersionWithId(siteNodeVersionId, db).getValueObject();
425         SiteNodeVersionVO returnVO = null;
426         
427         //Here we just updates the state if it's a publish-state-change.
428
if(stateId.intValue() == 2)
429         {
430             siteNodeVersionVO.setStateId(stateId);
431             siteNodeVersionVO.setVersionComment(versionComment);
432             returnVO = (SiteNodeVersionVO) updateEntity(SiteNodeVersionImpl.class, siteNodeVersionVO, db);
433         }
434                 
435         //Here we create a new version if it was a state-change back to working
436
if(stateId.intValue() == 0)
437         {
438             siteNodeVersionVO.setStateId(stateId);
439             siteNodeVersionVO.setVersionComment("");
440             returnVO = create(siteNodeId, infoGluePrincipal, siteNodeVersionVO, db).getValueObject();
441             //returnVO = getLatestSiteNodeVersionVO(siteNodeId, db);
442
}
443         
444         return returnVO;
445     }
446
447
448     public static void deleteVersionsForSiteNodeWithId(Integer JavaDoc siteNodeId) throws ConstraintException, SystemException, Bug
449     {
450         Database db = CastorDatabaseService.getDatabase();
451         ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();
452
453         beginTransaction(db);
454         List JavaDoc siteNodeVersions = new ArrayList JavaDoc();
455         try
456         {
457             OQLQuery oql = db.getOQLQuery( "SELECT cv FROM org.infoglue.cms.entities.structure.impl.simple.SiteNodeVersionImpl cv WHERE cv.owningSiteNode.siteNodeId = $1");
458             oql.bind(siteNodeId);
459             
460             QueryResults results = oql.execute(Database.ReadOnly);
461             
462             while (results.hasMore())
463             {
464                 SiteNodeVersion siteNodeVersion = (SiteNodeVersion)results.next();
465                 siteNodeVersions.add(siteNodeVersion.getValueObject());
466             }
467             
468             results.close();
469             oql.close();
470
471             commitTransaction(db);
472         }
473         catch(Exception JavaDoc e)
474         {
475             e.printStackTrace();
476             logger.error("An error occurred so we should not completes the transaction:" + e, e);
477             rollbackTransaction(db);
478             throw new SystemException(e.getMessage());
479         }
480
481         Iterator JavaDoc i = siteNodeVersions.iterator();
482         while(i.hasNext())
483         {
484             SiteNodeVersionVO siteNodeVersionVO = (SiteNodeVersionVO)i.next();
485             delete(siteNodeVersionVO);
486         }
487     }
488
489     /**
490      * This methods deletes all versions for the siteNode sent in
491      */

492
493     public static void deleteVersionsForSiteNode(SiteNode siteNode, Database db) throws ConstraintException, SystemException, Bug, Exception JavaDoc
494     {
495         Collection JavaDoc siteNodeVersions = Collections.synchronizedCollection(siteNode.getSiteNodeVersions());
496         Iterator JavaDoc siteNodeVersionIterator = siteNodeVersions.iterator();
497             
498         boolean metaInfoContentDeleted = false;
499         while (siteNodeVersionIterator.hasNext())
500         {
501             SiteNodeVersion siteNodeVersion = (SiteNodeVersion)siteNodeVersionIterator.next();
502             Collection JavaDoc serviceBindings = Collections.synchronizedCollection(siteNodeVersion.getServiceBindings());
503             Iterator JavaDoc serviceBindingIterator = serviceBindings.iterator();
504             while(serviceBindingIterator.hasNext())
505             {
506                 ServiceBinding serviceBinding = (ServiceBinding)serviceBindingIterator.next();
507                 if(serviceBinding.getAvailableServiceBinding().getName().equalsIgnoreCase("Meta information"))
508                 {
509                     if(!metaInfoContentDeleted)
510                     {
511                         deleteMetaInfoForSiteNodeVersion(db, serviceBinding);
512                         metaInfoContentDeleted = true;
513                     }
514                     serviceBindingIterator.remove();
515                     db.remove(serviceBinding);
516                 }
517                 else
518                 {
519                     serviceBindingIterator.remove();
520                     db.remove(serviceBinding);
521                 }
522             }
523             
524             logger.info("Deleting siteNodeVersion:" + siteNodeVersion.getSiteNodeVersionId());
525             siteNodeVersionIterator.remove();
526             db.remove(siteNodeVersion);
527         }
528     }
529
530     /**
531      * Deletes the meta info for the sitenode version.
532      *
533      * @param siteNodeVersionId
534      * @return
535      * @throws ConstraintException
536      * @throws SystemException
537      */

538     private static void deleteMetaInfoForSiteNodeVersion(Database db, ServiceBinding serviceBinding) throws ConstraintException, SystemException, Bug, Exception JavaDoc
539     {
540         List JavaDoc boundContents = ContentController.getBoundContents(db, serviceBinding.getId());
541         if(boundContents.size() > 0)
542         {
543             ContentVO contentVO = (ContentVO)boundContents.get(0);
544             ContentController.getContentController().delete(contentVO, db, true, true, true);
545         }
546     }
547     
548     
549     /**
550      * This method returns a list with AvailableServiceBidningVO-objects which are available for the
551      * siteNodeTypeDefinition sent in
552      */

553     
554     public static List JavaDoc getServiceBindningVOList(Integer JavaDoc siteNodeVersionId) throws ConstraintException, SystemException
555     {
556         Database db = CastorDatabaseService.getDatabase();
557         ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();
558
559         List JavaDoc serviceBindningVOList = null;
560
561         beginTransaction(db);
562
563         try
564         {
565             Collection JavaDoc serviceBindningList = getServiceBindningList(siteNodeVersionId, db);
566             serviceBindningVOList = toVOList(serviceBindningList);
567             
568             //If any of the validations or setMethods reported an error, we throw them up now before create.
569
ceb.throwIfNotEmpty();
570             commitTransaction(db);
571         }
572         catch(ConstraintException ce)
573         {
574             logger.warn("An error occurred so we should not complete the transaction:" + ce, ce);
575             rollbackTransaction(db);
576             throw ce;
577         }
578         catch(Exception JavaDoc e)
579         {
580             logger.error("An error occurred so we should not complete the transaction:" + e, e);
581             rollbackTransaction(db);
582             throw new SystemException(e.getMessage());
583         }
584
585         return serviceBindningVOList;
586     }
587
588     
589     /**
590      * This method returns a list with AvailableServiceBidningVO-objects which are available for the
591      * siteNodeTypeDefinition sent in
592      */

593     
594     public static List JavaDoc getServiceBindningVOList(Integer JavaDoc siteNodeVersionId, Database db) throws ConstraintException, SystemException
595     {
596         List JavaDoc serviceBindningVOList = null;
597
598         Collection JavaDoc serviceBindningList = getServiceBindningList(siteNodeVersionId, db);
599         serviceBindningVOList = toVOList(serviceBindningList);
600
601         return serviceBindningVOList;
602     }
603
604     /**
605      * This method returns a list with AvailableServiceBidningVO-objects which are available for the
606      * siteNodeTypeDefinition sent in
607      */

608     
609     public static Collection JavaDoc getServiceBindningList(Integer JavaDoc siteNodeVersionId, Database db) throws ConstraintException, SystemException
610     {
611         SiteNodeVersion siteNodeVersion = getSiteNodeVersionWithIdAsReadOnly(siteNodeVersionId, db);
612         return siteNodeVersion.getServiceBindings();
613     }
614
615     
616     public static SiteNodeVersion getLatestPublishedSiteNodeVersion(Integer JavaDoc siteNodeId) throws SystemException, Bug, Exception JavaDoc
617     {
618         SiteNodeVersion siteNodeVersion = null;
619         
620         Database db = CastorDatabaseService.getDatabase();
621         ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();
622
623         beginTransaction(db);
624         try
625         {
626             siteNodeVersion = getLatestPublishedSiteNodeVersion(siteNodeId, db);
627             
628             commitTransaction(db);
629         }
630         catch(Exception JavaDoc e)
631         {
632             logger.error("An error occurred so we should not completes the transaction:" + e, e);
633             rollbackTransaction(db);
634             throw new SystemException(e.getMessage());
635         }
636             
637         return siteNodeVersion;
638     }
639
640     
641     
642     public static SiteNodeVersion getLatestPublishedSiteNodeVersion(Integer JavaDoc siteNodeId, Database db) throws SystemException, Bug, Exception JavaDoc
643     {
644         SiteNodeVersion siteNodeVersion = null;
645         
646         OQLQuery oql = db.getOQLQuery( "SELECT cv FROM org.infoglue.cms.entities.structure.impl.simple.SiteNodeVersionImpl cv WHERE cv.owningSiteNode.siteNodeId = $1 AND cv.stateId = $2 AND cv.isActive = $3 ORDER BY cv.siteNodeVersionId desc");
647         oql.bind(siteNodeId);
648         oql.bind(SiteNodeVersionVO.PUBLISHED_STATE);
649         oql.bind(true);
650         
651         QueryResults results = oql.execute();
652         logger.info("Fetching entity in read/write mode");
653
654         if (results.hasMore())
655         {
656             siteNodeVersion = (SiteNodeVersion)results.next();
657         }
658             
659         results.close();
660         oql.close();
661
662         return siteNodeVersion;
663     }
664
665
666     /**
667      * This method returns the version previous to the one sent in.
668      */

669     
670     public static SiteNodeVersionVO getPreviousSiteNodeVersionVO(Integer JavaDoc siteNodeId, Integer JavaDoc siteNodeVersionId) throws SystemException, Bug
671     {
672         Database db = CastorDatabaseService.getDatabase();
673         ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();
674
675         SiteNodeVersionVO siteNodeVersionVO = null;
676
677         beginTransaction(db);
678
679         try
680         {
681             OQLQuery oql = db.getOQLQuery( "SELECT cv FROM org.infoglue.cms.entities.structure.impl.simple.SiteNodeVersionImpl cv WHERE cv.owningSiteNode.siteNodeId = $1 AND cv.siteNodeVersionId < $2 ORDER BY cv.siteNodeVersionId desc");
682             oql.bind(siteNodeId);
683             oql.bind(siteNodeVersionId);
684             
685             QueryResults results = oql.execute(Database.ReadOnly);
686             
687             if (results.hasMore())
688             {
689                 SiteNodeVersion siteNodeVersion = (SiteNodeVersion)results.next();
690                 logger.info("found one:" + siteNodeVersion.getValueObject());
691                 siteNodeVersionVO = siteNodeVersion.getValueObject();
692             }
693             
694             results.close();
695             oql.close();
696
697             commitTransaction(db);
698         }
699         catch(Exception JavaDoc e)
700         {
701             logger.error("An error occurred so we should not completes the transaction:" + e, e);
702             rollbackTransaction(db);
703             throw new SystemException(e.getMessage());
704         }
705         
706         return siteNodeVersionVO;
707     }
708
709
710     /**
711      * This method returns the version previous to the one sent in.
712      */

713     
714     public SiteNodeVersionVO getPreviousActiveSiteNodeVersionVO(Integer JavaDoc siteNodeId, Integer JavaDoc siteNodeVersionId, Database db) throws SystemException, Bug, Exception JavaDoc
715     {
716         SiteNodeVersionVO siteNodeVersionVO = null;
717
718         OQLQuery oql = db.getOQLQuery( "SELECT cv FROM org.infoglue.cms.entities.structure.impl.simple.SiteNodeVersionImpl cv WHERE cv.owningSiteNode.siteNodeId = $1 AND cv.isActive = $2 AND cv.siteNodeVersionId < $3 ORDER BY cv.siteNodeVersionId desc");
719         oql.bind(siteNodeId);
720         oql.bind(new Boolean JavaDoc(true));
721         oql.bind(siteNodeVersionId);
722         
723         QueryResults results = oql.execute(Database.ReadOnly);
724         
725         if (results.hasMore())
726         {
727             SiteNodeVersion siteNodeVersion = (SiteNodeVersion)results.next();
728             logger.info("found one:" + siteNodeVersion.getValueObject());
729             siteNodeVersionVO = siteNodeVersion.getValueObject();
730         }
731         
732         results.close();
733         oql.close();
734
735         return siteNodeVersionVO;
736     }
737
738     /**
739      * This method returns the version previous to the one sent in.
740      */

741     
742     public SiteNodeVersion getPreviousActiveSiteNodeVersion(Integer JavaDoc siteNodeId, Integer JavaDoc siteNodeVersionId, Database db) throws SystemException, Bug, Exception JavaDoc
743     {
744         SiteNodeVersion siteNodeVersion = null;
745
746         OQLQuery oql = db.getOQLQuery( "SELECT cv FROM org.infoglue.cms.entities.structure.impl.simple.SiteNodeVersionImpl cv WHERE cv.owningSiteNode.siteNodeId = $1 AND cv.isActive = $2 AND cv.siteNodeVersionId < $3 ORDER BY cv.siteNodeVersionId desc");
747         oql.bind(siteNodeId);
748         oql.bind(new Boolean JavaDoc(true));
749         oql.bind(siteNodeVersionId);
750         
751         QueryResults results = oql.execute(Database.ReadOnly);
752         
753         if (results.hasMore())
754         {
755             siteNodeVersion = (SiteNodeVersion)results.next();
756             logger.info("found one:" + siteNodeVersion.getValueObject());
757         }
758         
759         results.close();
760         oql.close();
761
762         return siteNodeVersion;
763     }
764
765     
766     /**
767      * Recursive methods to get all siteNodeVersions of a given state
768      * under the specified parent siteNode including the given siteNode.
769      */

770     
771     public List JavaDoc getSiteNodeVersionVOWithParentRecursive(Integer JavaDoc siteNodeId, Integer JavaDoc stateId) throws ConstraintException, SystemException
772     {
773         return getSiteNodeVersionVOWithParentRecursive(siteNodeId, stateId, new ArrayList JavaDoc());
774     }
775     
776     private List JavaDoc getSiteNodeVersionVOWithParentRecursive(Integer JavaDoc siteNodeId, Integer JavaDoc stateId, List JavaDoc resultList) throws ConstraintException, SystemException
777     {
778         SiteNodeVersionVO siteNodeVersionVO = getLatestSiteNodeVersionVO(siteNodeId);
779         if(siteNodeVersionVO.getStateId().intValue() == stateId.intValue())
780             resultList.add(siteNodeVersionVO);
781         
782         // Get the children of this sitenode and do the recursion
783
List JavaDoc childSiteNodeList = SiteNodeController.getController().getSiteNodeChildren(siteNodeId);
784         Iterator JavaDoc childSiteNodeListIterator = childSiteNodeList.iterator();
785         while(childSiteNodeListIterator.hasNext())
786         {
787             SiteNodeVO siteNodeVO = (SiteNodeVO)childSiteNodeListIterator.next();
788             getSiteNodeVersionVOWithParentRecursive(siteNodeVO.getId(), stateId, resultList);
789         }
790     
791         return resultList;
792     }
793
794     /**
795      * Recursive methods to get all siteNodeVersions of a given state
796      * under the specified parent siteNode including the given siteNode.
797      */

798     
799     public List JavaDoc getPublishedSiteNodeVersionVOWithParentRecursive(Integer JavaDoc siteNodeId) throws ConstraintException, SystemException
800     {
801         List JavaDoc publishedSiteNodeVersionVOList = new ArrayList JavaDoc();
802         
803         Database db = CastorDatabaseService.getDatabase();
804
805         beginTransaction(db);
806
807         try
808         {
809             SiteNode siteNode = SiteNodeController.getController().getSiteNodeWithId(siteNodeId, db);
810             List JavaDoc publishedSiteNodeVersions = new ArrayList JavaDoc();
811             getPublishedSiteNodeVersionWithParentRecursive(siteNode, publishedSiteNodeVersions, db);
812             publishedSiteNodeVersionVOList = toVOList(publishedSiteNodeVersions);
813             
814             commitTransaction(db);
815         }
816         catch(Exception JavaDoc e)
817         {
818             logger.error("An error occurred so we should not completes the transaction:" + e, e);
819             rollbackTransaction(db);
820             throw new SystemException(e.getMessage());
821         }
822         
823         return publishedSiteNodeVersionVOList;
824     }
825     
826     private List JavaDoc getPublishedSiteNodeVersionWithParentRecursive(SiteNode siteNode, List JavaDoc resultList, Database db) throws ConstraintException, SystemException, Exception JavaDoc
827     {
828         SiteNodeVersion siteNodeVersion = getLatestPublishedSiteNodeVersion(siteNode.getId(), db);
829         if(siteNodeVersion != null)
830             resultList.add(siteNodeVersion);
831         
832         // Get the children of this sitenode and do the recursion
833
Collection JavaDoc childSiteNodeList = siteNode.getChildSiteNodes();
834         Iterator JavaDoc childSiteNodeListIterator = childSiteNodeList.iterator();
835         while(childSiteNodeListIterator.hasNext())
836         {
837             SiteNode childSiteNode = (SiteNode)childSiteNodeListIterator.next();
838             getPublishedSiteNodeVersionWithParentRecursive(childSiteNode, resultList, db);
839         }
840         
841         return resultList;
842     }
843
844     
845     /**
846      * Recursive methods to get all contentVersions of a given state under the specified parent content.
847      */

848     
849     public void getSiteNodeAndAffectedItemsRecursive(Integer JavaDoc siteNodeId, Integer JavaDoc stateId, List JavaDoc siteNodeVersionVOList, List JavaDoc contenteVersionVOList, boolean includeMetaInfo) throws ConstraintException, SystemException
850     {
851         Database db = CastorDatabaseService.getDatabase();
852
853         beginTransaction(db);
854
855         try
856         {
857             SiteNode siteNode = SiteNodeController.getController().getSiteNodeWithId(siteNodeId, db);
858
859             getSiteNodeAndAffectedItemsRecursive(siteNode, stateId, new ArrayList JavaDoc(), new ArrayList JavaDoc(), db, siteNodeVersionVOList, contenteVersionVOList, includeMetaInfo);
860             
861             commitTransaction(db);
862         }
863         catch(Exception JavaDoc e)
864         {
865             logger.error("An error occurred so we should not completes the transaction:" + e, e);
866             rollbackTransaction(db);
867             throw new SystemException(e.getMessage());
868         }
869     }
870     
871     private void getSiteNodeAndAffectedItemsRecursive(SiteNode siteNode, Integer JavaDoc stateId, List JavaDoc checkedSiteNodes, List JavaDoc checkedContents, Database db, List JavaDoc siteNodeVersionVOList, List JavaDoc contentVersionVOList, boolean includeMetaInfo) throws ConstraintException, SystemException, Exception JavaDoc
872     {
873         checkedSiteNodes.add(siteNode.getId());
874         
875         // Get the versions of this siteNode.
876
//SiteNodeVersion siteNodeVersion = getLatestActiveSiteNodeVersionIfInState(siteNode, stateId, db);
877
SiteNodeVersion siteNodeVersion = getLatestActiveSiteNodeVersion(db, siteNode.getId());
878         if(siteNodeVersion != null && siteNodeVersion.getStateId().intValue() == stateId.intValue())
879         {
880             siteNodeVersionVOList.add(siteNodeVersion.getValueObject());
881         }
882         
883         List JavaDoc relatedEntities = RegistryController.getController().getMatchingRegistryVOListForReferencingEntity(SiteNodeVersion.class.getName(), siteNodeVersion.getId().toString(), db);
884         Iterator JavaDoc relatedEntitiesIterator = relatedEntities.iterator();
885         
886         while(relatedEntitiesIterator.hasNext())
887         {
888             RegistryVO registryVO = (RegistryVO)relatedEntitiesIterator.next();
889             if(registryVO.getEntityName().equals(SiteNode.class.getName()) && !checkedSiteNodes.contains(new Integer JavaDoc(registryVO.getEntityId())))
890             {
891                 try
892                 {
893                     SiteNode relatedSiteNode = SiteNodeController.getController().getSiteNodeWithId(new Integer JavaDoc(registryVO.getEntityId()), db);
894                     //SiteNodeVersion relatedSiteNodeVersion = getLatestActiveSiteNodeVersionIfInState(relatedSiteNode, stateId, db);
895
SiteNodeVersion relatedSiteNodeVersion = getLatestActiveSiteNodeVersion(db, new Integer JavaDoc(registryVO.getEntityId()));
896                     if(relatedSiteNodeVersion != null && siteNodeVersion.getStateId().intValue() == stateId.intValue() && siteNode.getRepository().getId().intValue() == relatedSiteNodeVersion.getOwningSiteNode().getRepository().getId().intValue())
897                     {
898                         siteNodeVersionVOList.add(relatedSiteNodeVersion.getValueObject());
899                     }
900                 }
901                 catch(Exception JavaDoc e)
902                 {
903                     logger.warn("A siteNode referenced by ID:" + registryVO.getEntityId() + " was not found - must be a invalid reference from " + siteNode.getName() + "[" + siteNode.getId() + "].", e);
904                 }
905
906                 checkedSiteNodes.add(new Integer JavaDoc(registryVO.getEntityId()));
907             }
908             else if(registryVO.getEntityName().equals(Content.class.getName()) && !checkedContents.contains(new Integer JavaDoc(registryVO.getEntityId())))
909             {
910                 try
911                 {
912                     Content relatedContent = ContentController.getContentController().getContentWithId(new Integer JavaDoc(registryVO.getEntityId()), db);
913                     if(includeMetaInfo || (!includeMetaInfo && (relatedContent.getContentTypeDefinition() == null || !relatedContent.getContentTypeDefinition().getName().equalsIgnoreCase("Meta info"))))
914                     {
915                         List JavaDoc relatedContentVersions = ContentVersionController.getContentVersionController().getLatestActiveContentVersionIfInState(relatedContent, stateId, db);
916                         
917                         Iterator JavaDoc relatedContentVersionsIterator = relatedContentVersions.iterator();
918                         while(relatedContentVersionsIterator.hasNext())
919                         {
920                             ContentVersion relatedContentVersion = (ContentVersion)relatedContentVersionsIterator.next();
921                             if(relatedContentVersion != null && siteNode.getRepository().getId().intValue() == relatedContentVersion.getOwningContent().getRepository().getId().intValue())
922                             {
923                                 contentVersionVOList.add(relatedContentVersion.getValueObject());
924                             }
925                         }
926                     }
927                 }
928                 catch(Exception JavaDoc e)
929                 {
930                     logger.warn("A content referenced by ID:" + registryVO.getEntityId() + " was not found - must be a invalid reference from " + siteNode.getName() + "[" + siteNode.getId() + "].", e);
931                 }
932                 
933                 checkedContents.add(new Integer JavaDoc(registryVO.getEntityId()));
934             }
935         //}
936

937         }
938         
939         // Get the children of this siteNode and do the recursion
940
Collection JavaDoc childSiteNodeList = siteNode.getChildSiteNodes();
941         Iterator JavaDoc cit = childSiteNodeList.iterator();
942         while (cit.hasNext())
943         {
944             SiteNode childSiteNode = (SiteNode) cit.next();
945             getSiteNodeAndAffectedItemsRecursive(childSiteNode, stateId, checkedSiteNodes, checkedContents, db, siteNodeVersionVOList, contentVersionVOList, includeMetaInfo);
946         }
947    
948     }
949
950     /**
951      * This method returns the latest sitenodeVersion there is for the given siteNode.
952      */

953     
954     public SiteNodeVersion getLatestActiveSiteNodeVersionIfInState(SiteNode siteNode, Integer JavaDoc stateId, Database db) throws SystemException, Exception JavaDoc
955     {
956         SiteNodeVersion siteNodeVersion = null;
957         
958         Collection JavaDoc siteNodeVersions = siteNode.getSiteNodeVersions();
959
960         SiteNodeVersion latestSiteNodeVersion = null;
961         
962         Iterator JavaDoc versionIterator = siteNodeVersions.iterator();
963         while(versionIterator.hasNext())
964         {
965             SiteNodeVersion siteNodeVersionCandidate = (SiteNodeVersion)versionIterator.next();
966             
967             if(latestSiteNodeVersion == null || (latestSiteNodeVersion.getId().intValue() < siteNodeVersionCandidate.getId().intValue() && siteNodeVersionCandidate.getIsActive().booleanValue()))
968                 latestSiteNodeVersion = siteNodeVersionCandidate;
969             
970             if(siteNodeVersionCandidate.getIsActive().booleanValue() && siteNodeVersionCandidate.getStateId().intValue() == stateId.intValue())
971             {
972                 if(siteNodeVersionCandidate.getOwningSiteNode().getSiteNodeId().intValue() == siteNode.getId().intValue())
973                 {
974                     if(siteNodeVersion == null || siteNodeVersion.getSiteNodeVersionId().intValue() < siteNodeVersionCandidate.getId().intValue())
975                     {
976                         siteNodeVersion = siteNodeVersionCandidate;
977                     }
978                 }
979             }
980         }
981
982         if(siteNodeVersion != latestSiteNodeVersion)
983             siteNodeVersion = null;
984             
985         return siteNodeVersion;
986     }
987
988     
989        /**
990      * This method gets the meta info for the siteNodeVersion.
991      * @param db
992      * @throws ConstraintException
993      * @throws SystemException
994      * @throws Exception
995      */

996     public List JavaDoc getMetaInfoContentVersionVOList(Integer JavaDoc siteNodeVersionId, InfoGluePrincipal infoGluePrincipal) throws ConstraintException, SystemException, Exception JavaDoc
997     {
998         List JavaDoc contentVersionVOList = new ArrayList JavaDoc();
999         
1000        Database db = CastorDatabaseService.getDatabase();
1001
1002        beginTransaction(db);
1003
1004        try
1005        {
1006            SiteNodeVersion siteNodeVersion = SiteNodeVersionController.getController().getSiteNodeVersionWithId(siteNodeVersionId, db);
1007            List JavaDoc contentVersions = getMetaInfoContentVersions(db, siteNodeVersion, infoGluePrincipal);
1008            contentVersionVOList = toVOList(contentVersions);
1009            
1010            commitTransaction(db);
1011        }
1012        catch(Exception JavaDoc e)
1013        {
1014            logger.error("An error occurred so we should not completes the transaction:" + e, e);
1015            rollbackTransaction(db);
1016            throw new SystemException(e.getMessage());
1017        }
1018        
1019        return contentVersionVOList;
1020    }
1021
1022    /**
1023     * This method gets the meta info for the siteNodeVersion.
1024     * @param db
1025     * @throws ConstraintException
1026     * @throws SystemException
1027     * @throws Exception
1028     */

1029    private List JavaDoc getMetaInfoContentVersions(Database db, SiteNodeVersion siteNodeVersion, InfoGluePrincipal infoGluePrincipal) throws ConstraintException, SystemException, Exception JavaDoc
1030    {
1031        List JavaDoc contentVersions = new ArrayList JavaDoc();
1032        
1033        List JavaDoc languages = LanguageController.getController().getLanguageList(siteNodeVersion.getOwningSiteNode().getRepository().getId(), db);
1034        Language masterLanguage = LanguageController.getController().getMasterLanguage(db, siteNodeVersion.getOwningSiteNode().getRepository().getId());
1035        
1036        Integer JavaDoc metaInfoAvailableServiceBindingId = null;
1037        Integer JavaDoc serviceBindingId = null;
1038        AvailableServiceBinding availableServiceBinding = AvailableServiceBindingController.getController().getAvailableServiceBindingWithName("Meta information", db, true);
1039        if(availableServiceBinding != null)
1040            metaInfoAvailableServiceBindingId = availableServiceBinding.getAvailableServiceBindingId();
1041        
1042        Collection JavaDoc serviceBindings = siteNodeVersion.getServiceBindings();
1043        Iterator JavaDoc serviceBindingIterator = serviceBindings.iterator();
1044        while(serviceBindingIterator.hasNext())
1045        {
1046            ServiceBinding serviceBinding = (ServiceBinding)serviceBindingIterator.next();
1047            if(serviceBinding.getAvailableServiceBinding().getId().intValue() == metaInfoAvailableServiceBindingId.intValue())
1048            {
1049                serviceBindingId = serviceBinding.getId();
1050                break;
1051            }
1052        }
1053
1054        if(serviceBindingId != null)
1055        {
1056            List JavaDoc boundContents = ContentController.getBoundContents(serviceBindingId);
1057            if(boundContents.size() > 0)
1058            {
1059                ContentVO contentVO = (ContentVO)boundContents.get(0);
1060                
1061                Iterator JavaDoc languageIterator = languages.iterator();
1062                while(languageIterator.hasNext())
1063                {
1064                    Language language = (Language)languageIterator.next();
1065                    ContentVersion contentVersion = ContentVersionController.getContentVersionController().getLatestActiveContentVersion(contentVO.getId(), language.getId(), db);
1066                    
1067                    if(contentVersion != null)
1068                        contentVersions.add(contentVersion);
1069                }
1070            }
1071        }
1072        
1073        return contentVersions;
1074    }
1075
1076    
1077    /**
1078     * Updates the SiteNodeVersion.
1079     */

1080    
1081    public SiteNodeVersionVO update(SiteNodeVersionVO siteNodeVersionVO) throws ConstraintException, SystemException
1082    {
1083        registryController.updateSiteNodeVersion(siteNodeVersionVO);
1084
1085        return (SiteNodeVersionVO) updateEntity(SiteNodeVersionImpl.class, (BaseEntityVO)siteNodeVersionVO);
1086    }
1087    
1088    /**
1089     * Updates the SiteNodeVersion within a transaction.
1090     */

1091    
1092    public SiteNodeVersionVO update(SiteNodeVersionVO siteNodeVersionVO, Database db) throws ConstraintException, SystemException, Exception JavaDoc
1093    {
1094        SiteNodeVersion siteNodeVersion = getSiteNodeVersionWithId(siteNodeVersionVO.getId(), db);
1095        registryController.updateSiteNodeVersion(siteNodeVersion, db);
1096
1097        siteNodeVersion.setValueObject(siteNodeVersionVO);
1098        return siteNodeVersionVO;
1099        //return (SiteNodeVersionVO) updateEntity(SiteNodeVersionImpl.class, (BaseEntityVO)siteNodeVersionVO, db);
1100
}
1101    
1102    
1103    /**
1104     * This method gets the meta info for the siteNodeVersion.
1105     * @param db
1106     * @throws ConstraintException
1107     * @throws SystemException
1108     * @throws Exception
1109     */

1110    public List JavaDoc getPublishedActiveSiteNodeVersionVOList(Integer JavaDoc siteNodeId) throws SystemException, Bug, Exception JavaDoc
1111    {
1112        List JavaDoc siteNodeVersionVOList = new ArrayList JavaDoc();
1113        
1114        Database db = CastorDatabaseService.getDatabase();
1115
1116        beginTransaction(db);
1117
1118        try
1119        {
1120            List JavaDoc siteNodeVersionList = getPublishedActiveSiteNodeVersionVOList(siteNodeId, db);
1121            siteNodeVersionVOList = toVOList(siteNodeVersionList);
1122            
1123            commitTransaction(db);
1124        }
1125        catch(Exception JavaDoc e)
1126        {
1127            logger.error("An error occurred so we should not completes the transaction:" + e, e);
1128            rollbackTransaction(db);
1129            throw new SystemException(e.getMessage());
1130        }
1131        
1132        return siteNodeVersionVOList;
1133    }
1134
1135    
1136    public List JavaDoc getPublishedActiveSiteNodeVersionVOList(Integer JavaDoc siteNodeId, Database db) throws SystemException, Bug, Exception JavaDoc
1137    {
1138        List JavaDoc siteNodeVersionList = new ArrayList JavaDoc();
1139        
1140        OQLQuery oql = db.getOQLQuery( "SELECT cv FROM org.infoglue.cms.entities.structure.impl.simple.SiteNodeVersionImpl cv WHERE cv.owningSiteNode.siteNodeId = $1 AND cv.stateId = $2 AND cv.isActive = $3 ORDER BY cv.siteNodeVersionId desc");
1141        oql.bind(siteNodeId);
1142        oql.bind(SiteNodeVersionVO.PUBLISHED_STATE);
1143        oql.bind(true);
1144        
1145        QueryResults results = oql.execute();
1146        logger.info("Fetching entity in read/write mode");
1147
1148        while (results.hasMore())
1149        {
1150            SiteNodeVersion siteNodeVersion = (SiteNodeVersion)results.next();
1151            siteNodeVersionList.add(siteNodeVersion);
1152        }
1153            
1154        results.close();
1155        oql.close();
1156
1157        return siteNodeVersionList;
1158    }
1159
1160    /**
1161     * This is a method that gives the user back an newly initialized ValueObject for this entity that the controller
1162     * is handling.
1163     */

1164
1165    public BaseEntityVO getNewVO()
1166    {
1167        return new SiteNodeVersionVO();
1168    }
1169
1170
1171}
1172 
1173
Popular Tags