@Override protected Collection<ValidationResult> customValidate(ValidationContext validationContext) { final List<ValidationResult> results = new ArrayList<>(super.customValidate(validationContext)); Validator validator = new RecordPathValidator(); Map<PropertyDescriptor, String> processorProperties = validationContext.getProperties(); for (final Map.Entry<PropertyDescriptor, String> entry : processorProperties.entrySet()) { PropertyDescriptor property = entry.getKey(); if (property.isDynamic() && property.isExpressionLanguageSupported()) { String dynamicValue = validationContext.getProperty(property).getValue(); if(!validationContext.isExpressionLanguagePresent(dynamicValue)) { results.add(validator.validate(property.getDisplayName(), dynamicValue, validationContext)); } } } return results; }
@Override public void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue) { super.onPropertyModified(descriptor, oldValue, newValue); if (descriptor.equals(STORE_STATE)) { if (DO_NOT_STORE_STATE.equals(newValue)){ stateful = false; relationships = statelessRelationshipSet; } else { stateful = true; relationships = statefulRelationshipSet; } } }
@Override protected void init(ProcessorInitializationContext context) { super.init(context); final List<PropertyDescriptor> properties = new ArrayList<>(); properties.add(CONTAINER_OPTIONS); properties.add(WRAP_SINGLE_RECORD); properties.add(SCHEMA); this.properties = Collections.unmodifiableList(properties); }
@Override public final void onTrigger(final ProcessContext context, final ProcessSessionFactory sessionFactory) throws ProcessException { final ProcessSession session = sessionFactory.createSession(); try { onTrigger(context, session); session.commit(); } catch (final Throwable t) { session.rollback(true); throw t; } }
builder.withWriteMode(mode); final PropertyDescriptor compressionTypeDescriptor = abstractProcessor.getPropertyDescriptor(COMPRESSION_TYPE.getName());
@Override protected Collection<ValidationResult> customValidate(final ValidationContext context) { final List<ValidationResult> results = new ArrayList<>(super.customValidate(context)); final String destination = context.getProperty(DESTINATION).getValue(); if (DESTINATION_CONTENT.equals(destination)) { int xpathCount = 0; for (final PropertyDescriptor desc : context.getProperties().keySet()) { if (desc.isDynamic()) { xpathCount++; } } if (xpathCount != 1) { results.add(new ValidationResult.Builder().subject("XPaths").valid(false) .explanation("Exactly one XPath must be set if using destination of " + DESTINATION_CONTENT).build()); } } return results; }
@Override public void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue) { super.onPropertyModified(descriptor, oldValue, newValue); if (descriptor.equals(RATE_CONTROL_CRITERIA) || descriptor.equals(RATE_CONTROL_ATTRIBUTE_NAME) || descriptor.equals(GROUPING_ATTRIBUTE_NAME) || descriptor.equals(TIME_PERIOD)) { // if the criteria that is being used to determine limits/throttles is changed, we must clear our throttle map. throttleMap.clear(); } else if (descriptor.equals(MAX_RATE)) { final long newRate; if (DataUnit.DATA_SIZE_PATTERN.matcher(newValue.toUpperCase()).matches()) { newRate = DataUnit.parseDataSize(newValue, DataUnit.B).longValue(); } else { newRate = Long.parseLong(newValue); } for (final Throttle throttle : throttleMap.values()) { throttle.setMaxRate(newRate); } } }
@Override protected void init(ProcessorInitializationContext context) { super.init(context); final List<PropertyDescriptor> properties = new ArrayList<>(); properties.add(FINGERPRINT_ALGORITHM); properties.add(METADATA_KEYS); properties.add(COUNT_ITEMS); this.properties = Collections.unmodifiableList(properties); final Set<Relationship> relationships = new HashSet<>(); relationships.add(REL_SUCCESS); relationships.add(REL_FAILURE); this.relationships = Collections.unmodifiableSet(relationships); }
@Override protected Collection<ValidationResult> customValidate(final ValidationContext context) { final List<ValidationResult> errors = new ArrayList<>(super.customValidate(context)); final String regexValue = context.getProperty(REGEX).evaluateAttributeExpressions().getValue(); final int numCapturingGroups = Pattern.compile(regexValue).matcher("").groupCount(); final int groupToMatch = context.getProperty(MATCHING_GROUP_FOR_LOOKUP_KEY).evaluateAttributeExpressions().asInteger(); if (groupToMatch > numCapturingGroups) { errors.add( new ValidationResult.Builder() .subject("Insufficient Matching Groups") .valid(false) .explanation("The specified matching group does not exist for the regular expression provided") .build()); } return errors; }
@Override public void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue) { super.onPropertyModified(descriptor, oldValue, newValue); if (descriptor.equals(STORE_STATE)) { if (DO_NOT_STORE_STATE.equals(newValue)){ stateful = false; relationships = statelessRelationshipSet; } else { stateful = true; relationships = statefulRelationshipSet; } } }
@Override protected void init(ProcessorInitializationContext context) { super.init(context); synchronized (ALL_FIELD_NAMES) { if (ALL_FIELD_NAMES.isEmpty()) { ALL_FIELD_NAMES.addAll(UserAgentAnalyzer .newBuilder() .hideMatcherLoadStats() .delayInitialization() .dropTests() .build() .getAllPossibleFieldNamesSorted()); } } final Set<Relationship> relationshipsSet = new HashSet<>(); relationshipsSet.add(SUCCESS); relationshipsSet.add(MISSING); this.relationships = Collections.unmodifiableSet(relationshipsSet); for (String fieldName: ALL_FIELD_NAMES) { PropertyDescriptor propertyDescriptor = new PropertyDescriptor.Builder() .name(PROPERTY_PREFIX + fieldName) .description("If enabled will extract the " + fieldName + " field") .required(true) .allowableValues("true", "false") .defaultValue("false") .addValidator(StandardValidators.BOOLEAN_VALIDATOR) .build(); supportedPropertyDescriptors.add(propertyDescriptor); } }
@Override protected Collection<ValidationResult> customValidate(final ValidationContext context) { final List<ValidationResult> results = new ArrayList<>(super.customValidate(context)); final String destination = context.getProperty(DESTINATION).getValue(); if (DESTINATION_CONTENT.equals(destination)) { int xQueryCount = 0; for (final PropertyDescriptor desc : context.getProperties().keySet()) { if (desc.isDynamic()) { xQueryCount++; } } if (xQueryCount != 1) { results.add(new ValidationResult.Builder().subject("XQueries").valid(false) .explanation("Exactly one XQuery must be set if using destination of " + DESTINATION_CONTENT).build()); } } return results; }
@Override public void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue) { super.onPropertyModified(descriptor, oldValue, newValue); if (descriptor.equals(RATE_CONTROL_CRITERIA) || descriptor.equals(RATE_CONTROL_ATTRIBUTE_NAME) || descriptor.equals(GROUPING_ATTRIBUTE_NAME) || descriptor.equals(TIME_PERIOD)) { // if the criteria that is being used to determine limits/throttles is changed, we must clear our throttle map. throttleMap.clear(); } else if (descriptor.equals(MAX_RATE)) { final long newRate; if (DataUnit.DATA_SIZE_PATTERN.matcher(newValue.toUpperCase()).matches()) { newRate = DataUnit.parseDataSize(newValue, DataUnit.B).longValue(); } else { newRate = Long.parseLong(newValue); } for (final Throttle throttle : throttleMap.values()) { throttle.setMaxRate(newRate); } } }
@Override protected Collection<ValidationResult> customValidate(ValidationContext validationContext) { final List<ValidationResult> errors = new ArrayList<>(super.customValidate(validationContext)); final Set<PropertyDescriptor> dynamicProperties = validationContext.getProperties().keySet().stream() .filter(prop -> prop.isDynamic()) .collect(Collectors.toSet()); if (dynamicProperties == null || dynamicProperties.size() < 1) { errors.add(new ValidationResult.Builder() .subject("User-Defined Properties") .valid(false) .explanation("At least one user-defined property must be specified.") .build()); } final Set<String> requiredKeys = validationContext.getProperty(LOOKUP_SERVICE).asControllerService(LookupService.class).getRequiredKeys(); if (requiredKeys == null || requiredKeys.size() != 1) { errors.add(new ValidationResult.Builder() .subject(LOOKUP_SERVICE.getDisplayName()) .valid(false) .explanation("LookupAttribute requires a key-value lookup service supporting exactly one required key.") .build()); } return errors; }
@Override public void onPropertyModified(PropertyDescriptor descriptor, String oldValue, String newValue) { super.onPropertyModified(descriptor, oldValue, newValue); if (descriptor.equals(TESS_DATA_PATH)) { getLogger().debug("Tesseract Install path was changed. Building list of supported languages"); SUPPORTED_LANGUAGES.clear(); SUPPORTED_LANGUAGES.add("eng"); //File will always exist since the Validator will take care of that. File[] files = getTesseractLanguages(newValue); //Guard against creating an empty list of allowable values in case the user points to an invalid directory if (files != null && files.length > 0) { for (int i = 0; i < files.length; i++) { if (getLogger().isDebugEnabled()) { getLogger().debug("Found Tesseract supported language: " + files[i].getName()); } SUPPORTED_LANGUAGES.add(StringUtils.split(files[i].getName(), ".")[0]); } } else { getLogger().debug("No languages found in user specified Tessdata directory: '" + newValue + "'"); } } }
@Override protected Collection<ValidationResult> customValidate(ValidationContext validationContext) { try { sleep(validationContext.getProperty(CUSTOM_VALIDATE_SLEEP_TIME).asTimePeriod(TimeUnit.MILLISECONDS), validationContext.getProperty(IGNORE_INTERRUPTS).asBoolean()); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return Collections.singleton(new ValidationResult.Builder() .valid(false) .subject("Validation") .explanation("Processor Interrupted while performing validation").build()); } return super.customValidate(validationContext); }
@Override protected Collection<ValidationResult> customValidate(final ValidationContext context) { final List<ValidationResult> errors = new ArrayList<>(super.customValidate(context)); final String to = context.getProperty(TO).getValue(); final String cc = context.getProperty(CC).getValue(); final String bcc = context.getProperty(BCC).getValue(); if (to == null && cc == null && bcc == null) { errors.add(new ValidationResult.Builder().subject("To, CC, BCC").valid(false).explanation("Must specify at least one To/CC/BCC address").build()); } return errors; }
@Override protected Collection<ValidationResult> customValidate(ValidationContext validationContext) { final List<ValidationResult> errors = new ArrayList<>(super.customValidate(validationContext)); switch (validationContext.getProperty(REPLACEMENT_STRATEGY).getValue()) { case literalReplaceValue: errors.add(StandardValidators.NON_EMPTY_VALIDATOR .validate(SEARCH_VALUE.getName(), validationContext.getProperty(SEARCH_VALUE).getValue(), validationContext)); break; case regexReplaceValue: errors.add(StandardValidators.createRegexValidator(0, Integer.MAX_VALUE, true) .validate(SEARCH_VALUE.getName(), validationContext.getProperty(SEARCH_VALUE).getValue(), validationContext)); break; case appendValue: case prependValue: case alwaysReplace: default: // nothing to check, search value is not used break; } return errors; }
@Override protected Collection<ValidationResult> customValidate(ValidationContext context) { final List<ValidationResult> results = new ArrayList<>(super.customValidate(context)); if (context.getProperty(MODE).getValue().equals(MODE_MULTIFILE.getValue())) { String path = context.getProperty(BASE_DIRECTORY).evaluateAttributeExpressions().getValue(); if (path == null) { results.add(new ValidationResult.Builder() .subject(BASE_DIRECTORY.getName()) .valid(false) .explanation("Base directory property cannot be empty in Multifile mode.") .build()); } else if (!new File(path).isDirectory()) { results.add(new ValidationResult.Builder() .subject(BASE_DIRECTORY.getName()) .valid(false) .explanation(path + " is not a directory.") .build()); } } return results; }
@Override protected Collection<ValidationResult> customValidate(ValidationContext validationContext) { List<ValidationResult> results = new ArrayList<>(super.customValidate(validationContext)); PropertyValue cacheEntryIdentifier = validationContext.getProperty(PROP_CACHE_ENTRY_IDENTIFIER); boolean elPresent = false; try { elPresent = cacheEntryIdentifier.isExpressionLanguagePresent(); } catch (NullPointerException npe) { // Unfortunate workaround to a mock framework bug (NIFI-4590) } if (elPresent) { // This doesn't do a full job of validating against the requirement that Put Cache Value In Attribute must be set if multiple // Cache Entry Identifiers are supplied (if Expression Language is used). The user could conceivably have a comma-separated list of EL statements, // or a single EL statement with commas inside it but that evaluates to a single item. results.add(new ValidationResult.Builder().valid(true).explanation("Contains Expression Language").build()); } else { if (!validationContext.getProperty(FetchDistributedMapCache.PROP_PUT_CACHE_VALUE_IN_ATTRIBUTE).isSet()) { String identifierString = cacheEntryIdentifier.getValue(); if (identifierString.contains(",")) { results.add(new ValidationResult.Builder().valid(false) .explanation("Multiple Cache Entry Identifiers specified without Put Cache Value In Attribute set").build()); } } } return results; }