showFormatError(maxAgeStr); return -1; String[] tokens = maxAgeStr.split(" +"); if ((tokens.length != 2)) { showFormatError(maxAgeStr); return -1; number = Integer.parseInt(tokens[0]); } catch (NumberFormatException e) { showFormatError(maxAgeStr); return -1; return 7 * 24 * number; } else { showFormatError(maxAgeStr); return -1;
/** * @see org.opencms.scheduler.I_CmsScheduledJob#launch(org.opencms.file.CmsObject, java.util.Map) */ public String launch(CmsObject cms, Map<String, String> parameters) throws Exception { String maxAgeStr = parameters.get(PARAM_MAX_AGE); long maxAgeHours = parseMaxAge(maxAgeStr); if (maxAgeHours > 0) { long maxAgeMillis = maxAgeHours * 3600L * 1000L; long now = System.currentTimeMillis(); CmsLogFilter filter = CmsLogFilter.ALL.filterTo(now - maxAgeMillis); LOG.info("Removing all entries from CMS_LOG older than " + maxAgeHours + " hours..."); cms.deleteLogEntries(filter); } else { LOG.info("Not deleting any log entries because of a problem with the max-age format."); } return "remove old db log entries (max age : " + maxAgeStr + ")"; }