Examples of MorphlineCompilationException


Examples of org.kitesdk.morphline.api.MorphlineCompilationException

   
    public Head(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) {
      super(builder, config, parent, child, context);   
      this.limit = getConfigs().getLong(config, "limit", -1);
      if (limit < -1) {
        throw new MorphlineCompilationException("Illegal limit: " + limit, config);
      }
      validateArguments();
    }
View Full Code Here

Examples of org.kitesdk.morphline.api.MorphlineCompilationException

      String handlerStr = getConfigs().getString(config, "solrContentHandlerFactory", TrimSolrContentHandlerFactory.class.getName());
      Class<? extends SolrContentHandlerFactory> factoryClass;
      try {
        factoryClass = (Class<? extends SolrContentHandlerFactory>)Class.forName(handlerStr);
      } catch (ClassNotFoundException cnfe) {
        throw new MorphlineCompilationException("Could not find class "
          + handlerStr + " to use for " + "solrContentHandlerFactory", config, cnfe);
      }
      this.solrContentHandlerFactory = getSolrContentHandlerFactory(factoryClass, dateFormats, config);

      this.locale = getLocale(getConfigs().getString(config, "locale", ""));
     
      this.mediaTypeToParserMap = new HashMap<MediaType, Parser>();
      //MimeTypes mimeTypes = MimeTypes.getDefaultMimeTypes(); // FIXME getMediaTypeRegistry.normalize()

      List<? extends Config> parserConfigs = getConfigs().getConfigList(config, "parsers");
      for (Config parserConfig : parserConfigs) {
        String parserClassName = getConfigs().getString(parserConfig, "parser");
       
        Object obj;
        try {
          obj = Class.forName(parserClassName).newInstance();
        } catch (Throwable e) {
          throw new MorphlineCompilationException("Cannot instantiate Tika parser: " + parserClassName, config, e);
        }
        if (!(obj instanceof Parser)) {
          throw new MorphlineCompilationException("Tika parser " + obj.getClass().getName()
              + " must be an instance of class " + Parser.class.getName(), config);
        }
        Parser parser = (Parser) obj;
        this.parsers.add(parser);
View Full Code Here

Examples of org.kitesdk.morphline.api.MorphlineCompilationException

    private static SolrContentHandlerFactory getSolrContentHandlerFactory(
        Class<? extends SolrContentHandlerFactory> factoryClass, Collection<String> dateFormats, Config config) {
      try {
        return factoryClass.getConstructor(Collection.class).newInstance(dateFormats);
      } catch (NoSuchMethodException nsme) {
        throw new MorphlineCompilationException("Unable to find valid constructor of type "
          + factoryClass.getName() + " for creating SolrContentHandler", config, nsme);
      } catch (Exception e) {
        throw new MorphlineCompilationException("Unexpected exception when trying to create SolrContentHandlerFactory of type "
          + factoryClass.getName(), config, e);
      }
    }
View Full Code Here

Examples of org.kitesdk.morphline.api.MorphlineCompilationException

      }
      assert Locale.ROOT.toString().equals("");
      if (name.equals(Locale.ROOT.toString())) {
        return Locale.ROOT;
      }
      throw new MorphlineCompilationException("Unknown locale: " + name, getConfig());
    }
View Full Code Here

Examples of org.kitesdk.morphline.api.MorphlineCompilationException

  @Override
  public Command build(Config config, Command parent, Command child, MorphlineContext context) {
    try {
      return new DetectMimeType(this, config, parent, child, context);
    } catch (IOException e) {
      throw new MorphlineCompilationException("Cannot instantiate command", config, e, this);
    } catch (MimeTypeException e) {
      throw new MorphlineCompilationException("Cannot instantiate command", config, e, this);
    }
  }
View Full Code Here

Examples of org.kitesdk.morphline.api.MorphlineCompilationException

        if (inputStreams.size() > 0) {
          MimeTypes mimeTypes = MimeTypesFactory.create(inputStreams.toArray(new InputStream[inputStreams.size()]));
          ServiceLoader loader = new ServiceLoader();
          this.detector = new DefaultDetector(mimeTypes, loader);
        } else {
          throw new MorphlineCompilationException("Missing specification for MIME type mappings", config);
        }     
      } finally {
        for (InputStream in : inputStreams) {
          Closeables.closeQuietly(in);
        }
View Full Code Here

Examples of org.kitesdk.morphline.api.MorphlineCompilationException

      this.inputFieldName = getConfigs().getString(config, "inputField");
      this.databaseFile = new File(getConfigs().getString(config, "database", "GeoLite2-City.mmdb"));
      try {
        this.databaseReader = new Reader(databaseFile);
      } catch (IOException e) {
        throw new MorphlineCompilationException("Cannot read Maxmind database: " + databaseFile, config, e);
      }
      validateArguments();
    }
View Full Code Here

Examples of org.kitesdk.morphline.api.MorphlineCompilationException

   * Validates that the given value is contained in the range [min, max]
   */
  public void validateRange(Config config, T value, Comparable<T> min, Comparable<T>  max) {
    boolean isValid = min.compareTo(value) <= 0 && 0 <= max.compareTo(value);
    if (!isValid) {
      throw new MorphlineCompilationException(
        String.format("Invalid choice: '%s' (choose from {%s..%s})",
                      value,
                      min,
                      max),
        config);
View Full Code Here

Examples of org.kitesdk.morphline.api.MorphlineCompilationException

      if (!Arrays.asList(choices).contains(result)) {
        throw new IllegalArgumentException();
      }
      return result;
    } catch (IllegalArgumentException e) {
      throw new MorphlineCompilationException(
        String.format("Invalid choice: '%s' (choose from {%s})",
                      value,
                      Joiner.on(",").join(choices)),
        config);
    }
View Full Code Here

Examples of org.kitesdk.morphline.api.MorphlineCompilationException

              .formatFor(locale);
             
          reporter = reporterBuilder.build(outputDir);
          outputDir.mkdirs();
          if (!outputDir.isDirectory()) {
            throw new MorphlineCompilationException("Directory not found: " + outputDir, config);
          }
          if (!outputDir.canWrite()) {
            throw new MorphlineCompilationException("Directory not writeable: " + outputDir, config);
          }
          reporter.start(frequency, TimeUnit.NANOSECONDS);
          reporters.put(outputDir, reporter);
        }
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.