mirror of https://github.com/apache/nifi.git
NIFI-10624 Removed sensitive properties key warning
- Corrected logging statements with placeholders instead of concatenation - Removed unused NiFiServerStub Signed-off-by: Matthew Burgess <mattyb149@apache.org> This closes #6513
This commit is contained in:
parent
14a2249c0e
commit
11314e8132
|
@ -27,7 +27,6 @@ import org.apache.nifi.nar.ExtensionManager;
|
|||
import org.apache.nifi.nar.ExtensionMapping;
|
||||
import org.apache.nifi.parameter.ParameterProvider;
|
||||
import org.apache.nifi.processor.Processor;
|
||||
import org.apache.nifi.reporting.InitializationException;
|
||||
import org.apache.nifi.reporting.ReportingTask;
|
||||
import org.apache.nifi.util.NiFiProperties;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -35,16 +34,14 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Uses the ExtensionManager to get a list of Processor, ControllerService, ParameterProvider, and
|
||||
* Reporting Task classes that were loaded and generate documentation for them.
|
||||
*
|
||||
* Enumerate available Components from Extension Manager and generate HTML documentation
|
||||
*
|
||||
*/
|
||||
public class DocGenerator {
|
||||
|
@ -61,7 +58,7 @@ public class DocGenerator {
|
|||
public static void generate(final NiFiProperties properties, final ExtensionManager extensionManager, final ExtensionMapping extensionMapping) {
|
||||
final File explodedNiFiDocsDir = properties.getComponentDocumentationWorkingDirectory();
|
||||
|
||||
logger.debug("Generating documentation for: " + extensionMapping.size() + " components in: " + explodedNiFiDocsDir);
|
||||
logger.debug("Generating Documentation: Components [{}] Directory [{}]", extensionMapping.size(), explodedNiFiDocsDir);
|
||||
|
||||
documentConfigurableComponent(extensionManager.getExtensions(Processor.class), explodedNiFiDocsDir, extensionManager);
|
||||
documentConfigurableComponent(extensionManager.getExtensions(ControllerService.class), explodedNiFiDocsDir, extensionManager);
|
||||
|
@ -79,7 +76,7 @@ public class DocGenerator {
|
|||
for (final ExtensionDefinition extensionDefinition : extensionDefinitions) {
|
||||
final Bundle bundle = extensionDefinition.getBundle();
|
||||
if (bundle == null) {
|
||||
logger.warn("Cannot document extension {} because it has no bundle associated with it", extensionDefinition);
|
||||
logger.warn("Documentation generation failed: Extension bundle not found [{}]", extensionDefinition);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -91,21 +88,23 @@ public class DocGenerator {
|
|||
final File indexHtml = new File(componentDirectory, "index.html");
|
||||
if (indexHtml.exists()) {
|
||||
// index.html already exists, no need to unpack the docs again.
|
||||
logger.debug("Found existing documentation file {}. Will not generate documentation for {}", indexHtml.getAbsolutePath(), extensionClassName);
|
||||
logger.debug("Existing documentation found [{}] skipped component class [{}]", indexHtml.getAbsolutePath(), extensionClassName);
|
||||
continue;
|
||||
}
|
||||
|
||||
final Class<?> extensionType = extensionDefinition.getExtensionType();
|
||||
if (ConfigurableComponent.class.isAssignableFrom(extensionType)) {
|
||||
componentDirectory.mkdirs();
|
||||
if (componentDirectory.mkdirs()) {
|
||||
logger.debug("Documentation directory created [{}]", componentDirectory);
|
||||
}
|
||||
|
||||
final Class<?> extensionClass = extensionManager.getClass(extensionDefinition);
|
||||
final Class<? extends ConfigurableComponent> componentClass = extensionClass.asSubclass(ConfigurableComponent.class);
|
||||
try {
|
||||
logger.debug("Documenting: " + componentClass);
|
||||
logger.debug("Documentation generation started: Component Class [{}]", componentClass);
|
||||
document(extensionManager, componentDirectory, componentClass, coordinate);
|
||||
} catch (Exception e) {
|
||||
logger.warn("Unable to document: " + componentClass, e);
|
||||
logger.warn("Documentation generation failed: Component Class [{}]", componentClass, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -118,16 +117,13 @@ public class DocGenerator {
|
|||
*
|
||||
* @param componentDocsDir the component documentation directory
|
||||
* @param componentClass the class to document
|
||||
* @throws InstantiationException ie
|
||||
* @throws IllegalAccessException iae
|
||||
* @throws IOException ioe
|
||||
* @throws InitializationException ie
|
||||
*/
|
||||
private static void document(final ExtensionManager extensionManager,
|
||||
final File componentDocsDir,
|
||||
final Class<? extends ConfigurableComponent> componentClass,
|
||||
final BundleCoordinate bundleCoordinate)
|
||||
throws InstantiationException, IllegalAccessException, IOException, InitializationException {
|
||||
throws IOException {
|
||||
|
||||
// use temp components from ExtensionManager which should always be populated before doc generation
|
||||
final String classType = componentClass.getCanonicalName();
|
||||
|
@ -137,52 +133,27 @@ public class DocGenerator {
|
|||
|
||||
final File baseDocumentationFile = new File(componentDocsDir, "index.html");
|
||||
if (baseDocumentationFile.exists()) {
|
||||
logger.warn(baseDocumentationFile + " already exists, overwriting!");
|
||||
logger.warn("Overwriting Component Documentation [{}]", baseDocumentationFile);
|
||||
}
|
||||
|
||||
try (final OutputStream output = new BufferedOutputStream(new FileOutputStream(baseDocumentationFile))) {
|
||||
try (final OutputStream output = new BufferedOutputStream(Files.newOutputStream(baseDocumentationFile.toPath()))) {
|
||||
writer.write(component, output, hasAdditionalInfo(componentDocsDir));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the DocumentationWriter for the type of component. Currently
|
||||
* Processor, ControllerService, ParameterProvider, and ReportingTask are supported.
|
||||
*
|
||||
* @param componentClass the class that requires a DocumentationWriter
|
||||
* @return a DocumentationWriter capable of generating documentation for
|
||||
* that specific type of class
|
||||
*/
|
||||
private static DocumentationWriter getDocumentWriter(final ExtensionManager extensionManager,
|
||||
final Class<? extends ConfigurableComponent> componentClass) {
|
||||
private static DocumentationWriter getDocumentWriter(
|
||||
final ExtensionManager extensionManager,
|
||||
final Class<? extends ConfigurableComponent> componentClass
|
||||
) {
|
||||
if (Processor.class.isAssignableFrom(componentClass)) {
|
||||
return new HtmlProcessorDocumentationWriter(extensionManager);
|
||||
} else if (ControllerService.class.isAssignableFrom(componentClass)) {
|
||||
return new HtmlDocumentationWriter(extensionManager);
|
||||
} else if (ReportingTask.class.isAssignableFrom(componentClass)) {
|
||||
return new HtmlDocumentationWriter(extensionManager);
|
||||
} else if (ParameterProvider.class.isAssignableFrom(componentClass)) {
|
||||
} else {
|
||||
return new HtmlDocumentationWriter(extensionManager);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if a directory to write to has an additionalDetails.html in
|
||||
* it already.
|
||||
*
|
||||
* @param directory to check
|
||||
* @return true if additionalDetails.html exists, false otherwise.
|
||||
*/
|
||||
private static boolean hasAdditionalInfo(File directory) {
|
||||
return directory.list(new FilenameFilter() {
|
||||
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
return name.equalsIgnoreCase(HtmlDocumentationWriter.ADDITIONAL_DETAILS_HTML);
|
||||
}
|
||||
|
||||
}).length > 0;
|
||||
final Path additionalDetailsPath = directory.toPath().resolve(HtmlDocumentationWriter.ADDITIONAL_DETAILS_HTML);
|
||||
return Files.exists(additionalDetailsPath);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,15 +54,17 @@ import javax.xml.stream.XMLStreamWriter;
|
|||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Generates HTML documentation for a ConfigurableComponent. This class is used
|
||||
* to generate documentation for ControllerService, ParameterProvider, and ReportingTask because
|
||||
* they have no additional information.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class HtmlDocumentationWriter implements DocumentationWriter {
|
||||
|
||||
|
@ -239,7 +241,7 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
|
|||
xmlStreamWriter.writeEndElement();
|
||||
|
||||
xmlStreamWriter.writeStartElement("tr");
|
||||
writeSimpleElement(xmlStreamWriter, "td", join(stateful.scopes(), ", "));
|
||||
writeSimpleElement(xmlStreamWriter, "td", join(stateful.scopes()));
|
||||
writeSimpleElement(xmlStreamWriter, "td", stateful.description());
|
||||
xmlStreamWriter.writeEndElement();
|
||||
|
||||
|
@ -387,7 +389,7 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
|
|||
xmlStreamWriter.writeEndElement();
|
||||
xmlStreamWriter.writeStartElement("p");
|
||||
if (tags != null) {
|
||||
final String tagString = join(tags.value(), ", ");
|
||||
final String tagString = join(tags.value());
|
||||
xmlStreamWriter.writeCharacters(tagString);
|
||||
} else {
|
||||
xmlStreamWriter.writeCharacters("No tags provided.");
|
||||
|
@ -395,15 +397,10 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
|
|||
xmlStreamWriter.writeEndElement();
|
||||
}
|
||||
|
||||
static String join(final Object[] objects, final String delimiter) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < objects.length; i++) {
|
||||
sb.append(objects[i].toString());
|
||||
if (i < objects.length - 1) {
|
||||
sb.append(delimiter);
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
static String join(final Object[] objects) {
|
||||
return Arrays.stream(objects)
|
||||
.map(Object::toString)
|
||||
.collect(Collectors.joining(", "));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -467,29 +464,15 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
|
|||
|
||||
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 ");
|
||||
xmlStreamWriter.writeCharacters(", and 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();
|
||||
|
||||
|
@ -516,7 +499,7 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
|
|||
}
|
||||
|
||||
xmlStreamWriter.writeEndElement();
|
||||
writeSimpleElement(xmlStreamWriter, "td", getDefaultValue(property), false, "default-value");
|
||||
writeSimpleElement(xmlStreamWriter, "td", getDefaultValue(property), "default-value");
|
||||
xmlStreamWriter.writeStartElement("td");
|
||||
xmlStreamWriter.writeAttribute("id", "allowable-values");
|
||||
writeValidValues(xmlStreamWriter, property);
|
||||
|
@ -698,21 +681,6 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
|
|||
return defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
|
@ -727,13 +695,13 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void writeDynamicProperties(final ConfigurableComponent configurableComponent,
|
||||
final XMLStreamWriter xmlStreamWriter) throws XMLStreamException {
|
||||
|
||||
final List<DynamicProperty> dynamicProperties = getDynamicProperties(configurableComponent);
|
||||
|
||||
if (dynamicProperties != null && dynamicProperties.size() > 0) {
|
||||
if (dynamicProperties.size() > 0) {
|
||||
writeSimpleElement(xmlStreamWriter, "h3", "Dynamic Properties: ");
|
||||
|
||||
writeSupportsSensitiveDynamicProperties(configurableComponent, xmlStreamWriter);
|
||||
|
@ -750,16 +718,16 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
|
|||
xmlStreamWriter.writeEndElement();
|
||||
for (final DynamicProperty dynamicProperty : dynamicProperties) {
|
||||
xmlStreamWriter.writeStartElement("tr");
|
||||
writeSimpleElement(xmlStreamWriter, "td", dynamicProperty.name(), false, "name");
|
||||
writeSimpleElement(xmlStreamWriter, "td", dynamicProperty.value(), false, "value");
|
||||
writeSimpleElement(xmlStreamWriter, "td", dynamicProperty.name(), "name");
|
||||
writeSimpleElement(xmlStreamWriter, "td", dynamicProperty.value(), "value");
|
||||
xmlStreamWriter.writeStartElement("td");
|
||||
xmlStreamWriter.writeCharacters(dynamicProperty.description());
|
||||
|
||||
xmlStreamWriter.writeEmptyElement("br");
|
||||
String text;
|
||||
|
||||
if(dynamicProperty.expressionLanguageScope().equals(ExpressionLanguageScope.NONE)) {
|
||||
if(dynamicProperty.supportsExpressionLanguage()) {
|
||||
if (dynamicProperty.expressionLanguageScope().equals(ExpressionLanguageScope.NONE)) {
|
||||
if (dynamicProperty.supportsExpressionLanguage()) {
|
||||
text = "Supports Expression Language: true (undefined scope)";
|
||||
} else {
|
||||
text = "Supports Expression Language: false";
|
||||
|
@ -772,7 +740,6 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
|
|||
case VARIABLE_REGISTRY:
|
||||
text = "Supports Expression Language: true (will be evaluated using variable registry only)";
|
||||
break;
|
||||
case NONE:
|
||||
default:
|
||||
text = "Supports Expression Language: false";
|
||||
break;
|
||||
|
@ -805,9 +772,7 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
|
|||
final List<DynamicProperty> dynamicProperties = new ArrayList<>();
|
||||
final DynamicProperties dynProps = configurableComponent.getClass().getAnnotation(DynamicProperties.class);
|
||||
if (dynProps != null) {
|
||||
for (final DynamicProperty dynProp : dynProps.value()) {
|
||||
dynamicProperties.add(dynProp);
|
||||
}
|
||||
Collections.addAll(dynamicProperties, dynProps.value());
|
||||
}
|
||||
|
||||
final DynamicProperty dynProp = configurableComponent.getClass().getAnnotation(DynamicProperty.class);
|
||||
|
@ -860,38 +825,19 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
|
|||
xmlStreamWriter.writeEmptyElement("br");
|
||||
xmlStreamWriter.writeCharacters(controllerServiceClass.getSimpleName());
|
||||
|
||||
final List<Class<? extends ControllerService>> implementationList = lookupControllerServiceImpls(controllerServiceClass);
|
||||
|
||||
// Convert it into an array before proceeding
|
||||
Class<? extends ControllerService>[] implementations = implementationList.stream().toArray(Class[]::new);
|
||||
final Class<? extends ControllerService>[] serviceImplementations = lookupControllerServiceImpls(controllerServiceClass);
|
||||
|
||||
xmlStreamWriter.writeEmptyElement("br");
|
||||
if (implementations.length > 0) {
|
||||
final String title = implementations.length > 1 ? "Implementations: " : "Implementation: ";
|
||||
if (serviceImplementations.length > 0) {
|
||||
final String title = serviceImplementations.length > 1 ? "Implementations: " : "Implementation: ";
|
||||
writeSimpleElement(xmlStreamWriter, "strong", title);
|
||||
iterateAndLinkComponents(xmlStreamWriter, implementations, null, "<br>", controllerServiceClass.getSimpleName());
|
||||
iterateAndLinkComponents(xmlStreamWriter, serviceImplementations, null, "<br>", controllerServiceClass.getSimpleName());
|
||||
} else {
|
||||
xmlStreamWriter.writeCharacters("No implementations found.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a begin element, then text, then end element for the element of a
|
||||
* users choosing. Example: <p>text</p>
|
||||
*
|
||||
* @param writer the stream writer to use
|
||||
* @param elementName the name of the element
|
||||
* @param characters the characters to insert into the element
|
||||
* @param strong whether the characters should be strong or not.
|
||||
* @throws XMLStreamException thrown if there was a problem writing to the
|
||||
* stream.
|
||||
*/
|
||||
protected final static void writeSimpleElement(final XMLStreamWriter writer, final String elementName,
|
||||
final String characters, boolean strong) throws XMLStreamException {
|
||||
writeSimpleElement(writer, elementName, characters, strong, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a begin element, an id attribute(if specified), then text, then
|
||||
* end element for element of the users choosing. Example: <p
|
||||
|
@ -900,26 +846,19 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
|
|||
* @param writer the stream writer to use
|
||||
* @param elementName the name of the element
|
||||
* @param characters the text of the element
|
||||
* @param strong whether to bold the text of the element or not
|
||||
* @param id the id of the element. specifying null will cause no element to
|
||||
* be written.
|
||||
* @throws XMLStreamException xse
|
||||
*/
|
||||
protected final static void writeSimpleElement(final XMLStreamWriter writer, final String elementName,
|
||||
final String characters, boolean strong, String id) throws XMLStreamException {
|
||||
protected static void writeSimpleElement(final XMLStreamWriter writer, final String elementName,
|
||||
final String characters, String id) throws XMLStreamException {
|
||||
writer.writeStartElement(elementName);
|
||||
|
||||
if (characters != null) {
|
||||
if (id != null) {
|
||||
writer.writeAttribute("id", id);
|
||||
}
|
||||
if (strong) {
|
||||
writer.writeStartElement("strong");
|
||||
}
|
||||
writer.writeCharacters(characters);
|
||||
if (strong) {
|
||||
writer.writeEndElement();
|
||||
}
|
||||
}
|
||||
|
||||
writer.writeEndElement();
|
||||
|
@ -932,12 +871,10 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
|
|||
* @param writer the stream writer to use
|
||||
* @param elementName the name of the element
|
||||
* @param characters the characters to insert into the element
|
||||
* @throws XMLStreamException thrown if there was a problem writing to the
|
||||
* stream
|
||||
*/
|
||||
protected final static void writeSimpleElement(final XMLStreamWriter writer, final String elementName,
|
||||
protected static void writeSimpleElement(final XMLStreamWriter writer, final String elementName,
|
||||
final String characters) throws XMLStreamException {
|
||||
writeSimpleElement(writer, elementName, characters, false);
|
||||
writeSimpleElement(writer, elementName, characters, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -996,9 +933,10 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
|
|||
* ControllerService API.
|
||||
*
|
||||
* @param parent the controller service API
|
||||
* @return a list of controller services that implement the controller service API
|
||||
* @return an array of controller services that implement the controller service API
|
||||
*/
|
||||
private List<Class<? extends ControllerService>> lookupControllerServiceImpls(
|
||||
@SuppressWarnings("unchecked")
|
||||
private Class<? extends ControllerService>[] lookupControllerServiceImpls(
|
||||
final Class<? extends ControllerService> parent) {
|
||||
|
||||
final List<Class<? extends ControllerService>> implementations = new ArrayList<>();
|
||||
|
@ -1009,13 +947,13 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
|
|||
// then iterate over all controller services looking for any that is a child of the parent
|
||||
// ControllerService API that was passed in as a parameter
|
||||
for (final ExtensionDefinition extensionDefinition : controllerServices) {
|
||||
final Class controllerServiceClass = extensionManager.getClass(extensionDefinition);
|
||||
final Class<? extends ControllerService> controllerServiceClass = (Class<? extends ControllerService>) extensionManager.getClass(extensionDefinition);
|
||||
if (parent.isAssignableFrom(controllerServiceClass)) {
|
||||
implementations.add(controllerServiceClass);
|
||||
}
|
||||
}
|
||||
|
||||
return implementations;
|
||||
return implementations.toArray(new Class[]{});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1035,15 +973,9 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
|
|||
throws XMLStreamException {
|
||||
String effectiveSeparator = separator;
|
||||
// Treat the the possible separators
|
||||
boolean separatorIsElement;
|
||||
|
||||
if (effectiveSeparator.startsWith("<") && effectiveSeparator.endsWith(">")) {
|
||||
separatorIsElement = true;
|
||||
} else {
|
||||
separatorIsElement = false;
|
||||
}
|
||||
final boolean separatorIsElement = effectiveSeparator.startsWith("<") && effectiveSeparator.endsWith(">");
|
||||
// Whatever the result, strip the possible < and > characters
|
||||
effectiveSeparator = effectiveSeparator.replaceAll("\\<([^>]*)>","$1");
|
||||
effectiveSeparator = effectiveSeparator.replaceAll("<([^>]*)>","$1");
|
||||
|
||||
int index = 0;
|
||||
for (final Class<? extends ConfigurableComponent> linkedComponent : linkedComponents ) {
|
||||
|
@ -1070,7 +1002,7 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
|
|||
|
||||
++index;
|
||||
} else {
|
||||
LOGGER.warn("Could not link to {} because no bundles were found for {}", new Object[] {linkedComponentName, sourceContextName});
|
||||
LOGGER.warn("Could not link to {} because no bundles were found for {}", linkedComponentName, sourceContextName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1102,7 +1034,7 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
|
|||
|
||||
++index;
|
||||
} else {
|
||||
LOGGER.warn("Could not link to {} because no bundles were found for {}", new Object[] {className, sourceContextName});
|
||||
LOGGER.warn("Could not link to {} because no bundles were found for {}", className, sourceContextName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,6 @@ import org.apache.nifi.processor.Relationship;
|
|||
* Writes documentation specific for a Processor. This includes everything for a
|
||||
* ConfigurableComponent as well as Relationship information.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class HtmlProcessorDocumentationWriter extends HtmlDocumentationWriter {
|
||||
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.nifi.documentation.example;
|
||||
|
||||
import org.apache.nifi.NiFiServer;
|
||||
import org.apache.nifi.bundle.Bundle;
|
||||
import org.apache.nifi.controller.DecommissionTask;
|
||||
import org.apache.nifi.controller.status.history.StatusHistoryDumpFactory;
|
||||
import org.apache.nifi.diagnostics.DiagnosticsFactory;
|
||||
import org.apache.nifi.nar.ExtensionMapping;
|
||||
import org.apache.nifi.util.NiFiProperties;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* This stub is the source code for the no-op NiFiServer implementation used in the nifiserver-test-nar.nar, as NiFi requires exactly one
|
||||
* implementation of NiFiServer in order to start successfully. The NAR was built externally, but the code is provided here in case
|
||||
* updates are needed.
|
||||
*/
|
||||
public class NiFiServerStub implements NiFiServer {
|
||||
@Override
|
||||
public void start() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(NiFiProperties properties, Bundle systemBundle, Set<Bundle> bundles, ExtensionMapping extensionMapping) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public DiagnosticsFactory getDiagnosticsFactory() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DiagnosticsFactory getThreadDumpFactory() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DecommissionTask getDecommissionTask() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StatusHistoryDumpFactory getStatusHistoryDumpFactory() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -20,6 +20,6 @@ import org.apache.nifi.controller.ControllerService;
|
|||
|
||||
public interface SampleService extends ControllerService {
|
||||
|
||||
public void doSomething();
|
||||
void doSomething();
|
||||
|
||||
}
|
||||
|
|
|
@ -54,9 +54,9 @@ public class HtmlDocumentationWriterTest {
|
|||
|
||||
@Test
|
||||
public void testJoin() {
|
||||
assertEquals("a, b, c", HtmlDocumentationWriter.join(new String[] { "a", "b", "c" }, ", "));
|
||||
assertEquals("a, b", HtmlDocumentationWriter.join(new String[] { "a", "b" }, ", "));
|
||||
assertEquals("a", HtmlDocumentationWriter.join(new String[] { "a" }, ", "));
|
||||
assertEquals("a, b, c", HtmlDocumentationWriter.join(new String[] { "a", "b", "c" }));
|
||||
assertEquals("a, b", HtmlDocumentationWriter.join(new String[] { "a", "b" }));
|
||||
assertEquals("a", HtmlDocumentationWriter.join(new String[] { "a" }));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -73,7 +73,7 @@ public class HtmlDocumentationWriterTest {
|
|||
writer.write(controllerService, baos, false);
|
||||
initializer.teardown(controllerService);
|
||||
|
||||
String results = new String(baos.toByteArray());
|
||||
String results = baos.toString();
|
||||
XmlValidator.assertXmlValid(results);
|
||||
|
||||
// description
|
||||
|
@ -126,7 +126,7 @@ public class HtmlDocumentationWriterTest {
|
|||
writer.write(parameterProvider, baos, false);
|
||||
initializer.teardown(parameterProvider);
|
||||
|
||||
String results = new String(baos.toByteArray());
|
||||
String results = baos.toString();
|
||||
XmlValidator.assertXmlValid(results);
|
||||
|
||||
// description
|
||||
|
@ -172,7 +172,7 @@ public class HtmlDocumentationWriterTest {
|
|||
writer.write(reportingTask, baos, false);
|
||||
initializer.teardown(reportingTask);
|
||||
|
||||
String results = new String(baos.toByteArray());
|
||||
String results = baos.toString();
|
||||
XmlValidator.assertXmlValid(results);
|
||||
|
||||
// description
|
||||
|
@ -218,7 +218,7 @@ public class HtmlDocumentationWriterTest {
|
|||
|
||||
writer.write(controllerService, baos, false);
|
||||
|
||||
String results = new String(baos.toByteArray());
|
||||
String results = baos.toString();
|
||||
XmlValidator.assertXmlValid(results);
|
||||
}
|
||||
|
||||
|
@ -234,7 +234,7 @@ public class HtmlDocumentationWriterTest {
|
|||
|
||||
writer.write(controllerService, baos, false);
|
||||
|
||||
String results = new String(baos.toByteArray());
|
||||
String results = baos.toString();
|
||||
XmlValidator.assertXmlValid(results);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public class ProcessorDocumentationWriterTest {
|
|||
writer.write(processor, baos, false);
|
||||
initializer.teardown(processor);
|
||||
|
||||
String results = new String(baos.toByteArray());
|
||||
String results = baos.toString();
|
||||
XmlValidator.assertXmlValid(results);
|
||||
|
||||
assertContains(results, FullyDocumentedProcessor.DIRECTORY.getDisplayName());
|
||||
|
@ -137,7 +137,7 @@ public class ProcessorDocumentationWriterTest {
|
|||
writer.write(processor, baos, false);
|
||||
initializer.teardown(processor);
|
||||
|
||||
String results = new String(baos.toByteArray());
|
||||
String results = baos.toString();
|
||||
XmlValidator.assertXmlValid(results);
|
||||
|
||||
// no description
|
||||
|
@ -177,7 +177,7 @@ public class ProcessorDocumentationWriterTest {
|
|||
writer.write(processor, baos, false);
|
||||
initializer.teardown(processor);
|
||||
|
||||
String results = new String(baos.toByteArray());
|
||||
String results = baos.toString();
|
||||
XmlValidator.assertXmlValid(results);
|
||||
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ public class ProcessorDocumentationWriterTest {
|
|||
writer.write(processor, baos, false);
|
||||
initializer.teardown(processor);
|
||||
|
||||
String results = new String(baos.toByteArray());
|
||||
String results = baos.toString();
|
||||
XmlValidator.assertXmlValid(results);
|
||||
|
||||
assertContains(results, DeprecatedProcessor.DIRECTORY.getDisplayName());
|
||||
|
|
|
@ -24,11 +24,6 @@ import org.apache.nifi.xml.processing.parsers.DocumentProvider;
|
|||
import org.apache.nifi.xml.processing.parsers.StandardDocumentProvider;
|
||||
import org.junit.Assert;
|
||||
|
||||
/**
|
||||
* A helper class to validate xml documents.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class XmlValidator {
|
||||
private static final String DOCTYPE = "<!DOCTYPE html>";
|
||||
|
||||
|
|
Loading…
Reference in New Issue