protected void addPromotionMessagesForType(List<PromotionMessageDTO> messageDTOs, List<PromotionMessageDTO> messages) { if (CollectionUtils.isNotEmpty(messages)) { messageDTOs.addAll(messages); } }
private void performInjectionForContentViewerUis(final Collection<WebAppContext> contentViewerWebContexts, final FilterHolder securityFilter) { if (CollectionUtils.isNotEmpty(contentViewerWebContexts)) { for (final WebAppContext contentViewerContext : contentViewerWebContexts) { // add the security filter to any content viewer wars if (securityFilter != null) { contentViewerContext.addFilter(securityFilter, "/*", EnumSet.allOf(DispatcherType.class)); } } } }
@Override public void addFiles(String merchantStoreCode, List<InputContentFile> inputStaticContentDataList) throws ServiceException { if (CollectionUtils.isNotEmpty(inputStaticContentDataList)) { for (InputContentFile inputFile : inputStaticContentDataList) { this.addFile(merchantStoreCode, inputFile); } } }
@Override public String getName() { String name = StandardConnection.this.getName(); final Collection<Relationship> relationships = getRelationships(); if (name == null && CollectionUtils.isNotEmpty(relationships)) { name = StringUtils.join(relationships.stream().map(relationship -> relationship.getName()).collect(Collectors.toSet()), ", "); } if (name == null) { name = "Connection"; } return name; }
protected Sku findMatchingSku(Product product, Map<String, String> attributeValuesForSku) { Sku matchingSku = null; List<Long> possibleSkuIds = new ArrayList<>(); for (Map.Entry<String, String> entry : MapUtils.emptyIfNull(attributeValuesForSku).entrySet()) { possibleSkuIds = productOptionValidationService.findSkuIdsForProductOptionValues(product.getId(), entry.getKey(), entry.getValue(), possibleSkuIds); if (CollectionUtils.isEmpty(possibleSkuIds)) { break; } } if (CollectionUtils.isNotEmpty(possibleSkuIds)) { matchingSku = catalogService.findSkuById(possibleSkuIds.iterator().next()); } return matchingSku; }
private void buildConsumesSection(MarkupDocBuilder markupDocBuilder, List<String> consumes) { if (isNotEmpty(consumes)) { consumesComponent.apply(markupDocBuilder, ConsumesComponent.parameters(consumes, SECTION_TITLE_LEVEL)); } }
private void buildTagsSection(MarkupDocBuilder markupDocBuilder, List<Tag> tags) { if (isNotEmpty(tags)) { tagsComponent.apply(markupDocBuilder, TagsComponent.parameters(tags, SECTION_TITLE_LEVEL)); } }
private void buildProducesSection(MarkupDocBuilder markupDocBuilder, List<String> produces) { if (isNotEmpty(produces)) { producesComponent.apply(markupDocBuilder, ProducesComponent.parameters(produces, SECTION_TITLE_LEVEL)); } }
public List<String> getAllLookupTypes() { if (CollectionUtils.isNotEmpty(getAdditionalLookupTypes())) { List<String> result = new ArrayList<>(getAdditionalLookupTypes()); result.add(getType()); return Collections.unmodifiableList(result); } else { return Arrays.asList(getType()); } }
public Object getModifiedWriteValue(Field field, Object value, Object newValue, EntityManager em) throws IllegalAccessException { Object response = newValue; // iterate through each modifier and if it can handle this field, receive the modified value if (CollectionUtils.isNotEmpty(fieldManagerModifiers)) { for (FieldManagerModifier modifier : fieldManagerModifiers) { if (modifier.canHandle(field, response, em)) { response = modifier.getModifiedWriteValue(field, value, response, em); } } } return response; }
public Object getModifiedReadValue(Field field, Object value, EntityManager em) throws IllegalAccessException { Object response = value; // iterate through each modifier and if it can handle this field, receive the modified value if (CollectionUtils.isNotEmpty(fieldManagerModifiers) && field != null) { for (FieldManagerModifier modifier : fieldManagerModifiers) { if (modifier.canHandle(field, response, em)) { response = modifier.getModifiedReadValue(field, response, em); } } } return response; }
public String plainSource() { Collection<String> unresolvedDeps = getUnresolvedDependencies(); if (isNotEmpty(unresolvedDeps)) { throw assembleError("Followed dependencies aren't resolved: %s", unresolvedDeps); } String result = this.source; for (SourceArtifact dependencyArtifact : injectedDependencies) { String importDefinition = format("import \"%s\";", dependencyArtifact.getName()); String dependencySrc = format("// %s\n%s", importDefinition, dependencyArtifact.plainSource()); result = result.replace(importDefinition, dependencySrc); } return result; }
/** * Provides both single and multiple addresses in LookupResult. This is because the purpose of a hostname * resolution request is to resolve to a single IP address (so that communication can be initiated with it). * We also resolve all addresses in case they are needed. */ private LookupResult resolveIPv6AddressForHostname(Object key) { final List<ADnsAnswer> aDnsAnswers; try { aDnsAnswers = dnsClient.resolveIPv6AddressForHostname(key.toString(), false); } catch (UnknownHostException e) { return LookupResult.empty(); // UnknownHostException is a valid case when the DNS record does not exist. Do not log an error. } catch (Exception e) { LOG.error("Could not resolve [{}] records for hostname [{}]. Cause [{}]", AAAA_RECORD_LABEL, key, ExceptionUtils.getRootCauseMessage(e)); errorCounter.inc(); return LookupResult.empty(); } if (CollectionUtils.isNotEmpty(aDnsAnswers)) { return buildLookupResult(aDnsAnswers); } LOG.debug("Could not resolve [{}] records for hostname [{}].", AAAA_RECORD_LABEL, key); return LookupResult.empty(); }
/** * Provides both single and multiple addresses in LookupResult. This is because the purpose of a hostname * resolution request is to resolve to a single IP address (so that communication can be initiated with it). * We also resolve all addresses in case they are needed. */ private LookupResult resolveIPv4AddressForHostname(Object key) { final List<ADnsAnswer> aDnsAnswers; try { aDnsAnswers = dnsClient.resolveIPv4AddressForHostname(key.toString(), false); } catch (UnknownHostException e) { return LookupResult.empty(); // UnknownHostException is a valid case when the DNS record does not exist. Do not log an error. } catch (Exception e) { LOG.error("Could not resolve [{}] records for hostname [{}]. Cause [{}]", A_RECORD_LABEL, key, ExceptionUtils.getRootCauseMessage(e)); errorCounter.inc(); return LookupResult.empty(); } if (CollectionUtils.isNotEmpty(aDnsAnswers)) { return buildLookupResult(aDnsAnswers); } LOG.debug("Could not resolve [{}] records for hostname [{}].", A_RECORD_LABEL, key); return LookupResult.empty(); }
public void start(String dnsServerIps, long requestTimeout) { LOG.debug("Attempting to start DNS client"); final List<InetSocketAddress> iNetDnsServerIps = parseServerIpAddresses(dnsServerIps); nettyEventLoop = new NioEventLoopGroup(); final DnsNameResolverBuilder dnsNameResolverBuilder = new DnsNameResolverBuilder(nettyEventLoop.next()); dnsNameResolverBuilder.channelType(NioDatagramChannel.class).queryTimeoutMillis(requestTimeout); // Specify custom DNS servers if provided. If not, use those specified in local network adapter settings. if (CollectionUtils.isNotEmpty(iNetDnsServerIps)) { LOG.debug("Attempting to start DNS client with server IPs [{}] on port [{}] with timeout [{}]", dnsServerIps, DEFAULT_DNS_PORT, requestTimeout); final DnsServerAddressStreamProvider dnsServer = new SequentialDnsServerAddressStreamProvider(iNetDnsServerIps); dnsNameResolverBuilder.nameServerProvider(dnsServer); } else { LOG.debug("Attempting to start DNS client with the local network adapter DNS server address on port [{}] with timeout [{}]", DEFAULT_DNS_PORT, requestTimeout); } resolver = dnsNameResolverBuilder.build(); LOG.debug("DNS client startup successful"); }
private LookupResult performTextLookup(Object key) { /* Query all TXT records for hostname and provide them in the multiValue field as an array. * Do not attempt to attempt to choose a single value for the user (all are valid). */ final List<TxtDnsAnswer> txtDnsAnswers; try { txtDnsAnswers = dnsClient.txtLookup(key.toString()); } catch (Exception e) { LOG.error("Could not perform TXT DNS lookup for [{}]. Cause [{}]", key, ExceptionUtils.getRootCauseMessage(e)); errorCounter.inc(); return LookupResult.empty(); } if (CollectionUtils.isNotEmpty(txtDnsAnswers)) { final LookupResult.Builder builder = LookupResult.builder(); builder.multiValue(Collections.singletonMap(RAW_RESULTS_FIELD, txtDnsAnswers)); assignMinimumTTL(txtDnsAnswers, builder); return builder.build(); } LOG.debug("Could not perform Text lookup on IP address [{}]. No TXT records were found.", key); return LookupResult.empty(); }
/** * A temporary credit card {@link OrderPayment} will only be added to the cart if the customer has opted out * of saving their credit card for future payments. * @param customerPaymentUsedForOrder */ protected boolean getShouldUseCustomerPaymentDefaultValue(CustomerPayment customerPaymentUsedForOrder) { boolean customerSavedPaymentsAreEnabled = areCustomerSavedPaymentsEnabled(); boolean customerHasSavedPayments = CollectionUtils.isNotEmpty(CustomerState.getCustomer().getCustomerPayments()); boolean orderUsingCustomerPayment = (customerPaymentUsedForOrder != null); boolean cartHasTemporaryCreditCard = cartStateService.cartHasTemporaryCreditCard(); return customerSavedPaymentsAreEnabled && (orderUsingCustomerPayment || (!cartHasTemporaryCreditCard && customerHasSavedPayments)); }
private void buildConsumesSection(MarkupDocBuilder markupDocBuilder, PathOperation operation) { List<String> consumes = operation.getOperation().getConsumes(); if (CollectionUtils.isNotEmpty(consumes)) { consumesComponent.apply(markupDocBuilder, ConsumesComponent.parameters(consumes, getSectionTitleLevel())); } }
private void buildProducesSection(MarkupDocBuilder markupDocBuilder, PathOperation operation) { List<String> produces = operation.getOperation().getProduces(); if (CollectionUtils.isNotEmpty(produces)) { producesComponent.apply(markupDocBuilder, ProducesComponent.parameters(produces, getSectionTitleLevel())); } }
private void buildTagsSection(MarkupDocBuilder markupDocBuilder, PathOperation operation) { if (config.getPathsGroupedBy() == GroupBy.AS_IS) { List<String> tags = operation.getOperation().getTags(); if (CollectionUtils.isNotEmpty(tags)) { buildSectionTitle(markupDocBuilder, labels.getLabel(TAGS)); if (config.getTagOrdering() != null) { tags.sort(config.getTagOrdering()); } markupDocBuilder.unorderedList(tags); } } }