http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d29a2d68/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/JmsProperties.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/JmsProperties.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/JmsProperties.java index 8332082..ed73569 100644 --- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/JmsProperties.java +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/JmsProperties.java @@ -37,144 +37,144 @@ public class JmsProperties { public static final String MSG_TYPE_EMPTY = "empty"; // Standard JMS Properties - public static final PropertyDescriptor JMS_PROVIDER = new PropertyDescriptor.Builder(). - name("JMS Provider"). - description("The Provider used for the JMS Server"). - required(true). - allowableValues(ACTIVEMQ_PROVIDER). - defaultValue(ACTIVEMQ_PROVIDER). - build(); - public static final PropertyDescriptor URL = new PropertyDescriptor.Builder(). - name("URL"). - description("The URL of the JMS Server"). - addValidator(StandardValidators.URI_VALIDATOR). - required(true). - build(); - public static final PropertyDescriptor TIMEOUT = new PropertyDescriptor.Builder(). - name("Communications Timeout"). - description("The amount of time to wait when attempting to receive a message before giving up and assuming failure"). - required(true). - addValidator(StandardValidators.TIME_PERIOD_VALIDATOR). - defaultValue("30 sec"). - build(); - public static final PropertyDescriptor USERNAME = new PropertyDescriptor.Builder(). - name("Username"). - description("Username used for authentication and authorization"). - required(false). - addValidator(StandardValidators.NON_EMPTY_VALIDATOR). - build(); - public static final PropertyDescriptor PASSWORD = new PropertyDescriptor.Builder(). - name("Password"). - description("Password used for authentication and authorization"). - required(false). - addValidator(Validator.VALID). - sensitive(true). - build(); - public static final PropertyDescriptor CLIENT_ID_PREFIX = new PropertyDescriptor.Builder(). - name("Client ID Prefix"). - description("A human-readable ID that can be used to associate connections with yourself so that the maintainers of the JMS Server know who to contact if problems arise"). - required(false). - addValidator(StandardValidators.NON_EMPTY_VALIDATOR). - build(); + public static final PropertyDescriptor JMS_PROVIDER = new PropertyDescriptor.Builder() + .name("JMS Provider") + .description("The Provider used for the JMS Server") + .required(true) + .allowableValues(ACTIVEMQ_PROVIDER) + .defaultValue(ACTIVEMQ_PROVIDER) + .build(); + public static final PropertyDescriptor URL = new PropertyDescriptor.Builder() + .name("URL") + .description("The URL of the JMS Server") + .addValidator(StandardValidators.URI_VALIDATOR) + .required(true) + .build(); + public static final PropertyDescriptor TIMEOUT = new PropertyDescriptor.Builder() + .name("Communications Timeout") + .description("The amount of time to wait when attempting to receive a message before giving up and assuming failure") + .required(true) + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) + .defaultValue("30 sec") + .build(); + public static final PropertyDescriptor USERNAME = new PropertyDescriptor.Builder() + .name("Username") + .description("Username used for authentication and authorization") + .required(false) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .build(); + public static final PropertyDescriptor PASSWORD = new PropertyDescriptor.Builder() + .name("Password") + .description("Password used for authentication and authorization") + .required(false) + .addValidator(Validator.VALID) + .sensitive(true) + .build(); + public static final PropertyDescriptor CLIENT_ID_PREFIX = new PropertyDescriptor.Builder() + .name("Client ID Prefix") + .description("A human-readable ID that can be used to associate connections with yourself so that the maintainers of the JMS Server know who to contact if problems arise") + .required(false) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .build(); // Topic/Queue determination Properties - public static final PropertyDescriptor DESTINATION_NAME = new PropertyDescriptor.Builder(). - name("Destination Name"). - description("The name of the JMS Topic or queue to use"). - required(true). - addValidator(StandardValidators.NON_EMPTY_VALIDATOR). - build(); - public static final PropertyDescriptor DESTINATION_TYPE = new PropertyDescriptor.Builder(). - name("Destination Type"). - description("The type of the JMS Destination to use"). - required(true). - allowableValues(DESTINATION_TYPE_QUEUE, DESTINATION_TYPE_TOPIC). - defaultValue(DESTINATION_TYPE_QUEUE). - build(); + public static final PropertyDescriptor DESTINATION_NAME = new PropertyDescriptor.Builder() + .name("Destination Name") + .description("The name of the JMS Topic or queue to use") + .required(true) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .build(); + public static final PropertyDescriptor DESTINATION_TYPE = new PropertyDescriptor.Builder() + .name("Destination Type") + .description("The type of the JMS Destination to use") + .required(true) + .allowableValues(DESTINATION_TYPE_QUEUE, DESTINATION_TYPE_TOPIC) + .defaultValue(DESTINATION_TYPE_QUEUE) + .build(); - public static final PropertyDescriptor DURABLE_SUBSCRIPTION = new PropertyDescriptor.Builder(). - name("Use Durable Subscription"). - description("If true, connections to the specified topic will use Durable Subscription so that messages are queued when we are not pulling them"). - required(true). - allowableValues("true", "false"). - defaultValue("false"). - build(); + public static final PropertyDescriptor DURABLE_SUBSCRIPTION = new PropertyDescriptor.Builder() + .name("Use Durable Subscription") + .description("If true, connections to the specified topic will use Durable Subscription so that messages are queued when we are not pulling them") + .required(true) + .allowableValues("true", "false") + .defaultValue("false") + .build(); // JMS Publisher Properties - public static final PropertyDescriptor ATTRIBUTES_TO_JMS_PROPS = new PropertyDescriptor.Builder(). - name("Copy Attributes to JMS Properties"). - description("Whether or not FlowFile Attributes should be translated into JMS Message Properties. If true, all " + public static final PropertyDescriptor ATTRIBUTES_TO_JMS_PROPS = new PropertyDescriptor.Builder() + .name("Copy Attributes to JMS Properties") + .description("Whether or not FlowFile Attributes should be translated into JMS Message Properties. If true, all " + "attributes starting with 'jms.' will be set as Properties on the JMS Message (without the 'jms.' prefix). " + "If an attribute exists that starts with the same value but ends in '.type', that attribute will be used " - + "to determine the JMS Message Property type."). - required(true). - allowableValues("true", "false"). - defaultValue("true"). - build(); + + "to determine the JMS Message Property type.") + .required(true) + .allowableValues("true", "false") + .defaultValue("true") + .build(); // JMS Listener Properties - public static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder(). - name("Message Batch Size"). - description("The number of messages to pull/push in a single iteration of the processor"). - required(true). - addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR). - defaultValue("10"). - build(); - public static final PropertyDescriptor ACKNOWLEDGEMENT_MODE = new PropertyDescriptor.Builder(). - name("Acknowledgement Mode"). - description("The JMS Acknowledgement Mode. Using Auto Acknowledge can cause messages to be lost on restart of NiFi but may provide better performance than Client Acknowledge."). - required(true). - allowableValues(ACK_MODE_CLIENT, ACK_MODE_AUTO). - defaultValue(ACK_MODE_CLIENT). - build(); - public static final PropertyDescriptor JMS_PROPS_TO_ATTRIBUTES = new PropertyDescriptor.Builder(). - name("Copy JMS Properties to Attributes"). - description("Whether or not the JMS Message Properties should be copied to the FlowFile Attributes; if so, the attribute name will be jms.XXX, where XXX is the JMS Property name"). - required(true). - allowableValues("true", "false"). - defaultValue("true"). - build(); - public static final PropertyDescriptor MESSAGE_SELECTOR = new PropertyDescriptor.Builder(). - name("Message Selector"). - description("The JMS Message Selector to use in order to narrow the messages that are pulled"). - required(false). - addValidator(StandardValidators.NON_EMPTY_VALIDATOR). - build(); + public static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder() + .name("Message Batch Size") + .description("The number of messages to pull/push in a single iteration of the processor") + .required(true) + .addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) + .defaultValue("10") + .build(); + public static final PropertyDescriptor ACKNOWLEDGEMENT_MODE = new PropertyDescriptor.Builder() + .name("Acknowledgement Mode") + .description("The JMS Acknowledgement Mode. Using Auto Acknowledge can cause messages to be lost on restart of NiFi but may provide better performance than Client Acknowledge.") + .required(true) + .allowableValues(ACK_MODE_CLIENT, ACK_MODE_AUTO) + .defaultValue(ACK_MODE_CLIENT) + .build(); + public static final PropertyDescriptor JMS_PROPS_TO_ATTRIBUTES = new PropertyDescriptor.Builder() + .name("Copy JMS Properties to Attributes") + .description("Whether or not the JMS Message Properties should be copied to the FlowFile Attributes; if so, the attribute name will be jms.XXX, where XXX is the JMS Property name") + .required(true) + .allowableValues("true", "false") + .defaultValue("true") + .build(); + public static final PropertyDescriptor MESSAGE_SELECTOR = new PropertyDescriptor.Builder() + .name("Message Selector") + .description("The JMS Message Selector to use in order to narrow the messages that are pulled") + .required(false) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .build(); // JMS Producer Properties - public static final PropertyDescriptor MESSAGE_TYPE = new PropertyDescriptor.Builder(). - name("Message Type"). - description("The Type of JMS Message to Construct"). - required(true). - allowableValues(MSG_TYPE_BYTE, MSG_TYPE_STREAM, MSG_TYPE_TEXT, MSG_TYPE_MAP, MSG_TYPE_EMPTY). - defaultValue(MSG_TYPE_BYTE). - build(); - public static final PropertyDescriptor MESSAGE_PRIORITY = new PropertyDescriptor.Builder(). - name("Message Priority"). - description("The Priority of the Message"). - required(false). - addValidator(StandardValidators.NON_EMPTY_VALIDATOR). - expressionLanguageSupported(true). - build(); - public static final PropertyDescriptor REPLY_TO_QUEUE = new PropertyDescriptor.Builder(). - name("Reply-To Queue"). - description("The name of the queue to which a reply to should be added"). - required(false). - addValidator(StandardValidators.NON_EMPTY_VALIDATOR). - expressionLanguageSupported(true). - build(); - public static final PropertyDescriptor MESSAGE_TTL = new PropertyDescriptor.Builder(). - name("Message Time to Live"). - description("The amount of time that the message should live on the destination before being removed; if not specified, the message will never expire."). - required(false). - addValidator(StandardValidators.TIME_PERIOD_VALIDATOR). - build(); - public static final PropertyDescriptor MAX_BUFFER_SIZE = new PropertyDescriptor.Builder(). - name("Max Buffer Size"). - description("The maximum amount of data that can be buffered for a JMS Message. If a FlowFile's size exceeds this value, the FlowFile will be routed to failure."). - required(true). - addValidator(StandardValidators.DATA_SIZE_VALIDATOR). - defaultValue("1 MB"). - build(); + public static final PropertyDescriptor MESSAGE_TYPE = new PropertyDescriptor.Builder() + .name("Message Type") + .description("The Type of JMS Message to Construct") + .required(true) + .allowableValues(MSG_TYPE_BYTE, MSG_TYPE_STREAM, MSG_TYPE_TEXT, MSG_TYPE_MAP, MSG_TYPE_EMPTY) + .defaultValue(MSG_TYPE_BYTE) + .build(); + public static final PropertyDescriptor MESSAGE_PRIORITY = new PropertyDescriptor.Builder() + .name("Message Priority") + .description("The Priority of the Message") + .required(false) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .expressionLanguageSupported(true) + .build(); + public static final PropertyDescriptor REPLY_TO_QUEUE = new PropertyDescriptor.Builder() + .name("Reply-To Queue") + .description("The name of the queue to which a reply to should be added") + .required(false) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .expressionLanguageSupported(true) + .build(); + public static final PropertyDescriptor MESSAGE_TTL = new PropertyDescriptor.Builder() + .name("Message Time to Live") + .description("The amount of time that the message should live on the destination before being removed; if not specified, the message will never expire.") + .required(false) + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) + .build(); + public static final PropertyDescriptor MAX_BUFFER_SIZE = new PropertyDescriptor.Builder() + .name("Max Buffer Size") + .description("The maximum amount of data that can be buffered for a JMS Message. If a FlowFile's size exceeds this value, the FlowFile will be routed to failure.") + .required(true) + .addValidator(StandardValidators.DATA_SIZE_VALIDATOR) + .defaultValue("1 MB") + .build(); }
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d29a2d68/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/JsonPathExpressionValidator.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/JsonPathExpressionValidator.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/JsonPathExpressionValidator.java index 8a1a056..2a0bd43 100644 --- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/JsonPathExpressionValidator.java +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/JsonPathExpressionValidator.java @@ -36,10 +36,8 @@ import java.util.regex.Pattern; import static java.util.Arrays.asList; /** - * JsonPathExpressionValidator performs the same execution as - * com.jayway.jsonpath.internal.PathCompiler, but does not throw exceptions when - * an invalid path segment is found. Limited access to create JsonPath objects - * requires a separate flow of execution in avoiding exceptions. + * JsonPathExpressionValidator performs the same execution as com.jayway.jsonpath.internal.PathCompiler, but does not throw exceptions when an invalid path segment is found. Limited access to create + * JsonPath objects requires a separate flow of execution in avoiding exceptions. * * @see * <a href="https://github.com/jayway/JsonPath">https://github.com/jayway/JsonPath</a> @@ -72,8 +70,7 @@ public class JsonPathExpressionValidator { * </code> * * @param path to evaluate for validity - * @param filters applied to path expression; this is typically unused in - * the context of Processors + * @param filters applied to path expression; this is typically unused in the context of Processors * @return true if the specified path is valid; false otherwise */ public static boolean isValidExpression(String path, Predicate... filters) { @@ -138,8 +135,7 @@ public class JsonPathExpressionValidator { } else if (positions == 1 && path.charAt(i) == '*') { fragment = "[*]"; } else { - fragment = PROPERTY_OPEN + path. - substring(i, i + positions) + PROPERTY_CLOSE; + fragment = PROPERTY_OPEN + path.substring(i, i + positions) + PROPERTY_CLOSE; } i += positions; } @@ -160,8 +156,7 @@ public class JsonPathExpressionValidator { * Analyze each component represented by a fragment. If there is a failure to properly evaluate, * a null result is returned */ - PathToken analyzedComponent = PathComponentAnalyzer. - analyze(fragment, filterList); + PathToken analyzedComponent = PathComponentAnalyzer.analyze(fragment, filterList); if (analyzedComponent == null) { return false; } @@ -219,8 +214,7 @@ public class JsonPathExpressionValidator { static class PathComponentAnalyzer { - private static final Pattern FILTER_PATTERN = Pattern. - compile("^\\[\\s*\\?\\s*[,\\s*\\?]*?\\s*]$"); //[?] or [?, ?, ...] + private static final Pattern FILTER_PATTERN = Pattern.compile("^\\[\\s*\\?\\s*[,\\s*\\?]*?\\s*]$"); //[?] or [?, ?, ...] private int i; private char current; @@ -248,8 +242,7 @@ public class JsonPathExpressionValidator { return new WildcardPathToken(); } else if ("[?]".equals(pathFragment)) { return new PredicatePathToken(filterList.poll()); - } else if (FILTER_PATTERN.matcher(pathFragment). - matches()) { + } else if (FILTER_PATTERN.matcher(pathFragment).matches()) { final int criteriaCount = Utils.countMatches(pathFragment, "?"); List<Predicate> filters = new ArrayList<>(criteriaCount); for (int i = 0; i < criteriaCount; i++) { @@ -288,8 +281,7 @@ public class JsonPathExpressionValidator { } i = bounds[1]; - return new PredicatePathToken(Filter.parse(pathFragment. - substring(bounds[0], bounds[1]))); + return new PredicatePathToken(Filter.parse(pathFragment.substring(bounds[0], bounds[1]))); } int[] findFilterBounds() { @@ -461,8 +453,7 @@ public class JsonPathExpressionValidator { sliceFrom = true; } else { sliceBetween = true; - numbers.add(Integer.parseInt(buffer. - toString())); + numbers.add(Integer.parseInt(buffer.toString())); buffer.setLength(0); } } http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d29a2d68/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/NLKBufferedReader.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/NLKBufferedReader.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/NLKBufferedReader.java index 20726b2..c524761 100644 --- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/NLKBufferedReader.java +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/NLKBufferedReader.java @@ -35,8 +35,7 @@ public class NLKBufferedReader extends BufferedReader { private static int defaultExpectedLineLength = 80; /** - * Creates a buffering character-input stream that uses an input buffer of - * the specified size. + * Creates a buffering character-input stream that uses an input buffer of the specified size. * * @param in A Reader * @param sz Input-buffer size @@ -51,8 +50,7 @@ public class NLKBufferedReader extends BufferedReader { } /** - * Creates a buffering character-input stream that uses a default-sized - * input buffer. + * Creates a buffering character-input stream that uses a default-sized input buffer. * * @param in A Reader */ @@ -61,13 +59,9 @@ public class NLKBufferedReader extends BufferedReader { } /** - * Reads a line of text. A line is considered to be terminated by any one of - * a line feed ('\n'), a carriage return ('\r'), or a carriage return - * followed immediately by a linefeed. + * Reads a line of text. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a linefeed. * - * @return A String containing the contents of the line, including any - * line-termination characters, or null if the end of the stream has been - * reached + * @return A String containing the contents of the line, including any line-termination characters, or null if the end of the stream has been reached * * @exception IOException If an I/O error occurs */ http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d29a2d68/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/SFTPTransfer.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/SFTPTransfer.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/SFTPTransfer.java index c8e7b78..5034b83 100644 --- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/SFTPTransfer.java +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/SFTPTransfer.java @@ -50,64 +50,61 @@ import com.jcraft.jsch.SftpException; public class SFTPTransfer implements FileTransfer { - public static final PropertyDescriptor PRIVATE_KEY_PATH = new PropertyDescriptor.Builder(). - name("Private Key Path"). - description("The fully qualified path to the Private Key file"). - required(false). - addValidator(StandardValidators.FILE_EXISTS_VALIDATOR). - build(); - public static final PropertyDescriptor PRIVATE_KEY_PASSPHRASE = new PropertyDescriptor.Builder(). - name("Private Key Passphrase"). - description("Password for the private key"). - required(false). - addValidator(StandardValidators.NON_EMPTY_VALIDATOR). - sensitive(true). - build(); - public static final PropertyDescriptor HOST_KEY_FILE = new PropertyDescriptor.Builder(). - name("Host Key File"). - description("If supplied, the given file will be used as the Host Key; otherwise, no use host key file will be used"). - addValidator(StandardValidators.FILE_EXISTS_VALIDATOR). - required(false). - build(); - public static final PropertyDescriptor STRICT_HOST_KEY_CHECKING = new PropertyDescriptor.Builder(). - name("Strict Host Key Checking"). - description("Indicates whether or not strict enforcement of hosts keys should be applied"). - allowableValues("true", "false"). - defaultValue("false"). - required(true). - build(); - public static final PropertyDescriptor PORT = new PropertyDescriptor.Builder(). - name("Port"). - description("The port that the remote system is listening on for file transfers"). - addValidator(StandardValidators.PORT_VALIDATOR). - required(true). - defaultValue("22"). - build(); - public static final PropertyDescriptor USE_KEEPALIVE_ON_TIMEOUT = new PropertyDescriptor.Builder(). - name("Send Keep Alive On Timeout"). - description("Indicates whether or not to send a single Keep Alive message when SSH socket times out"). - allowableValues("true", "false"). - defaultValue("true"). - required(true). - build(); + public static final PropertyDescriptor PRIVATE_KEY_PATH = new PropertyDescriptor.Builder() + .name("Private Key Path") + .description("The fully qualified path to the Private Key file") + .required(false) + .addValidator(StandardValidators.FILE_EXISTS_VALIDATOR) + .build(); + public static final PropertyDescriptor PRIVATE_KEY_PASSPHRASE = new PropertyDescriptor.Builder() + .name("Private Key Passphrase") + .description("Password for the private key") + .required(false) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .sensitive(true) + .build(); + public static final PropertyDescriptor HOST_KEY_FILE = new PropertyDescriptor.Builder() + .name("Host Key File") + .description("If supplied, the given file will be used as the Host Key; otherwise, no use host key file will be used") + .addValidator(StandardValidators.FILE_EXISTS_VALIDATOR) + .required(false) + .build(); + public static final PropertyDescriptor STRICT_HOST_KEY_CHECKING = new PropertyDescriptor.Builder() + .name("Strict Host Key Checking") + .description("Indicates whether or not strict enforcement of hosts keys should be applied") + .allowableValues("true", "false") + .defaultValue("false") + .required(true) + .build(); + public static final PropertyDescriptor PORT = new PropertyDescriptor.Builder() + .name("Port") + .description("The port that the remote system is listening on for file transfers") + .addValidator(StandardValidators.PORT_VALIDATOR) + .required(true) + .defaultValue("22") + .build(); + public static final PropertyDescriptor USE_KEEPALIVE_ON_TIMEOUT = new PropertyDescriptor.Builder() + .name("Send Keep Alive On Timeout") + .description("Indicates whether or not to send a single Keep Alive message when SSH socket times out") + .allowableValues("true", "false") + .defaultValue("true") + .required(true) + .build(); /** - * Dynamic property which is used to decide if the - * {@link #ensureDirectoryExists(FlowFile, File)} method should perform a - * {@link ChannelSftp#ls(String)} before calling - * {@link ChannelSftp#mkdir(String)}. In most cases, the code should call ls - * before mkdir, but some weird permission setups (chmod 100) on a directory - * would cause the 'ls' to throw a permission exception. + * Dynamic property which is used to decide if the {@link #ensureDirectoryExists(FlowFile, File)} method should perform a {@link ChannelSftp#ls(String)} before calling + * {@link ChannelSftp#mkdir(String)}. In most cases, the code should call ls before mkdir, but some weird permission setups (chmod 100) on a directory would cause the 'ls' to throw a permission + * exception. * <p> * This property is dynamic until deemed a worthy inclusion as proper. */ - public static final PropertyDescriptor DISABLE_DIRECTORY_LISTING = new PropertyDescriptor.Builder(). - name("Disable Directory Listing"). - description("Disables directory listings before operations which might fail, such as configurations which create directory structures."). - addValidator(StandardValidators.BOOLEAN_VALIDATOR). - dynamic(true). - defaultValue("false"). - build(); + public static final PropertyDescriptor DISABLE_DIRECTORY_LISTING = new PropertyDescriptor.Builder() + .name("Disable Directory Listing") + .description("Disables directory listings before operations which might fail, such as configurations which create directory structures.") + .addValidator(StandardValidators.BOOLEAN_VALIDATOR) + .dynamic(true) + .defaultValue("false") + .build(); private final ProcessorLog logger; @@ -123,10 +120,8 @@ public class SFTPTransfer implements FileTransfer { this.ctx = processContext; this.logger = logger; - final PropertyValue disableListing = processContext. - getProperty(DISABLE_DIRECTORY_LISTING); - disableDirectoryListing = disableListing == null ? false : Boolean.TRUE. - equals(disableListing.asBoolean()); + final PropertyValue disableListing = processContext.getProperty(DISABLE_DIRECTORY_LISTING); + disableDirectoryListing = disableListing == null ? false : Boolean.TRUE.equals(disableListing.asBoolean()); } @Override @@ -136,13 +131,9 @@ public class SFTPTransfer implements FileTransfer { @Override public List<FileInfo> getListing() throws IOException { - final String path = ctx.getProperty(FileTransfer.REMOTE_PATH). - evaluateAttributeExpressions(). - getValue(); + final String path = ctx.getProperty(FileTransfer.REMOTE_PATH).evaluateAttributeExpressions().getValue(); final int depth = 0; - final int maxResults = ctx. - getProperty(FileTransfer.REMOTE_POLL_BATCH_SIZE). - asInteger(); + final int maxResults = ctx.getProperty(FileTransfer.REMOTE_POLL_BATCH_SIZE).asInteger(); final List<FileInfo> listing = new ArrayList<>(1000); getListing(path, depth, maxResults, listing); return listing; @@ -154,43 +145,28 @@ public class SFTPTransfer implements FileTransfer { } if (depth >= 100) { - logger. - warn(this + " had to stop recursively searching directories at a recursive depth of " + depth + " to avoid memory issues"); + logger.warn(this + " had to stop recursively searching directories at a recursive depth of " + depth + " to avoid memory issues"); return; } final boolean ignoreDottedFiles = ctx. - getProperty(FileTransfer.IGNORE_DOTTED_FILES). - asBoolean(); - final boolean recurse = ctx.getProperty(FileTransfer.RECURSIVE_SEARCH). - asBoolean(); - final String fileFilterRegex = ctx. - getProperty(FileTransfer.FILE_FILTER_REGEX). - getValue(); - final Pattern pattern = (fileFilterRegex == null) ? null : Pattern. - compile(fileFilterRegex); - final String pathFilterRegex = ctx. - getProperty(FileTransfer.PATH_FILTER_REGEX). - getValue(); - final Pattern pathPattern = (!recurse || pathFilterRegex == null) ? null : Pattern. - compile(pathFilterRegex); - final String remotePath = ctx.getProperty(FileTransfer.REMOTE_PATH). - evaluateAttributeExpressions(). - getValue(); + getProperty(FileTransfer.IGNORE_DOTTED_FILES).asBoolean(); + final boolean recurse = ctx.getProperty(FileTransfer.RECURSIVE_SEARCH).asBoolean(); + final String fileFilterRegex = ctx.getProperty(FileTransfer.FILE_FILTER_REGEX).getValue(); + final Pattern pattern = (fileFilterRegex == null) ? null : Pattern.compile(fileFilterRegex); + final String pathFilterRegex = ctx.getProperty(FileTransfer.PATH_FILTER_REGEX).getValue(); + final Pattern pathPattern = (!recurse || pathFilterRegex == null) ? null : Pattern.compile(pathFilterRegex); + final String remotePath = ctx.getProperty(FileTransfer.REMOTE_PATH).evaluateAttributeExpressions().getValue(); // check if this directory path matches the PATH_FILTER_REGEX boolean pathFilterMatches = true; if (pathPattern != null) { Path reldir = path == null ? Paths.get(".") : Paths.get(path); if (remotePath != null) { - reldir = Paths.get(remotePath). - relativize(reldir); - } - if (reldir != null && !reldir.toString(). - isEmpty()) { - if (!pathPattern.matcher(reldir.toString(). - replace("\\", "/")). - matches()) { + reldir = Paths.get(remotePath).relativize(reldir); + } + if (reldir != null && !reldir.toString().isEmpty()) { + if (!pathPattern.matcher(reldir.toString().replace("\\", "/")).matches()) { pathFilterMatches = false; } } @@ -219,19 +195,15 @@ public class SFTPTransfer implements FileTransfer { } // if is a directory and we're supposed to recurse - if (recurse && entry.getAttrs(). - isDir()) { + if (recurse && entry.getAttrs().isDir()) { subDirs.add(entry); return LsEntrySelector.CONTINUE; } // if is not a directory and is not a link and it matches // FILE_FILTER_REGEX - then let's add it - if (!entry.getAttrs(). - isDir() && !entry.getAttrs(). - isLink() && isPathMatch) { - if (pattern == null || pattern.matcher(entryFilename). - matches()) { + if (!entry.getAttrs().isDir() && !entry.getAttrs().isLink() && isPathMatch) { + if (pattern == null || pattern.matcher(entryFilename).matches()) { listing.add(newFileInfo(entry, path)); } } @@ -245,8 +217,7 @@ public class SFTPTransfer implements FileTransfer { }; - if (path == null || path.trim(). - isEmpty()) { + if (path == null || path.trim().isEmpty()) { sftp.ls(".", filter); } else { sftp.ls(path, filter); @@ -258,8 +229,7 @@ public class SFTPTransfer implements FileTransfer { for (final LsEntry entry : subDirs) { final String entryFilename = entry.getFilename(); final File newFullPath = new File(path, entryFilename); - final String newFullForwardPath = newFullPath.getPath(). - replace("\\", "/"); + final String newFullForwardPath = newFullPath.getPath().replace("\\", "/"); try { getListing(newFullForwardPath, depth + 1, maxResults, listing); @@ -275,29 +245,22 @@ public class SFTPTransfer implements FileTransfer { return null; } final File newFullPath = new File(path, entry.getFilename()); - final String newFullForwardPath = newFullPath.getPath(). - replace("\\", "/"); + final String newFullForwardPath = newFullPath.getPath().replace("\\", "/"); - String perms = entry.getAttrs(). - getPermissionsString(); + String perms = entry.getAttrs().getPermissionsString(); if (perms.length() > 9) { perms = perms.substring(perms.length() - 9); } FileInfo.Builder builder = new FileInfo.Builder() - .filename(entry.getFilename()). - fullPathFileName(newFullForwardPath). - directory(entry.getAttrs(). - isDir()). - size(entry.getAttrs(). - getSize()). - lastModifiedTime(entry.getAttrs(). - getMTime() * 1000L). - permissions(perms). - owner(Integer.toString(entry.getAttrs(). - getUId())). - group(Integer.toString(entry.getAttrs(). - getGId())); + .filename(entry.getFilename()) + .fullPathFileName(newFullForwardPath) + .directory(entry.getAttrs().isDir()) + .size(entry.getAttrs().getSize()) + .lastModifiedTime(entry.getAttrs().getMTime() * 1000L) + .permissions(perms) + .owner(Integer.toString(entry.getAttrs().getUId())) + .group(Integer.toString(entry.getAttrs().getGId())); return builder.build(); } @@ -318,9 +281,7 @@ public class SFTPTransfer implements FileTransfer { @Override public void deleteFile(final String path, final String remoteFileName) throws IOException { - final String fullPath = (path == null) - ? remoteFileName - : (path.endsWith("/")) ? path + remoteFileName : path + "/" + remoteFileName; + final String fullPath = (path == null) ? remoteFileName : (path.endsWith("/")) ? path + remoteFileName : path + "/" + remoteFileName; try { sftp.rm(fullPath); } catch (final SftpException e) { @@ -340,9 +301,7 @@ public class SFTPTransfer implements FileTransfer { @Override public void ensureDirectoryExists(final FlowFile flowFile, final File directoryName) throws IOException { final ChannelSftp channel = getChannel(flowFile); - final String remoteDirectory = directoryName.getAbsolutePath(). - replace("\\", "/"). - replaceAll("^.\\:", ""); + final String remoteDirectory = directoryName.getAbsolutePath().replace("\\", "/").replaceAll("^.\\:", ""); // if we disable the directory listing, we just want to blindly perform the mkdir command, // eating any exceptions thrown (like if the directory already exists). @@ -374,13 +333,10 @@ public class SFTPTransfer implements FileTransfer { if (!exists) { // first ensure parent directories exist before creating this one - if (directoryName.getParent() != null && !directoryName. - getParentFile(). - equals(new File(File.separator))) { + if (directoryName.getParent() != null && !directoryName.getParentFile().equals(new File(File.separator))) { ensureDirectoryExists(flowFile, directoryName.getParentFile()); } - logger. - debug("Remote Directory {} does not exist; creating it", new Object[]{remoteDirectory}); + logger.debug("Remote Directory {} does not exist; creating it", new Object[]{remoteDirectory}); try { channel.mkdir(remoteDirectory); logger.debug("Created {}", new Object[]{remoteDirectory}); @@ -393,9 +349,7 @@ public class SFTPTransfer implements FileTransfer { private ChannelSftp getChannel(final FlowFile flowFile) throws IOException { if (sftp != null) { String sessionhost = session.getHost(); - String desthost = ctx.getProperty(HOSTNAME). - evaluateAttributeExpressions(flowFile). - getValue(); + String desthost = ctx.getProperty(HOSTNAME).evaluateAttributeExpressions(flowFile).getValue(); if (sessionhost.equals(desthost)) { // destination matches so we can keep our current session return sftp; @@ -407,35 +361,22 @@ public class SFTPTransfer implements FileTransfer { final JSch jsch = new JSch(); try { - final Session session = jsch.getSession(ctx.getProperty(USERNAME). - getValue(), - ctx.getProperty(HOSTNAME). - evaluateAttributeExpressions(flowFile). - getValue(), - ctx.getProperty(PORT). - evaluateAttributeExpressions(flowFile). - asInteger(). - intValue()); - - final String hostKeyVal = ctx.getProperty(HOST_KEY_FILE). - getValue(); + final Session session = jsch.getSession(ctx.getProperty(USERNAME).getValue(), + ctx.getProperty(HOSTNAME).evaluateAttributeExpressions(flowFile).getValue(), + ctx.getProperty(PORT).evaluateAttributeExpressions(flowFile).asInteger().intValue()); + + final String hostKeyVal = ctx.getProperty(HOST_KEY_FILE).getValue(); if (hostKeyVal != null) { jsch.setKnownHosts(hostKeyVal); } final Properties properties = new Properties(); - properties.setProperty("StrictHostKeyChecking", ctx. - getProperty(STRICT_HOST_KEY_CHECKING). - asBoolean() ? "yes" : "no"); - properties. - setProperty("PreferredAuthentications", "publickey,password"); - - if (ctx.getProperty(FileTransfer.USE_COMPRESSION). - asBoolean()) { - properties. - setProperty("compression.s2c", "z...@openssh.com,zlib,none"); - properties. - setProperty("compression.c2s", "z...@openssh.com,zlib,none"); + properties.setProperty("StrictHostKeyChecking", ctx.getProperty(STRICT_HOST_KEY_CHECKING).asBoolean() ? "yes" : "no"); + properties.setProperty("PreferredAuthentications", "publickey,password"); + + if (ctx.getProperty(FileTransfer.USE_COMPRESSION).asBoolean()) { + properties.setProperty("compression.s2c", "z...@openssh.com,zlib,none"); + properties.setProperty("compression.c2s", "z...@openssh.com,zlib,none"); } else { properties.setProperty("compression.s2c", "none"); properties.setProperty("compression.c2s", "none"); @@ -443,42 +384,32 @@ public class SFTPTransfer implements FileTransfer { session.setConfig(properties); - final String privateKeyFile = ctx.getProperty(PRIVATE_KEY_PATH). - getValue(); + final String privateKeyFile = ctx.getProperty(PRIVATE_KEY_PATH).getValue(); if (privateKeyFile != null) { - jsch.addIdentity(privateKeyFile, ctx. - getProperty(PRIVATE_KEY_PASSPHRASE). - getValue()); + jsch.addIdentity(privateKeyFile, ctx.getProperty(PRIVATE_KEY_PASSPHRASE).getValue()); } - final String password = ctx.getProperty(FileTransfer.PASSWORD). - getValue(); + final String password = ctx.getProperty(FileTransfer.PASSWORD).getValue(); if (password != null) { session.setPassword(password); } - session.setTimeout(ctx.getProperty(FileTransfer.CONNECTION_TIMEOUT). - asTimePeriod(TimeUnit.MILLISECONDS). - intValue()); + session.setTimeout(ctx.getProperty(FileTransfer.CONNECTION_TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS).intValue()); session.connect(); this.session = session; this.closed = false; sftp = (ChannelSftp) session.openChannel("sftp"); sftp.connect(); - session.setTimeout(ctx.getProperty(FileTransfer.DATA_TIMEOUT). - asTimePeriod(TimeUnit.MILLISECONDS). - intValue()); - if (!ctx.getProperty(USE_KEEPALIVE_ON_TIMEOUT). - asBoolean()) { + session.setTimeout(ctx.getProperty(FileTransfer.DATA_TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS).intValue()); + if (!ctx.getProperty(USE_KEEPALIVE_ON_TIMEOUT).asBoolean()) { session.setServerAliveCountMax(0); // do not send keepalive message on SocketTimeoutException } this.homeDir = sftp.getHome(); return sftp; } catch (final SftpException | JSchException e) { - throw new IOException("Failed to obtain connection to remote host due to " + e. - toString(), e); + throw new IOException("Failed to obtain connection to remote host due to " + e.toString(), e); } } @@ -500,9 +431,7 @@ public class SFTPTransfer implements FileTransfer { sftp.exit(); } } catch (final Exception ex) { - logger. - warn("Failed to close ChannelSftp due to {}", new Object[]{ex. - toString()}, ex); + logger.warn("Failed to close ChannelSftp due to {}", new Object[]{ex.toString()}, ex); } sftp = null; @@ -511,8 +440,7 @@ public class SFTPTransfer implements FileTransfer { session.disconnect(); } } catch (final Exception ex) { - logger.warn("Failed to close session due to {}", new Object[]{ex. - toString()}, ex); + logger.warn("Failed to close session due to {}", new Object[]{ex.toString()}, ex); } session = null; } @@ -552,8 +480,7 @@ public class SFTPTransfer implements FileTransfer { LsEntry matchingEntry = null; for (final LsEntry entry : vector) { - if (entry.getFilename(). - equalsIgnoreCase(filename)) { + if (entry.getFilename().equalsIgnoreCase(filename)) { matchingEntry = entry; break; } @@ -567,22 +494,15 @@ public class SFTPTransfer implements FileTransfer { final ChannelSftp sftp = getChannel(flowFile); // destination path + filename - final String fullPath = (path == null) - ? filename - : (path.endsWith("/")) ? path + filename : path + "/" + filename; + final String fullPath = (path == null) ? filename : (path.endsWith("/")) ? path + filename : path + "/" + filename; // temporary path + filename - String tempFilename = ctx.getProperty(TEMP_FILENAME). - evaluateAttributeExpressions(flowFile). - getValue(); + String tempFilename = ctx.getProperty(TEMP_FILENAME).evaluateAttributeExpressions(flowFile).getValue(); if (tempFilename == null) { - final boolean dotRename = ctx.getProperty(DOT_RENAME). - asBoolean(); + final boolean dotRename = ctx.getProperty(DOT_RENAME).asBoolean(); tempFilename = dotRename ? "." + filename : filename; } - final String tempPath = (path == null) - ? tempFilename - : (path.endsWith("/")) ? path + tempFilename : path + "/" + tempFilename; + final String tempPath = (path == null) ? tempFilename : (path.endsWith("/")) ? path + tempFilename : path + "/" + tempFilename; try { sftp.put(content, tempPath); @@ -590,61 +510,45 @@ public class SFTPTransfer implements FileTransfer { throw new IOException("Unable to put content to " + fullPath + " due to " + e, e); } - final String lastModifiedTime = ctx.getProperty(LAST_MODIFIED_TIME). - evaluateAttributeExpressions(flowFile). - getValue(); - if (lastModifiedTime != null && !lastModifiedTime.trim(). - isEmpty()) { + final String lastModifiedTime = ctx.getProperty(LAST_MODIFIED_TIME).evaluateAttributeExpressions(flowFile).getValue(); + if (lastModifiedTime != null && !lastModifiedTime.trim().isEmpty()) { try { final DateFormat formatter = new SimpleDateFormat(FILE_MODIFY_DATE_ATTR_FORMAT, Locale.US); final Date fileModifyTime = formatter.parse(lastModifiedTime); int time = (int) (fileModifyTime.getTime() / 1000L); sftp.setMtime(tempPath, time); } catch (final Exception e) { - logger. - error("Failed to set lastModifiedTime on {} to {} due to {}", new Object[]{tempPath, lastModifiedTime, e}); + logger.error("Failed to set lastModifiedTime on {} to {} due to {}", new Object[]{tempPath, lastModifiedTime, e}); } } - final String permissions = ctx.getProperty(PERMISSIONS). - evaluateAttributeExpressions(flowFile). - getValue(); - if (permissions != null && !permissions.trim(). - isEmpty()) { + final String permissions = ctx.getProperty(PERMISSIONS).evaluateAttributeExpressions(flowFile).getValue(); + if (permissions != null && !permissions.trim().isEmpty()) { try { int perms = numberPermissions(permissions); if (perms >= 0) { sftp.chmod(perms, tempPath); } } catch (final Exception e) { - logger. - error("Failed to set permission on {} to {} due to {}", new Object[]{tempPath, permissions, e}); + logger.error("Failed to set permission on {} to {} due to {}", new Object[]{tempPath, permissions, e}); } } - final String owner = ctx.getProperty(REMOTE_OWNER). - evaluateAttributeExpressions(flowFile). - getValue(); - if (owner != null && !owner.trim(). - isEmpty()) { + final String owner = ctx.getProperty(REMOTE_OWNER).evaluateAttributeExpressions(flowFile).getValue(); + if (owner != null && !owner.trim().isEmpty()) { try { sftp.chown(Integer.parseInt(owner), tempPath); } catch (final Exception e) { - logger. - error("Failed to set owner on {} to {} due to {}", new Object[]{tempPath, owner, e}); + logger.error("Failed to set owner on {} to {} due to {}", new Object[]{tempPath, owner, e}); } } - final String group = ctx.getProperty(REMOTE_GROUP). - evaluateAttributeExpressions(flowFile). - getValue(); - if (group != null && !group.trim(). - isEmpty()) { + final String group = ctx.getProperty(REMOTE_GROUP).evaluateAttributeExpressions(flowFile).getValue(); + if (group != null && !group.trim().isEmpty()) { try { sftp.chgrp(Integer.parseInt(group), tempPath); } catch (final Exception e) { - logger. - error("Failed to set group on {} to {} due to {}", new Object[]{tempPath, group, e}); + logger.error("Failed to set group on {} to {} due to {}", new Object[]{tempPath, group, e}); } } @@ -668,8 +572,7 @@ public class SFTPTransfer implements FileTransfer { int number = -1; final Pattern rwxPattern = Pattern.compile("^[rwx-]{9}$"); final Pattern numPattern = Pattern.compile("\\d+"); - if (rwxPattern.matcher(perms). - matches()) { + if (rwxPattern.matcher(perms).matches()) { number = 0; if (perms.charAt(0) == 'r') { number |= 0x100; @@ -698,8 +601,7 @@ public class SFTPTransfer implements FileTransfer { if (perms.charAt(8) == 'x') { number |= 0x1; } - } else if (numPattern.matcher(perms). - matches()) { + } else if (numPattern.matcher(perms).matches()) { try { number = Integer.parseInt(perms, 8); } catch (NumberFormatException ignore) { @@ -717,8 +619,7 @@ public class SFTPTransfer implements FileTransfer { @Override public void log(int level, String message) { - LoggerFactory.getLogger(SFTPTransfer.class). - debug("SFTP Log: {}", message); + LoggerFactory.getLogger(SFTPTransfer.class).debug("SFTP Log: {}", message); } }); } http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d29a2d68/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/SFTPUtils.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/SFTPUtils.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/SFTPUtils.java index 9121089..fc6275f 100644 --- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/SFTPUtils.java +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/SFTPUtils.java @@ -40,80 +40,80 @@ import com.jcraft.jsch.SftpException; public class SFTPUtils { - public static final PropertyDescriptor SFTP_PRIVATEKEY_PATH = new PropertyDescriptor.Builder(). - required(false). - description("sftp.privatekey.path"). - defaultValue(null). - name("sftp.privatekey.path"). - addValidator(StandardValidators.FILE_EXISTS_VALIDATOR). - sensitive(false). - build(); - public static final PropertyDescriptor REMOTE_PASSWORD = new PropertyDescriptor.Builder(). - required(false). - description("remote.password"). - defaultValue(null). - name("remote.password"). - addValidator(StandardValidators.NON_EMPTY_VALIDATOR). - sensitive(true). - build(); - public static final PropertyDescriptor SFTP_PRIVATEKEY_PASSPHRASE = new PropertyDescriptor.Builder(). - required(false). - description("sftp.privatekey.passphrase"). - defaultValue(null). - name("sftp.privatekey.passphrase"). - addValidator(StandardValidators.NON_EMPTY_VALIDATOR). - sensitive(true). - build(); - public static final PropertyDescriptor SFTP_PORT = new PropertyDescriptor.Builder(). - required(false). - description("sftp.port"). - defaultValue(null). - name("sftp.port"). - addValidator(StandardValidators.NON_NEGATIVE_INTEGER_VALIDATOR). - sensitive(false). - build(); - public static final PropertyDescriptor NETWORK_DATA_TIMEOUT = new PropertyDescriptor.Builder(). - required(false). - description("network.data.timeout"). - defaultValue(null). - name("network.data.timeout"). - addValidator(StandardValidators.INTEGER_VALIDATOR). - sensitive(false). - build(); - public static final PropertyDescriptor SFTP_HOSTKEY_FILENAME = new PropertyDescriptor.Builder(). - required(false). - description("sftp.hostkey.filename"). - defaultValue(null). - name("sftp.hostkey.filename"). - addValidator(StandardValidators.FILE_EXISTS_VALIDATOR). - sensitive(false). - build(); - public static final PropertyDescriptor NETWORK_CONNECTION_TIMEOUT = new PropertyDescriptor.Builder(). - required(false). - description("network.connection.timeout"). - defaultValue(null). - name("network.connection.timeout"). - addValidator(StandardValidators.INTEGER_VALIDATOR). - sensitive(false). - build(); + public static final PropertyDescriptor SFTP_PRIVATEKEY_PATH = new PropertyDescriptor.Builder() + .required(false) + .description("sftp.privatekey.path") + .defaultValue(null) + .name("sftp.privatekey.path") + .addValidator(StandardValidators.FILE_EXISTS_VALIDATOR) + .sensitive(false) + .build(); + public static final PropertyDescriptor REMOTE_PASSWORD = new PropertyDescriptor.Builder() + .required(false) + .description("remote.password") + .defaultValue(null) + .name("remote.password") + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .sensitive(true) + .build(); + public static final PropertyDescriptor SFTP_PRIVATEKEY_PASSPHRASE = new PropertyDescriptor.Builder() + .required(false) + .description("sftp.privatekey.passphrase") + .defaultValue(null) + .name("sftp.privatekey.passphrase") + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .sensitive(true) + .build(); + public static final PropertyDescriptor SFTP_PORT = new PropertyDescriptor.Builder() + .required(false) + .description("sftp.port") + .defaultValue(null) + .name("sftp.port") + .addValidator(StandardValidators.NON_NEGATIVE_INTEGER_VALIDATOR) + .sensitive(false) + .build(); + public static final PropertyDescriptor NETWORK_DATA_TIMEOUT = new PropertyDescriptor.Builder() + .required(false) + .description("network.data.timeout") + .defaultValue(null) + .name("network.data.timeout") + .addValidator(StandardValidators.INTEGER_VALIDATOR) + .sensitive(false) + .build(); + public static final PropertyDescriptor SFTP_HOSTKEY_FILENAME = new PropertyDescriptor.Builder() + .required(false) + .description("sftp.hostkey.filename") + .defaultValue(null) + .name("sftp.hostkey.filename") + .addValidator(StandardValidators.FILE_EXISTS_VALIDATOR) + .sensitive(false) + .build(); + public static final PropertyDescriptor NETWORK_CONNECTION_TIMEOUT = new PropertyDescriptor.Builder() + .required(false) + .description("network.connection.timeout") + .defaultValue(null) + .name("network.connection.timeout") + .addValidator(StandardValidators.INTEGER_VALIDATOR) + .sensitive(false) + .build(); // required properties - public static final PropertyDescriptor REMOTE_HOSTNAME = new PropertyDescriptor.Builder(). - required(true). - description("remote.hostname"). - defaultValue(null). - name("remote.hostname"). - addValidator(StandardValidators.NON_EMPTY_VALIDATOR). - sensitive(false). - build(); - public static final PropertyDescriptor REMOTE_USERNAME = new PropertyDescriptor.Builder(). - required(true). - description("remote.username"). - defaultValue(null). - name("remote.username"). - addValidator(StandardValidators.NON_EMPTY_VALIDATOR). - sensitive(false). - build(); + public static final PropertyDescriptor REMOTE_HOSTNAME = new PropertyDescriptor.Builder() + .required(true) + .description("remote.hostname") + .defaultValue(null) + .name("remote.hostname") + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .sensitive(false) + .build(); + public static final PropertyDescriptor REMOTE_USERNAME = new PropertyDescriptor.Builder() + .required(true) + .description("remote.username") + .defaultValue(null) + .name("remote.username") + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .sensitive(false) + .build(); private static final List<PropertyDescriptor> propertyDescriptors = new ArrayList<>(); @@ -149,22 +149,16 @@ public class SFTPUtils { File dir = new File(dirPath); String currentWorkingDirectory = null; boolean dirExists = false; - final String forwardPaths = dir.getPath(). - replaceAll(Matcher.quoteReplacement("\\"), Matcher. - quoteReplacement("/")); + final String forwardPaths = dir.getPath().replaceAll(Matcher.quoteReplacement("\\"), Matcher.quoteReplacement("/")); try { currentWorkingDirectory = sftp.pwd(); - logger. - debug(proc + " attempting to change directory from " + currentWorkingDirectory + " to " + dir. - getPath()); + logger.debug(proc + " attempting to change directory from " + currentWorkingDirectory + " to " + dir.getPath()); //always use forward paths for long string attempt sftp.cd(forwardPaths); dirExists = true; - logger. - debug(proc + " changed working directory to '" + forwardPaths + "' from '" + currentWorkingDirectory + "'"); + logger.debug(proc + " changed working directory to '" + forwardPaths + "' from '" + currentWorkingDirectory + "'"); } catch (final SftpException sftpe) { - logger. - debug(proc + " could not change directory to '" + forwardPaths + "' from '" + currentWorkingDirectory + "' so trying the hard way."); + logger.debug(proc + " could not change directory to '" + forwardPaths + "' from '" + currentWorkingDirectory + "' so trying the hard way."); } if (dirExists) { return; @@ -185,14 +179,12 @@ public class SFTPUtils { try { sftp.cd(dirName); } catch (final SftpException sftpe) { - logger. - debug(proc + " creating new directory and changing to it " + dirName); + logger.debug(proc + " creating new directory and changing to it " + dirName); try { sftp.mkdir(dirName); sftp.cd(dirName); } catch (final SftpException e) { - throw new IOException(proc + " could not make/change directory to [" + dirName + "] [" + e. - getLocalizedMessage() + "]", e); + throw new IOException(proc + " could not make/change directory to [" + dirName + "] [" + e.getLocalizedMessage() + "]", e); } } } @@ -205,8 +197,7 @@ public class SFTPUtils { final Hashtable<String, String> newOptions = new Hashtable<>(); - Session session = jsch. - getSession(conf.username, conf.hostname, conf.port); + Session session = jsch.getSession(conf.username, conf.hostname, conf.port); final String hostKeyVal = conf.hostkeyFile; http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d29a2d68/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/UDPStreamConsumer.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/UDPStreamConsumer.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/UDPStreamConsumer.java index 84f431d..ad2cca5 100644 --- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/UDPStreamConsumer.java +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/UDPStreamConsumer.java @@ -109,8 +109,7 @@ public class UDPStreamConsumer implements StreamConsumer { } // time to make a new flow file newFlowFile = session.create(); - newFlowFile = session. - putAttribute(newFlowFile, "source.stream.identifier", uniqueId); + newFlowFile = session.putAttribute(newFlowFile, "source.stream.identifier", uniqueId); newFlowFile = session.write(newFlowFile, udpCallback); if (newFlowFile.getSize() == 0) { session.remove(newFlowFile); @@ -123,8 +122,7 @@ public class UDPStreamConsumer implements StreamConsumer { try { session.remove(newFlowFile); } catch (final Exception ex2) { - logger. - warn("Unable to delete partial flow file due to: ", ex2); + logger.warn("Unable to delete partial flow file due to: ", ex2); } } throw new IOException("Problem while processing data stream", ex); @@ -158,21 +156,17 @@ public class UDPStreamConsumer implements StreamConsumer { return false; } UDPStreamConsumer rhs = (UDPStreamConsumer) obj; - return new EqualsBuilder().appendSuper(super.equals(obj)). - append(uniqueId, rhs.uniqueId). - isEquals(); + return new EqualsBuilder().appendSuper(super.equals(obj)).append(uniqueId, rhs.uniqueId).isEquals(); } @Override public final int hashCode() { - return new HashCodeBuilder(17, 37).append(uniqueId). - toHashCode(); + return new HashCodeBuilder(17, 37).append(uniqueId).toHashCode(); } @Override public final String toString() { - return new ToStringBuilder(this).append(uniqueId). - toString(); + return new ToStringBuilder(this).append(uniqueId).toString(); } public static final class UDPConsumerCallback implements OutputStreamCallback { @@ -194,11 +188,9 @@ public class UDPStreamConsumer implements StreamConsumer { public void process(final OutputStream out) throws IOException { try { long totalBytes = 0L; - try (WritableByteChannel wbc = Channels. - newChannel(new BufferedOutputStream(out))) { + try (WritableByteChannel wbc = Channels.newChannel(new BufferedOutputStream(out))) { ByteBuffer buffer = null; - while ((buffer = filledBuffers. - poll(50, TimeUnit.MILLISECONDS)) != null) { + while ((buffer = filledBuffers.poll(50, TimeUnit.MILLISECONDS)) != null) { int bytesWrittenThisPass = 0; try { while (buffer.hasRemaining()) { @@ -209,8 +201,7 @@ public class UDPStreamConsumer implements StreamConsumer { break;// this is enough data } } finally { - bufferPool. - returnBuffer(buffer, bytesWrittenThisPass); + bufferPool.returnBuffer(buffer, bytesWrittenThisPass); } } } http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d29a2d68/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/ValidatingBase32InputStream.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/ValidatingBase32InputStream.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/ValidatingBase32InputStream.java index 692947d..711efce 100644 --- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/ValidatingBase32InputStream.java +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/ValidatingBase32InputStream.java @@ -23,8 +23,7 @@ import java.util.Arrays; import org.apache.commons.codec.binary.Base32; /** - * An InputStream that throws an IOException if any byte is read that is not a - * valid Base32 character. Whitespace is considered valid. + * An InputStream that throws an IOException if any byte is read that is not a valid Base32 character. Whitespace is considered valid. */ public class ValidatingBase32InputStream extends FilterInputStream { http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d29a2d68/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/ValidatingBase64InputStream.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/ValidatingBase64InputStream.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/ValidatingBase64InputStream.java index 6867681..5002906 100644 --- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/ValidatingBase64InputStream.java +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/ValidatingBase64InputStream.java @@ -24,8 +24,7 @@ import java.util.Arrays; import org.apache.commons.codec.binary.Base64; /** - * An InputStream that throws an IOException if any byte is read that is not a - * valid Base64 character. Whitespace is considered valid. + * An InputStream that throws an IOException if any byte is read that is not a valid Base64 character. Whitespace is considered valid. */ public class ValidatingBase64InputStream extends FilterInputStream { http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d29a2d68/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/WrappedMessageConsumer.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/WrappedMessageConsumer.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/WrappedMessageConsumer.java index 7d16b73..fca6a70 100644 --- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/WrappedMessageConsumer.java +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/WrappedMessageConsumer.java @@ -55,22 +55,19 @@ public class WrappedMessageConsumer { try { connection.close(); } catch (final JMSException e) { - logger. - warn("unable to close connection to JMS Server due to {}; resources may not be cleaned up appropriately", e); + logger.warn("unable to close connection to JMS Server due to {}; resources may not be cleaned up appropriately", e); } try { session.close(); } catch (final JMSException e) { - logger. - warn("unable to close connection to JMS Server due to {}; resources may not be cleaned up appropriately", e); + logger.warn("unable to close connection to JMS Server due to {}; resources may not be cleaned up appropriately", e); } try { consumer.close(); } catch (final JMSException e) { - logger. - warn("unable to close connection to JMS Server due to {}; resources may not be cleaned up appropriately", e); + logger.warn("unable to close connection to JMS Server due to {}; resources may not be cleaned up appropriately", e); } } http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d29a2d68/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/WrappedMessageProducer.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/WrappedMessageProducer.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/WrappedMessageProducer.java index a2d7459..fc01b02 100644 --- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/WrappedMessageProducer.java +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/WrappedMessageProducer.java @@ -55,22 +55,19 @@ public class WrappedMessageProducer { try { connection.close(); } catch (final JMSException e) { - logger. - warn("unable to close connection to JMS Server due to {}; resources may not be cleaned up appropriately", e); + logger.warn("unable to close connection to JMS Server due to {}; resources may not be cleaned up appropriately", e); } try { session.close(); } catch (final JMSException e) { - logger. - warn("unable to close connection to JMS Server due to {}; resources may not be cleaned up appropriately", e); + logger.warn("unable to close connection to JMS Server due to {}; resources may not be cleaned up appropriately", e); } try { producer.close(); } catch (final JMSException e) { - logger. - warn("unable to close connection to JMS Server due to {}; resources may not be cleaned up appropriately", e); + logger.warn("unable to close connection to JMS Server due to {}; resources may not be cleaned up appropriately", e); } } http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d29a2d68/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/TestIngestAndUpdate.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/TestIngestAndUpdate.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/TestIngestAndUpdate.java index 70f2579..c9ed9f9 100644 --- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/TestIngestAndUpdate.java +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/TestIngestAndUpdate.java @@ -21,8 +21,7 @@ public class TestIngestAndUpdate { public static void main(String[] args) throws IOException { byte[] bytes = new byte[1024]; - System.out.write(System.getProperty("user.dir"). - getBytes()); + System.out.write(System.getProperty("user.dir").getBytes()); System.out.println(":ModifiedResult"); int numRead = 0; while ((numRead = System.in.read(bytes)) != -1) { http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d29a2d68/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/CaptureServlet.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/CaptureServlet.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/CaptureServlet.java index 772ca0b..d6c87d6 100644 --- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/CaptureServlet.java +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/CaptureServlet.java @@ -48,8 +48,7 @@ public class CaptureServlet extends HttpServlet { @Override protected void doHead(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { - response. - setHeader("Accept", "application/flowfile-v3,application/flowfile-v2"); + response.setHeader("Accept", "application/flowfile-v3,application/flowfile-v2"); response.setHeader("x-nifi-transfer-protocol-version", "1"); response.setHeader("Accept-Encoding", "gzip"); } http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d29a2d68/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/RESTServiceContentModified.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/RESTServiceContentModified.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/RESTServiceContentModified.java index 580450f..ec3211c 100644 --- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/RESTServiceContentModified.java +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/RESTServiceContentModified.java @@ -47,11 +47,9 @@ public class RESTServiceContentModified extends HttpServlet { dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); response.setContentType("application/json"); - if (ifNoneMatch != null && ifNoneMatch.length() > 0 && !IGNORE_ETAG && Integer. - parseInt(ifNoneMatch) == ETAG) { + if (ifNoneMatch != null && ifNoneMatch.length() > 0 && !IGNORE_ETAG && Integer.parseInt(ifNoneMatch) == ETAG) { response.setStatus(304); - response.setHeader("Last-Modified", dateFormat. - format(modificationDate)); + response.setHeader("Last-Modified", dateFormat.format(modificationDate)); response.setHeader("ETag", Integer.toString(ETAG)); return; } @@ -59,16 +57,14 @@ public class RESTServiceContentModified extends HttpServlet { long date = -1; if (ifModifiedSince != null && ifModifiedSince.length() > 0 && !IGNORE_LAST_MODIFIED) { try { - date = dateFormat.parse(ifModifiedSince). - getTime(); + date = dateFormat.parse(ifModifiedSince).getTime(); } catch (Exception e) { } } if (date >= modificationDate) { response.setStatus(304); - response.setHeader("Last-Modified", dateFormat. - format(modificationDate)); + response.setHeader("Last-Modified", dateFormat.format(modificationDate)); response.setHeader("ETag", Integer.toString(ETAG)); return; } @@ -76,8 +72,7 @@ public class RESTServiceContentModified extends HttpServlet { response.setStatus(200); response.setHeader("Last-Modified", dateFormat.format(modificationDate)); response.setHeader("ETag", Integer.toString(ETAG)); - response.getOutputStream(). - println(result); + response.getOutputStream().println(result); } } http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d29a2d68/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestBase64EncodeContent.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestBase64EncodeContent.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestBase64EncodeContent.java index 4005db7..eef4dbc 100644 --- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestBase64EncodeContent.java +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestBase64EncodeContent.java @@ -16,7 +16,6 @@ */ package org.apache.nifi.processors.standard; -import org.apache.nifi.processors.standard.Base64EncodeContent; import java.io.File; import java.io.IOException; import java.nio.file.Paths; @@ -31,68 +30,53 @@ public class TestBase64EncodeContent { @Test public void testRoundTrip() throws IOException { - final TestRunner testRunner = TestRunners. - newTestRunner(new Base64EncodeContent()); + final TestRunner testRunner = TestRunners.newTestRunner(new Base64EncodeContent()); - testRunner. - setProperty(Base64EncodeContent.MODE, Base64EncodeContent.ENCODE_MODE); + testRunner.setProperty(Base64EncodeContent.MODE, Base64EncodeContent.ENCODE_MODE); testRunner.enqueue(Paths.get("src/test/resources/hello.txt")); testRunner.clearTransferState(); testRunner.run(); - testRunner. - assertAllFlowFilesTransferred(Base64EncodeContent.REL_SUCCESS, 1); + testRunner.assertAllFlowFilesTransferred(Base64EncodeContent.REL_SUCCESS, 1); - MockFlowFile flowFile = testRunner. - getFlowFilesForRelationship(Base64EncodeContent.REL_SUCCESS). - get(0); + MockFlowFile flowFile = testRunner.getFlowFilesForRelationship(Base64EncodeContent.REL_SUCCESS).get(0); testRunner.assertQueueEmpty(); - testRunner. - setProperty(Base64EncodeContent.MODE, Base64EncodeContent.DECODE_MODE); + testRunner.setProperty(Base64EncodeContent.MODE, Base64EncodeContent.DECODE_MODE); testRunner.enqueue(flowFile); testRunner.clearTransferState(); testRunner.run(); - testRunner. - assertAllFlowFilesTransferred(Base64EncodeContent.REL_SUCCESS, 1); + testRunner.assertAllFlowFilesTransferred(Base64EncodeContent.REL_SUCCESS, 1); - flowFile = testRunner. - getFlowFilesForRelationship(Base64EncodeContent.REL_SUCCESS). - get(0); + flowFile = testRunner.getFlowFilesForRelationship(Base64EncodeContent.REL_SUCCESS).get(0); flowFile.assertContentEquals(new File("src/test/resources/hello.txt")); } @Test public void testFailDecodeNotBase64() throws IOException { - final TestRunner testRunner = TestRunners. - newTestRunner(new Base64EncodeContent()); + final TestRunner testRunner = TestRunners.newTestRunner(new Base64EncodeContent()); - testRunner. - setProperty(Base64EncodeContent.MODE, Base64EncodeContent.DECODE_MODE); + testRunner.setProperty(Base64EncodeContent.MODE, Base64EncodeContent.DECODE_MODE); testRunner.enqueue(Paths.get("src/test/resources/hello.txt")); testRunner.clearTransferState(); testRunner.run(); - testRunner. - assertAllFlowFilesTransferred(Base64EncodeContent.REL_FAILURE, 1); + testRunner.assertAllFlowFilesTransferred(Base64EncodeContent.REL_FAILURE, 1); } @Test public void testFailDecodeNotBase64ButIsAMultipleOfFourBytes() throws IOException { - final TestRunner testRunner = TestRunners. - newTestRunner(new Base64EncodeContent()); + final TestRunner testRunner = TestRunners.newTestRunner(new Base64EncodeContent()); - testRunner. - setProperty(Base64EncodeContent.MODE, Base64EncodeContent.DECODE_MODE); + testRunner.setProperty(Base64EncodeContent.MODE, Base64EncodeContent.DECODE_MODE); testRunner.enqueue("four@@@@multiple".getBytes()); testRunner.clearTransferState(); testRunner.run(); - testRunner. - assertAllFlowFilesTransferred(Base64EncodeContent.REL_FAILURE, 1); + testRunner.assertAllFlowFilesTransferred(Base64EncodeContent.REL_FAILURE, 1); } }