当前位置: 首页>>代码示例>>Java>>正文


Java ValidationContext类代码示例

本文整理汇总了Java中org.apache.nifi.components.ValidationContext的典型用法代码示例。如果您正苦于以下问题:Java ValidationContext类的具体用法?Java ValidationContext怎么用?Java ValidationContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ValidationContext类属于org.apache.nifi.components包,在下文中一共展示了ValidationContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validate

import org.apache.nifi.components.ValidationContext; //导入依赖的package包/类
@Override
public ValidationResult validate(String subject, String input, ValidationContext context) {
    String libDirPath = context.getProperty(CLIENT_LIB_DIR_PATH).getValue();
    StringBuilder invalidationMessageBuilder = new StringBuilder();
    if (libDirPath != null) {
        File file = new File(libDirPath);
        if (!file.isDirectory()) {
            invalidationMessageBuilder.append("'MQ Client Libraries path' must point to a directory. Was '"
                    + file.getAbsolutePath() + "'.");
        }
    } else {
        invalidationMessageBuilder.append("'MQ Client Libraries path' must be provided. \n");
    }
    String invalidationMessage = invalidationMessageBuilder.toString();
    ValidationResult vResult;
    if (invalidationMessage.length() == 0) {
        vResult = new ValidationResult.Builder().subject(subject).input(input)
                .explanation("Client lib path is valid and points to a directory").valid(true).build();
    } else {
        vResult = new ValidationResult.Builder().subject(subject).input(input)
                .explanation("Client lib path is invalid. " + invalidationMessage)
                .valid(false).build();
    }
    return vResult;
}
 
开发者ID:lsac,项目名称:nifi-jms-jndi,代码行数:26,代码来源:JMSConnectionFactoryProviderDefinition.java

示例2: customValidate

import org.apache.nifi.components.ValidationContext; //导入依赖的package包/类
@Override
protected Collection<ValidationResult> customValidate(ValidationContext validationContext) {
    final Collection<ValidationResult> results = new ArrayList<>();

    parseAtlasUrls(validationContext.getProperty(ATLAS_URLS), input -> {
        final ValidationResult.Builder builder = new ValidationResult.Builder().subject(ATLAS_URLS.getDisplayName()).input(input);
        try {
            new URL(input);
            results.add(builder.explanation("Valid URI").valid(true).build());
        } catch (Exception e) {
            results.add(builder.explanation("Contains invalid URI: " + e).valid(false).build());
        }
    });

    clusterResolverLoader.forEach(resolver -> results.addAll(resolver.validate(validationContext)));

    return results;
}
 
开发者ID:bcgov,项目名称:nifi-atlas,代码行数:19,代码来源:AtlasNiFiFlowLineage.java

示例3: validate

import org.apache.nifi.components.ValidationContext; //导入依赖的package包/类
@Override
public Collection<ValidationResult> validate(ValidationContext validationContext) {
    final List<ValidationResult> validationResults = new ArrayList<>();
    consumeConfigurations(validationContext.getAllProperties(),
            (clusterNamePatterns, patterns) -> {},
            (entry, e) -> {
                final ValidationResult result = new ValidationResult.Builder()
                        .subject(entry.getKey())
                        .input(entry.getValue())
                        .explanation(e.getMessage())
                        .valid(false)
                        .build();
                validationResults.add(result);
            });
    return validationResults;
}
 
开发者ID:bcgov,项目名称:nifi-atlas,代码行数:17,代码来源:RegexClusterResolver.java

示例4: customValidate

