Search in sources :

Example 16 with StringUtils.isNotBlank

use of org.apache.commons.lang3.StringUtils.isNotBlank in project pulsar by yahoo.

the class NamespaceService method createLookupResult.

private CompletableFuture<LookupResult> createLookupResult(String candidateBroker) throws Exception {
    CompletableFuture<LookupResult> lookupFuture = new CompletableFuture<>();
    try {
        checkArgument(StringUtils.isNotBlank(candidateBroker), "Lookup broker can't be null " + candidateBroker);
        URI uri = new URI(candidateBroker);
        String path = String.format("%s/%s:%s", SimpleLoadManagerImpl.LOADBALANCE_BROKERS_ROOT, uri.getHost(), uri.getPort());
        pulsar.getLocalZkCache().getDataAsync(path, loadReportDeserializer).thenAccept(reportData -> {
            if (reportData.isPresent()) {
                LoadReport report = reportData.get();
                lookupFuture.complete(new LookupResult(report.getWebServiceUrl(), report.getWebServiceUrlTls(), report.getPulsarServiceUrl(), report.getPulsarServieUrlTls()));
            } else {
                lookupFuture.completeExceptionally(new KeeperException.NoNodeException(path));
            }
        }).exceptionally(ex -> {
            lookupFuture.completeExceptionally(ex);
            return null;
        });
    } catch (Exception e) {
        lookupFuture.completeExceptionally(e);
    }
    return lookupFuture;
}
Also used : URL(java.net.URL) LoggerFactory(org.slf4j.LoggerFactory) StringUtils(org.apache.commons.lang3.StringUtils) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) Matcher(java.util.regex.Matcher) Pair(org.apache.commons.lang3.tuple.Pair) Map(java.util.Map) PulsarService(com.yahoo.pulsar.broker.PulsarService) URI(java.net.URI) LocalPolicies(com.yahoo.pulsar.common.policies.data.LocalPolicies) DestinationName(com.yahoo.pulsar.common.naming.DestinationName) NamespaceBundleFactory.getBundlesData(com.yahoo.pulsar.common.naming.NamespaceBundleFactory.getBundlesData) Set(java.util.Set) StatCallback(org.apache.zookeeper.AsyncCallback.StatCallback) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) ObjectMapperFactory(com.yahoo.pulsar.common.util.ObjectMapperFactory) NamespaceIsolationPolicies(com.yahoo.pulsar.common.policies.impl.NamespaceIsolationPolicies) List(java.util.List) NamespaceBundles(com.yahoo.pulsar.common.naming.NamespaceBundles) AdminResource(com.yahoo.pulsar.broker.admin.AdminResource) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) LOCAL_POLICIES_ROOT(com.yahoo.pulsar.broker.cache.LocalZooKeeperCacheService.LOCAL_POLICIES_ROOT) PulsarWebResource.joinPath(com.yahoo.pulsar.broker.web.PulsarWebResource.joinPath) AdminResource.jsonMapper(com.yahoo.pulsar.broker.admin.AdminResource.jsonMapper) LoadManager(com.yahoo.pulsar.broker.loadbalance.LoadManager) BundlesData(com.yahoo.pulsar.common.policies.data.BundlesData) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) Hashing(com.google.common.hash.Hashing) LookupData(com.yahoo.pulsar.common.lookup.data.LookupData) SimpleLoadManagerImpl(com.yahoo.pulsar.broker.loadbalance.impl.SimpleLoadManagerImpl) SafeRun.safeRun(org.apache.bookkeeper.mledger.util.SafeRun.safeRun) NamespaceIsolationPolicy(com.yahoo.pulsar.common.policies.NamespaceIsolationPolicy) Lists(com.google.common.collect.Lists) LoadReport(com.yahoo.pulsar.common.policies.data.loadbalancer.LoadReport) Deserializer(com.yahoo.pulsar.zookeeper.ZooKeeperCache.Deserializer) Codec(com.yahoo.pulsar.common.util.Codec) NamespaceBundle(com.yahoo.pulsar.common.naming.NamespaceBundle) NamespaceBundleFactory(com.yahoo.pulsar.common.naming.NamespaceBundleFactory) BrokerAssignment(com.yahoo.pulsar.common.policies.data.BrokerAssignment) ServiceUnitId(com.yahoo.pulsar.common.naming.ServiceUnitId) Logger(org.slf4j.Logger) KeeperException(org.apache.zookeeper.KeeperException) LookupResult(com.yahoo.pulsar.broker.lookup.LookupResult) PulsarAdmin(com.yahoo.pulsar.client.admin.PulsarAdmin) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) NamespaceName(com.yahoo.pulsar.common.naming.NamespaceName) ServiceUnitNotReadyException(com.yahoo.pulsar.broker.service.BrokerServiceException.ServiceUnitNotReadyException) NamespaceOwnershipStatus(com.yahoo.pulsar.common.policies.data.NamespaceOwnershipStatus) ServiceConfiguration(com.yahoo.pulsar.broker.ServiceConfiguration) PulsarServerException(com.yahoo.pulsar.broker.PulsarServerException) CompletableFuture(java.util.concurrent.CompletableFuture) LoadReport(com.yahoo.pulsar.common.policies.data.loadbalancer.LoadReport) LookupResult(com.yahoo.pulsar.broker.lookup.LookupResult) URI(java.net.URI) KeeperException(org.apache.zookeeper.KeeperException) ServiceUnitNotReadyException(com.yahoo.pulsar.broker.service.BrokerServiceException.ServiceUnitNotReadyException) PulsarServerException(com.yahoo.pulsar.broker.PulsarServerException)

