Exemplo n.º 1
0
  /*
   * Returns a keystore entry alias and a list of target keystores.
   * When the supplied alias prefix identifies a keystore then that single
   * keystore is returned. When no alias prefix is supplied then all the
   * keystores are returned.
   */
  private AbstractMap.SimpleEntry<String, Collection<KeyStore>> getKeystoresForReading(
      String alias) {

    String[] splits = alias.split(this.entryNameSeparatorRegEx, 2);
    if (splits.length == 2) { // prefixed alias
      KeyStore keystore = keystores.get(splits[0]);
      if (keystore != null) {
        return new AbstractMap.SimpleEntry<>(
            splits[1], (Collection<KeyStore>) Collections.singleton(keystore));
      }
    } else if (splits.length == 1) { // unprefixed alias
      // Check all keystores for the first occurrence of the alias
      return new AbstractMap.SimpleEntry<>(alias, keystores.values());
    }
    return new AbstractMap.SimpleEntry<>(
        "", (Collection<KeyStore>) Collections.<KeyStore>emptyList());
  }
Exemplo n.º 2
0
 public static List<Variant> getPossibleVariants(
     Product product, Variant variant, String selectedAttribute) {
   List<Variant> matchingVariantList = new ArrayList<Variant>();
   List<Attribute> desiredAttributes = new ArrayList<Attribute>();
   for (Attribute attribute : variant.getAttributes()) {
     if (!selectedAttribute.equals(attribute.getName())
         && hasMoreAttributeValues(product, attribute.getName())) {
       desiredAttributes.add(attribute);
     }
   }
   VariantList variantList = product.getVariants().byAttributes(desiredAttributes);
   for (Attribute attr : product.getVariants().getAvailableAttributes(selectedAttribute)) {
     if (variantList.byAttributes(attr).size() < 1) {
       matchingVariantList.add((product.getVariants().byAttributes(attr).first()).orNull());
     } else {
       matchingVariantList.add((variantList.byAttributes(attr).first()).orNull());
     }
   }
   matchingVariantList.removeAll(Collections.singleton(null));
   return matchingVariantList;
 }