org.apache.nifi.components.PropertyDescriptor Java Examples

The following examples show how to use org.apache.nifi.components.PropertyDescriptor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AzureLogAnalyticsProvenanceReportingTask.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Override
protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
        final List<PropertyDescriptor> properties = new ArrayList<>();
        properties.add(LOG_ANALYTICS_WORKSPACE_ID);
        properties.add(LOG_ANALYTICS_CUSTOM_LOG_NAME);
        properties.add(LOG_ANALYTICS_WORKSPACE_KEY);
        properties.add(APPLICATION_ID);
        properties.add(INSTANCE_ID);
        properties.add(JOB_NAME);
        properties.add(LOG_ANALYTICS_URL_ENDPOINT_FORMAT);
        properties.add(FILTER_EVENT_TYPE);
        properties.add(FILTER_EVENT_TYPE_EXCLUDE);
        properties.add(FILTER_COMPONENT_TYPE);
        properties.add(FILTER_COMPONENT_TYPE_EXCLUDE);
        properties.add(FILTER_COMPONENT_ID);
        properties.add(FILTER_COMPONENT_ID_EXCLUDE);
        properties.add(FILTER_COMPONENT_NAME);
        properties.add(FILTER_COMPONENT_NAME_EXCLUDE);
        properties.add(START_POSITION);
        properties.add(ALLOW_NULL_VALUES);
        properties.add(PLATFORM);
        properties.add(INSTANCE_URL);
        properties.add(BATCH_SIZE);
        return properties;
}
 
Example #2
Source File: StatelessControllerServiceLookup.java    From nifi with Apache License 2.0 6 votes vote down vote up
public ValidationResult setControllerServiceProperty(final ControllerService service, final PropertyDescriptor property, final StatelessProcessContext context,
                                                     final VariableRegistry registry, final String value) {
    final StatelessStateManager serviceStateManager = controllerServiceStateManagers.get(service.getIdentifier());
    if (serviceStateManager == null) {
        throw new IllegalStateException("Controller service " + service + " has not been added to this TestRunner via the #addControllerService method");
    }

    final ValidationContext validationContext = new StatelessValidationContext(context, this, serviceStateManager, registry, parameterContext);
    final ValidationResult validationResult = property.validate(value, validationContext);

    final StatelessControllerServiceConfiguration configuration = getControllerServiceConfigToUpdate(service);
    final PropertyConfiguration oldValue = configuration.getProperties().get(property);
    final PropertyConfiguration propertyConfiguration = createPropertyConfiguration(value, property.isExpressionLanguageSupported());
    configuration.setProperty(property, propertyConfiguration);

    if (oldValue == null && value != null) {
        service.onPropertyModified(property, null, value);
    } else if ((value == null && oldValue.getRawValue() != null) || (value != null && !value.equals(oldValue.getRawValue()))) {
        service.onPropertyModified(property, oldValue.getRawValue(), value);
    }

    return validationResult;
}
 
Example #3
Source File: StandardSSLContextService.java    From nifi with Apache License 2.0 6 votes vote down vote up
/**
 * Returns a list of {@link ValidationResult}s for truststore validity checking. Ensures none of the properties
 * are populated or at least filename and type are populated; if populated, validates the truststore file on disk
 * and password as well.
 *
 * @param properties the component properties
 * @return the list of validation results (empty is valid)
 */
private static List<ValidationResult> validateTruststore(final Map<PropertyDescriptor, String> properties) {
    String filename = properties.get(TRUSTSTORE);
    String password = properties.get(TRUSTSTORE_PASSWORD);
    String type = properties.get(TRUSTSTORE_TYPE);

    List<ValidationResult> results = new ArrayList<>();

    if (!StringUtils.isBlank(filename) && !StringUtils.isBlank(type)) {
        // In this case both the filename and type are populated, which is sufficient
        results.addAll(validateTruststoreFile(filename, password, type));
    } else {
        // The filename or type are blank; all values must be unpopulated for this to be valid
        if (!StringUtils.isBlank(filename) || !StringUtils.isBlank(type)) {
            results.add(new ValidationResult.Builder().valid(false).explanation("If the truststore filename or type are set, both must be populated").subject("Truststore Properties").build());
        }
    }

    return results;
}
 
