Esempio n. 1
0
  protected String[] listResources() throws IOException, URISyntaxException {
    String[] files = new String[0];
    URL dirURL = ClassLoader.getSystemResource(schemaPath);
    FilenameFilter fileFilter =
        new FilenameFilter() {

          @Override
          public boolean accept(File dir, String name) {
            return ((name.lastIndexOf('.') > -1)
                && (".xml".equalsIgnoreCase(name.substring(name.lastIndexOf('.')))));
          }
        };

    if (dirURL == null) {
      throw new FileNotFoundException(schemaPath);
    }

    if (dirURL.getProtocol().equals("file")) {
      files = listFileResources(dirURL, schemaPath, fileFilter);
    }

    if (dirURL.getProtocol().equals("jar")) {
      files = listJarResources(dirURL, fileFilter);
    }

    return files;
  }
Esempio n. 2
0
  protected void loadFromXmlFiles() throws IOException, XMLStreamException, URISyntaxException {
    XMLInputFactory xmlIf = XMLInputFactory.newInstance();
    final List<StoreObject> storeObjects = new ArrayList<>();

    xmlIf.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE);

    for (String resname : listResources()) {
      URL filePath = ClassLoader.getSystemResource(resname);

      if (filePath == null) {
        throw new FileNotFoundException(resname);
      }

      loadFromXmlFile(xmlIf, filePath, storeObjects);
    }

    mergeXmlSchemas(storeObjects);
  }