Example 17 with StringUtils.isNotBlank

use of org.apache.commons.lang3.StringUtils.isNotBlank in project Asqatasun by Asqatasun.

the class Rgaa30Rule110102 method check.

@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
    /* If the page has no input form element, the test is not applicable */
    if (inputFormMap.entrySet().isEmpty()) {
        testSolutionHandler.addTestSolution(TestSolution.NOT_APPLICABLE);
        return;
    }
    for (Map.Entry<Element, ElementHandler<Element>> entry : inputFormMap.entrySet()) {
        /* The attribute Presence Checker */
        ElementChecker attributePresenceChecker = new AttributePresenceChecker(ID_ATTR, new ImmutablePair(TestSolution.PASSED, ""), new ImmutablePair(TestSolution.FAILED, ID_MISSING_MSG));
        attributePresenceChecker.check(sspHandler, entry.getValue(), testSolutionHandler);
        /* The attribute Emptiness Checker. Keep default value i.e failed 
             when attribute is empty
             */
        ElementChecker attributeEmptinessChecker = new TextEmptinessChecker(new TextAttributeOfElementBuilder(ID_ATTR), ID_MISSING_MSG, null);
        attributeEmptinessChecker.check(sspHandler, entry.getValue(), testSolutionHandler);
        /* The id unicityChecker */
        ElementChecker idUnicityChecker = new IdUnicityChecker(ID_NOT_UNIQUE_MSG);
        idUnicityChecker.check(sspHandler, entry.getValue(), testSolutionHandler);
    }
    for (Map.Entry<Element, ElementHandler<Element>> entry : labelFormMap.entrySet()) {
        /* The attribute Presence Checker */
        ElementChecker attributePresenceChecker = new AttributePresenceChecker(FOR_ATTR, new ImmutablePair(TestSolution.PASSED, ""), new ImmutablePair(TestSolution.FAILED, FOR_MISSING_MSG));
        attributePresenceChecker.check(sspHandler, entry.getValue(), testSolutionHandler);
        /* The attribute Emptiness Checker. Keep default value i.e failed 
             when attribute is empty
             */
        ElementChecker attributeEmptinessChecker = new TextEmptinessChecker(new TextAttributeOfElementBuilder(FOR_ATTR), FOR_MISSING_MSG, null);
        attributeEmptinessChecker.check(sspHandler, entry.getValue(), testSolutionHandler);
    }
    for (Map.Entry<Element, ElementHandler<Element>> entry : inputFormMap.entrySet()) {
        ElementHandler<Element> inputOnError = new ElementHandlerImpl();
        /* Check if each input id attribute is linked to a for attribute*/
        for (Element el : entry.getValue().get()) {
            String id = el.id();
            if (StringUtils.isNotBlank(id)) {
                ElementHandler<Element> linkedLabelToInputHandler = new ElementHandlerImpl();
                if (entry.getKey().select(LABEL_ELEMENT + " " + CssLikeSelectorBuilder.buildSelectorFromElementsAndAttributeValue(INPUT_ELEMENT, ID_ATTR, id)).isEmpty()) {
                    linkedLabelToInputHandler.addAll(entry.getKey().select(CssLikeSelectorBuilder.buildSelectorFromElementsAndAttributeValue(LABEL_ELEMENT, FOR_ATTR, id)));
                    if (linkedLabelToInputHandler.isEmpty()) {
                        inputOnError.add(el);
                    }
                }
            }
        }
        ElementChecker elementPresenceChecker = new ElementPresenceChecker(new ImmutablePair(TestSolution.FAILED, INVALID_INPUT_MSG), new ImmutablePair(TestSolution.PASSED, ""));
        elementPresenceChecker.check(sspHandler, inputOnError, testSolutionHandler);
    }
    for (Map.Entry<Element, ElementHandler<Element>> entry : labelFormMap.entrySet()) {
        ElementHandler<Element> labelOnError = new ElementHandlerImpl();
        /* Check if each label for attribute is associated to an input id attribute*/
        for (Element el : entry.getValue().get()) {
            String id = el.attr(FOR_ATTR);
            if (StringUtils.isNotBlank(id)) {
                ElementHandler<Element> linkedLabelToInputHandler = new ElementHandlerImpl();
                linkedLabelToInputHandler.addAll(entry.getKey().select(CssLikeSelectorBuilder.buildSelectorFromId(id)));
                if (linkedLabelToInputHandler.isEmpty()) {
                    labelOnError.add(el);
                }
            }
        }
        ElementChecker elementPresenceChecker = new ElementPresenceChecker(new ImmutablePair(TestSolution.FAILED, INVALID_LABEL_MSG), new ImmutablePair(TestSolution.PASSED, ""));
        elementPresenceChecker.check(sspHandler, labelOnError, testSolutionHandler);
    }
}
Also used : ElementPresenceChecker(org.asqatasun.rules.elementchecker.element.ElementPresenceChecker) IdUnicityChecker(org.asqatasun.rules.elementchecker.attribute.IdUnicityChecker) Element(org.jsoup.nodes.Element) TextEmptinessChecker(org.asqatasun.rules.elementchecker.text.TextEmptinessChecker) ElementHandlerImpl(org.asqatasun.ruleimplementation.ElementHandlerImpl) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) TextAttributeOfElementBuilder(org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder) ElementHandler(org.asqatasun.ruleimplementation.ElementHandler) ElementChecker(org.asqatasun.rules.elementchecker.ElementChecker) AttributePresenceChecker(org.asqatasun.rules.elementchecker.attribute.AttributePresenceChecker) HashMap(java.util.HashMap) Map(java.util.Map)