import org.apache.nifi.components.ValidationContext; //导入依赖的package包/类
@Override
protected Collection<ValidationResult> customValidate(final ValidationContext context) {
    final Collection<ValidationResult> results = new ArrayList<>();

    PropertyValue usernameProperty = context.getProperty(USERNAME);
    PropertyValue passwordProperty = context.getProperty(PASSWORD);
    PropertyValue authDatabaseProperty = context.getProperty(AUTH_DATABASE);

    boolean valid = true;
    if (usernameProperty.isSet() || passwordProperty.isSet() || authDatabaseProperty.isSet()) {
        valid = usernameProperty.isSet() && passwordProperty.isSet() && authDatabaseProperty.isSet();
    }

    results.add(new ValidationResult.Builder()
            .explanation("Using authentication requires Username, Password, and the Authentication Database")
            .valid(valid)
            .subject("Mongo Authentication")
            .build());

    return results;
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:22,代码来源:StandardMongoClientService.java

示例5: customValidate

import org.apache.nifi.components.ValidationContext; //导入依赖的package包/类
@Override
protected Collection<ValidationResult> customValidate(ValidationContext validationContext) {
    boolean zkQuorumProvided = validationContext.getProperty(ZOOKEEPER_QUORUM).isSet();
    boolean instanceNamerovided = validationContext.getProperty(INSTANCE_NAME).isSet();
    boolean userProvided = validationContext.getProperty(USER).isSet();
    boolean passwordProvided = validationContext.getProperty(PASSWORD).isSet();

    final List<ValidationResult> problems = new ArrayList<>();

    if (!zkQuorumProvided && (!instanceNamerovided || !userProvided || !passwordProvided)) {
        problems.add(new ValidationResult.Builder()
                .valid(false)
                .subject(this.getClass().getSimpleName())
                .explanation("ZooKeeper Quorum, Instance Name, Accumulo User, and Accumulo Password are required " +
                        "to connect")
                .build());
    }
    return problems;
}
 
开发者ID:pinkdevelops,项目名称:nifi-accumulo-service,代码行数:20,代码来源:Accumulo_1_7_0_ConnectorService.java

示例6: validate

import org.apache.nifi.components.ValidationContext; //导入依赖的package包/类
@Override
public ValidationResult validate(String subject, String input, ValidationContext context) {
    try {
        JSONUtils.INSTANCE.load(input, new TypeReference<Map<String, String>>() {
        });
    } catch (IOException e) {
        return new ValidationResult.Builder()
                .subject(subject)
                .input(value)
                .valid(false)
                .explanation("Not a valid JSON map value: " + e.getMessage())
                .build();
    }
    return new ValidationResult.Builder()
            .valid(true)
            .input(value)
            .subject(subject)
            .build();
}
 
开发者ID:mmiklavc,项目名称:scalable-ocr,代码行数:20,代码来源:JsonValidator.java

示例7: customValidate

import org.apache.nifi.components.ValidationContext; //导入依赖的package包/类
@Override
protected Collection<ValidationResult> customValidate(
		final ValidationContext validationContext) {
	final List<ValidationResult> results = new ArrayList<>();
	final String endpointName = validationContext.getProperty(ENDPOINT)
			.getValue();

	if (ENDPOINT_FILTER.getValue().equals(endpointName)) {
		if (!validationContext.getProperty(TERMS).isSet()
				&& !validationContext.getProperty(FOLLOWING).isSet()
				&& !validationContext.getProperty(LOCATIONS).isSet()) {
			results.add(new ValidationResult.Builder()
					.input("")
					.subject(FOLLOWING.getName())
					.valid(false)
					.explanation(
							"When using the 'Filter Endpoint', at least one of '"
									+ TERMS.getName() + "' or '"
									+ FOLLOWING.getName() + "'" + "' or '"
									+ LOCATIONS.getName() + " must be set")
					.build());
		}
	}

	return results;
}
 
开发者ID:simonellistonball,项目名称:nifi-GetTwitterWithProxy,代码行数:27,代码来源:GetTwitterWithProxy.java

示例8: customValidate

import org.apache.nifi.components.ValidationContext; //导入依赖的package包/类
@Override
protected Collection<ValidationResult> customValidate(ValidationContext validationContext) {
    final List<ValidationResult> results = new ArrayList<>(1);

    ObjectMapper mapper = new ObjectMapper();

    JsonNode rootNode = null;
    try {
        rootNode = mapper.readValue(new File(validationContext.getProperty(GENERATOR_RESOURCE).getValue()), JsonNode.class);

        generator = new RecordGenerator(rootNode);

    } catch (IOException ioe) {
        results.add(new ValidationResult.Builder().subject("Generator Resource").valid(false).explanation("Couldn't read specified resource").build());
    }

    return results;
}
 
开发者ID:dstreev,项目名称:nifi-processor-examples,代码行数:19,代码来源:GenerateRecordProcessor.java

示例9: validate

import org.apache.nifi.components.ValidationContext; //导入依赖的package包/类
@Override
public Collection<ValidationResult> validate(ValidationContext validationContext) {
    Collection<ValidationResult> results = new ArrayList<>();
    for (ClusterResolver resolver : resolvers) {
        results.addAll(resolver.validate(validationContext));
    }
    return results;
}
 
开发者ID:bcgov,项目名称:nifi-atlas,代码行数:9,代码来源:ClusterResolvers.java

示例10: validate

import org.apache.nifi.components.ValidationContext; //导入依赖的package包/类
@Override
        public ValidationResult validate(final String subject, final String value, final ValidationContext context) {
            String reason = null;
            try {
                Object root = JSON.parse(value);
                if (!(root instanceof BasicDBList)) {
                    reason = "not a valid JsonArray";
                }
            } catch (Exception e) {
//                LOGGER.debug("not a valid JSON list", e);
                reason = "unable to parse JSON";
            }
            return new ValidationResult.Builder().subject(subject).input(value).explanation(reason).valid(reason == null).build();
        }
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:15,代码来源:MongoProps.java

示例11: customValidate

import org.apache.nifi.components.ValidationContext; //导入依赖的package包/类
@Override
protected Collection<ValidationResult> customValidate(final ValidationContext validationContext) {
    List<ValidationResult> results = new ArrayList<>();

    if (validationContext.getProperty(INSERT_COMMAND_SOURCE).getValue().equals("attribute")) {
        results.add(StandardValidators.NON_BLANK_VALIDATOR.validate(
                INSERT_COMMAND_ATTRIBUTE.getName(),
                validationContext.getProperty(INSERT_COMMAND_ATTRIBUTE).getValue(),
                validationContext));
    }

    return results;
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:14,代码来源:StoreInMongo.java

示例12: customValidate

import org.apache.nifi.components.ValidationContext; //导入依赖的package包/类
/**
 * 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
 */
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(ScriptingComponentUtils.SCRIPT_FILE)) == StringUtils.isEmpty(propertyMap.get(ScriptingComponentUtils.SCRIPT_BODY))) {
        results.add(new ValidationResult.Builder().valid(false).explanation(
                "Exactly one of Script File or Script Body must be set").build());
    }

    return results;
}
 
