Package org.kitesdk.morphline.api

Examples of org.kitesdk.morphline.api.MorphlineCompilationException


      if (line.startsWith("#")) {
        continue; // ignore comment lines
      }
      int i = line.indexOf(" ");
      if (i < 0) {
        throw new MorphlineCompilationException("Dictionary entry line must contain a space to separate name and value: " + line, getConfig());
      }
      if (i == 0) {
        throw new MorphlineCompilationException("Dictionary entry line must contain a name: " + line, getConfig());
      }
      String name = line.substring(0, i);
      String value = line.substring(i + 1, line.length()).trim();
      if (value.length() == 0) {
        throw new MorphlineCompilationException("Dictionary entry line must contain a value: " + line, getConfig());
      }
      dictionary.put(name, value);
    }     
  }
View Full Code Here


        }
      }
      //LOG.debug("patternName=" + patternName + ", groupName=" + groupName + ", conversion=" + conversion);
      String refValue = dictionary.get(regexName);
      if (refValue == null) {
        throw new MorphlineCompilationException("Missing value for name: " + regexName, getConfig());
      }
      if (refValue.contains(PATTERN_START)) {
        break; // not a literal value; defer resolution until next iteration
      }
      String replacement = refValue;
View Full Code Here

      super(builder, config, parent, child, context);
     
      Command devNull = new DropRecordBuilder().build(null, this, null, context); // pipes into /dev/null
      List<Command> conditions = buildCommandChain(config, "conditions", devNull, true);
      if (conditions.size() == 0) {
        throw new MorphlineCompilationException("Missing conditions", config);
      } else {
        this.conditionChain = conditions.get(0);
      }

      List<Command> thenCommands = buildCommandChain(config, "then", child, true);
View Full Code Here

 
  public void validateArguments(Config config) {
    Set<String> recognizedArgs = getRecognizedArguments();
    for (String key : config.root().keySet()) {
      if (!recognizedArgs.contains(key)) {
        throw new MorphlineCompilationException("Unrecognized command argument: " + key +
            ", recognized arguments: " + recognizedArgs, config);
      }
    }     
  }
View Full Code Here

    } else if (parts.length == 2) {
      return new Locale(parts[0], parts[1]);
    } else if (parts.length == 3) {
      return new Locale(parts[0], parts[1], parts[2]);
    } else {
      throw new MorphlineCompilationException("Illegal locale: " + str, config);
    }
  } 
View Full Code Here

        String projectionSchemaFile = getConfigs().getString(config, "projectionSchemaFile", null);
        if (projectionSchemaFile != null) {
          try {
            projectionSchema = new Parser().parse(new File(projectionSchemaFile));
          } catch (IOException e) {
            throw new MorphlineCompilationException("Cannot parse external Avro projection schema file: " + projectionSchemaFile, config, e);
          }
        } else {
          projectionSchema = null;
        }
      }     
     
      if (projectionSchema != null) {
        AvroReadSupport.setRequestedProjection(conf, projectionSchema);
      }
     
      // configure reader schema, if any
      String readerSchemaString = getConfigs().getString(config, "readerSchemaString", null);
      Schema readerSchema;
      if (readerSchemaString != null) {
        readerSchema = new Parser().parse(readerSchemaString);
      } else {       
        String readerSchemaFile = getConfigs().getString(config, "readerSchemaFile", null);
        if (readerSchemaFile != null) {
          try {
            readerSchema = new Parser().parse(new File(readerSchemaFile));
          } catch (IOException e) {
            throw new MorphlineCompilationException("Cannot parse external Avro reader schema file: " + readerSchemaFile, config, e);
          }
        } else {
          readerSchema = null;
        }
      }     
View Full Code Here

   
    public Sample(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) {
      super(builder, config, parent, child, context);   
      this.probability = getConfigs().getDouble(config, "probability", 1.0);
      if (probability < 0.0) {
        throw new MorphlineCompilationException("Probability must not be negative: " + probability, config);
      }
      if (probability >= 1.0) {
        this.prng = null;
      } else {
        if (config.hasPath("seed")) {
View Full Code Here

      super(builder, config, parent, child, context);     
      this.inputFieldName = getConfigs().getString(config, "inputField");     
      this.outputFieldPrefix = getConfigs().getString(config, "outputFieldPrefix", "");
      this.separator = getConfigs().getString(config, "separator", "=");
      if (separator.length() == 0) {
        throw new MorphlineCompilationException("separator must not be the empty string", config);
      }
      if (getConfigs().getBoolean(config, "isRegex", false)) {
        GrokDictionaries dict = new GrokDictionaries(config, getConfigs());
        this.regex = dict.compileExpression(separator).pattern().matcher("");
      } else {
View Full Code Here

   
    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

      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

TOP

Related Classes of org.kitesdk.morphline.api.MorphlineCompilationException

Copyright © 2018 www.massapicom. 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.