1 23 24 package org.infoglue.cms.controllers.kernel.impl.simple; 25 26 import java.util.Collection ; 27 import java.util.Collections ; 28 import java.util.Enumeration ; 29 import java.util.HashSet ; 30 import java.util.Set ; 31 32 import org.apache.log4j.Logger; 33 import org.exolab.castor.jdo.Database; 34 import org.infoglue.cms.applications.workflowtool.function.email.UsersAddressProvider; 35 import org.infoglue.cms.exception.SystemException; 36 37 public abstract class BaseUCCController 38 { 39 private final static Logger logger = Logger.getLogger(BaseUCCController.class.getName()); 40 41 44 45 protected void beginTransaction(Database db) throws SystemException 46 { 47 try 48 { 49 db.begin(); 50 } 51 catch(Exception e) 52 { 53 e.printStackTrace(); 54 throw new SystemException("An error occurred when we tried to begin an transaction. Reason:" + e.getMessage(), e); 55 } 56 } 57 58 59 60 63 64 protected void commitTransaction(Database db) throws SystemException 65 { 66 try 67 { 68 db.commit(); 69 db.close(); 70 } 71 catch(Exception e) 72 { 73 e.printStackTrace(); 74 throw new SystemException("An error occurred when we tried to commit an transaction. Reason:" + e.getMessage(), e); 75 } 76 } 77 78 79 82 83 protected void rollbackTransaction(Database db) throws SystemException 84 { 85 try 86 { 87 if (db.isActive()) 88 { 89 db.rollback(); 90 db.close(); 91 } 92 } 93 catch(Exception e) 94 { 95 e.printStackTrace(); 96 throw new SystemException("An error occurred when we tried to rollback an transaction. Reason:" + e.getMessage(), e); 97 } 98 } 99 100 103 protected Collection toCollection(Enumeration enumeration) 104 { 105 final Set set = new HashSet (); 106 while(enumeration.hasMoreElements()) 107 { 108 set.add(enumeration.nextElement()); 109 } 110 return Collections.unmodifiableSet(set); 111 } 112 113 114 } | Popular Tags |