public Properties extractFields(CharSequence text) { Properties dest = new Properties(); extractFields(dest, text); return dest; }
referenceValue = metadata.getString(sourceReferenceField); metadata.setString(targetReferenceField, referenceValue); && !Objects.equals( sourceReferenceField, targetReferenceField)) { metadata.remove(sourceReferenceField); List<String >content = metadata.getStrings(sourceContentField); metadata.setString(targetContentField, content.toArray(ArrayUtils.EMPTY_STRING_ARRAY)); if (!keepSourceContentField && !Objects.equals( sourceContentField, targetContentField)) { metadata.remove(sourceContentField); metadata.setString(targetContentField, IOUtils.toString(is, StandardCharsets.UTF_8)); IOUtils.closeQuietly(is);
@Override public void add( String reference, InputStream content, Properties metadata) { try { File targetFile = createFile(FILE_SUFFIX_ADD); // Content FileUtils.copyInputStreamToFile(content, new File(targetFile.getAbsolutePath() + EXTENSION_CONTENT)); // Metadata FileOutputStream out = new FileOutputStream(new File( targetFile.getAbsolutePath() + EXTENSION_METADATA)); metadata.store(out, ""); IOUtils.closeQuietly(out); // Reference FileUtils.writeStringToFile(new File( targetFile.getAbsolutePath() + EXTENSION_REFERENCE), reference, StandardCharsets.UTF_8); } catch (IOException e) { throw new CommitterException( "Cannot queue document addition. Ref: " + reference, e); } } @Override
Properties config = new Properties(); config.load(sr); } catch (IOException e) { LOG.error("Cannot read file: " + file.getAbsolutePath()); jobStatus.setProgress(config.getDouble("progress", 0d)); jobStatus.setNote(config.getString("note", null)); jobStatus.setResumeAttempts(config.getInt("resumeAttempts", 0)); config.getDate("resumedStartTime", null)); duration.setResumedLastActivity( config.getDate("resumedLastActivity", null)); duration.setStartTime(config.getDate("startTime", null)); duration.setEndTime(config.getDate("endTime", null)); jobStatus.setDuration(duration); jobStatus.setStopRequested(config.getBoolean("stopped", false)); for (String key : config.keySet()) { if (key.startsWith("prop.")) { props.put(StringUtils.removeStart( "prop.", key), props.get(key));
throws IOException { Properties config = new Properties(); config.setString("jobId", jobStatus.getJobId()); config.setDouble("progress", jobStatus.getProgress()); if (jobStatus.getNote() != null) { config.setString("note", jobStatus.getNote()); config.setInt("resumeAttempts", jobStatus.getResumeAttempts()); config.setDate("resumedStartTime", duration.getResumedStartTime()); config.setDate("resumedLastActivity", duration.getResumedLastActivity()); config.setDate("startTime", duration.getStartTime()); config.setDate("endTime", duration.getEndTime()); config.setBoolean("stopped", true); for (String key : props.keySet()) { config.put("prop." + key, props.get(key)); FileLock lock = channel.lock()) { StringWriter sw = new StringWriter(); config.store(sw, "Status for job: " + jobStatus.getJobId()); ras.writeUTF(sw.toString());
"Could not load reference for " + refFile, e); this.metadata = new Properties(); synchronized (metadata) { if (metaFile.exists()) { try { is = new FileInputStream(metaFile); metadata.load(is); } catch (IOException e) { throw new CommitterException(
appendValues(b, field, metadata.getStrings(field)); for (Entry<String, List<String>> entry : metadata.entrySet()) { if (p.matcher(entry.getKey()).matches()) { appendValues(b, entry.getKey(), entry.getValue());
public void extractFields(Properties dest, CharSequence text) { Matcher m = matcher(text); while (m.find()) { String fieldName = extractFieldName(m); String fieldValue = extractFieldValue(m); if (StringUtils.isBlank(fieldName)) { LOG.warn("No field name for value: " + fieldValue); } else if (fieldValue == null) { LOG.warn("Null value for field: " + field); } else { dest.addString(fieldName, fieldValue); } } } public Properties extractFields(CharSequence text) {
@Override public boolean acceptMetadata(String reference, Properties metadata) { if (StringUtils.isBlank(regex)) { return getOnMatch() == OnMatch.INCLUDE; } Collection<String> values = metadata.getStrings(field); for (Object value : values) { String strVal = Objects.toString(value, StringUtils.EMPTY); if (getCachedPattern().matcher(strVal).matches()) { return getOnMatch() == OnMatch.INCLUDE; } } return getOnMatch() == OnMatch.EXCLUDE; }
xml.writeElementString("reference", reference); xml.writeStartElement("metadata"); for (Entry<String, List<String>> entry : metadata.entrySet()) { for (String value : entry.getValue()) { xml.writeStartElement("meta");
public JobStatusUpdater(final MutableJobStatus status) { this.status = status; status.getProperties().addMapChangeListener( new IMapChangeListener<String, List<String>>() { @Override public void mapChanged(MapChangeEvent<String, List<String>> event) { statusUpdated(status); } }); }
@Override public final String createMetadataChecksum(Properties metadata) { String checksum = doCreateMetaChecksum(metadata); if (isKeep()) { String field = getTargetField(); if (StringUtils.isBlank(field)) { field = CollectorMetadata.COLLECTOR_CHECKSUM_METADATA; } metadata.addString(field, checksum); if (LOG.isDebugEnabled()) { LOG.debug("Meta checksum stored in " + field); } } return checksum; }
public static Properties extractFields( CharSequence text, RegexFieldExtractor... patterns) { Properties dest = new Properties(); extractFields(dest, text, patterns); return dest; } }
Properties metadata = new Properties(); ImporterConfig config = loadCommandLineConfig(cmd, configFile, varFile);