Ejemplo n.º 1
0
  // TODO(jon): better name
  public Map<EntryType, Set<AddeEntry>> getVerifiedEntriesByTypes() {
    Map<EntryType, Set<AddeEntry>> entryMap = newLinkedHashMap(EntryType.values().length);
    int size = trie.size();
    for (EntryType type : EntryType.values()) {
      entryMap.put(type, new LinkedHashSet<AddeEntry>(size));
    }

    for (AddeEntry entry : trie.values()) {
      Set<AddeEntry> entrySet = entryMap.get(entry.getEntryType());
      entrySet.add(entry);
    }
    return entryMap;
  }
Ejemplo n.º 2
0
 /**
  * Searches the set of servers in an attempt to locate the accounting information for the matching
  * server. <b>Note</b> that because the data structure is a {@link Set}, there <i>cannot</i> be
  * duplicate entries, so there is no need to worry about our criteria finding multiple matches.
  *
  * <p>Also note that none of the given parameters accept {@code null} values.
  *
  * @param address Address of the server.
  * @param group Dataset.
  * @param type Group type.
  * @return Either the {@link AddeAccount} for the given criteria, or {@link
  *     AddeEntry#DEFAULT_ACCOUNT} if there was no match.
  * @see RemoteAddeEntry#equals(Object)
  */
 public AddeAccount getAccountingFor(final String address, final String group, EntryType type) {
   Collection<AddeEntry> entries =
       trie.getPrefixedBy(address + '!' + group + '!' + type.name()).values();
   for (AddeEntry entry : entries) {
     if (!isInvalidEntry(entry)) {
       return entry.getAccount();
     }
   }
   return AddeEntry.DEFAULT_ACCOUNT;
 }
Ejemplo n.º 3
0
  public Set<AddeServer.Group> getIdvStyleRemoteGroups(final String server, final EntryType type) {
    Set<AddeServer.Group> idvGroups = newLinkedHashSet(trie.size());
    String typeStr = type.name();
    for (AddeEntry matched : trie.getPrefixedBy(server).values()) {
      if (matched == RemoteAddeEntry.INVALID_ENTRY) {
        continue;
      }

      if ((matched.getEntryStatus() == EntryStatus.ENABLED)
          && (matched.getEntryValidity() == EntryValidity.VERIFIED)
          && (matched.getEntryType() == type)) {
        String group = matched.getGroup();
        idvGroups.add(new AddeServer.Group(typeStr, group, group));
      }
    }
    return idvGroups;
  }