Refine search
/** * */ @Override protected String getProtocol(ProcessContext processContext) { return processContext.getProperty(USE_SSL).asBoolean() ? "imaps" : "imap"; }
private Properties getTransformerProperties(ProcessContext context) { final String method = context.getProperty(XML_OUTPUT_METHOD).getValue(); boolean indent = context.getProperty(XML_OUTPUT_INDENT).asBoolean(); boolean omitDeclaration = context.getProperty(XML_OUTPUT_OMIT_XML_DECLARATION).asBoolean(); return getTransformerProperties(method, indent, omitDeclaration); }
ProcessorConfiguration(final ProcessContext context) { ignoreDottedFiles = context.getProperty(IGNORE_DOTTED_FILES).asBoolean(); final String fileFilterRegex = context.getProperty(FILE_FILTER_REGEX).getValue(); fileFilterPattern = (fileFilterRegex == null) ? null : Pattern.compile(fileFilterRegex); filterMatchBasenameOnly = context.getProperty(FILTER_MATCH_NAME_ONLY).asBoolean(); final Long minAgeProp = context.getProperty(MIN_AGE).asTimePeriod(TimeUnit.MILLISECONDS); minimumAge = (minAgeProp == null) ? 0L : minAgeProp; final Long maxAgeProp = context.getProperty(MAX_AGE).asTimePeriod(TimeUnit.MILLISECONDS); maximumAge = (maxAgeProp == null) ? Long.MAX_VALUE : maxAgeProp; recurseSubdirs = context.getProperty(RECURSE_SUBDIRS).asBoolean(); }
@OnEnabled public void storeCsvFormat(final ConfigurationContext context) { this.csvParser = context.getProperty(CSV_PARSER).getValue(); this.csvFormat = CSVUtils.createCSVFormat(context); this.dateFormat = context.getProperty(DateTimeUtils.DATE_FORMAT).getValue(); this.timeFormat = context.getProperty(DateTimeUtils.TIME_FORMAT).getValue(); this.timestampFormat = context.getProperty(DateTimeUtils.TIMESTAMP_FORMAT).getValue(); this.firstLineIsHeader = context.getProperty(CSVUtils.FIRST_LINE_IS_HEADER).asBoolean(); this.ignoreHeader = context.getProperty(CSVUtils.IGNORE_CSV_HEADER).asBoolean(); this.charSet = context.getProperty(CSVUtils.CHARSET).getValue(); // Ensure that if we are deriving schema from header that we always treat the first line as a header, // regardless of the 'First Line is Header' property final String accessStrategy = context.getProperty(SchemaAccessUtils.SCHEMA_ACCESS_STRATEGY).getValue(); if (headerDerivedAllowableValue.getValue().equals(accessStrategy)) { this.csvFormat = this.csvFormat.withFirstRecordAsHeader(); this.firstLineIsHeader = true; } }
int getCompileFlags(ProcessContext context) { int flags = (context.getProperty(UNIX_LINES).asBoolean() ? Pattern.UNIX_LINES : 0) | (context.getProperty(CASE_INSENSITIVE).asBoolean() ? Pattern.CASE_INSENSITIVE : 0) | (context.getProperty(COMMENTS).asBoolean() ? Pattern.COMMENTS : 0) | (context.getProperty(MULTILINE).asBoolean() ? Pattern.MULTILINE : 0) | (context.getProperty(LITERAL).asBoolean() ? Pattern.LITERAL : 0) | (context.getProperty(DOTALL).asBoolean() ? Pattern.DOTALL : 0) | (context.getProperty(UNICODE_CASE).asBoolean() ? Pattern.UNICODE_CASE : 0) | (context.getProperty(CANON_EQ).asBoolean() ? Pattern.CANON_EQ : 0) | (context.getProperty(UNICODE_CHARACTER_CLASS).asBoolean() ? Pattern.UNICODE_CHARACTER_CLASS : 0); return flags; } }
private DMLSettings(ProcessContext context) { translateFieldNames = context.getProperty(TRANSLATE_FIELD_NAMES).asBoolean(); ignoreUnmappedFields = IGNORE_UNMATCHED_FIELD.getValue().equalsIgnoreCase(context.getProperty(UNMATCHED_FIELD_BEHAVIOR).getValue()); failUnmappedColumns = FAIL_UNMATCHED_COLUMN.getValue().equalsIgnoreCase(context.getProperty(UNMATCHED_COLUMN_BEHAVIOR).getValue()); warningUnmappedColumns = WARNING_UNMATCHED_COLUMN.getValue().equalsIgnoreCase(context.getProperty(UNMATCHED_COLUMN_BEHAVIOR).getValue()); escapeColumnNames = context.getProperty(QUOTED_IDENTIFIERS).asBoolean(); quoteTableName = context.getProperty(QUOTED_TABLE_IDENTIFIER).asBoolean(); }
@Override protected Collection<ValidationResult> customValidate(ValidationContext context) { final List<ValidationResult> problems = new ArrayList<>(super.customValidate(context)); // Don't allow Pretty Print if One Line Per Object is selected if (context.getProperty(PRETTY_PRINT_JSON).asBoolean() && context.getProperty(OUTPUT_GROUPING).getValue().equals(OUTPUT_ONELINE.getValue())) { problems.add(new ValidationResult.Builder().input("Pretty Print").valid(false) .explanation("Pretty Print JSON must be false when 'Output Grouping' is set to 'One Line Per Object'").build()); } return problems; }
public SFTPTransfer(final ProcessContext processContext, final ComponentLog logger) { this.ctx = processContext; this.logger = logger; final PropertyValue disableListing = processContext.getProperty(DISABLE_DIRECTORY_LISTING); disableDirectoryListing = disableListing == null ? false : Boolean.TRUE.equals(disableListing.asBoolean()); }
ProcessorConfiguration(final ProcessContext context) { conflictResolution = context.getProperty(CONFLICT_RESOLUTION).getValue(); operation = context.getProperty(OPERATION).getValue(); final String outputDirValue = context.getProperty(OUTPUT_DIRECTORY).evaluateAttributeExpressions().getValue(); outputRootDirPath = new Path(outputDirValue); final String fileFilterRegex = context.getProperty(FILE_FILTER_REGEX).getValue(); fileFilterPattern = (fileFilterRegex == null) ? null : Pattern.compile(fileFilterRegex); ignoreDottedFiles = context.getProperty(IGNORE_DOTTED_FILES).asBoolean(); }
@Override protected Collection<ValidationResult> customValidate(ValidationContext validationContext) { final List<ValidationResult> results = new ArrayList<>(1); final boolean isUnique = validationContext.getProperty(UNIQUE_FLOWFILES).asBoolean(); final boolean isText = validationContext.getProperty(DATA_FORMAT).getValue().equals(DATA_FORMAT_TEXT); final boolean isCustom = validationContext.getProperty(CUSTOM_TEXT).isSet(); if(isCustom && (isUnique || !isText)) { results.add(new ValidationResult.Builder().subject("Custom Text").valid(false).explanation("If Custom Text is set, then Data Format must be " + "text and Unique FlowFiles must be false.").build()); } return results; }
private RequestBody getRequestBodyToSend(final ProcessSession session, final ProcessContext context, final FlowFile requestFlowFile) { if(context.getProperty(PROP_SEND_BODY).asBoolean()) { return new RequestBody() { @Override public MediaType contentType() { String contentType = context.getProperty(PROP_CONTENT_TYPE).evaluateAttributeExpressions(requestFlowFile).getValue(); contentType = StringUtils.isBlank(contentType) ? DEFAULT_CONTENT_TYPE : contentType; return MediaType.parse(contentType); } @Override public void writeTo(BufferedSink sink) throws IOException { session.exportTo(requestFlowFile, sink.outputStream()); } @Override public long contentLength(){ return useChunked ? -1 : requestFlowFile.getSize(); } }; } else { return RequestBody.create(null, new byte[0]); } }
@OnScheduled public void onScheduled(ProcessContext context) { includeCoreAttributes = context.getProperty(INCLUDE_CORE_ATTRIBUTES).asBoolean(); coreAttributes = Arrays.stream(CoreAttributes.values()).map(CoreAttributes::key).collect(Collectors.toSet()); destinationContent = OUTPUT_OVERWRITE_CONTENT.getValue().equals(context.getProperty(DESTINATION).getValue()); nullValForEmptyString = context.getProperty(NULL_VALUE_FOR_EMPTY_STRING).asBoolean(); includeSchema = context.getProperty(INCLUDE_SCHEMA).asBoolean(); }
@Override protected Collection<ValidationResult> customValidate(final ValidationContext validationContext) { final List<ValidationResult> results = new ArrayList<>(); results.addAll(KafkaProcessorUtils.validateCommonProperties(validationContext)); final boolean useTransactions = validationContext.getProperty(USE_TRANSACTIONS).asBoolean(); if (useTransactions) { final String deliveryGuarantee = validationContext.getProperty(DELIVERY_GUARANTEE).getValue(); if (!DELIVERY_REPLICATED.getValue().equals(deliveryGuarantee)) { results.add(new ValidationResult.Builder() .subject("Delivery Guarantee") .valid(false) .explanation("In order to use Transactions, the Delivery Guarantee must be \"Guarantee Replicated Delivery.\" " + "Either change the <Use Transactions> property or the <Delivery Guarantee> property.") .build()); } } return results; }
protected InputStream getRequestBodyToSend(final ProcessSession session, final ProcessContext context, final FlowFile requestFlowFile) { if (context.getProperty(PROP_SEND_BODY).asBoolean() && requestFlowFile != null) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); session.exportTo(requestFlowFile, outputStream); return new ByteArrayInputStream(outputStream.toByteArray()); } else { return new ByteArrayInputStream(new byte[0]); } }
@OnScheduled public void onSchedule(ProcessContext context) { this.countLines = context.getProperty(TEXT_LINE_COUNT_PD).isSet() ? context.getProperty(TEXT_LINE_COUNT_PD).asBoolean() : false; this.countLinesNonEmpty = context.getProperty(TEXT_LINE_NONEMPTY_COUNT_PD).isSet() ? context.getProperty(TEXT_LINE_NONEMPTY_COUNT_PD).asBoolean() : false; this.countWords = context.getProperty(TEXT_WORD_COUNT_PD).isSet() ? context.getProperty(TEXT_WORD_COUNT_PD).asBoolean() : false; this.countCharacters = context.getProperty(TEXT_CHARACTER_COUNT_PD).isSet() ? context.getProperty(TEXT_CHARACTER_COUNT_PD).asBoolean() : false; this.splitWordsOnSymbols = context.getProperty(SPLIT_WORDS_ON_SYMBOLS_PD).isSet() ? context.getProperty(SPLIT_WORDS_ON_SYMBOLS_PD).asBoolean() : false; this.characterEncoding = context.getProperty(CHARACTER_ENCODING_PD).getValue(); }
@Override protected Collection<ValidationResult> customValidate(final ValidationContext validationContext) { final List<ValidationResult> results = new ArrayList<>(); results.addAll(KafkaProcessorUtils.validateCommonProperties(validationContext)); final boolean useTransactions = validationContext.getProperty(USE_TRANSACTIONS).asBoolean(); if (useTransactions) { final String deliveryGuarantee = validationContext.getProperty(DELIVERY_GUARANTEE).getValue(); if (!DELIVERY_REPLICATED.getValue().equals(deliveryGuarantee)) { results.add(new ValidationResult.Builder() .subject("Delivery Guarantee") .valid(false) .explanation("In order to use Transactions, the Delivery Guarantee must be \"Guarantee Replicated Delivery.\" " + "Either change the <Use Transactions> property or the <Delivery Guarantee> property.") .build()); } } return results; }
@Override public long getContentLength() { if (compressionLevel == 0 && !sendAsFlowFile && !context.getProperty(CHUNKED_ENCODING).asBoolean()) { return toSend.get(0).getSize(); } else { return -1; } } };
@Override public void process(InputStream in) throws IOException { avroSchema.set(CSVUtil .inferSchema( context.getProperty(RECORD_NAME).evaluateAttributeExpressions(inputFlowFile).getValue(), in, props) .toString(context.getProperty(PRETTY_AVRO_OUTPUT).asBoolean())); } });
@Override protected Collection<ValidationResult> customValidate(final ValidationContext validationContext) { final List<ValidationResult> results = new ArrayList<>(); results.addAll(KafkaProcessorUtils.validateCommonProperties(validationContext)); final boolean useTransactions = validationContext.getProperty(USE_TRANSACTIONS).asBoolean(); if (useTransactions) { final String deliveryGuarantee = validationContext.getProperty(DELIVERY_GUARANTEE).getValue(); if (!DELIVERY_REPLICATED.getValue().equals(deliveryGuarantee)) { results.add(new ValidationResult.Builder() .subject("Delivery Guarantee") .valid(false) .explanation("In order to use Transactions, the Delivery Guarantee must be \"Guarantee Replicated Delivery.\" " + "Either change the <Use Transactions> property or the <Delivery Guarantee> property.") .build()); } } return results; }