1 64 package com.jcorporate.expresso.services.job; 65 66 import com.jcorporate.expresso.core.db.DBConnection; 67 import com.jcorporate.expresso.core.dbobj.SecuredDBObject; 68 import com.jcorporate.expresso.services.dbobj.ValidationQueue; 69 import org.apache.log4j.Logger; 70 71 import java.util.ArrayList ; 72 73 83 public class ClearOldValidation extends com.jcorporate.expresso.core.job.Job { 84 85 88 private static final String THIS_CLASS = ClearOldValidation.class.getName() + "."; 89 90 93 private static final transient Logger log = Logger.getLogger(ClearOldValidation.class); 94 95 96 102 public ClearOldValidation() { 103 super(); 104 105 this.setSchema(com.jcorporate.expresso.core.ExpressoSchema.class.getName()); 106 } 107 108 109 112 public void run() { 113 super.run(); 114 try { 115 if (log.isInfoEnabled()) { 116 log.info("Beginning job " + THIS_CLASS); 117 } 118 int recordsDeleted = 0; 119 120 ValidationQueue vq = new ValidationQueue(SecuredDBObject.SYSTEM_ACCOUNT); 121 vq.setDataContext(this.getDataContext()); 122 ArrayList al = new ArrayList (); 123 DBConnection connection = vq.createAndExecuteSearch(al); 124 125 ValidationQueue oneEntry = new ValidationQueue(SecuredDBObject.SYSTEM_ACCOUNT); 126 oneEntry.setDataContext(this.getDataContext()); 127 while (connection.next()) { 128 oneEntry.clear(); 129 vq.loadFromConnection(oneEntry, connection, al); 130 if (oneEntry.isExpired()) { 131 if (log.isDebugEnabled()) { 132 log.debug("Deleting validation entry: " + vq.getKey()); 133 } 134 135 oneEntry.delete(true); 136 recordsDeleted++; 137 } 138 } 139 140 finish("Validation Queue Clearance Complete.\n\n\t+ " + recordsDeleted 141 + " expired validation entries were deleted."); 142 } catch (Throwable t) { 143 log.error("Caught exception finishing job " + THIS_CLASS, t); 144 finish("Error finishing job " + THIS_CLASS, t); 145 } 146 } 147 148 149 154 public String getTitle() { 155 return "Clear old validation entries"; 156 } 157 158 } 159 | Popular Tags |