Esempio n. 1
0
  private void loadDirectory(String[] files, String path) throws Exception {
    StringBuilder currentPath = new StringBuilder();
    for (int i = 0; i < files.length; i++) {
      if (!path.endsWith("/")) {
        currentPath.append(path).append("/");
      }
      currentPath.append(files[i]);

      if (SingletonFSInterface.instance().isFile(new URI(currentPath.toString()))) // if it's a file
      {
        try {
          if (!files[i].startsWith(".")) {
            mibLoader.load(files[i]);
          }
        } catch (Exception e) {
          GlobalLogger.instance()
              .getApplicationLogger()
              .error(TextEvent.Topic.PROTOCOL, e, "ERROR : loading the MIBS files");
          if (e instanceof MibLoaderException) {
            ((MibLoaderException) e).getLog().printTo(new PrintStream("../logs/snmpStack.log"));
          }
        }
      } else // if it's a directory, load it and all it's content
      {
        if (!files[i].startsWith(".")) {
          loadDirectory(
              SingletonFSInterface.instance().list(new URI(currentPath.toString())),
              currentPath.toString());
        }
      }
      // reset currentPath
      currentPath.delete(0, currentPath.length());
    }
  }
Esempio n. 2
0
  public Mib loadMib(File file) throws MibLoaderException, IOException {

    MibLoader loader = new MibLoader();

    loader.addDir(file.getParentFile());
    return loader.load(file);
  }
Esempio n. 3
0
  public void convert() throws IOException, MibLoaderException {
    m_loader = new MibLoader();

    URL url;
    try {
      url = new URL(m_mibLocation);
    } catch (MalformedURLException e) {
      url = null;
    }

    if (url == null) {
      File file = new File(m_mibLocation);
      m_loader.addDir(file.getParentFile());
      m_mib = m_loader.load(file);
    } else {
      m_mib = m_loader.load(url);
    }
  }