mirror of https://github.com/apache/nifi.git
NIFI-503: Removed dependencies on commons-lang3 and commons-io
This commit is contained in:
parent
512ac9c704
commit
e18c0a7d26
|
@ -32,14 +32,6 @@
|
||||||
<groupId>org.apache.nifi</groupId>
|
<groupId>org.apache.nifi</groupId>
|
||||||
<artifactId>nifi-properties</artifactId>
|
<artifactId>nifi-properties</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>commons-io</groupId>
|
|
||||||
<artifactId>commons-io</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.commons</groupId>
|
|
||||||
<artifactId>commons-lang3</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.nifi</groupId>
|
<groupId>org.apache.nifi</groupId>
|
||||||
<artifactId>nifi-processor-utils</artifactId>
|
<artifactId>nifi-processor-utils</artifactId>
|
||||||
|
|
|
@ -26,7 +26,6 @@ import javax.xml.stream.XMLOutputFactory;
|
||||||
import javax.xml.stream.XMLStreamException;
|
import javax.xml.stream.XMLStreamException;
|
||||||
import javax.xml.stream.XMLStreamWriter;
|
import javax.xml.stream.XMLStreamWriter;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.apache.nifi.annotation.behavior.DynamicProperties;
|
import org.apache.nifi.annotation.behavior.DynamicProperties;
|
||||||
import org.apache.nifi.annotation.behavior.DynamicProperty;
|
import org.apache.nifi.annotation.behavior.DynamicProperty;
|
||||||
import org.apache.nifi.annotation.documentation.CapabilityDescription;
|
import org.apache.nifi.annotation.documentation.CapabilityDescription;
|
||||||
|
@ -212,13 +211,23 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
|
||||||
xmlStreamWriter.writeEndElement();
|
xmlStreamWriter.writeEndElement();
|
||||||
xmlStreamWriter.writeStartElement("p");
|
xmlStreamWriter.writeStartElement("p");
|
||||||
if (tags != null) {
|
if (tags != null) {
|
||||||
final String tagString = StringUtils.join(tags.value(), ", ");
|
final String tagString = join(tags.value(), ", ");
|
||||||
xmlStreamWriter.writeCharacters(tagString);
|
xmlStreamWriter.writeCharacters(tagString);
|
||||||
} else {
|
} else {
|
||||||
xmlStreamWriter.writeCharacters("None.");
|
xmlStreamWriter.writeCharacters("None.");
|
||||||
}
|
}
|
||||||
xmlStreamWriter.writeEndElement();
|
xmlStreamWriter.writeEndElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
static String join(final String[] toJoin, final String delimiter) {
|
||||||
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
for (int i=0; i < toJoin.length; i++) {
|
||||||
|
sb.append(toJoin[i]);
|
||||||
|
if ( i < toJoin.length - 1 ) {
|
||||||
|
sb.append(delimiter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,7 +23,6 @@ import java.util.List;
|
||||||
import javax.xml.stream.XMLStreamException;
|
import javax.xml.stream.XMLStreamException;
|
||||||
import javax.xml.stream.XMLStreamWriter;
|
import javax.xml.stream.XMLStreamWriter;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.apache.nifi.annotation.behavior.DynamicRelationship;
|
import org.apache.nifi.annotation.behavior.DynamicRelationship;
|
||||||
import org.apache.nifi.annotation.behavior.ReadsAttribute;
|
import org.apache.nifi.annotation.behavior.ReadsAttribute;
|
||||||
import org.apache.nifi.annotation.behavior.ReadsAttributes;
|
import org.apache.nifi.annotation.behavior.ReadsAttributes;
|
||||||
|
@ -67,6 +66,13 @@ public class HtmlProcessorDocumentationWriter extends HtmlDocumentationWriter {
|
||||||
handleWritesAttributes(xmlStreamWriter, processor);
|
handleWritesAttributes(xmlStreamWriter, processor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String defaultIfBlank(final String test, final String defaultValue) {
|
||||||
|
if ( test == null || test.trim().isEmpty() ) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
return test;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes out just the attributes that are being read in a table form.
|
* Writes out just the attributes that are being read in a table form.
|
||||||
*
|
*
|
||||||
|
@ -91,10 +97,10 @@ public class HtmlProcessorDocumentationWriter extends HtmlDocumentationWriter {
|
||||||
for (ReadsAttribute attribute : attributesRead) {
|
for (ReadsAttribute attribute : attributesRead) {
|
||||||
xmlStreamWriter.writeStartElement("tr");
|
xmlStreamWriter.writeStartElement("tr");
|
||||||
writeSimpleElement(xmlStreamWriter, "td",
|
writeSimpleElement(xmlStreamWriter, "td",
|
||||||
StringUtils.defaultIfBlank(attribute.attribute(), "Not Specified"));
|
defaultIfBlank(attribute.attribute(), "Not Specified"));
|
||||||
// TODO allow for HTML characters here.
|
// TODO allow for HTML characters here.
|
||||||
writeSimpleElement(xmlStreamWriter, "td",
|
writeSimpleElement(xmlStreamWriter, "td",
|
||||||
StringUtils.defaultIfBlank(attribute.description(), "Not Specified"));
|
defaultIfBlank(attribute.description(), "Not Specified"));
|
||||||
xmlStreamWriter.writeEndElement();
|
xmlStreamWriter.writeEndElement();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -129,10 +135,10 @@ public class HtmlProcessorDocumentationWriter extends HtmlDocumentationWriter {
|
||||||
for (WritesAttribute attribute : attributesRead) {
|
for (WritesAttribute attribute : attributesRead) {
|
||||||
xmlStreamWriter.writeStartElement("tr");
|
xmlStreamWriter.writeStartElement("tr");
|
||||||
writeSimpleElement(xmlStreamWriter, "td",
|
writeSimpleElement(xmlStreamWriter, "td",
|
||||||
StringUtils.defaultIfBlank(attribute.attribute(), "Not Specified"));
|
defaultIfBlank(attribute.attribute(), "Not Specified"));
|
||||||
// TODO allow for HTML characters here.
|
// TODO allow for HTML characters here.
|
||||||
writeSimpleElement(xmlStreamWriter, "td",
|
writeSimpleElement(xmlStreamWriter, "td",
|
||||||
StringUtils.defaultIfBlank(attribute.description(), "Not Specified"));
|
defaultIfBlank(attribute.description(), "Not Specified"));
|
||||||
xmlStreamWriter.writeEndElement();
|
xmlStreamWriter.writeEndElement();
|
||||||
}
|
}
|
||||||
xmlStreamWriter.writeEndElement();
|
xmlStreamWriter.writeEndElement();
|
||||||
|
|
|
@ -30,9 +30,17 @@ import org.apache.nifi.reporting.ReportingTask;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.apache.nifi.documentation.html.XmlValidator.assertContains;
|
import static org.apache.nifi.documentation.html.XmlValidator.assertContains;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class HtmlDocumentationWriterTest {
|
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"}, ", "));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDocumentControllerService() throws InitializationException, IOException {
|
public void testDocumentControllerService() throws InitializationException, IOException {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue