mirror of https://github.com/apache/nifi.git
NIFI-5145 Made MockPropertyValue.evaluateExpressionLanguage(FlowFile able to accommodate null flowfiles the way live NiFi does.
NIFI-5145 Fixed a mistake with evaluateAttributeExpressions found in a code review. NIFI-5145 Removed a property descriptor from GetHBase that was a duplication of the one in VisibilityFetchSupport. NIFI-5145 Added comments in the code that were requested in the review. NIFI-5145 Fixed check style issue. NIFI-5145 Fixed a few improperly scoped items in ListFileTransfer that impacted the FTP processor(s). NIFI-5145 Changed which override gets called based on code review feedback. NIFI-5145: Reverted changes to ListFileTransfer re ExpressionLanguageScope NIFI-5145: Removed TODO from MockPropertyValue javadoc Signed-off-by: Matthew Burgess <mattyb149@apache.org> This closes #2672
This commit is contained in:
parent
0688363d87
commit
ea41b41ede
|
@ -202,6 +202,15 @@ public class MockPropertyValue implements PropertyValue {
|
|||
|
||||
@Override
|
||||
public PropertyValue evaluateAttributeExpressions(final FlowFile flowFile) throws ProcessException {
|
||||
/*
|
||||
* The reason for this null check is that somewhere in the test API, it automatically assumes that a null FlowFile
|
||||
* should be treated as though it were evaluated with the VARIABLE_REGISTRY scope instead of the flowfile scope. When NiFi
|
||||
* is running, it doesn't care when it's evaluating EL against a null flowfile. However, the testing framework currently
|
||||
* raises an error which makes it not mimick real world behavior.
|
||||
*/
|
||||
if (flowFile == null) {
|
||||
return evaluateAttributeExpressions();
|
||||
}
|
||||
return evaluateAttributeExpressions(flowFile, null, null);
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,6 @@ import org.apache.nifi.components.AllowableValue;
|
|||
import org.apache.nifi.components.PropertyDescriptor;
|
||||
import org.apache.nifi.components.ValidationContext;
|
||||
import org.apache.nifi.components.ValidationResult;
|
||||
import org.apache.nifi.components.Validator;
|
||||
import org.apache.nifi.components.state.Scope;
|
||||
import org.apache.nifi.components.state.StateManager;
|
||||
import org.apache.nifi.components.state.StateMap;
|
||||
|
@ -147,14 +146,6 @@ public class GetHBase extends AbstractProcessor implements VisibilityFetchSuppor
|
|||
.allowableValues(NONE, CURRENT_TIME)
|
||||
.defaultValue(NONE.getValue())
|
||||
.build();
|
||||
static final PropertyDescriptor AUTHORIZATIONS = new PropertyDescriptor.Builder()
|
||||
.name("hbase-fetch-row-authorizations")
|
||||
.displayName("Authorizations")
|
||||
.description("The list of authorizations to pass to the scanner. This will be ignored if cell visibility labels are not in use.")
|
||||
.required(false)
|
||||
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
|
||||
.addValidator(Validator.VALID)
|
||||
.build();
|
||||
|
||||
static final Relationship REL_SUCCESS = new Relationship.Builder()
|
||||
.name("success")
|
||||
|
|
|
@ -267,8 +267,7 @@ public abstract class AbstractMongoProcessor extends AbstractProcessor {
|
|||
|
||||
protected void writeBatch(String payload, FlowFile parent, ProcessContext context, ProcessSession session,
|
||||
Map<String, String> extraAttributes, Relationship rel) throws UnsupportedEncodingException {
|
||||
String charset = parent != null ? context.getProperty(CHARSET).evaluateAttributeExpressions(parent).getValue()
|
||||
: context.getProperty(CHARSET).evaluateAttributeExpressions().getValue();
|
||||
String charset = context.getProperty(CHARSET).evaluateAttributeExpressions(parent).getValue();
|
||||
|
||||
FlowFile flowFile = parent != null ? session.create(parent) : session.create();
|
||||
flowFile = session.importFrom(new ByteArrayInputStream(payload.getBytes(charset)), flowFile);
|
||||
|
|
|
@ -96,7 +96,7 @@ public class GetMongo extends AbstractMongoProcessor {
|
|||
"the flowfile's body. If this field is left blank and a timer is enabled instead of an incoming connection, " +
|
||||
"that will result in a full collection fetch using a \"{}\" query.")
|
||||
.required(false)
|
||||
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
|
||||
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
|
||||
.addValidator(DOCUMENT_VALIDATOR)
|
||||
.build();
|
||||
|
||||
|
@ -346,6 +346,7 @@ public class GetMongo extends AbstractMongoProcessor {
|
|||
}
|
||||
} else {
|
||||
while (cursor.hasNext()) {
|
||||
final FlowFile ffPtr = input;
|
||||
flowFile = session.create();
|
||||
flowFile = session.write(flowFile, out -> {
|
||||
String json;
|
||||
|
@ -354,7 +355,7 @@ public class GetMongo extends AbstractMongoProcessor {
|
|||
} else {
|
||||
json = cursor.next().toJson();
|
||||
}
|
||||
out.write(json.getBytes(context.getProperty(CHARSET).evaluateAttributeExpressions().getValue()));
|
||||
out.write(json.getBytes(context.getProperty(CHARSET).evaluateAttributeExpressions(ffPtr).getValue()));
|
||||
});
|
||||
flowFile = session.putAllAttributes(flowFile, attributes);
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.apache.nifi.components.AllowableValue;
|
|||
import org.apache.nifi.components.PropertyDescriptor;
|
||||
import org.apache.nifi.components.ValidationContext;
|
||||
import org.apache.nifi.components.ValidationResult;
|
||||
import org.apache.nifi.expression.ExpressionLanguageScope;
|
||||
import org.apache.nifi.flowfile.FlowFile;
|
||||
import org.apache.nifi.logging.ComponentLog;
|
||||
import org.apache.nifi.processor.ProcessContext;
|
||||
|
@ -92,7 +93,7 @@ public class PutMongo extends AbstractMongoProcessor {
|
|||
+ "otherwise it is ignored. Example: _id")
|
||||
.required(false)
|
||||
.addValidator(StandardValidators.NON_BLANK_VALIDATOR)
|
||||
.expressionLanguageSupported(true)
|
||||
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
|
||||
.build();
|
||||
static final PropertyDescriptor UPDATE_QUERY = new PropertyDescriptor.Builder()
|
||||
.name("putmongo-update-query")
|
||||
|
@ -100,7 +101,7 @@ public class PutMongo extends AbstractMongoProcessor {
|
|||
.description("Specify a full MongoDB query to be used for the lookup query to do an update/upsert.")
|
||||
.required(false)
|
||||
.addValidator(StandardValidators.NON_BLANK_VALIDATOR)
|
||||
.expressionLanguageSupported(true)
|
||||
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
|
||||
.build();
|
||||
|
||||
static final PropertyDescriptor UPDATE_MODE = new PropertyDescriptor.Builder()
|
||||
|
|
Loading…
Reference in New Issue