Example #4
Source File: HiveConnectionPool.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
@Override
protected void init(final ControllerServiceInitializationContext context) {
    List<PropertyDescriptor> props = new ArrayList<>();
    props.add(DATABASE_URL);
    props.add(HIVE_CONFIGURATION_RESOURCES);
    props.add(DB_USER);
    props.add(DB_PASSWORD);
    props.add(MAX_WAIT_TIME);
    props.add(MAX_TOTAL_CONNECTIONS);
    props.add(VALIDATION_QUERY);

    kerberosConfigFile = context.getKerberosConfigurationFile();
    kerberosProperties = new KerberosProperties(kerberosConfigFile);
    props.add(kerberosProperties.getKerberosPrincipal());
    props.add(kerberosProperties.getKerberosKeytab());
    properties = props;
}
 
Example #5
Source File: ProxyConfiguration.java    From nifi with Apache License 2.0 6 votes vote down vote up
public static PropertyDescriptor createProxyConfigPropertyDescriptor(final boolean hasComponentProxyConfigs, final ProxySpec ... _specs) {

        final Set<ProxySpec> specs = getUniqueProxySpecs(_specs);

        final StringBuilder description = new StringBuilder("Specifies the Proxy Configuration Controller Service to proxy network requests.");
        if (hasComponentProxyConfigs) {
            description.append(" If set, it supersedes proxy settings configured per component.");
        }
        description.append(" Supported proxies: ");
        description.append(specs.stream().map(ProxySpec::getDisplayName).collect(Collectors.joining(", ")));

        return new PropertyDescriptor.Builder()
                .fromPropertyDescriptor(ProxyConfigurationService.PROXY_CONFIGURATION_SERVICE)
                .description(description.toString())
                .build();
    }
 
Example #6
Source File: AuthorizeParameterReference.java    From nifi with Apache License 2.0 6 votes vote down vote up
public static void authorizeParameterReferences(final ComponentAuthorizable authorizable, final Authorizer authorizer, final Authorizable parameterContextAuthorizable, final NiFiUser user) {
    if (parameterContextAuthorizable == null) {
        return;
    }

    final ParameterParser parameterParser = new ExpressionLanguageAgnosticParameterParser();

    boolean referencesParameter = false;
    for (final PropertyDescriptor propertyDescriptor : authorizable.getPropertyDescriptors()) {
        final String rawValue = authorizable.getRawValue(propertyDescriptor);

        final ParameterTokenList tokenList = parameterParser.parseTokens(rawValue);
        if (!tokenList.toReferenceList().isEmpty()) {
            referencesParameter = true;
            break;
        }
    }

    if (referencesParameter) {
        parameterContextAuthorizable.authorize(authorizer, RequestAction.READ, user);
    }
}
 
Example #7
Source File: StandardProcessorTestRunner.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Override
public boolean removeProperty(final ControllerService service, final PropertyDescriptor property) {
    final MockStateManager serviceStateManager = controllerServiceStateManagers.get(service.getIdentifier());
    if (serviceStateManager == null) {
        throw new IllegalStateException("Controller service " + service + " has not been added to this TestRunner via the #addControllerService method");
    }

    final ControllerServiceConfiguration configuration = getConfigToUpdate(service);
    final Map<PropertyDescriptor, String> curProps = configuration.getProperties();
    final Map<PropertyDescriptor, String> updatedProps = new HashMap<>(curProps);

    final String oldValue = updatedProps.remove(property);
    if (oldValue == null) {
        return false;
    }

    configuration.setProperties(updatedProps);
    service.onPropertyModified(property, oldValue, null);
    return true;
}
 
Example #8
Source File: SnippetUtils.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
private Set<ControllerServiceDTO> getControllerServices(final Map<PropertyDescriptor, String> componentProperties) {
    final Set<ControllerServiceDTO> serviceDtos = new HashSet<>();

    for (final Map.Entry<PropertyDescriptor, String> entry : componentProperties.entrySet()) {
        final PropertyDescriptor descriptor = entry.getKey();
        if (descriptor.getControllerServiceDefinition() != null) {
            final String controllerServiceId = entry.getValue();
            if (controllerServiceId != null) {
                final ControllerServiceNode serviceNode = flowController.getControllerServiceNode(controllerServiceId);
                if (serviceNode != null) {
                    serviceDtos.add(dtoFactory.createControllerServiceDto(serviceNode));

                    final Set<ControllerServiceDTO> recursiveRefs = getControllerServices(serviceNode.getProperties());
                    serviceDtos.addAll(recursiveRefs);
                }
            }
        }
    }

    return serviceDtos;
}
 