开发者ID:mattyb149,项目名称:nifi-script-tester,代码行数:21,代码来源:ScriptingComponentHelper.java

示例13: validate

import org.apache.nifi.components.ValidationContext; //导入依赖的package包/类
default Collection<ValidationResult> validate(final ValidationContext validationContext) {
    return Collections.emptySet();
}
 
开发者ID:bcgov,项目名称:nifi-atlas,代码行数:4,代码来源:ClusterResolver.java

示例14: setupMock

import org.apache.nifi.components.ValidationContext; //导入依赖的package包/类
public void setupMock(Map<String, String> properties) {
    context = Mockito.mock(PropertyContext.class);
    validationContext = Mockito.mock(ValidationContext.class);
    when(validationContext.getAllProperties()).thenReturn(properties);
    when(context.getAllProperties()).thenReturn(properties);
}
 
开发者ID:bcgov,项目名称:nifi-atlas,代码行数:7,代码来源:TestRegexClusterResolver.java

示例15: validate

import org.apache.nifi.components.ValidationContext; //导入依赖的package包/类
@Override
public ValidationResult validate(String subject, String input, ValidationContext context) {
    return validator.validate(subject, input, context);
}
 
开发者ID:mmiklavc,项目名称:scalable-ocr,代码行数:5,代码来源:Validation.java


注:本文中的org.apache.nifi.components.ValidationContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。