KickJava   Java API By Example, From Geeks To Geeks.

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


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.Iterator JavaDoc;
29 import java.util.List JavaDoc;
30
31 import org.apache.log4j.Logger;
32 import org.exolab.castor.jdo.Database;
33 import org.exolab.castor.jdo.OQLQuery;
34 import org.exolab.castor.jdo.QueryResults;
35 import org.infoglue.cms.entities.kernel.BaseEntityVO;
36 import org.infoglue.cms.entities.management.Language;
37 import org.infoglue.cms.entities.management.LanguageVO;
38 import org.infoglue.cms.entities.management.Repository;
39 import org.infoglue.cms.entities.management.RepositoryLanguage;
40 import org.infoglue.cms.entities.management.RepositoryLanguageVO;
41 import org.infoglue.cms.entities.management.impl.simple.RepositoryLanguageImpl;
42 import org.infoglue.cms.exception.Bug;
43 import org.infoglue.cms.exception.ConstraintException;
44 import org.infoglue.cms.exception.SystemException;
45 import org.infoglue.cms.util.ConstraintExceptionBuffer;
46 import org.infoglue.deliver.util.CacheController;
47
48 public class RepositoryLanguageController extends BaseController
49 {
50     private final static Logger logger = Logger.getLogger(RepositoryLanguageController.class.getName());
51
52     /**
53      * Factory method
54      */

55
56     public static RepositoryLanguageController getController()
57     {
58         return new RepositoryLanguageController();
59     }
60
61     public RepositoryLanguage getRepositoryLanguageWithId(Integer JavaDoc id, Database db) throws SystemException, Bug
62     {
63         return (RepositoryLanguage) getObjectWithId(RepositoryLanguageImpl.class, id, db);
64     }
65
66
67     public RepositoryLanguage getRepositoryLanguageWithId(Integer JavaDoc repositoryLanguageId) throws ConstraintException, SystemException, Bug
68     {
69         Database db = CastorDatabaseService.getDatabase();
70         ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();
71
72         RepositoryLanguage repositoryLanguage = null;
73
74         try
75         {
76             beginTransaction(db);
77
78             repositoryLanguage = getRepositoryLanguageWithId(repositoryLanguageId, db);
79         
80             //If any of the validations or setMethods reported an error, we throw them up now before create.
81
ceb.throwIfNotEmpty();
82             
83             commitTransaction(db);
84         }
85         catch(ConstraintException ce)
86         {
87             logger.warn("An error occurred so we should not complete the transaction:" + ce, ce);
88             rollbackTransaction(db);
89             throw ce;
90         }
91         catch(Exception JavaDoc e)
92         {
93             logger.error("An error occurred so we should not complete the transaction:" + e, e);
94             rollbackTransaction(db);
95             throw new SystemException(e.getMessage());
96         }
97         
98         return repositoryLanguage;
99     }
100     
101
102     public List JavaDoc getRepositoryLanguageVOList() throws SystemException, Bug
103     {
104         return getAllVOObjects(RepositoryLanguageImpl.class, "repositoryLanguageImplId");
105     }
106
107
108     public List JavaDoc getRepositoryLanguageVOListWithLanguageId(Integer JavaDoc languageId) throws SystemException, Bug
109     {
110         Database db = CastorDatabaseService.getDatabase();
111         ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();
112
113         ArrayList JavaDoc repositoryLanguageList = new ArrayList JavaDoc();
114         
115         beginTransaction(db);
116         
117         try
118         {
119             OQLQuery oql = db.getOQLQuery("SELECT rl FROM org.infoglue.cms.entities.management.impl.simple.RepositoryLanguageImpl rl WHERE rl.language = $1 order by rl.sortOrder, rl.language.languageId");
120             oql.bind(languageId);
121             
122             QueryResults results = oql.execute(Database.ReadOnly);
123             
124             while (results.hasMore())
125             {
126                 RepositoryLanguage repositoryLanguage = (RepositoryLanguage)results.next();
127                 repositoryLanguageList.add(repositoryLanguage.getValueObject());
128             }
129
130             results.close();
131             oql.close();
132
133             ceb.throwIfNotEmpty();
134             commitTransaction(db);
135         }
136         catch(Exception JavaDoc e)
137         {
138             logger.error("An error occurred so we should not completes the transaction:" + e, e);
139             rollbackTransaction(db);
140             throw new SystemException(e.getMessage());
141         }
142     
143         return repositoryLanguageList;
144     }
145
146
147     public List JavaDoc getRepositoryLanguageVOListWithRepositoryId(Integer JavaDoc repositoryId) throws SystemException, Bug
148     {
149         List JavaDoc repositoryLanguageList = new ArrayList JavaDoc();
150         
151         /*
152         String repositoryLanguageListKey = "" + repositoryId;
153         logger.info("repositoryLanguageListKey:" + repositoryLanguageListKey);
154         repositoryLanguageList = (List)CacheController.getCachedObject("repositoryLanguageListCache", repositoryLanguageListKey);
155         if(repositoryLanguageList != null)
156         {
157             logger.info("There was an cached list:" + repositoryLanguageList);
158         }
159         else
160         {
161         */

162             Database db = CastorDatabaseService.getDatabase();
163             ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();
164             
165             beginTransaction(db);
166             
167             try
168             {
169                 repositoryLanguageList = getRepositoryLanguageVOListWithRepositoryId(repositoryId, db);
170                 
171                 //if(repositoryLanguageList != null)
172
//{
173
// CacheController.cacheObject("repositoryLanguageListCache", repositoryLanguageListKey, repositoryLanguageList);
174
//}
175

176                 ceb.throwIfNotEmpty();
177                 commitTransaction(db);
178             }
179             catch(Exception JavaDoc e)
180             {
181                 logger.error("An error occurred so we should not completes the transaction:" + e, e);
182                 rollbackTransaction(db);
183                 throw new SystemException(e.getMessage());
184             }
185             //}
186

187         return repositoryLanguageList;
188     }
189
190     
191     public List JavaDoc getRepositoryLanguageVOListWithRepositoryId(Integer JavaDoc repositoryId, Database db) throws SystemException, Bug, Exception JavaDoc
192     {
193         ArrayList JavaDoc repositoryLanguageList = new ArrayList JavaDoc();
194         
195         OQLQuery oql = db.getOQLQuery("SELECT rl FROM org.infoglue.cms.entities.management.impl.simple.RepositoryLanguageImpl rl WHERE rl.repository = $1 ORDER BY rl.sortOrder, rl.language.languageId");
196         oql.bind(repositoryId);
197             
198         QueryResults results = oql.execute(Database.ReadOnly);
199             
200         while (results.hasMore())
201         {
202             RepositoryLanguage repositoryLanguage = (RepositoryLanguage)results.next();
203             repositoryLanguageList.add(repositoryLanguage);
204         }
205    
206         results.close();
207         oql.close();
208
209         return repositoryLanguageList;
210     }
211     
212     
213     public List JavaDoc getAvailableLanguageVOListForRepositoryId(Integer JavaDoc repositoryId) throws ConstraintException, SystemException, Exception JavaDoc
214     {
215         List JavaDoc repositoryLanguageVOList = null;
216         
217         String JavaDoc repositoryLanguageListKey = "" + repositoryId;
218         logger.info("repositoryLanguageListKey:" + repositoryLanguageListKey);
219         repositoryLanguageVOList = (List JavaDoc)CacheController.getCachedObject("repositoryLanguageListCache", repositoryLanguageListKey);
220         if(repositoryLanguageVOList != null)
221         {
222             logger.info("There was an cached list:" + repositoryLanguageVOList);
223         }
224         else
225         {
226             Database db = CastorDatabaseService.getDatabase();
227             ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();
228             
229             beginTransaction(db);
230             
231             try
232             {
233                 List JavaDoc availableRepositoryLanguageList = RepositoryLanguageController.getController().getRepositoryLanguageListWithRepositoryId(repositoryId, db);
234                 
235                 repositoryLanguageVOList = new ArrayList JavaDoc();
236                 Iterator JavaDoc i = availableRepositoryLanguageList.iterator();
237                 while(i.hasNext())
238                 {
239                     RepositoryLanguage repositoryLanguage = (RepositoryLanguage)i.next();
240                     repositoryLanguageVOList.add(repositoryLanguage.getLanguage().getValueObject());
241                 }
242             
243                 CacheController.cacheObject("repositoryLanguageListCache", repositoryLanguageListKey, repositoryLanguageVOList);
244                 
245                 ceb.throwIfNotEmpty();
246                 commitTransaction(db);
247             }
248             catch(Exception JavaDoc e)
249             {
250                 logger.error("An error occurred so we should not completes the transaction:" + e, e);
251                 rollbackTransaction(db);
252                 throw new SystemException(e.getMessage());
253             }
254         }
255         
256         return repositoryLanguageVOList;
257     }
258     
259     public List JavaDoc getRepositoryLanguageListWithRepositoryId(Integer JavaDoc repositoryId, Database db) throws SystemException, Bug, Exception JavaDoc
260     {
261         ArrayList JavaDoc repositoryLanguageList = new ArrayList JavaDoc();
262         
263         OQLQuery oql = db.getOQLQuery("SELECT rl FROM org.infoglue.cms.entities.management.impl.simple.RepositoryLanguageImpl rl WHERE rl.repository = $1 ORDER BY rl.sortOrder, rl.language.languageId");
264         oql.bind(repositoryId);
265             
266         QueryResults results = oql.execute();
267         this.logger.info("Fetching entity in read/write mode");
268
269         while (results.hasMore())
270         {
271             RepositoryLanguage repositoryLanguage = (RepositoryLanguage)results.next();
272             repositoryLanguageList.add(repositoryLanguage);
273         }
274    
275         results.close();
276         oql.close();
277
278         return repositoryLanguageList;
279     }
280     
281     /**
282      * This method removes a RepositoryLanguage from the system
283      */

284     
285     public void delete(RepositoryLanguageVO vo) throws ConstraintException, SystemException
286     {
287         deleteEntity(RepositoryLanguageImpl.class, vo.getRepositoryLanguageId());
288     }
289     
290     /*
291     public RepositoryLanguage deleteAllRepositoryLanguageWithRepositoryId(Integer repositoryId) throws SystemException, Bug
292     {
293         try
294         {
295             List repositoryLanguages = getRepositoryLanguageVOListWithRepositoryId(repositoryId);
296             Iterator iterator = repositoryLanguages.iterator();
297             while(iterator.hasNext())
298             {
299                 RepositoryLanguageVO repositoryLanguage = (RepositoryLanguageVO)iterator.next();
300                 deleteEntity(RepositoryLanguageImpl.class, repositoryLanguage.getRepositoryLanguageId());
301             }
302         }
303         catch(Exception e)
304         {
305             throw new SystemException("An error occurred when we tried to find the matching RepositoryLanguage in the database. Reason: " + e.getMessage(), e);
306         }
307         
308         return null;
309     }
310     */

311
312     
313     public void deleteRepositoryLanguages(Repository repository, Database db) throws SystemException, Bug
314     {
315         try
316         {
317             Collection JavaDoc repositoryLanguages = repository.getRepositoryLanguages();
318             Iterator JavaDoc iterator = repositoryLanguages.iterator();
319             while(iterator.hasNext())
320             {
321                 RepositoryLanguage repositoryLanguage = (RepositoryLanguage)iterator.next();
322                 Language language = repositoryLanguage.getLanguage();
323                 language.getRepositoryLanguages().remove(repositoryLanguage);
324                 
325                 db.remove(repositoryLanguage);
326                 //deleteEntity(RepositoryLanguageImpl.class, repositoryLanguage.getRepositoryLanguageId(), db);
327
}
328         }
329         catch(Exception JavaDoc e)
330         {
331             throw new SystemException("An error occurred when we tried to find the matching RepositoryLanguage in the database. Reason: " + e.getMessage(), e);
332         }
333     }
334     
335     /*
336     public RepositoryLanguage deleteAllRepositoryLanguageWithRepositoryId(Integer repositoryId, Database db) throws SystemException, Bug
337     {
338         try
339         {
340             List repositoryLanguages = getRepositoryLanguageVOListWithRepositoryId(repositoryId);
341             Iterator iterator = repositoryLanguages.iterator();
342             while(iterator.hasNext())
343             {
344                 RepositoryLanguageVO repositoryLanguage = (RepositoryLanguageVO)iterator.next();
345                 deleteEntity(RepositoryLanguageImpl.class, repositoryLanguage.getRepositoryLanguageId(), db);
346             }
347         }
348         catch(Exception e)
349         {
350             throw new SystemException("An error occurred when we tried to find the matching RepositoryLanguage in the database. Reason: " + e.getMessage(), e);
351         }
352         
353         return null;
354     }
355     */

356
357     /**
358      * This method deletes all repositoryLanguages with a certain languageId.
359      */

360     
361     public RepositoryLanguage deleteAllRepositoryLanguageWithLanguageId(Integer JavaDoc languageId) throws SystemException, Bug
362     {
363         try
364         {
365             List JavaDoc repositoryLanguages = getRepositoryLanguageVOListWithLanguageId(languageId);
366             Iterator JavaDoc iterator = repositoryLanguages.iterator();
367             while(iterator.hasNext())
368             {
369                 RepositoryLanguageVO repositoryLanguage = (RepositoryLanguageVO)iterator.next();
370                 deleteEntity(RepositoryLanguageImpl.class, repositoryLanguage.getRepositoryLanguageId());
371             }
372         }
373         catch(Exception JavaDoc e)
374         {
375             throw new SystemException("An error occurred when we tried to find the matching RepositoryLanguage in the database. Reason: " + e.getMessage(), e);
376         }
377         
378         return null;
379     }
380     
381     /**
382      * This method deletes all repositoryLanguages with a certain languageId.
383      */

384     
385     public RepositoryLanguage deleteAllRepositoryLanguageWithLanguage(Language language, Database db) throws SystemException, Bug
386     {
387         try
388         {
389             Collection JavaDoc repositoryLanguages = language.getRepositoryLanguages();
390             Iterator JavaDoc iterator = repositoryLanguages.iterator();
391             while(iterator.hasNext())
392             {
393                 RepositoryLanguage repositoryLanguage = (RepositoryLanguage)iterator.next();
394                 Repository repository = repositoryLanguage.getRepository();
395                 repository.getRepositoryLanguages().remove(repositoryLanguage);
396                 db.remove(repositoryLanguage);
397             }
398         }
399         catch(Exception JavaDoc e)
400         {
401             throw new SystemException("An error occurred when we tried to delete a RepositoryLanguage in the database. Reason: " + e.getMessage(), e);
402         }
403         
404         return null;
405     }
406
407      
408     public RepositoryLanguage create(Integer JavaDoc repositoryId, Integer JavaDoc languageId, Integer JavaDoc sortOrder, Database db) throws Exception JavaDoc
409     {
410         RepositoryLanguage repositoryLanguage = new RepositoryLanguageImpl();
411
412         repositoryLanguage.setIsPublished(new Boolean JavaDoc(false));
413         repositoryLanguage.setLanguage(LanguageController.getController().getLanguageWithId(languageId, db));
414         repositoryLanguage.setRepository(RepositoryController.getController().getRepositoryWithId(repositoryId, db));
415         repositoryLanguage.setSortOrder(sortOrder);
416         
417         db.create(repositoryLanguage);
418
419         return repositoryLanguage;
420     }
421     
422     public void publishRepositoryLanguage(RepositoryLanguageVO repositoryLanguageVO) throws ConstraintException, SystemException
423      {
424          Database db = CastorDatabaseService.getDatabase();
425          ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();
426
427          RepositoryLanguage repositoryLanguage = null;
428
429          beginTransaction(db);
430
431          try
432          {
433              repositoryLanguage = getRepositoryLanguageWithId(repositoryLanguageVO.getRepositoryLanguageId(), db);
434              repositoryLanguage.setIsPublished(new Boolean JavaDoc(true));
435              commitTransaction(db);
436          }
437          catch(Exception JavaDoc e)
438          {
439              logger.error("An error occurred so we should not complete the transaction:" + e, e);
440              rollbackTransaction(db);
441              throw new SystemException(e.getMessage());
442          }
443      }
444     
445     
446      public void unpublishRepositoryLanguage(RepositoryLanguageVO repositoryLanguageVO) throws ConstraintException, SystemException
447      {
448          Database db = CastorDatabaseService.getDatabase();
449          ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();
450
451          RepositoryLanguage repositoryLanguage = null;
452
453          beginTransaction(db);
454
455          try
456          {
457              //Here we should do some serious cleanup.... take away all content-attributes that has this language for example?
458
repositoryLanguage = getRepositoryLanguageWithId(repositoryLanguageVO.getRepositoryLanguageId(), db);
459              repositoryLanguage.setIsPublished(new Boolean JavaDoc(false));
460              commitTransaction(db);
461          }
462          catch(Exception JavaDoc e)
463          {
464              logger.error("An error occurred so we should not complete the transaction:" + e, e);
465              rollbackTransaction(db);
466              throw new SystemException(e.getMessage());
467          }
468      }
469     
470      
471      public void moveRepositoryLanguage(RepositoryLanguageVO repositoryLanguageVO, boolean down) throws ConstraintException, SystemException
472      {
473          Database db = CastorDatabaseService.getDatabase();
474          ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();
475
476          beginTransaction(db);
477
478          try
479          {
480              RepositoryLanguage originalRepositoryLanguage = this.getRepositoryLanguageWithId(repositoryLanguageVO.getRepositoryLanguageId(), db);
481              List JavaDoc repositoryLanguages = this.getRepositoryLanguageListWithRepositoryId(originalRepositoryLanguage.getRepository().getId(), db);
482              
483              for(int i=0; i<repositoryLanguages.size(); i++)
484              {
485                  RepositoryLanguage repositoryLanguage = (RepositoryLanguage)repositoryLanguages.get(i);
486                  if(repositoryLanguage.getRepositoryLanguageId().intValue() == repositoryLanguageVO.getRepositoryLanguageId().intValue())
487                  {
488                      if(down && i != repositoryLanguages.size() - 1)
489                      {
490                          RepositoryLanguage nextRepositoryLanguage = (RepositoryLanguage)repositoryLanguages.get(i+1);
491                          Integer JavaDoc currentSortOrder = repositoryLanguage.getSortOrder();
492                          repositoryLanguage.setSortOrder(nextRepositoryLanguage.getSortOrder());
493                          nextRepositoryLanguage.setSortOrder(currentSortOrder);
494                      }
495                      else if(!down && i != 0)
496                      {
497                          RepositoryLanguage previousRepositoryLanguage = (RepositoryLanguage)repositoryLanguages.get(i-1);
498                          Integer JavaDoc currentSortOrder = repositoryLanguage.getSortOrder();
499                          repositoryLanguage.setSortOrder(previousRepositoryLanguage.getSortOrder());
500                          previousRepositoryLanguage.setSortOrder(currentSortOrder);
501                      }
502                  }
503              }
504              
505              commitTransaction(db);
506          }
507          catch(Exception JavaDoc e)
508          {
509              logger.error("An error occurred so we should not complete the transaction:" + e, e);
510              rollbackTransaction(db);
511              throw new SystemException(e.getMessage());
512          }
513      }
514     
515
516      public void createRepositoryLanguage(Integer JavaDoc repositoryId, Integer JavaDoc languageId, Integer JavaDoc sortOrder) throws ConstraintException, SystemException
517      {
518          Database db = CastorDatabaseService.getDatabase();
519          ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();
520
521          RepositoryLanguage repositoryLanguage = null;
522
523          beginTransaction(db);
524
525          try
526          {
527              repositoryLanguage = create(repositoryId, languageId, sortOrder, db);
528              commitTransaction(db);
529          }
530          catch(Exception JavaDoc e)
531          {
532              logger.error("An error occurred so we should not complete the transaction:" + e, e);
533              rollbackTransaction(db);
534              throw new SystemException(e.getMessage());
535          }
536      }
537     
538     
539      public void updateRepositoryLanguages(Integer JavaDoc repositoryId, String JavaDoc[] languageValues) throws ConstraintException, SystemException
540      {
541         Database db = CastorDatabaseService.getDatabase();
542         ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();
543
544         beginTransaction(db);
545
546         try
547         {
548             Repository repository = RepositoryController.getController().getRepositoryWithId(repositoryId, db);
549             deleteRepositoryLanguages(repository, db);
550
551             //add validation here if needed
552
List JavaDoc repositoryLanguageList = new ArrayList JavaDoc();
553             if(languageValues != null)
554             {
555                 for (int i=0; i < languageValues.length; i++)
556                 {
557                     Language language = LanguageController.getController().getLanguageWithId(new Integer JavaDoc(languageValues[i]), db);
558                     RepositoryLanguage repositoryLanguage = create(repository.getId(), new Integer JavaDoc(languageValues[i]), new Integer JavaDoc(i), db);
559                     repositoryLanguageList.add(repositoryLanguage);
560                 }
561             }
562             
563             //repository = RepositoryController.getController().getRepositoryWithId(repositoryVO.getRepositoryId(), db);
564
//repository.setValueObject(repositoryVO);
565
repository.setRepositoryLanguages(repositoryLanguageList);
566             
567             //If any of the validations or setMethods reported an error, we throw them up now before create.
568
ceb.throwIfNotEmpty();
569             
570             commitTransaction(db);
571         }
572         catch(ConstraintException ce)
573         {
574             logger.warn("An error occurred so we should not completes 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 completes the transaction:" + e, e);
581             rollbackTransaction(db);
582             throw new SystemException(e.getMessage());
583         }
584     }
585     
586     public List JavaDoc getRemainingLanguages(Integer JavaDoc repositoryId) throws ConstraintException, SystemException
587     {
588         Database db = CastorDatabaseService.getDatabase();
589         ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();
590
591         List JavaDoc remainingLanguages = new ArrayList JavaDoc();
592
593         beginTransaction(db);
594
595         try
596         {
597             Repository repository = RepositoryController.getController().getRepositoryWithId(repositoryId, db);
598             Collection JavaDoc repositoryLanguageList = repository.getRepositoryLanguages();
599             List JavaDoc languageList = LanguageController.getController().getLanguageVOList();
600             remainingLanguages.addAll(languageList);
601             
602             Iterator JavaDoc languageIterator = languageList.iterator();
603             while(languageIterator.hasNext())
604             {
605                 LanguageVO languageVO = (LanguageVO)languageIterator.next();
606                 logger.info("Language:" + languageVO.getName());
607                 Iterator JavaDoc repositoryLanguageIterator = repositoryLanguageList.iterator();
608                 while(repositoryLanguageIterator.hasNext())
609                 {
610                     RepositoryLanguage repositoryLanguage = (RepositoryLanguage)repositoryLanguageIterator.next();
611                     logger.info("Comparing" + languageVO.getLanguageId().intValue() + " and " + repositoryLanguage.getLanguage().getLanguageId().intValue());
612                     if(languageVO.getLanguageId().intValue() == repositoryLanguage.getLanguage().getLanguageId().intValue())
613                     {
614                         remainingLanguages.remove(languageVO);
615                     }
616                 }
617             }
618             
619             //If any of the validations or setMethods reported an error, we throw them up now before create.
620
ceb.throwIfNotEmpty();
621             
622             commitTransaction(db);
623         }
624         catch(ConstraintException ce)
625         {
626             logger.warn("An error occurred so we should not complete the transaction:" + ce, ce);
627             rollbackTransaction(db);
628             throw ce;
629         }
630         catch(Exception JavaDoc e)
631         {
632             logger.error("An error occurred so we should not complete the transaction:" + e, e);
633             e.printStackTrace();
634             rollbackTransaction(db);
635             throw new SystemException(e.getMessage());
636         }
637
638         return remainingLanguages;
639     }
640
641
642     /**
643      * This is a method that gives the user back an newly initialized ValueObject for this entity that the controller
644      * is handling.
645      */

646
647     public BaseEntityVO getNewVO()
648     {
649         return new RepositoryLanguageVO();
650     }
651    
652 }
653
654
655
656  
657
Popular Tags