Example #9
Source File: CSVRecordSetWriter.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Override
protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
    final List<PropertyDescriptor> properties = new ArrayList<>(super.getSupportedPropertyDescriptors());
    properties.add(CSVUtils.CSV_FORMAT);
    properties.add(CSVUtils.VALUE_SEPARATOR);
    properties.add(CSVUtils.INCLUDE_HEADER_LINE);
    properties.add(CSVUtils.QUOTE_CHAR);
    properties.add(CSVUtils.ESCAPE_CHAR);
    properties.add(CSVUtils.COMMENT_MARKER);
    properties.add(CSVUtils.NULL_STRING);
    properties.add(CSVUtils.TRIM_FIELDS);
    properties.add(CSVUtils.QUOTE_MODE);
    properties.add(CSVUtils.RECORD_SEPARATOR);
    properties.add(CSVUtils.TRAILING_DELIMITER);
    properties.add(CSVUtils.CHARSET);
    return properties;
}
 
Example #10
Source File: GenerateTableFetch.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
public GenerateTableFetch() {
    final Set<Relationship> r = new HashSet<>();
    r.add(REL_SUCCESS);
    r.add(REL_FAILURE);
    relationships = Collections.unmodifiableSet(r);

    final List<PropertyDescriptor> pds = new ArrayList<>();
    pds.add(DBCP_SERVICE);
    pds.add(DB_TYPE);
    pds.add(TABLE_NAME);
    pds.add(COLUMN_NAMES);
    pds.add(MAX_VALUE_COLUMN_NAMES);
    pds.add(QUERY_TIMEOUT);
    pds.add(PARTITION_SIZE);
    propDescriptors = Collections.unmodifiableList(pds);
}
 
Example #11
Source File: AuthorizeParameterReference.java    From nifi with Apache License 2.0 6 votes vote down vote up
/**
 * If any parameter is referenced by the given component node, will authorize user against the given group's Parameter context
 * @param destinationGroup the group that the component is being moved to
 * @param component the component being moved
 * @param authorizer the authorizer
 * @param user the nifi user
 */
public static void authorizeParameterReferences(final ProcessGroup destinationGroup, final ComponentAuthorizable component, final Authorizer authorizer, final NiFiUser user) {
    final ParameterParser parameterParser = new ExpressionLanguageAgnosticParameterParser();

    boolean referencesParameter = false;
    for (final PropertyDescriptor propertyDescriptor : component.getPropertyDescriptors()) {
        final String rawValue = component.getRawValue(propertyDescriptor);

        final ParameterTokenList tokenList = parameterParser.parseTokens(rawValue);
        if (!tokenList.toReferenceList().isEmpty()) {
            referencesParameter = true;
            break;
        }
    }

    if (referencesParameter) {
        final ParameterContext destinationContext = destinationGroup.getParameterContext();
        if (destinationContext != null) {
            destinationContext.authorize(authorizer, RequestAction.READ, user);
        }
    }
}
 
Example #12
Source File: DistributedMapCacheLookupService.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String propertyDescriptorName) {
    return new PropertyDescriptor.Builder()
        .name(propertyDescriptorName)
        .required(false)
        .dynamic(true)
        .addValidator(Validator.VALID)
        .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
        .build();
}
 
Example #13
Source File: NotificationValidationContext.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, String> getAllProperties() {
    final Map<String,String> propValueMap = new LinkedHashMap<>();
    for (final Map.Entry<PropertyDescriptor, String> entry : getProperties().entrySet()) {
        propValueMap.put(entry.getKey().getName(), entry.getValue());
    }
    return propValueMap;
}
 
Example #14
Source File: ConvertExcelToCSVProcessor.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
protected void init(final ProcessorInitializationContext context) {
    final List<PropertyDescriptor> descriptors = new ArrayList<>();
    descriptors.add(DESIRED_SHEETS);
    descriptors.add(ROWS_TO_SKIP);
    descriptors.add(COLUMNS_TO_SKIP);
    descriptors.add(FORMAT_VALUES);

    descriptors.add(CSVUtils.CSV_FORMAT);
    descriptors.add(CSVUtils.VALUE_SEPARATOR);
    descriptors.add(CSVUtils.INCLUDE_HEADER_LINE);
    descriptors.add(CSVUtils.QUOTE_CHAR);
    descriptors.add(CSVUtils.ESCAPE_CHAR);
    descriptors.add(CSVUtils.COMMENT_MARKER);
    descriptors.add(CSVUtils.NULL_STRING);
    descriptors.add(CSVUtils.TRIM_FIELDS);
    descriptors.add(new PropertyDescriptor.Builder()
            .fromPropertyDescriptor(CSVUtils.QUOTE_MODE)
            .defaultValue(CSVUtils.QUOTE_NONE.getValue())
            .build());
    descriptors.add(CSVUtils.RECORD_SEPARATOR);
    descriptors.add(CSVUtils.TRAILING_DELIMITER);
    this.descriptors = Collections.unmodifiableList(descriptors);

    final Set<Relationship> relationships = new HashSet<>();
    relationships.add(ORIGINAL);
    relationships.add(SUCCESS);
    relationships.add(FAILURE);
    this.relationships = Collections.unmodifiableSet(relationships);
}
 
