@Override public void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue) { if (descriptor.isRequired()) { return; } final Map<String, String> attributeToGeneratedNameMap = new HashMap<>(attributeToGenerateNameMapRef.get()); if (newValue == null) { attributeToGeneratedNameMap.remove(descriptor.getName()); } else { attributeToGeneratedNameMap.put(descriptor.getName(), newValue); } attributeToGenerateNameMapRef.set(Collections.unmodifiableMap(attributeToGeneratedNameMap)); }
@Override public void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue) { if (descriptor.isRequired()) { return; } final Map<String, Pattern> patternMap = new HashMap<>(regexMapRef.get()); if (newValue == null) { patternMap.remove(descriptor.getName()); } else { if (newValue.equals(".*")) { patternMap.put(descriptor.getName(), null); } else { final Pattern pattern = Pattern.compile(newValue); patternMap.put(descriptor.getName(), pattern); } } regexMapRef.set(Collections.unmodifiableMap(patternMap)); }
xmlStreamWriter.writeStartElement("td"); xmlStreamWriter.writeAttribute("id", "name"); if (property.isRequired()) { writeSimpleElement(xmlStreamWriter, "strong", property.getDisplayName()); } else {
/** * @param context the current context * @param flowFile the current flow file * @param propertyDescriptor the property to evaluate * @return an InternetAddress[] parsed from the supplied property * @throws AddressException if the property cannot be parsed to a valid InternetAddress[] */ private InternetAddress[] toInetAddresses(final ProcessContext context, final FlowFile flowFile, PropertyDescriptor propertyDescriptor) throws AddressException { InternetAddress[] parse; String value = context.getProperty(propertyDescriptor).evaluateAttributeExpressions(flowFile).getValue(); if (value == null || value.isEmpty()){ if (propertyDescriptor.isRequired()) { final String exceptionMsg = "Required property '" + propertyDescriptor.getDisplayName() + "' evaluates to an empty string."; throw new AddressException(exceptionMsg); } else { parse = new InternetAddress[0]; } } else { try { parse = InternetAddress.parse(value); } catch (AddressException e) { final String exceptionMsg = "Unable to parse a valid address for property '" + propertyDescriptor.getDisplayName() + "' with value '"+ value +"'"; throw new AddressException(exceptionMsg); } } return parse; }
String value = null; final boolean allowRemoval = allowRemovalOfRequiredProperties || !descriptor.isRequired(); if (allowRemoval && (value = properties.remove(descriptor)) != null) {
value = descriptor.getDefaultValue(); if (value == null && descriptor.isRequired()) { String displayName = descriptor.getDisplayName(); ValidationResult.Builder builder = new ValidationResult.Builder().valid(false).input(null).subject(displayName != null ? displayName : descriptor.getName());
dto.setRequired(propertyDescriptor.isRequired()); dto.setSensitive(propertyDescriptor.isSensitive()); dto.setDynamic(propertyDescriptor.isDynamic());
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 void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue) { if (descriptor.isRequired()) { return; } final Map<String, String> attributeToGeneratedNameMap = new HashMap<>(attributeToGenerateNameMapRef.get()); if (newValue == null) { attributeToGeneratedNameMap.remove(descriptor.getName()); } else { attributeToGeneratedNameMap.put(descriptor.getName(), newValue); } attributeToGenerateNameMapRef.set(Collections.unmodifiableMap(attributeToGeneratedNameMap)); }
@Override public void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue) { if (descriptor.isRequired()) { return; } final Map<String, Pattern> patternMap = new HashMap<>(regexMapRef.get()); if (newValue == null) { patternMap.remove(descriptor.getName()); } else { if (newValue.equals(".*")) { patternMap.put(descriptor.getName(), null); } else { final Pattern pattern = Pattern.compile(newValue); patternMap.put(descriptor.getName(), pattern); } } regexMapRef.set(Collections.unmodifiableMap(patternMap)); }
/** * @param context the current context * @param flowFile the current flow file * @param propertyDescriptor the property to evaluate * @return an InternetAddress[] parsed from the supplied property * @throws AddressException if the property cannot be parsed to a valid InternetAddress[] */ private InternetAddress[] toInetAddresses(final ProcessContext context, final FlowFile flowFile, PropertyDescriptor propertyDescriptor) throws AddressException { InternetAddress[] parse; String value = context.getProperty(propertyDescriptor).evaluateAttributeExpressions(flowFile).getValue(); if (value == null || value.isEmpty()){ if (propertyDescriptor.isRequired()) { final String exceptionMsg = "Required property '" + propertyDescriptor.getDisplayName() + "' evaluates to an empty string."; throw new AddressException(exceptionMsg); } else { parse = new InternetAddress[0]; } } else { try { parse = InternetAddress.parse(value); } catch (AddressException e) { final String exceptionMsg = "Unable to parse a valid address for property '" + propertyDescriptor.getDisplayName() + "' with value '"+ value +"'"; throw new AddressException(exceptionMsg); } } return parse; }
String value = null; final boolean allowRemoval = allowRemovalOfRequiredProperties || !descriptor.isRequired(); if (allowRemoval && (value = properties.remove(descriptor)) != null) {