Пример #1
0
 public void saveForShutdown() {
   idvStore.put(PREF_ADDE_ENTRIES, arrList(getPersistedEntrySet()));
   idvStore.saveIfNeeded();
   try {
     EntryTransforms.writeResolvFile(ADDE_RESOLV, getPersistedLocalEntries());
   } catch (IOException e) {
     logger.error("EntryStore: RESOLV.SRV missing; expected=\"" + ADDE_RESOLV + "\"");
   }
 }
Пример #2
0
 public AddeAccount getAccountingFor(final AddeServer idvServer, String typeAsStr) {
   String address = idvServer.getName();
   List<AddeServer.Group> groups = (List<AddeServer.Group>) idvServer.getGroups();
   if (groups != null && !groups.isEmpty()) {
     EntryType type = EntryTransforms.strToEntryType(typeAsStr);
     return getAccountingFor(address, groups.get(0).getName(), type);
   } else {
     return RemoteAddeEntry.DEFAULT_ACCOUNT;
   }
 }
Пример #3
0
 /**
  * Process all of the {@literal "user"} XML resources.
  *
  * @param xmlResources Resource collection. Cannot be {@code null}.
  * @return {@link Set} of {@link RemoteAddeEntry}s contained within {@code resource}.
  */
 private Set<AddeEntry> extractUserEntries(final XmlResourceCollection xmlResources) {
   int rcSize = xmlResources.size();
   Set<AddeEntry> entries = newLinkedHashSet(rcSize);
   for (int i = 0; i < rcSize; i++) {
     Element root = xmlResources.getRoot(i);
     if (root == null) {
       continue;
     }
     entries.addAll(EntryTransforms.convertUserXml(root));
   }
   return entries;
 }
Пример #4
0
 /**
  * Process all of the {@literal "IDV-style"} XML resources for a given {@literal "source"}.
  *
  * @param source Origin of the XML resources.
  * @param xmlResources Actual XML resources.
  * @return {@link Set} of the {@link AddeEntry AddeEntrys} extracted from {@code xmlResources}.
  */
 private Set<AddeEntry> extractResourceEntries(
     EntrySource source, final XmlResourceCollection xmlResources) {
   Set<AddeEntry> entries = newLinkedHashSet(xmlResources.size());
   for (int i = 0; i < xmlResources.size(); i++) {
     Element root = xmlResources.getRoot(i);
     if (root == null) {
       continue;
     }
     entries.addAll(EntryTransforms.convertAddeServerXml(root, source));
   }
   return entries;
 }
Пример #5
0
  /**
   * Constructs a server manager.
   *
   * @param store
   * @param rscManager
   */
  public EntryStore(final IdvObjectStore store, final IdvResourceManager rscManager) {
    notNull(store);
    notNull(rscManager);

    this.idvStore = store;
    this.trie = new PatriciaTrie<>(new CharSequenceKeyAnalyzer());
    this.ADDE_DIRECTORY = getAddeRootDirectory();
    this.ADDE_BIN = ADDE_DIRECTORY + File.separator + "bin";
    this.ADDE_DATA = ADDE_DIRECTORY + File.separator + "data";
    this.localPort = Constants.LOCAL_ADDE_PORT;
    this.restartingMcserv = false;
    this.lastAdded = arrList();
    AnnotationProcessor.process(this);

    McIDASV mcv = McIDASV.getStaticMcv();
    USER_DIRECTORY = mcv.getUserDirectory();
    ADDE_RESOLV = mcv.getUserFile("RESOLV.SRV");
    MCTRACE = "0";

    if (McIDASV.isWindows()) {
      ADDE_MCSERVL = ADDE_BIN + "\\mcservl.exe";
    } else {
      ADDE_MCSERVL = ADDE_BIN + "/mcservl";
    }

    try {
      Set<LocalAddeEntry> locals = EntryTransforms.readResolvFile(ADDE_RESOLV);
      putEntries(trie, locals);
    } catch (IOException e) {
      logger.warn("EntryStore: RESOLV.SRV missing; expected=\"" + ADDE_RESOLV + '"');
    }

    XmlResourceCollection userResource =
        rscManager.getXmlResources(ResourceManager.RSC_NEW_USERSERVERS);
    XmlResourceCollection sysResource =
        rscManager.getXmlResources(IdvResourceManager.RSC_ADDESERVER);

    Set<AddeEntry> systemEntries = extractResourceEntries(EntrySource.SYSTEM, sysResource);

    Set<AddeEntry> prefEntries = extractPreferencesEntries(store);
    prefEntries = removeDeletedSystemEntries(prefEntries, systemEntries);

    Set<AddeEntry> userEntries = extractUserEntries(userResource);
    userEntries = removeDeletedSystemEntries(userEntries, systemEntries);

    putEntries(trie, prefEntries);
    putEntries(trie, userEntries);
    putEntries(trie, systemEntries);
    saveEntries();
  }
Пример #6
0
 /**
  * Returns a list that consists of the available ADDE datasets for a given {@link EntryType},
  * converted to IDV {@link AddeServer} objects.
  *
  * @param typeAsStr Only add entries with this type to the returned list. Cannot be {@code null}
  *     and must be a value that works with {@link EntryTransforms#strToEntryType(String)}.
  * @return {@code AddeServer} objects for each ADDE entry of the given type.
  * @see EntryTransforms#strToEntryType(String)
  */
 public Set<AddeServer> getIdvStyleEntries(final String typeAsStr) {
   return getIdvStyleEntries(EntryTransforms.strToEntryType(typeAsStr));
 }
Пример #7
0
 /**
  * Returns a list that consists of the available ADDE datasets for a given {@link EntryType},
  * converted to IDV {@link AddeServer} objects.
  *
  * @param type Only add entries with this type to the returned list. Cannot be {@code null}.
  * @return {@code AddeServer} objects for each ADDE entry of the given type.
  */
 public Set<AddeServer> getIdvStyleEntries(final EntryType type) {
   return EntryTransforms.convertMcvServers(getVerifiedEntries(type));
 }
Пример #8
0
 /**
  * Returns a list of all available ADDE datasets, converted to IDV {@link AddeServer} objects.
  *
  * @return List of {@code AddeServer} objects for each ADDE entry.
  */
 public List<AddeServer> getIdvStyleEntries() {
   return arrList(EntryTransforms.convertMcvServers(getEntrySet()));
 }
Пример #9
0
 public Set<AddeServer.Group> getIdvStyleRemoteGroups(
     final String server, final String typeAsStr) {
   return getIdvStyleRemoteGroups(server, EntryTransforms.strToEntryType(typeAsStr));
 }