private Map<String, String> getFieldsNameMapping(ProcessContext context) { /** * list alternative regex */ Map<String, String> fieldsNameMappings = new HashMap<>(); // loop over dynamic properties to add alternative regex for (final Map.Entry<PropertyDescriptor, String> entry : context.getProperties().entrySet()) { if (!entry.getKey().isDynamic()) { continue; } final String fieldName = entry.getKey().getName(); final String mapping = entry.getValue(); fieldsNameMappings.put(fieldName, mapping); } return fieldsNameMappings; } }
logger.debug("property {} value changed from {} to {}", descriptor.getName(), oldValue, newValue); if (descriptor.equals(DEBUG)) if (descriptor.equals(SMTP_SERVER)) if (descriptor.equals(SMTP_PORT)) if (descriptor.equals(SMTP_SECURITY_USERNAME)) if (descriptor.equals(SMTP_SECURITY_PASSWORD)) if (descriptor.equals(SMTP_SECURITY_SSL)) if (descriptor.equals(MAIL_FROM_ADDRESS)) if (descriptor.equals(MAIL_FROM_NAME)) if (descriptor.equals(MAIL_BOUNCE_ADDRESS)) if (descriptor.equals(MAIL_REPLYTO_ADDRESS)) if (descriptor.equals(MAIL_SUBJECT)) if (descriptor.equals(MAIL_TO)) if (descriptor.equals(ALLOW_OVERWRITE)) if (descriptor.equals(HTML_TEMPLATE))
public StandardValidationContext(final Map<PropertyDescriptor, String> properties) { this.properties = new HashMap<>(properties); expressionLanguageSupported = new HashMap<>(properties.size()); for (final PropertyDescriptor descriptor : properties.keySet()) { expressionLanguageSupported.put(descriptor.getName(), descriptor.isExpressionLanguageSupported()); } }
generator.writeStringField("name", property.getName()); generator.writeBooleanField("isRequired", property.isRequired()); if (property.getDescription() != null && property.getDescription().trim().length() > 0) { generator.writeStringField("description", property.getDescription()); } else { generator.writeStringField("description", "No Description Provided."); generator.writeStringField("defaultValue", property.getDefaultValue()); generator.writeBooleanField("isDynamic", property.isDynamic()); generator.writeBooleanField("isSensitive", property.isSensitive()); generator.writeBooleanField("isExpressionLanguageSupported", property.isExpressionLanguageSupported()); generator.writeEndObject();
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; }
String value = context.getPropertyValue(descriptor).asString(); if (value == null) { value = descriptor.getDefaultValue(); if (value == null && descriptor.isRequired()) { results.add(new ValidationResult.Builder().valid(false).input(null).subject(descriptor.getName()).explanation(descriptor.getName() + " is required").build()); continue; } else if (value == null) { final ValidationResult result = descriptor.validate(value); if (!result.isValid()) { results.add(result); final ValidationResult result = descriptor.validate(value); if (!result.isValid()) { results.add(result);
xmlStreamWriter.writeStartElement("td"); xmlStreamWriter.writeAttribute("id", "name"); if (property.isRequired()) { writeSimpleElement(xmlStreamWriter, "strong", property.getDisplayName()); } else { xmlStreamWriter.writeCharacters(property.getDisplayName()); writeSimpleElement(xmlStreamWriter, "td", property.getDefaultValue(), false, "default-value"); xmlStreamWriter.writeStartElement("td"); xmlStreamWriter.writeAttribute("id", "allowable-values"); xmlStreamWriter.writeStartElement("td"); xmlStreamWriter.writeAttribute("id", "description"); if (property.getDescription() != null && property.getDescription().trim().length() > 0) { xmlStreamWriter.writeCharacters(property.getDescription()); } else { xmlStreamWriter.writeCharacters("No Description Provided."); if (property.isSensitive()) { xmlStreamWriter.writeEmptyElement("br"); writeSimpleElement(xmlStreamWriter, "strong", "Sensitive Property: true"); if (property.isExpressionLanguageSupported()) { xmlStreamWriter.writeEmptyElement("br"); writeSimpleElement(xmlStreamWriter, "strong", "Supports Expression Language: true");
@Override public void onPropertyModified(PropertyDescriptor descriptor, String oldValue, String newValue) { if (descriptor.isDynamic()) { if (!StringUtils.equals(oldValue, newValue)) { if (oldValue != null) { cachedJsonPathMap.remove(oldValue); } } } }
@Override public PropertyValue getPropertyValue(final PropertyDescriptor property) { final String configuredValue = properties.get(property); return new StandardPropertyValue(configuredValue == null ? property.getDefaultValue() : configuredValue); }
@Override protected Collection<ValidationResult> customValidate(ValidationContext validationContext) { final boolean isAvroSerializer = validationContext.getPropertyValue(RECORD_SERIALIZER).asString().toLowerCase().contains("avro"); final boolean isAvroSchemaSet = validationContext.getPropertyValue(RECORD_SCHEMA).isSet(); final List<ValidationResult> problems = new ArrayList<>(); if (isAvroSerializer && !isAvroSchemaSet) { problems.add(new ValidationResult.Builder() .subject(RECORD_SERIALIZER.getDisplayName()) .valid(false) .explanation("an avro schema must be provided with an avro serializer") .build()); } return problems; }
/** * Indicates whether or not the component contains at least one property that supports Expression Language. * * @param component the component to interogate * @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; }
if (property.isRequired()) { rstWriter.printStrong(property.getDisplayName()); } else { rstWriter.print(property.getDisplayName()); if (property.getDescription() != null && property.getDescription().trim().length() > 0) { rstWriter.print(property.getDescription()); } else { rstWriter.print("No Description Provided."); rstWriter.print(property.getDefaultValue()); rstWriter.print("\", "); if (property.isSensitive()) { rstWriter.printStrong( "true"); }else { if (property.isExpressionLanguageSupported()) { rstWriter.printStrong( "true"); }else {
@Override protected Collection<ValidationResult> customValidate(final ValidationContext context) { final List<ValidationResult> results = new ArrayList<>(super.customValidate(context)); int jsonPathCount = 0; for (final PropertyDescriptor desc : context.getProperties().keySet()) { if (desc.isDynamic()) { jsonPathCount++; } } if (jsonPathCount != 1) { results.add(new ValidationResult.Builder().subject("JsonPaths").valid(false) .explanation("Exactly one JsonPath must be set if using d").build()); } return results; }
@Override public PropertyValue getPropertyValue(final String propertyName) { final PropertyDescriptor descriptor = component.getPropertyDescriptor(propertyName); if (descriptor == null) { return null; } final String setPropertyValue = getProperty(descriptor); final String propValue = (setPropertyValue == null) ? descriptor.getDefaultValue() : setPropertyValue; return new StandardPropertyValue(propValue); }
.subject(RedisUtils.CONNECTION_STRING.getDisplayName()) .valid(false) .explanation("Connection String cannot be blank") if (hostAndPort == null || hostAndPort.length != 2 || StringUtils.isBlank(hostAndPort[0]) || StringUtils.isBlank(hostAndPort[1]) || !isInteger(hostAndPort[1])) { results.add(new ValidationResult.Builder() .subject(RedisUtils.CONNECTION_STRING.getDisplayName()) .input(connectionString) .valid(false) if (hostAndPort == null || hostAndPort.length != 2 || StringUtils.isBlank(hostAndPort[0]) || StringUtils.isBlank(hostAndPort[1]) || !isInteger(hostAndPort[1])) { results.add(new ValidationResult.Builder() .subject(RedisUtils.CONNECTION_STRING.getDisplayName()) .input(connection) .valid(false) .subject(RedisUtils.DATABASE.getDisplayName()) .valid(false) .explanation("Database Index must be 0 when using clustered Redis") if (StringUtils.isEmpty(sentinelMaster)) { results.add(new ValidationResult.Builder() .subject(RedisUtils.SENTINEL_MASTER.getDisplayName()) .valid(false) .explanation("Sentinel Master must be provided when Mode is Sentinel")
/** * Indicates whether or not the component contains at least one property that supports Expression Language. * * @param component the component to interogate * @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 void onPropertyModified(PropertyDescriptor descriptor, String oldValue, String newValue) { logger.info("property {} value changed from {} to {}", descriptor.getName(), oldValue, newValue); }
private Map<String, String[]> getFieldsNameMapping(ProcessContext context) { /** * list alternative regex */ Map<String, String[]> fieldsNameMappings = new HashMap<>(); // loop over dynamic properties to add alternative regex for (final Map.Entry<PropertyDescriptor, String> entry : context.getProperties().entrySet()) { if (!entry.getKey().isDynamic()) { continue; } final String fieldName = entry.getKey().getName(); final String[] mapping = entry.getValue().split(","); fieldsNameMappings.put(fieldName, mapping); } return fieldsNameMappings; }
@Override public PropertyValue getPropertyValue(final String propertyName) { final PropertyDescriptor descriptor = component.getPropertyDescriptor(propertyName); if (descriptor == null) { return null; } final String setPropertyValue = getProperty(descriptor); final String propValue = (setPropertyValue == null) ? descriptor.getDefaultValue() : setPropertyValue; return PropertyValueFactory.getInstance(descriptor, propValue, controllerServiceLookup); }