String morphlineId = context.getString(MORPHLINE_ID_PARAM); if (morphlineFile == null || morphlineFile.trim().length() == 0) { throw new MorphlineCompilationException("Missing parameter: " + MORPHLINE_FILE_PARAM, null);
@Override public Command build(Config config, Command parent, Command child, MorphlineContext context) { try { return new XSLT(this, config, parent, child, context); } catch (SaxonApiException e) { throw new MorphlineCompilationException("Cannot compile", config, e); } catch (IOException e) { throw new MorphlineCompilationException("Cannot compile", config, e); } catch (XMLStreamException e) { throw new MorphlineCompilationException("Cannot compile", config, e); } }
@Override public Command build(Config config, Command parent, Command child, MorphlineContext context) { try { return new XQuery(this, config, parent, child, context); } catch (SaxonApiException e) { throw new MorphlineCompilationException("Cannot compile", config, e); } catch (IOException e) { throw new MorphlineCompilationException("Cannot compile", config, e); } catch (XMLStreamException e) { throw new MorphlineCompilationException("Cannot compile", config, e); } }
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); } }
@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); } }
@Override public Command build(Config config, Command parent, Command child, MorphlineContext context) { try { return new ConvertHTML(this, config, parent, child, context); } catch (SAXNotRecognizedException e) { throw new MorphlineCompilationException("Cannot compile", config, e); } catch (SAXNotSupportedException e) { throw new MorphlineCompilationException("Cannot compile", config, e); } }
@Override public Command build(Config config, Command parent, Command child, MorphlineContext context) { try { return new Java(this, config, parent, child, context); } catch (ScriptException e) { throw new MorphlineCompilationException("Cannot compile script", config, e); } }
@Override public Command build(Config config, Command parent, Command child, MorphlineContext context) { try { return new DownloadHdfsFile(this, config, parent, child, context); } catch (IOException e) { throw new MorphlineCompilationException("Cannot compile", config, e); } }
private Locale getLocale(String name) { for (Locale locale : Locale.getAvailableLocales()) { if (locale.toString().equals(name)) { return locale; } } assert Locale.ROOT.toString().equals(""); if (name.equals(Locale.ROOT.toString())) { return Locale.ROOT; } throw new MorphlineCompilationException("Unknown locale: " + name, getConfig()); }
@Override public Command build(Config config, Command parent, Command child, MorphlineContext context) { try { return new Java(this, config, parent, child, context); } catch (ScriptException e) { throw new MorphlineCompilationException("Cannot compile script", config, e); } }
private TimeZone getTimeZone(String timeZoneID) { if (!Arrays.asList(TimeZone.getAvailableIDs()).contains(timeZoneID)) { throw new MorphlineCompilationException("Unknown timezone: " + timeZoneID, getConfig()); } return TimeZone.getTimeZone(timeZoneID); }
private void validateSchema(IndexSchema schema) { if (schema.getUniqueKeyField() == null) { throw new MorphlineCompilationException("Solr schema.xml is missing unique key field", config); } if (!schema.getUniqueKeyField().isRequired()) { throw new MorphlineCompilationException("Solr schema.xml must contain a required unique key field", config); } }
@Override protected void validateArguments() { super.validateArguments(); if (writerSchema == null) { throw new MorphlineCompilationException( "You must specify an external Avro writer schema because this is required to read containerless Avro", getConfig()); } }
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); } } }
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); } } }
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(); }
private List resolveReference(String reference, Record record, Config config) { Matcher matcher = PATTERN.matcher(reference); if (!matcher.matches()) { throw new MorphlineCompilationException("Invalid variable reference", config); } String value = reference.substring("@{".length(), reference.length() - "}".length()); List resolvedValues = record.getFields().get(value); return resolvedValues; }
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(); }
public ReadLine(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) { super(builder, config, parent, child, context); this.charset = getConfigs().getCharset(config, "charset", null); this.ignoreFirstLine = getConfigs().getBoolean(config, "ignoreFirstLine", false); String cprefix = getConfigs().getString(config, "commentPrefix", ""); if (cprefix.length() > 1) { throw new MorphlineCompilationException("commentPrefix must be at most one character long: " + cprefix, config); } this.commentPrefix = (cprefix.length() > 0 ? cprefix : null); validateArguments(); }
public GeoIP(CommandBuilder builder, Config config, Command parent, Command child, final MorphlineContext context) { super(builder, config, parent, child, context); 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(); }