Пример #1
0
  @Override
  public List<Item> generate(File inputFile, String source)
      throws GenerationException, IOException {
    FileValidation.standardChecks(inputFile);

    List<Item> generated = this.generate(new FileInputStream(inputFile), source);
    List<Item> enriched = new Vector<Item>();

    for (Item item : generated) {
      // Basic File Comparitors, FILE_NAME, FILE_SIZE and FILE_MODIFIED_UTC
      // TODO - check if this is enough
      item.addComparitor(StandardAspects.FILE_FILENAME);
      item.addComparitor(StandardAspects.FILE_SIZE_BYTES);
      item.addComparitor(StandardAspects.FILE_MODIFIED_UTC);

      enriched.add(AspectEnrichment.fileEnrichment(item, inputFile));
    }

    return enriched;
  }
Пример #2
0
  @Override
  public List<Item> generate(URL url, String source) throws GenerationException {
    try {
      HttpURLConnection connection = (HttpURLConnection) url.openConnection();

      List<Item> generated = this.generate(connection.getInputStream(), source);
      List<Item> enriched = new Vector<Item>();

      for (Item item : generated) {
        // URL basic Text, comparitors are URL and MODIFIED
        // TODO - This may not work with dynamic pages, check and fix
        item.addComparitor(StandardAspects.URL_URL);
        item.addComparitor(StandardAspects.URL_MODIFIED_UTC);

        enriched.add(AspectEnrichment.urlEnrichment(item, connection));
      }

      return enriched;
    } catch (Exception exc) {
      throw new GenerationException(exc);
    }
  }