Search in sources :

Example 1 with DeprecationNotice

use of org.apache.nifi.annotation.documentation.DeprecationNotice in project nifi by apache.

the class HtmlDocumentationWriter method writeDeprecationWarning.

/**
 * Writes a warning about the deprecation of a component.
 *
 * @param configurableComponent the component to describe
 * @param xmlStreamWriter the stream writer
 * @throws XMLStreamException thrown if there was a problem writing to the
 * XML stream
 */
private void writeDeprecationWarning(final ConfigurableComponent configurableComponent, final XMLStreamWriter xmlStreamWriter) throws XMLStreamException {
    final DeprecationNotice deprecationNotice = configurableComponent.getClass().getAnnotation(DeprecationNotice.class);
    if (deprecationNotice != null) {
        xmlStreamWriter.writeStartElement("h2");
        xmlStreamWriter.writeCharacters("Deprecation notice: ");
        xmlStreamWriter.writeEndElement();
        xmlStreamWriter.writeStartElement("p");
        xmlStreamWriter.writeCharacters("");
        if (!StringUtils.isEmpty(deprecationNotice.reason())) {
            xmlStreamWriter.writeCharacters(deprecationNotice.reason());
        } else {
            // Write a default note
            xmlStreamWriter.writeCharacters("Please be aware this processor is deprecated and may be removed in " + "the near future.");
        }
        xmlStreamWriter.writeEndElement();
        xmlStreamWriter.writeStartElement("p");
        xmlStreamWriter.writeCharacters("Please consider using one the following alternatives: ");
        Class<? extends ConfigurableComponent>[] componentNames = deprecationNotice.alternatives();
        String[] classNames = deprecationNotice.classNames();
        if (componentNames.length > 0 || classNames.length > 0) {
            // Write alternatives
            iterateAndLinkComponents(xmlStreamWriter, componentNames, classNames, ",", configurableComponent.getClass().getSimpleName());
        } else {
            xmlStreamWriter.writeCharacters("No alternative components suggested.");
        }
        xmlStreamWriter.writeEndElement();
    }
}
Also used : DeprecationNotice(org.apache.nifi.annotation.documentation.DeprecationNotice) ConfigurableComponent(org.apache.nifi.components.ConfigurableComponent)

Aggregations

DeprecationNotice (org.apache.nifi.annotation.documentation.DeprecationNotice)1 ConfigurableComponent (org.apache.nifi.components.ConfigurableComponent)1