Example #15
Source File: ReportingTaskAuditor.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Locates the actual property descriptor for the given spec property descriptor.
 *
 * @param propertyDescriptors properties
 * @param specDescriptor example property
 * @return property
 */
private PropertyDescriptor locatePropertyDescriptor(Set<PropertyDescriptor> propertyDescriptors, PropertyDescriptor specDescriptor) {
    for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
        if (propertyDescriptor.equals(specDescriptor)) {
            return propertyDescriptor;
        }
    }
    return specDescriptor;
}
 
Example #16
Source File: NotificationValidationContext.java    From nifi with Apache License 2.0 5 votes vote down vote up
public NotificationValidationContext(final NotificationContext processContext, VariableRegistry variableRegistry) {
    this.context = processContext;

    final Map<PropertyDescriptor, String> properties = processContext.getProperties();
    expressionLanguageSupported = new HashMap<>(properties.size());
    for (final PropertyDescriptor descriptor : properties.keySet()) {
        expressionLanguageSupported.put(descriptor.getName(), descriptor.isExpressionLanguageSupported());
    }
    this.variableRegistry = variableRegistry;
}
 
Example #17
Source File: AbstractPutHBase.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String propertyDescriptorName) {
    if (propertyDescriptorName.startsWith("visibility.")) {
        String[] parts = propertyDescriptorName.split("\\.");
        String displayName;
        String description;

        if (parts.length == 2) {
            displayName = String.format("Column Family %s Default Visibility", parts[1]);
            description = String.format("Default visibility setting for %s", parts[1]);
        } else if (parts.length == 3) {
            displayName = String.format("Column Qualifier %s.%s Default Visibility", parts[1], parts[2]);
            description = String.format("Default visibility setting for %s.%s", parts[1], parts[2]);
        } else {
            return null;
        }

        return new PropertyDescriptor.Builder()
            .name(propertyDescriptorName)
            .displayName(displayName)
            .description(description)
            .addValidator(StandardValidators.NON_BLANK_VALIDATOR)
            .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
            .dynamic(true)
            .build();
    }

    return null;
}
 
Example #18
Source File: ReportLineageToAtlas.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(String propertyDescriptorName) {
    for (NamespaceResolver resolver : namespaceResolverLoader) {
        final PropertyDescriptor propertyDescriptor = resolver.getSupportedDynamicPropertyDescriptor(propertyDescriptorName);
        if(propertyDescriptor != null) {
            return propertyDescriptor;
        }
    }
    return null;
}
 
Example #19
Source File: TestZooKeeperStateProvider.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
private void initializeProvider(final ZooKeeperStateProvider provider, final Map<PropertyDescriptor, String> properties) throws IOException {
    provider.initialize(new StateProviderInitializationContext() {
        @Override
        public String getIdentifier() {
            return "Unit Test Provider Initialization Context";
        }

        @Override
        public Map<PropertyDescriptor, PropertyValue> getProperties() {
            final Map<PropertyDescriptor, PropertyValue> propValueMap = new HashMap<>();
            for (final Map.Entry<PropertyDescriptor, String> entry : properties.entrySet()) {
                propValueMap.put(entry.getKey(), new StandardPropertyValue(entry.getValue(), null));
            }
            return propValueMap;
        }

        @Override
        public PropertyValue getProperty(final PropertyDescriptor property) {
            final String prop = properties.get(property);
            return new StandardPropertyValue(prop, null);
        }

        @Override
        public SSLContext getSSLContext() {
            return null;
        }
    });
}
 
