Class HtmlDocumentationWriter

java.lang.Object
org.apache.nifi.documentation.html.HtmlDocumentationWriter
All Implemented Interfaces:
DocumentationWriter
Direct Known Subclasses:
HtmlProcessorDocumentationWriter

public class HtmlDocumentationWriter extends Object implements DocumentationWriter
Generates HTML documentation for a ConfigurableComponent. This class is used to generate documentation for ControllerService, ParameterProvider, and ReportingTask because they have no additional information.
  • Field Details

    • LOGGER

      public static final org.slf4j.Logger LOGGER
    • ADDITIONAL_DETAILS_HTML

      public static final String ADDITIONAL_DETAILS_HTML
      The filename where additional user specified information may be stored.
      See Also:
    • extensionManager

      private final ExtensionManager extensionManager
  • Constructor Details

    • HtmlDocumentationWriter

      public HtmlDocumentationWriter(ExtensionManager extensionManager)
  • Method Details

    • write

      public void write(ConfigurableComponent configurableComponent, OutputStream streamToWriteTo, boolean includesAdditionalDocumentation) throws IOException
      Specified by:
      write in interface DocumentationWriter
      Throws:
      IOException
    • writeHead

      protected void writeHead(ConfigurableComponent configurableComponent, XMLStreamWriter xmlStreamWriter) throws XMLStreamException
      Writes the head portion of the HTML documentation.
      Parameters:
      configurableComponent - the component to describe
      xmlStreamWriter - the stream to write to
      Throws:
      XMLStreamException - thrown if there was a problem writing to the stream
    • getTitle

      protected String getTitle(ConfigurableComponent configurableComponent)
      Gets the class name of the component.
      Parameters:
      configurableComponent - the component to describe
      Returns:
      the class name of the component
    • writeBody

      private void writeBody(ConfigurableComponent configurableComponent, XMLStreamWriter xmlStreamWriter, boolean hasAdditionalDetails) throws XMLStreamException
      Writes the body section of the documentation, this consists of the component description, the tags, and the PropertyDescriptors.
      Parameters:
      configurableComponent - the component to describe
      xmlStreamWriter - the stream writer
      hasAdditionalDetails - whether there are additional details present or not
      Throws:
      XMLStreamException - thrown if there was a problem writing to the XML stream
    • writeHeader

      private void writeHeader(ConfigurableComponent configurableComponent, XMLStreamWriter xmlStreamWriter) throws XMLStreamException
      Write the header to be displayed when loaded outside an iframe.
      Parameters:
      configurableComponent - the component to describe
      xmlStreamWriter - the stream writer to use
      Throws:
      XMLStreamException - thrown if there was a problem writing the XML
    • writeInputRequirementInfo

      private void writeInputRequirementInfo(ConfigurableComponent configurableComponent, XMLStreamWriter xmlStreamWriter) throws XMLStreamException
      Add in the documentation information regarding the component whether it accepts an incoming relationship or not.
      Parameters:
      configurableComponent - the component to describe
      xmlStreamWriter - the stream writer to use
      Throws:
      XMLStreamException - thrown if there was a problem writing the XML
    • writeStatefulInfo

      private void writeStatefulInfo(ConfigurableComponent configurableComponent, XMLStreamWriter xmlStreamWriter) throws XMLStreamException
      Write the description of the Stateful annotation if provided in this component.
      Parameters:
      configurableComponent - the component to describe
      xmlStreamWriter - the stream writer to use
      Throws:
      XMLStreamException - thrown if there was a problem writing the XML
    • writeRestrictedInfo

      private void writeRestrictedInfo(ConfigurableComponent configurableComponent, XMLStreamWriter xmlStreamWriter) throws XMLStreamException
      Write the description of the Restricted annotation if provided in this component.
      Parameters:
      configurableComponent - the component to describe
      xmlStreamWriter - the stream writer to use
      Throws:
      XMLStreamException - thrown if there was a problem writing the XML
    • writeDeprecationWarning

      private void writeDeprecationWarning(ConfigurableComponent configurableComponent, XMLStreamWriter xmlStreamWriter) throws XMLStreamException
      Writes a warning about the deprecation of a component.
      Parameters:
      configurableComponent - the component to describe
      xmlStreamWriter - the stream writer
      Throws:
      XMLStreamException - thrown if there was a problem writing to the XML stream
    • writeSeeAlso

      private void writeSeeAlso(ConfigurableComponent configurableComponent, XMLStreamWriter xmlStreamWriter) throws XMLStreamException
      Writes the list of components that may be linked from this component.
      Parameters:
      configurableComponent - the component to describe
      xmlStreamWriter - the stream writer to use
      Throws:
      XMLStreamException - thrown if there was a problem writing the XML
    • writeAdditionalBodyInfo

      protected void writeAdditionalBodyInfo(ConfigurableComponent configurableComponent, XMLStreamWriter xmlStreamWriter) throws XMLStreamException
      This method may be overridden by sub classes to write additional information to the body of the documentation.
      Parameters:
      configurableComponent - the component to describe
      xmlStreamWriter - the stream writer
      Throws:
      XMLStreamException - thrown if there was a problem writing to the XML stream
    • writeTags

      private void writeTags(ConfigurableComponent configurableComponent, XMLStreamWriter xmlStreamWriter) throws XMLStreamException
      Throws:
      XMLStreamException
    • join

      static String join(Object[] objects)
    • writeDescription

      protected void writeDescription(ConfigurableComponent configurableComponent, XMLStreamWriter xmlStreamWriter, boolean hasAdditionalDetails) throws XMLStreamException
      Writes a description of the configurable component.
      Parameters:
      configurableComponent - the component to describe
      xmlStreamWriter - the stream writer
      hasAdditionalDetails - whether there are additional details available as 'additionalDetails.html'
      Throws:
      XMLStreamException - thrown if there was a problem writing to the XML stream
    • getDescription

      protected String getDescription(ConfigurableComponent configurableComponent)
      Gets a description of the ConfigurableComponent using the CapabilityDescription annotation.
      Parameters:
      configurableComponent - the component to describe
      Returns:
      a description of the configurableComponent
    • writeUseCases

      protected void writeUseCases(ConfigurableComponent component, XMLStreamWriter xmlStreamWriter) throws XMLStreamException
      Throws:
      XMLStreamException
    • writeMultiComponentUseCases

      protected void writeMultiComponentUseCases(ConfigurableComponent component, XMLStreamWriter xmlStreamWriter) throws XMLStreamException
      Throws:
      XMLStreamException
    • writeUseCaseConfiguration

      private void writeUseCaseConfiguration(String configuration, XMLStreamWriter xmlStreamWriter) throws XMLStreamException
      Throws:
      XMLStreamException
    • writeProperties

      protected void writeProperties(ConfigurableComponent configurableComponent, XMLStreamWriter xmlStreamWriter) throws XMLStreamException
      Writes the PropertyDescriptors out as a table.
      Parameters:
      configurableComponent - the component to describe
      xmlStreamWriter - the stream writer
      Throws:
      XMLStreamException - thrown if there was a problem writing to the XML Stream
    • getDefaultValue

      private String getDefaultValue(PropertyDescriptor propertyDescriptor)
    • containsExpressionLanguage

      private boolean containsExpressionLanguage(ConfigurableComponent component)
      Indicates whether or not the component contains at least one property that supports Expression Language.
      Parameters:
      component - the component to interrogate
      Returns:
      whether or not the component contains at least one sensitive property.
    • writeDynamicProperties

      private void writeDynamicProperties(ConfigurableComponent configurableComponent, XMLStreamWriter xmlStreamWriter) throws XMLStreamException
      Throws:
      XMLStreamException
    • writeSupportsSensitiveDynamicProperties

      private void writeSupportsSensitiveDynamicProperties(ConfigurableComponent configurableComponent, XMLStreamWriter writer) throws XMLStreamException
      Throws:
      XMLStreamException
    • getDynamicProperties

      private List<DynamicProperty> getDynamicProperties(ConfigurableComponent configurableComponent)
    • writeValidValueDescription

      private void writeValidValueDescription(XMLStreamWriter xmlStreamWriter, String description) throws XMLStreamException
      Throws:
      XMLStreamException
    • writeValidValues

      protected void writeValidValues(XMLStreamWriter xmlStreamWriter, PropertyDescriptor property) throws XMLStreamException
      Interrogates a PropertyDescriptor to get a list of AllowableValues, if there are none, nothing is written to the stream.
      Parameters:
      xmlStreamWriter - the stream writer to use
      property - the property to describe
      Throws:
      XMLStreamException - thrown if there was a problem writing to the XML Stream
    • writeSimpleElement

      protected static void writeSimpleElement(XMLStreamWriter writer, String elementName, String characters, String id) throws XMLStreamException
      Writes a begin element, an id attribute(if specified), then text, then end element for element of the users choosing. Example: <p id="p-id">text</p>
      Parameters:
      writer - the stream writer to use
      elementName - the name of the element
      characters - the text of the element
      id - the id of the element. specifying null will cause no element to be written.
      Throws:
      XMLStreamException - xse
    • writeSimpleElement

      protected static void writeSimpleElement(XMLStreamWriter writer, String elementName, String characters) throws XMLStreamException
      Writes a begin element, then text, then end element for the element of a users choosing. Example: <p>text</p>
      Parameters:
      writer - the stream writer to use
      elementName - the name of the element
      characters - the characters to insert into the element
      Throws:
      XMLStreamException
    • writeLink

      protected void writeLink(XMLStreamWriter xmlStreamWriter, String text, String location) throws XMLStreamException
      A helper method to write a link
      Parameters:
      xmlStreamWriter - the stream to write to
      text - the text of the link
      location - the location of the link
      Throws:
      XMLStreamException - thrown if there was a problem writing to the stream
    • writeSystemResourceConsiderationInfo

      private void writeSystemResourceConsiderationInfo(ConfigurableComponent configurableComponent, XMLStreamWriter xmlStreamWriter) throws XMLStreamException
      Writes all the system resource considerations for this component
      Parameters:
      configurableComponent - the component to describe
      xmlStreamWriter - the xml stream writer to use
      Throws:
      XMLStreamException - thrown if there was a problem writing the XML
    • lookupControllerServiceImpls

      private Class<? extends ControllerService>[] lookupControllerServiceImpls(Class<? extends ControllerService> parent)
      Uses the ExtensionManager to discover any ControllerService implementations that implement a specific ControllerService API.
      Parameters:
      parent - the controller service API
      Returns:
      an array of controller services that implement the controller service API
    • iterateAndLinkComponents

      protected void iterateAndLinkComponents(XMLStreamWriter xmlStreamWriter, Class<? extends ConfigurableComponent>[] linkedComponents, String[] classNames, String separator, String sourceContextName) throws XMLStreamException
      Writes a link to another configurable component
      Parameters:
      xmlStreamWriter - the xml stream writer
      linkedComponents - the array of configurable component to link to
      classNames - the array of class names in string format to link to
      separator - a separator used to split the values (in case more than 1. If the separator is enclosed in between "invalid input: '<'" and ">" (.e.g "
      " it is treated as a tag and written to the xmlStreamWriter as an empty tag
      sourceContextName - the source context/name of the item being linked
      Throws:
      XMLStreamException - thrown if there is a problem writing the XML