1 64 65 package com.jcorporate.expresso.services.job; 66 67 import com.jcorporate.expresso.core.db.DBException; 68 import com.jcorporate.expresso.core.job.Job; 69 import com.jcorporate.expresso.services.dbobj.Event; 70 import com.jcorporate.expresso.services.dbobj.JobQueue; 71 import com.jcorporate.expresso.services.validation.AuthValidationException; 72 import com.jcorporate.expresso.services.validation.ValidationEntry; 73 import com.jcorporate.expresso.services.validation.ValidationHandler; 74 import org.apache.log4j.Logger; 75 76 import java.util.List ; 77 78 79 93 public class ValidationJob 94 extends Job { 95 96 private static Logger log = Logger.getLogger(ValidationJob.class); 98 99 105 public ValidationJob() { 106 super(); 107 setSchema("com.jcorporate.expresso.core.ExpressoSchema"); 108 } 109 110 117 private void errorNotify(String msg) { 118 try { 119 120 new Event(getJobQueueEntry().getDataContext(), 122 "SYSERROR", 123 getClass().getName() + 124 ":Unable to run validation job:" + msg + 125 " Job:" + getJobNumber() + " User:" + 126 getUser(), false); 127 } catch (Exception e) { 128 log.error(e); 129 } 130 } 131 132 139 public String getTitle() { 140 return "Validation Job"; 141 } 142 143 150 protected void initialize() 151 throws AuthValidationException { 152 if (log.isDebugEnabled()) { 153 try { 154 log.debug("Running validation job, job id=" + 155 getJobQueueEntry().getField("ServerID")); 156 } catch (DBException dbe) { 157 throw new AuthValidationException("DB error getting job queue entry", 158 dbe); 159 } 160 } 161 } 162 163 174 public void run() { 175 super.run(); 176 177 String desc = getTitle(); 179 180 try { 181 182 initialize(); 184 185 List paramsVector = this.getJobParameterList(); 187 188 JobQueue jq = getJobQueueEntry(); 190 191 desc = jq.getParamValue(ValidationEntry.PRM_VAL_TITLE) + "(" + 193 jq.getParamValue(ValidationEntry.PRM_VAL_DESC) + ")"; 194 195 ValidationEntry ve = new ValidationEntry(getDataContext(), paramsVector, 198 jq); 199 200 ValidationHandler vh = ve.instantiateHandler(); 202 203 vh.notify(ve.getParams(), ve.validationURL()); 205 ve.setStatus("W"); 206 207 finish(desc + ":succeeded"); 209 } catch (Exception e) { 210 211 finish(desc + ":failed", e); 213 } finally { 214 215 try { 217 getJobQueueEntry().delete(); 218 } catch (DBException de2) { 219 errorNotify(de2.getMessage()); 220 } 221 } 222 } 223 224 } 225 | Popular Tags |