@Override public void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue) { if (descriptor.isDynamic()) { final Set<String> newDynamicPropertyNames = new HashSet<>(dynamicPropertyNames); if (newValue == null) { // removing a property newDynamicPropertyNames.remove(descriptor.getName()); } else if (oldValue == null) { // adding a new property newDynamicPropertyNames.add(descriptor.getName()); } this.dynamicPropertyNames = Collections.unmodifiableSet(newDynamicPropertyNames); } }
private void checkWritingMultipleRecords() throws IOException { if (!allowWritingMultipleRecords && hasWrittenRecord) { StringBuilder message = new StringBuilder(); message.append("The writer attempts to write multiple record although property \'") .append(ROOT_TAG_NAME.getDisplayName()) .append("\' has not been set. If the XMLRecordSetWriter is supposed to write multiple records into one ") .append("FlowFile, this property is required to be configured."); throw new IOException(message.toString() ); } }
@Override public void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue) { if (descriptor.equals(TABLE_NAME)) { lastResult = null; } }
@Override public void onPropertyModified(PropertyDescriptor descriptor, String oldValue, String newValue) { if ( ((oldValue != null && !oldValue.equals(newValue))) && (descriptor.equals(QUERY) || descriptor.equals(TIME_FIELD_STRATEGY) || descriptor.equals(TIME_RANGE_STRATEGY) || descriptor.equals(EARLIEST_TIME) || descriptor.equals(LATEST_TIME) || descriptor.equals(HOSTNAME)) ) { getLogger().debug("A property that require resetting state was modified - {} oldValue {} newValue {}", new Object[] {descriptor.getDisplayName(), oldValue, newValue}); resetState = true; } }
private MockPropertyValue(final String rawValue, final ControllerServiceLookup serviceLookup, final PropertyDescriptor propertyDescriptor, final boolean alreadyEvaluated, final VariableRegistry variableRegistry) { this.stdPropValue = new StandardPropertyValue(rawValue, serviceLookup, variableRegistry); this.rawValue = rawValue; this.serviceLookup = (MockControllerServiceLookup) serviceLookup; this.expectExpressions = propertyDescriptor == null ? null : propertyDescriptor.isExpressionLanguageSupported(); this.expressionLanguageScope = propertyDescriptor == null ? null : propertyDescriptor.getExpressionLanguageScope(); this.propertyDescriptor = propertyDescriptor; this.expressionsEvaluated = alreadyEvaluated; this.variableRegistry = variableRegistry; }
private void writeProperty(final PropertyDescriptor property) throws IOException { writeStartElement("property"); writeTextElement("name", property.getName()); writeTextElement("displayName", property.getDisplayName()); writeTextElement("description", property.getDescription()); writeTextElement("defaultValue", property.getDefaultValue()); writeTextElement("controllerServiceDefinition", property.getControllerServiceDefinition() == null ? null : property.getControllerServiceDefinition().getName()); writeTextArray("allowableValues", "allowableValue", property.getAllowableValues(), AllowableValue::getDisplayName); writeBooleanElement("required", property.isRequired()); writeBooleanElement("sensitive", property.isSensitive()); writeBooleanElement("expressionLanguageSupported", property.isExpressionLanguageSupported()); writeTextElement("expressionLanguageScope", property.getExpressionLanguageScope() == null ? null : property.getExpressionLanguageScope().name()); writeBooleanElement("dynamicallyModifiesClasspath", property.isDynamicClasspathModifier()); writeBooleanElement("dynamic", property.isDynamic()); writeEndElement(); }
@Override public PropertyValue getProperty(final PropertyDescriptor descriptor) { final String propName = descriptor.getName(); String value = propertyValues.get(propName); if (value == null) { value = descriptor.getDefaultValue(); } return new StandardPropertyValue(value, null, variableRegistry); }
private Map<String, VersionedPropertyDescriptor> mapPropertyDescriptors(final ComponentNode component) { final Map<String, VersionedPropertyDescriptor> descriptors = new HashMap<>(); for (final PropertyDescriptor descriptor : component.getProperties().keySet()) { final VersionedPropertyDescriptor versionedDescriptor = new VersionedPropertyDescriptor(); versionedDescriptor.setName(descriptor.getName()); versionedDescriptor.setDisplayName(descriptor.getDisplayName()); versionedDescriptor.setIdentifiesControllerService(descriptor.getControllerServiceDefinition() != null); descriptors.put(descriptor.getName(), versionedDescriptor); } return descriptors; }
private PropertyDescriptor getPropertyDescriptor(final PropertyDescriptor specDescriptor) { PropertyDescriptor descriptor = null; //check if property supported final List<PropertyDescriptor> supportedDescriptors = getSupportedPropertyDescriptors(); if (supportedDescriptors != null) { for (final PropertyDescriptor desc : supportedDescriptors) { //find actual descriptor if (specDescriptor.equals(desc)) { return desc; } } } descriptor = getSupportedDynamicPropertyDescriptor(specDescriptor.getName()); if (descriptor != null && !descriptor.isDynamic()) { descriptor = new PropertyDescriptor.Builder().fromPropertyDescriptor(descriptor).dynamic(true).build(); } if (descriptor == null) { descriptor = new PropertyDescriptor.Builder().fromPropertyDescriptor(specDescriptor).addValidator(Validator.INVALID).dynamic(true).build(); } return descriptor; }
@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; }
public StandardValidationContext( final ControllerServiceProvider controllerServiceProvider, final Set<String> serviceIdentifiersToNotValidate, final Map<PropertyDescriptor, String> properties, final String annotationData, final String groupId, final String componentId, final VariableRegistry variableRegistry) { this.controllerServiceProvider = controllerServiceProvider; this.properties = new HashMap<>(properties); this.annotationData = annotationData; this.variableRegistry = variableRegistry; this.groupId = groupId; this.componentId = componentId; preparedQueries = new HashMap<>(properties.size()); for (final Map.Entry<PropertyDescriptor, String> entry : properties.entrySet()) { final PropertyDescriptor desc = entry.getKey(); String value = entry.getValue(); if (value == null) { value = desc.getDefaultValue(); } final PreparedQuery pq = Query.prepare(value); preparedQueries.put(desc, pq); } expressionLanguageSupported = new HashMap<>(properties.size()); for (final PropertyDescriptor descriptor : properties.keySet()) { expressionLanguageSupported.put(descriptor.getName(), descriptor.isExpressionLanguageSupported()); } }
public MockValidationContext(final MockProcessContext processContext, final StateManager stateManager, final VariableRegistry variableRegistry) { this.context = processContext; this.stateManager = stateManager; this.variableRegistry = variableRegistry; final Map<PropertyDescriptor, String> properties = processContext.getProperties(); expressionLanguageSupported = new HashMap<>(properties.size()); for (final PropertyDescriptor descriptor : properties.keySet()) { expressionLanguageSupported.put(descriptor.getName(), descriptor.isExpressionLanguageSupported()); } }
private Map<String, String> mapProperties(final ComponentNode component, final ControllerServiceProvider serviceProvider) { final Map<String, String> mapped = new HashMap<>(); component.getProperties().keySet().stream() .filter(property -> !property.isSensitive()) .forEach(property -> { String value = component.getProperty(property); if (value == null) { value = property.getDefaultValue(); } if (value != null && property.getControllerServiceDefinition() != null) { // Property references a Controller Service. Instead of storing the existing value, we want // to store the Versioned Component ID of the service. final ControllerServiceNode controllerService = serviceProvider.getControllerServiceNode(value); if (controllerService != null) { value = getId(controllerService.getVersionedComponentId(), controllerService.getIdentifier()); } } mapped.put(property.getName(), value); }); return mapped; }
private void buildHeaders(ConfigurationContext context) { headers = new HashMap<>(); for (PropertyDescriptor descriptor : context.getProperties().keySet()) { if (descriptor.isDynamic()) { headers.put( descriptor.getDisplayName(), context.getProperty(descriptor).evaluateAttributeExpressions().getValue() ); } } }
@Override public void onPropertyModified(PropertyDescriptor descriptor, String oldValue, String newValue) { if (descriptor.isDynamic()) { if (!StringUtils.equals(oldValue, newValue)) { if (oldValue != null) { cachedJsonPathMap.remove(oldValue); } } } }
/** * This method is intended to be overridden by SubClasses those do not support TARGET_SYSTEM_TIMESTAMP_PRECISION property. * So that it use return different precisions than PRECISION_AUTO_DETECT. * If TARGET_SYSTEM_TIMESTAMP_PRECISION is supported as a valid Processor property, * then PRECISION_AUTO_DETECT will be the default value when not specified by a user. * @return */ protected String getDefaultTimePrecision() { return TARGET_SYSTEM_TIMESTAMP_PRECISION.getDefaultValue(); }
/** * Indicates whether or not the component contains at least one property that supports Expression Language. * * @param component the component to interrogate * @return whether or not the component contains at least one sensitive property. */ private boolean containsExpressionLanguage(final ConfigurableComponent component) { for (PropertyDescriptor descriptor : component.getPropertyDescriptors()) { if (descriptor.isExpressionLanguageSupported()) { return true; } } return false; }
@Override public PropertyValue getProperty(final PropertyDescriptor property) { final PropertyDescriptor descriptor = reportingTask.getPropertyDescriptor(property.getName()); if (descriptor == null) { return null; } final String configuredValue = properties.get(property); return new StandardPropertyValue(configuredValue == null ? descriptor.getDefaultValue() : configuredValue, this, preparedQueries.get(property), variableRegistry); }