Example #1
0
  /**
   * Iterate through all registered vocabularies and populate a map where each key is the name of
   * the file if it were persisted, and the value is the Vocabulary object.
   *
   * @return map containing all registered vocabularies
   */
  private Map<String, Vocabulary> getFileNameToVocabularyMap() {
    Map<String, Vocabulary> map = Maps.newHashMap();
    try {
      for (Vocabulary v : registryManager.getVocabularies()) {
        if (v.getUriString() != null && v.getUriResolvable() != null) {
          String filename =
              org.gbif.ipt.utils.FileUtils.getSuffixedFileName(
                  v.getUriResolvable().toString(), VOCAB_FILE_SUFFIX);
          map.put(filename, v);
        }
      }
    } catch (RegistryException e) {
      // add startup error message about Registry error
      String msg = RegistryException.logRegistryException(e.getType(), baseAction);
      warnings.addStartupError(msg);
      log.error(msg);

      // add startup error message that explains the consequence of the Registry error
      msg =
          baseAction.getText(
              "admin.extensions.vocabularies.couldnt.load", new String[] {cfg.getRegistryUrl()});
      warnings.addStartupError(msg);
      log.error(msg);
    }
    return map;
  }
Example #2
0
 /**
  * Retrieve vocabulary file by its resolvable URI.
  *
  * @param uri resolvable URI of vocabulary to retrieve
  * @return vocabulary file
  */
 private File getVocabFile(URI uri) {
   String filename =
       org.gbif.ipt.utils.FileUtils.getSuffixedFileName(uri.toString(), VOCAB_FILE_SUFFIX);
   return dataDir.configFile(CONFIG_FOLDER + "/" + filename);
 }