Example 18 with StringUtils.isNotBlank

use of org.apache.commons.lang3.StringUtils.isNotBlank in project Asqatasun by Asqatasun.

the class Rgaa32016Rule110102 method check.

@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
    /* If the page has no input form element, the test is not applicable */
    if (inputFormMap.entrySet().isEmpty()) {
        testSolutionHandler.addTestSolution(TestSolution.NOT_APPLICABLE);
        return;
    }
    for (Map.Entry<Element, ElementHandler<Element>> entry : inputFormMap.entrySet()) {
        /* The attribute Presence Checker */
        ElementChecker attributePresenceChecker = new AttributePresenceChecker(ID_ATTR, new ImmutablePair(TestSolution.PASSED, ""), new ImmutablePair(TestSolution.FAILED, ID_MISSING_MSG));
        attributePresenceChecker.check(sspHandler, entry.getValue(), testSolutionHandler);
        /* The attribute Emptiness Checker. Keep default value i.e failed 
             when attribute is empty
             */
        ElementChecker attributeEmptinessChecker = new TextEmptinessChecker(new TextAttributeOfElementBuilder(ID_ATTR), ID_MISSING_MSG, null);
        attributeEmptinessChecker.check(sspHandler, entry.getValue(), testSolutionHandler);
        /* The id unicityChecker */
        ElementChecker idUnicityChecker = new IdUnicityChecker(ID_NOT_UNIQUE_MSG);
        idUnicityChecker.check(sspHandler, entry.getValue(), testSolutionHandler);
    }
    for (Map.Entry<Element, ElementHandler<Element>> entry : labelFormMap.entrySet()) {
        /* The attribute Presence Checker */
        ElementChecker attributePresenceChecker = new AttributePresenceChecker(FOR_ATTR, new ImmutablePair(TestSolution.PASSED, ""), new ImmutablePair(TestSolution.FAILED, FOR_MISSING_MSG));
        attributePresenceChecker.check(sspHandler, entry.getValue(), testSolutionHandler);
        /* The attribute Emptiness Checker. Keep default value i.e failed 
             when attribute is empty
             */
        ElementChecker attributeEmptinessChecker = new TextEmptinessChecker(new TextAttributeOfElementBuilder(FOR_ATTR), FOR_MISSING_MSG, null);
        attributeEmptinessChecker.check(sspHandler, entry.getValue(), testSolutionHandler);
    }
    for (Map.Entry<Element, ElementHandler<Element>> entry : inputFormMap.entrySet()) {
        ElementHandler<Element> inputOnError = new ElementHandlerImpl();
        /* Check if each input id attribute is linked to a for attribute*/
        for (Element el : entry.getValue().get()) {
            String id = el.id();
            if (StringUtils.isNotBlank(id)) {
                ElementHandler<Element> linkedLabelToInputHandler = new ElementHandlerImpl();
                if (entry.getKey().select(LABEL_ELEMENT + " " + CssLikeSelectorBuilder.buildSelectorFromElementsAndAttributeValue(INPUT_ELEMENT, ID_ATTR, id)).isEmpty()) {
                    linkedLabelToInputHandler.addAll(entry.getKey().select(CssLikeSelectorBuilder.buildSelectorFromElementsAndAttributeValue(LABEL_ELEMENT, FOR_ATTR, id)));
                    if (linkedLabelToInputHandler.isEmpty()) {
                        inputOnError.add(el);
                    }
                }
            }
        }
        ElementChecker elementPresenceChecker = new ElementPresenceChecker(new ImmutablePair(TestSolution.FAILED, INVALID_INPUT_MSG), new ImmutablePair(TestSolution.PASSED, ""));
        elementPresenceChecker.check(sspHandler, inputOnError, testSolutionHandler);
    }
    for (Map.Entry<Element, ElementHandler<Element>> entry : labelFormMap.entrySet()) {
        ElementHandler<Element> labelOnError = new ElementHandlerImpl();
        /* Check if each label for attribute is associated to an input id attribute*/
        for (Element el : entry.getValue().get()) {
            String id = el.attr(FOR_ATTR);
            if (StringUtils.isNotBlank(id)) {
                ElementHandler<Element> linkedLabelToInputHandler = new ElementHandlerImpl();
                linkedLabelToInputHandler.addAll(entry.getKey().select(CssLikeSelectorBuilder.buildSelectorFromId(id)));
                if (linkedLabelToInputHandler.isEmpty()) {
                    labelOnError.add(el);
                }
            }
        }
        ElementChecker elementPresenceChecker = new ElementPresenceChecker(new ImmutablePair(TestSolution.FAILED, INVALID_LABEL_MSG), new ImmutablePair(TestSolution.PASSED, ""));
        elementPresenceChecker.check(sspHandler, labelOnError, testSolutionHandler);
    }
}
Also used : ElementPresenceChecker(org.asqatasun.rules.elementchecker.element.ElementPresenceChecker) IdUnicityChecker(org.asqatasun.rules.elementchecker.attribute.IdUnicityChecker) Element(org.jsoup.nodes.Element) TextEmptinessChecker(org.asqatasun.rules.elementchecker.text.TextEmptinessChecker) ElementHandlerImpl(org.asqatasun.ruleimplementation.ElementHandlerImpl) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) TextAttributeOfElementBuilder(org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder) ElementHandler(org.asqatasun.ruleimplementation.ElementHandler) ElementChecker(org.asqatasun.rules.elementchecker.ElementChecker) AttributePresenceChecker(org.asqatasun.rules.elementchecker.attribute.AttributePresenceChecker) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

StringUtils (org.apache.commons.lang3.StringUtils)13 Logger (org.slf4j.Logger)12 LoggerFactory (org.slf4j.LoggerFactory)12 ServicesManager (org.apereo.cas.services.ServicesManager)11 CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)9 Map (java.util.Map)8 PrincipalFactory (org.apereo.cas.authentication.principal.PrincipalFactory)7 Autowired (org.springframework.beans.factory.annotation.Autowired)7 ArrayList (java.util.ArrayList)6 Collection (java.util.Collection)6 Set (java.util.Set)6 AuthenticationEventExecutionPlan (org.apereo.cas.authentication.AuthenticationEventExecutionPlan)6 AuthenticationHandler (org.apereo.cas.authentication.AuthenticationHandler)6 DefaultPrincipalFactory (org.apereo.cas.authentication.principal.DefaultPrincipalFactory)6 AuthenticationEventExecutionPlanConfigurer (org.apereo.cas.config.support.authentication.AuthenticationEventExecutionPlanConfigurer)6 Qualifier (org.springframework.beans.factory.annotation.Qualifier)6 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)6 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)6 Bean (org.springframework.context.annotation.Bean)6 Configuration (org.springframework.context.annotation.Configuration)6