Example #20
Source File: UpdateAttribute.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
private Map<String, Action> getDefaultActions(final Map<PropertyDescriptor, String> properties) {
    final Map<String, Action> defaultActions = new HashMap<>();

    for (final Map.Entry<PropertyDescriptor, String> entry : properties.entrySet()) {
        if(entry.getKey() != STORE_STATE && entry.getKey() != STATEFUL_VARIABLES_INIT_VALUE) {
            final Action action = new Action();
            action.setAttribute(entry.getKey().getName());
            action.setValue(entry.getValue());
            defaultActions.put(action.getAttribute(), action);
        }
    }

    return defaultActions;
}
 
Example #21
Source File: CredentialsFactoryTest.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testJsonFileCredentials() throws Exception {
    final TestRunner runner = TestRunners.newTestRunner(MockCredentialsFactoryProcessor.class);
    runner.setProperty(CredentialPropertyDescriptors.SERVICE_ACCOUNT_JSON_FILE,
            "src/test/resources/mock-gcp-service-account.json");
    runner.assertValid();

    Map<PropertyDescriptor, String> properties = runner.getProcessContext().getProperties();
    final CredentialsFactory factory = new CredentialsFactory();
    final GoogleCredentials credentials = factory.getGoogleCredentials(properties);

    assertNotNull(credentials);
    assertEquals("credentials class should be equal", ServiceAccountCredentials.class,
            credentials.getClass());
}
 
Example #22
Source File: TailFile.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
    final List<PropertyDescriptor> properties = new ArrayList<>();
    properties.add(MODE);
    properties.add(FILENAME);
    properties.add(ROLLING_FILENAME_PATTERN);
    properties.add(BASE_DIRECTORY);
    properties.add(START_POSITION);
    properties.add(STATE_LOCATION);
    properties.add(RECURSIVE);
    properties.add(LOOKUP_FREQUENCY);
    properties.add(MAXIMUM_AGE);
    return properties;
}
 
Example #23
Source File: ITestSFTPTransferWithSSHTestServer.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testPutWithLastModifiedTime() throws IOException, ParseException {
    final String permissions = "rw-rw-rw-";
    final String lastModifiedTime = "2019-09-01T11:11:11-0500";

    final DateFormat formatter = new SimpleDateFormat(SFTPTransfer.FILE_MODIFY_DATE_ATTR_FORMAT, Locale.US);
    final long expectedLastModifiedTime = formatter.parse(lastModifiedTime).getTime();

    final Map<PropertyDescriptor, String> properties = createBaseProperties();
    properties.put(SFTPTransfer.PERMISSIONS, permissions);
    properties.put(SFTPTransfer.LAST_MODIFIED_TIME, lastModifiedTime);

    final String filename = "test-put-simple.txt";
    final String fileContent = "this is a test";

    try(final SFTPTransfer transfer = createSFTPTransfer(properties);
        final InputStream in = new ByteArrayInputStream(fileContent.getBytes(StandardCharsets.UTF_8))) {

        // Verify file does not already exist
        final FileInfo fileInfoBefore = transfer.getRemoteFileInfo(null, DIR_4, filename);
        assertNull(fileInfoBefore);

        final String fullPath = transfer.put(null, DIR_4, filename, in);
        assertNotNull(fullPath);

        // Verify file now exists
        final FileInfo fileInfoAfter = transfer.getRemoteFileInfo(null, DIR_4, filename);
        assertNotNull(fileInfoAfter);
        assertEquals(permissions, fileInfoAfter.getPermissions());
        assertEquals(expectedLastModifiedTime, fileInfoAfter.getLastModifiedTime());
    }
}
 
