mirror of https://github.com/apache/nifi.git
NIFI-3776 Correcting links in documentation for SeeAlso and properties referencing controller services. This closes #1739
This commit is contained in:
parent
ce233bdbbb
commit
e723a2c5c4
|
@ -23,12 +23,16 @@ import org.apache.nifi.annotation.behavior.Stateful;
|
|||
import org.apache.nifi.annotation.documentation.CapabilityDescription;
|
||||
import org.apache.nifi.annotation.documentation.SeeAlso;
|
||||
import org.apache.nifi.annotation.documentation.Tags;
|
||||
import org.apache.nifi.bundle.Bundle;
|
||||
import org.apache.nifi.bundle.BundleCoordinate;
|
||||
import org.apache.nifi.components.AllowableValue;
|
||||
import org.apache.nifi.components.ConfigurableComponent;
|
||||
import org.apache.nifi.components.PropertyDescriptor;
|
||||
import org.apache.nifi.controller.ControllerService;
|
||||
import org.apache.nifi.documentation.DocumentationWriter;
|
||||
import org.apache.nifi.nar.ExtensionManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.xml.stream.FactoryConfigurationError;
|
||||
import javax.xml.stream.XMLOutputFactory;
|
||||
|
@ -49,6 +53,8 @@ import java.util.Set;
|
|||
*/
|
||||
public class HtmlDocumentationWriter implements DocumentationWriter {
|
||||
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(HtmlDocumentationWriter.class);
|
||||
|
||||
/**
|
||||
* The filename where additional user specified information may be stored.
|
||||
*/
|
||||
|
@ -239,13 +245,26 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
|
|||
xmlStreamWriter.writeCharacters(", ");
|
||||
}
|
||||
|
||||
final String link = "../" + linkedComponent + "/index.html";
|
||||
final List<Bundle> linkedComponentBundles = ExtensionManager.getBundles(linkedComponent);
|
||||
|
||||
final int indexOfLastPeriod = linkedComponent.lastIndexOf(".") + 1;
|
||||
if (linkedComponentBundles != null && linkedComponentBundles.size() > 0) {
|
||||
final Bundle firstBundle = linkedComponentBundles.get(0);
|
||||
final BundleCoordinate firstCoordinate = firstBundle.getBundleDetails().getCoordinate();
|
||||
|
||||
writeLink(xmlStreamWriter, linkedComponent.substring(indexOfLastPeriod), link);
|
||||
final String group = firstCoordinate.getGroup();
|
||||
final String id = firstCoordinate.getId();
|
||||
final String version = firstCoordinate.getVersion();
|
||||
|
||||
++index;
|
||||
final String link = "/nifi-docs/components/" + group + "/" + id + "/" + version + "/" + linkedComponent + "/index.html";
|
||||
|
||||
final int indexOfLastPeriod = linkedComponent.lastIndexOf(".") + 1;
|
||||
|
||||
writeLink(xmlStreamWriter, linkedComponent.substring(indexOfLastPeriod), link);
|
||||
|
||||
++index;
|
||||
} else {
|
||||
LOGGER.warn("Could not link to {} because no bundles were found", new Object[] {linkedComponent});
|
||||
}
|
||||
}
|
||||
xmlStreamWriter.writeEndElement();
|
||||
}
|
||||
|
@ -661,8 +680,23 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
|
|||
* @param clazz the configurable component to link to
|
||||
* @throws XMLStreamException thrown if there is a problem writing the XML
|
||||
*/
|
||||
protected void writeLinkForComponent(final XMLStreamWriter xmlStreamWriter, final Class<?> clazz) throws XMLStreamException {
|
||||
writeLink(xmlStreamWriter, clazz.getSimpleName(), "../" + clazz.getCanonicalName() + "/index.html");
|
||||
protected void writeLinkForComponent(final XMLStreamWriter xmlStreamWriter, final Class<?> clazz)
|
||||
throws XMLStreamException {
|
||||
final String linkedComponentName = clazz.getName();
|
||||
final List<Bundle> linkedComponentBundles = ExtensionManager.getBundles(linkedComponentName);
|
||||
|
||||
if (linkedComponentBundles != null && linkedComponentBundles.size() > 0) {
|
||||
final Bundle firstLinkedComponentBundle = linkedComponentBundles.get(0);
|
||||
final BundleCoordinate coordinate = firstLinkedComponentBundle.getBundleDetails().getCoordinate();
|
||||
|
||||
final String group = coordinate.getGroup();
|
||||
final String id = coordinate.getId();
|
||||
final String version = coordinate.getVersion();
|
||||
|
||||
writeLink(xmlStreamWriter, clazz.getSimpleName(), "/nifi-docs/components/" + group + "/" + id + "/" + version + "/" + clazz.getCanonicalName() + "/index.html");
|
||||
} else {
|
||||
LOGGER.warn("Could not link to {} because no bundles were found", new Object[] {linkedComponentName});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue