public void doGet(HttpServletRequest req, HttpServletResponse resp) {
log.info("-- Job1009 start --");
long startTime = System.currentTimeMillis();
Job job = null;
try {
job = (new JobDao()).getJob(this.getClass().getName());
job.setStatus(JobStatus.RUNNING);
PMF.saveEntity(job);
log.info("job's status:" + job);
// トークン情報の削除
AuthTokenDao authTokenDao = new AuthTokenDao();
authTokenDao.clearTempToken(Integer.valueOf(this.configMap.get("app.piment.temptoken.lifetime")));
UserMapDao userMapDao = new UserMapDao();
List<UserMap> allUserMap = userMapDao.getAllUserMaps();
// メッセージ履歴の掃除
WeiboMapDao weiboMapDao = new WeiboMapDao();
weiboMapDao.removeOlder(allUserMap, Integer.valueOf(this.configMap.get("app.piment.weibomap.lifetime")));
// コメント履歴の掃除
CommentMapDao commentMapDao = new CommentMapDao();
commentMapDao.removeOlder(allUserMap, Integer.valueOf(this.configMap.get("app.piment.weibomap.lifetime")));
// ジョブ状態変更
job.setStatus(JobStatus.SUCCESSED);
} catch (Exception e) {
// ジョブ状態変更
if (job != null) {
job.setStatus(JobStatus.FAILED);
}
throw new RuntimeException(e);
} finally {
long costTime = System.currentTimeMillis() - startTime;
if (job != null) {
job.setLastExecuteTime(DateUtils.getSysDate());
job.setCostTime(costTime);
PMF.saveEntity(job);
log.info("job's status:" + job);
}
log.info("-- Job1009 end [cost " + costTime + " TimeMillis]--");
}