Search in sources :

Example 1 with JsonInputException

use of org.pentaho.di.trans.steps.jsoninput.exception.JsonInputException in project pentaho-kettle by pentaho.

the class FastJsonReader method evalCombinedResult.

private List<List<?>> evalCombinedResult() throws JsonInputException {
    int lastSize = -1;
    String prevPath = null;
    List<List<?>> results = new ArrayList<>(compiledJsonPaths.length);
    int i = 0;
    for (JsonPath path : compiledJsonPaths) {
        List<Object> result = getReadContext().read(path);
        if (result.size() != lastSize && lastSize > 0 && !result.isEmpty()) {
            throw new JsonInputException(BaseMessages.getString(PKG, "JsonInput.Error.BadStructure", result.size(), inputFields[i].getPath(), prevPath, lastSize));
        }
        if (!isIgnoreMissingPath() && (isAllNull(result) || result.isEmpty())) {
            throw new JsonInputException(BaseMessages.getString(PKG, "JsonReader.Error.CanNotFindPath", inputFields[i].getPath()));
        }
        results.add(result);
        lastSize = result.size();
        prevPath = inputFields[i].getPath();
        i++;
    }
    return results;
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) JsonPath(com.jayway.jsonpath.JsonPath) JsonInputException(org.pentaho.di.trans.steps.jsoninput.exception.JsonInputException)

Example 2 with JsonInputException

use of org.pentaho.di.trans.steps.jsoninput.exception.JsonInputException in project pentaho-kettle by pentaho.

the class JsonInput method parseNextInputToRowSet.

private void parseNextInputToRowSet(InputStream input) throws KettleException {
    try {
        data.readerRowSet = data.reader.parse(input);
        input.close();
    } catch (KettleException ke) {
        logInputError(ke);
        throw new JsonInputException(ke);
    } catch (Exception e) {
        logInputError(e);
        throw new JsonInputException(e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) JsonInputException(org.pentaho.di.trans.steps.jsoninput.exception.JsonInputException) KettleException(org.pentaho.di.core.exception.KettleException) JsonInputException(org.pentaho.di.trans.steps.jsoninput.exception.JsonInputException) NotImplementedException(org.apache.commons.lang.NotImplementedException) FileSystemException(org.apache.commons.vfs2.FileSystemException) IOException(java.io.IOException) KettleStepException(org.pentaho.di.core.exception.KettleStepException)

Aggregations

JsonInputException (org.pentaho.di.trans.steps.jsoninput.exception.JsonInputException)2 JsonPath (com.jayway.jsonpath.JsonPath)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 NotImplementedException (org.apache.commons.lang.NotImplementedException)1 FileSystemException (org.apache.commons.vfs2.FileSystemException)1 KettleException (org.pentaho.di.core.exception.KettleException)1 KettleStepException (org.pentaho.di.core.exception.KettleStepException)1