NIFI-680 Processor docs don't always need to mention Sensitive properties or EL

This commit is contained in:
danbress 2015-06-20 18:07:39 -04:00
parent 33848b3036
commit 47847ab404
1 changed files with 60 additions and 17 deletions

View File

@ -268,25 +268,38 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
*/
protected void writeProperties(final ConfigurableComponent configurableComponent,
final XMLStreamWriter xmlStreamWriter) throws XMLStreamException {
writeSimpleElement(xmlStreamWriter, "h3", "Properties: ");
xmlStreamWriter.writeStartElement("p");
xmlStreamWriter.writeCharacters("In the list below, the names of required properties appear in ");
writeSimpleElement(xmlStreamWriter, "strong", "bold");
xmlStreamWriter.writeCharacters(". Any "
+ "other properties (not in bold) are considered optional. The table also "
+ "indicates any default values, whether a property supports the ");
writeLink(xmlStreamWriter, "NiFi Expression Language", "../../html/expression-language-guide.html");
xmlStreamWriter.writeCharacters(", and whether a property is considered "
+ "\"sensitive\", meaning that its value will be encrypted. Before entering a "
+ "value in a sensitive property, ensure that the ");
writeSimpleElement(xmlStreamWriter, "strong", "nifi.properties");
xmlStreamWriter.writeCharacters(" file has " + "an entry for the property ");
writeSimpleElement(xmlStreamWriter, "strong", "nifi.sensitive.props.key");
xmlStreamWriter.writeCharacters(".");
xmlStreamWriter.writeEndElement();
List<PropertyDescriptor> properties = configurableComponent.getPropertyDescriptors();
final List<PropertyDescriptor> properties = configurableComponent.getPropertyDescriptors();
writeSimpleElement(xmlStreamWriter, "h3", "Properties: ");
if (properties.size() > 0) {
final boolean containsExpressionLanguage = containsExpressionLanguage(configurableComponent);
final boolean containsSensitiveProperties = containsSensitiveProperties(configurableComponent);
xmlStreamWriter.writeStartElement("p");
xmlStreamWriter.writeCharacters("In the list below, the names of required properties appear in ");
writeSimpleElement(xmlStreamWriter, "strong", "bold");
xmlStreamWriter.writeCharacters(". Any other properties (not in bold) are considered optional. " +
"The table also indicates any default values");
if (containsExpressionLanguage) {
if (!containsSensitiveProperties) {
xmlStreamWriter.writeCharacters(", and ");
} else {
xmlStreamWriter.writeCharacters(", ");
}
xmlStreamWriter.writeCharacters("whether a property supports the ");
writeLink(xmlStreamWriter, "NiFi Expression Language", "../../html/expression-language-guide.html");
}
if (containsSensitiveProperties) {
xmlStreamWriter.writeCharacters(", and whether a property is considered " + "\"sensitive\", meaning that its value will be encrypted. Before entering a "
+ "value in a sensitive property, ensure that the ");
writeSimpleElement(xmlStreamWriter, "strong", "nifi.properties");
xmlStreamWriter.writeCharacters(" file has " + "an entry for the property ");
writeSimpleElement(xmlStreamWriter, "strong", "nifi.sensitive.props.key");
}
xmlStreamWriter.writeCharacters(".");
xmlStreamWriter.writeEndElement();
xmlStreamWriter.writeStartElement("table");
xmlStreamWriter.writeAttribute("id", "properties");
@ -345,6 +358,36 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
}
}
/**
* Indicates whether or not the component contains at least one sensitive property.
*
* @param component the component to interogate
* @return whether or not the component contains at least one sensitive property.
*/
private boolean containsSensitiveProperties(final ConfigurableComponent component) {
for (PropertyDescriptor descriptor : component.getPropertyDescriptors()) {
if (descriptor.isSensitive()) {
return true;
}
}
return false;
}
/**
* 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;
}
private void writeDynamicProperties(final ConfigurableComponent configurableComponent,
final XMLStreamWriter xmlStreamWriter) throws XMLStreamException {