/** * Factory method for ResultsPruners (used to load ConfigurationManager properties. * * @param props * @throws FileNotFoundException */ public static ResultsPruner getPruner(Context context, Properties props) throws FileNotFoundException { ResultsPruner rp = new ResultsPruner(context); Pattern retentionPattern = Pattern.compile("checker\\.retention\\.(.*)"); for (Enumeration<String> en = (Enumeration<String>) props.propertyNames(); en.hasMoreElements(); ) { String name = en.nextElement(); Matcher matcher = retentionPattern.matcher(name); if (!matcher.matches()) { continue; } String resultCode = matcher.group(1); long duration; try { duration = Utils.parseDuration(props.getProperty(name)); } catch (ParseException e) { throw new IllegalStateException("Problem parsing duration: " + e.getMessage(), e); } ChecksumResultCode code = ChecksumResultCode.valueOf(resultCode); if (code == null) { throw new IllegalStateException("Checksum result code not found: " + resultCode); } if ("default".equals(resultCode)) { rp.setDefaultDuration(duration); } else { rp.addInterested(code, duration); } } return rp; }
/** * Add a result and the length of time before it is removed from the checksum history table. * * @param result code in the database. * @param duration before bitstreams with the specified result type in the checksum history is * removed. * @throws ParseException if the duration cannot be parsed into a long value. */ public void addInterested(ChecksumResultCode result, String duration) throws ParseException { addInterested(result, Utils.parseDuration(duration)); }