/** * Returns the whitelisted proxy hostnames (and IP addresses) as a comma-delimited string. * The hosts have been normalized to the form {@code somehost.com}, {@code somehost.com:port}, or {@code 127.0.0.1}. * <p> * Note: Calling {@code NiFiProperties.getProperty(NiFiProperties.WEB_PROXY_HOST)} will not normalize the hosts. * * @return the hostname(s) */ public String getWhitelistedHosts() { return StringUtils.join(getWhitelistedHostsAsList(), ","); }
/** * Returns the whitelisted proxy context paths as a comma-delimited string. The paths have been normalized to the form {@code /some/context/path}. * <p> * Note: Calling {@code NiFiProperties.getProperty(NiFiProperties.WEB_PROXY_CONTEXT_PATH)} will not normalize the paths. * * @return the path(s) */ public String getWhitelistedContextPaths() { return StringUtils.join(getWhitelistedContextPathsAsList(), ","); }
private String generateMetricsMessage() { StringBuilder sb = new StringBuilder("Counted "); List<String> metrics = new ArrayList<>(); if (countLines) { metrics.add(lineCount + " lines"); } if (countLinesNonEmpty) { metrics.add(lineNonEmptyCount + " non-empty lines"); } if (countWords) { metrics.add(wordCount + " words"); } if (countCharacters) { metrics.add(characterCount + " characters"); } sb.append(StringUtils.join(metrics, ", ")); return sb.toString(); }
private static boolean checkControllerServiceEligibility(Class extensionType) { final Class originalExtensionType = extensionType; final ClassLoader originalExtensionClassLoader = extensionType.getClassLoader(); // if the extension does not require instance classloading, its eligible final boolean requiresInstanceClassLoading = extensionType.isAnnotationPresent(RequiresInstanceClassLoading.class); final Set<Class> cobundledApis = new HashSet<>(); while (extensionType != null) { for (final Class i : extensionType.getInterfaces()) { if (originalExtensionClassLoader.equals(i.getClassLoader())) { cobundledApis.add(i); } } extensionType = extensionType.getSuperclass(); } if (!cobundledApis.isEmpty()) { logger.warn(String.format("Controller Service %s is bundled with its supporting APIs %s. The service APIs should not be bundled with the implementations.", originalExtensionType.getName(), StringUtils.join(cobundledApis.stream().map(cls -> cls.getName()).collect(Collectors.toSet()), ", "))); } // the service is eligible when it does not require instance classloading or when the supporting APIs are bundled in a parent NAR return requiresInstanceClassLoading == false || cobundledApis.isEmpty(); }
private static boolean checkControllerServiceReferenceEligibility(final ConfigurableComponent component, final ClassLoader classLoader) { // if the extension does not require instance classloading, its eligible final boolean requiresInstanceClassLoading = component.getClass().isAnnotationPresent(RequiresInstanceClassLoading.class); final Set<Class> cobundledApis = new HashSet<>(); try (final NarCloseable closeable = NarCloseable.withComponentNarLoader(component.getClass().getClassLoader())) { final List<PropertyDescriptor> descriptors = component.getPropertyDescriptors(); if (descriptors != null && !descriptors.isEmpty()) { for (final PropertyDescriptor descriptor : descriptors) { final Class<? extends ControllerService> serviceApi = descriptor.getControllerServiceDefinition(); if (serviceApi != null && classLoader.equals(serviceApi.getClassLoader())) { cobundledApis.add(serviceApi); } } } } if (!cobundledApis.isEmpty()) { logger.warn(String.format( "Component %s is bundled with its referenced Controller Service APIs %s. The service APIs should not be bundled with component implementations that reference it.", component.getClass().getName(), StringUtils.join(cobundledApis.stream().map(cls -> cls.getName()).collect(Collectors.toSet()), ", "))); } // the component is eligible when it does not require instance classloading or when the supporting APIs are bundled in a parent NAR return requiresInstanceClassLoading == false || cobundledApis.isEmpty(); }
int countWordsInLine(String line, boolean splitWordsOnSymbols) throws IOException { if (line == null || line.trim().length() == 0) { return 0; } else { Pattern regex = splitWordsOnSymbols ? SYMBOL_PATTERN : WHITESPACE_ONLY_PATTERN; final String[] words = regex.split(line); // TODO: Trim individual words before counting to eliminate whitespace words? if (getLogger().isDebugEnabled()) { getLogger().debug("Split [" + line + "] to [" + StringUtils.join(Arrays.asList(words), ", ") + "] (" + words.length + ")"); } return words.length; } }
@Override public ValidationResult validate(final String subject, final String input, final ValidationContext context) { final ValidationResult.Builder builder = new ValidationResult.Builder(); builder.subject(subject).input(input); if (context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(input)) { return builder.valid(true).explanation("Contains Expression Language").build(); } if(TYPES.contains(input.toUpperCase())) { builder.valid(true); } else { builder.valid(false).explanation("Load File Type must be one of the following options: " + StringUtils.join(TYPES, ", ")); } return builder.build(); } };
/** * Returns the whitelisted proxy hostnames (and IP addresses) as a comma-delimited string. * The hosts have been normalized to the form {@code somehost.com}, {@code somehost.com:port}, or {@code 127.0.0.1}. * <p> * Note: Calling {@code NiFiProperties.getProperty(NiFiProperties.WEB_PROXY_HOST)} will not normalize the hosts. * * @return the hostname(s) */ public String getWhitelistedHosts() { return StringUtils.join(getWhitelistedHostsAsList(), ","); }
/** * Returns the whitelisted proxy context paths as a comma-delimited string. The paths have been normalized to the form {@code /some/context/path}. * <p> * Note: Calling {@code NiFiProperties.getProperty(NiFiProperties.WEB_PROXY_CONTEXT_PATH)} will not normalize the paths. * * @return the path(s) */ public String getWhitelistedContextPaths() { return StringUtils.join(getWhitelistedContextPathsAsList(), ","); }
private String generateMetricsMessage() { StringBuilder sb = new StringBuilder("Counted "); List<String> metrics = new ArrayList<>(); if (countLines) { metrics.add(lineCount + " lines"); } if (countLinesNonEmpty) { metrics.add(lineNonEmptyCount + " non-empty lines"); } if (countWords) { metrics.add(wordCount + " words"); } if (countCharacters) { metrics.add(characterCount + " characters"); } sb.append(StringUtils.join(metrics, ", ")); return sb.toString(); }
private static boolean checkControllerServiceEligibility(Class extensionType) { final Class originalExtensionType = extensionType; final ClassLoader originalExtensionClassLoader = extensionType.getClassLoader(); // if the extension does not require instance classloading, its eligible final boolean requiresInstanceClassLoading = extensionType.isAnnotationPresent(RequiresInstanceClassLoading.class); final Set<Class> cobundledApis = new HashSet<>(); while (extensionType != null) { for (final Class i : extensionType.getInterfaces()) { if (originalExtensionClassLoader.equals(i.getClassLoader())) { cobundledApis.add(i); } } extensionType = extensionType.getSuperclass(); } if (!cobundledApis.isEmpty()) { logger.warn(String.format("Controller Service %s is bundled with its supporting APIs %s. The service APIs should not be bundled with the implementations.", originalExtensionType.getName(), StringUtils.join(cobundledApis.stream().map(cls -> cls.getName()).collect(Collectors.toSet()), ", "))); } // the service is eligible when it does not require instance classloading or when the supporting APIs are bundled in a parent NAR return requiresInstanceClassLoading == false || cobundledApis.isEmpty(); }
private static boolean checkControllerServiceEligibility(Class extensionType) { final Class originalExtensionType = extensionType; final ClassLoader originalExtensionClassLoader = extensionType.getClassLoader(); // if the extension does not require instance classloading, its eligible final boolean requiresInstanceClassLoading = extensionType.isAnnotationPresent(RequiresInstanceClassLoading.class); final Set<Class> cobundledApis = new HashSet<>(); while (extensionType != null) { for (final Class i : extensionType.getInterfaces()) { if (originalExtensionClassLoader.equals(i.getClassLoader())) { cobundledApis.add(i); } } extensionType = extensionType.getSuperclass(); } if (!cobundledApis.isEmpty()) { logger.warn(String.format("Controller Service %s is bundled with its supporting APIs %s. The service APIs should not be bundled with the implementations.", originalExtensionType.getName(), StringUtils.join(cobundledApis.stream().map(cls -> cls.getName()).collect(Collectors.toSet()), ", "))); } // the service is eligible when it does not require instance classloading or when the supporting APIs are bundled in a parent NAR return requiresInstanceClassLoading == false || cobundledApis.isEmpty(); }
private static boolean checkControllerServiceReferenceEligibility(final ConfigurableComponent component, final ClassLoader classLoader) { // if the extension does not require instance classloading, its eligible final boolean requiresInstanceClassLoading = component.getClass().isAnnotationPresent(RequiresInstanceClassLoading.class); final Set<Class> cobundledApis = new HashSet<>(); try (final NarCloseable closeable = NarCloseable.withComponentNarLoader(component.getClass().getClassLoader())) { final List<PropertyDescriptor> descriptors = component.getPropertyDescriptors(); if (descriptors != null && !descriptors.isEmpty()) { for (final PropertyDescriptor descriptor : descriptors) { final Class<? extends ControllerService> serviceApi = descriptor.getControllerServiceDefinition(); if (serviceApi != null && classLoader.equals(serviceApi.getClassLoader())) { cobundledApis.add(serviceApi); } } } } if (!cobundledApis.isEmpty()) { logger.warn(String.format( "Component %s is bundled with its referenced Controller Service APIs %s. The service APIs should not be bundled with component implementations that reference it.", component.getClass().getName(), StringUtils.join(cobundledApis.stream().map(cls -> cls.getName()).collect(Collectors.toSet()), ", "))); } // the component is eligible when it does not require instance classloading or when the supporting APIs are bundled in a parent NAR return requiresInstanceClassLoading == false || cobundledApis.isEmpty(); }
private static boolean checkControllerServiceReferenceEligibility(final ConfigurableComponent component, final ClassLoader classLoader) { // if the extension does not require instance classloading, its eligible final boolean requiresInstanceClassLoading = component.getClass().isAnnotationPresent(RequiresInstanceClassLoading.class); final Set<Class> cobundledApis = new HashSet<>(); try (final NarCloseable closeable = NarCloseable.withComponentNarLoader(component.getClass().getClassLoader())) { final List<PropertyDescriptor> descriptors = component.getPropertyDescriptors(); if (descriptors != null && !descriptors.isEmpty()) { for (final PropertyDescriptor descriptor : descriptors) { final Class<? extends ControllerService> serviceApi = descriptor.getControllerServiceDefinition(); if (serviceApi != null && classLoader.equals(serviceApi.getClassLoader())) { cobundledApis.add(serviceApi); } } } } if (!cobundledApis.isEmpty()) { logger.warn(String.format( "Component %s is bundled with its referenced Controller Service APIs %s. The service APIs should not be bundled with component implementations that reference it.", component.getClass().getName(), StringUtils.join(cobundledApis.stream().map(cls -> cls.getName()).collect(Collectors.toSet()), ", "))); } // the component is eligible when it does not require instance classloading or when the supporting APIs are bundled in a parent NAR return requiresInstanceClassLoading == false || cobundledApis.isEmpty(); }
int countWordsInLine(String line, boolean splitWordsOnSymbols) throws IOException { if (line == null || line.trim().length() == 0) { return 0; } else { Pattern regex = splitWordsOnSymbols ? SYMBOL_PATTERN : WHITESPACE_ONLY_PATTERN; final String[] words = regex.split(line); // TODO: Trim individual words before counting to eliminate whitespace words? if (getLogger().isDebugEnabled()) { getLogger().debug("Split [" + line + "] to [" + StringUtils.join(Arrays.asList(words), ", ") + "] (" + words.length + ")"); } return words.length; } }