Ejemplo n.º 1
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();
  }
Ejemplo n.º 2
0
 /**
  * Get the xml resource collection that defines the image default xml
  *
  * @return Image defaults resources
  */
 protected XmlResourceCollection getImageDefaults() {
   XmlResourceCollection ret = null;
   try {
     ControlContext controlContext = getControlContext();
     if (controlContext != null) {
       IdvResourceManager irm = controlContext.getResourceManager();
       ret = irm.getXmlResources(IdvResourceManager.RSC_IMAGEDEFAULTS);
       if (ret.hasWritableResource()) {
         imageDefaultsDocument = ret.getWritableDocument("<imagedefaults></imagedefaults>");
         imageDefaultsRoot = ret.getWritableRoot("<imagedefaults></imagedefaults>");
       }
     }
   } catch (Exception e) {
     logger.error("problem trying to set up xml document", e);
   }
   return ret;
 }