Example #24
Source File: PutSFTP.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
protected void init(final ProcessorInitializationContext context) {
    final List<PropertyDescriptor> properties = new ArrayList<>();
    properties.add(SFTPTransfer.HOSTNAME);
    properties.add(SFTPTransfer.PORT);
    properties.add(SFTPTransfer.USERNAME);
    properties.add(SFTPTransfer.PASSWORD);
    properties.add(SFTPTransfer.PRIVATE_KEY_PATH);
    properties.add(SFTPTransfer.PRIVATE_KEY_PASSPHRASE);
    properties.add(SFTPTransfer.REMOTE_PATH);
    properties.add(SFTPTransfer.CREATE_DIRECTORY);
    properties.add(SFTPTransfer.DISABLE_DIRECTORY_LISTING);
    properties.add(SFTPTransfer.BATCH_SIZE);
    properties.add(SFTPTransfer.CONNECTION_TIMEOUT);
    properties.add(SFTPTransfer.DATA_TIMEOUT);
    properties.add(SFTPTransfer.CONFLICT_RESOLUTION);
    properties.add(SFTPTransfer.REJECT_ZERO_BYTE);
    properties.add(SFTPTransfer.DOT_RENAME);
    properties.add(SFTPTransfer.TEMP_FILENAME);
    properties.add(SFTPTransfer.HOST_KEY_FILE);
    properties.add(SFTPTransfer.LAST_MODIFIED_TIME);
    properties.add(SFTPTransfer.PERMISSIONS);
    properties.add(SFTPTransfer.REMOTE_OWNER);
    properties.add(SFTPTransfer.REMOTE_GROUP);
    properties.add(SFTPTransfer.STRICT_HOST_KEY_CHECKING);
    properties.add(SFTPTransfer.USE_KEEPALIVE_ON_TIMEOUT);
    properties.add(SFTPTransfer.USE_COMPRESSION);
    properties.add(SFTPTransfer.PROXY_CONFIGURATION_SERVICE);
    properties.add(FTPTransfer.PROXY_TYPE);
    properties.add(FTPTransfer.PROXY_HOST);
    properties.add(FTPTransfer.PROXY_PORT);
    properties.add(FTPTransfer.HTTP_PROXY_USERNAME);
    properties.add(FTPTransfer.HTTP_PROXY_PASSWORD);
    this.properties = Collections.unmodifiableList(properties);
}
 
Example #25
Source File: KafkaRecordSink_2_0.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String propertyDescriptorName) {
    return new PropertyDescriptor.Builder()
            .description("Specifies the value for '" + propertyDescriptorName + "' Kafka Configuration.")
            .name(propertyDescriptorName)
            .addValidator(new KafkaProcessorUtils.KafkaConfigValidator(ProducerConfig.class))
            .dynamic(true)
            .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
            .build();
}
 
Example #26
Source File: MockConfigurationContext.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
public MockConfigurationContext(final ControllerService service,
        final Map<PropertyDescriptor, String> properties,
        final ControllerServiceLookup serviceLookup,
        final VariableRegistry variableRegistry) {
    this.service = service;
    this.properties = properties;
    this.serviceLookup = serviceLookup;
    this.variableRegistry = variableRegistry;
}
 
Example #27
Source File: PartitionRecord.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String propertyDescriptorName) {
    return new PropertyDescriptor.Builder()
        .name(propertyDescriptorName)
        .dynamic(true)
        .required(false)
        .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
        .addValidator(new RecordPathValidator())
        .build();
}
 
Example #28
Source File: AbstractEasyRulesEngineController.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Custom validation for ensuring exactly one of Script File or Script Body is populated
 *
 * @param validationContext provides a mechanism for obtaining externally
 *                          managed values, such as property values and supplies convenience methods
 *                          for operating on those values
 * @return A collection of validation results
 */
@Override
public Collection<ValidationResult> customValidate(ValidationContext validationContext) {
    Set<ValidationResult> results = new HashSet<>();

    // Verify that exactly one of "script file" or "script body" is set
    Map<PropertyDescriptor, String> propertyMap = validationContext.getProperties();
    if (StringUtils.isEmpty(propertyMap.get(RULES_FILE_PATH)) == StringUtils.isEmpty(propertyMap.get(RULES_BODY))) {
        results.add(new ValidationResult.Builder().subject("Rules Body or Rules File").valid(false).explanation(
                "exactly one of Rules File or Rules Body must be set").build());
    }
    return results;
}
 
Example #29
Source File: TestReportLineageToAtlas.java    From nifi with Apache License 2.0 5 votes vote down vote up
private void testNotificationSendingIsSynchronous(Map<PropertyDescriptor, String> properties) throws Exception {
    ConfigurationContext configurationContext = new MockConfigurationContext(properties, null);

    testSubject.initialize(initializationContext);
    testSubject.setup(configurationContext);

    Configuration atlasProperties = ApplicationProperties.get();
    boolean isAsync = atlasProperties.getBoolean(AtlasHook.ATLAS_NOTIFICATION_ASYNCHRONOUS, Boolean.TRUE);
    assertFalse(isAsync);
}
 
Example #30
Source File: UpdateCounter.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Override
protected void init(final ProcessorInitializationContext context) {
    final List<PropertyDescriptor> descriptors = new ArrayList<>();
    descriptors.add(COUNTER_NAME);
    descriptors.add(DELTA);
    this.descriptors = Collections.unmodifiableList(descriptors);

    final Set<Relationship> relationships = new HashSet<>();
    relationships.add(SUCCESS);
    this.relationships = Collections.unmodifiableSet(relationships);
}