use of com.bazaarvoice.jolt.exception.SpecException in project nifi by apache.
the class TransformFactory method getChainrJoltTransformations.
protected static List<JoltTransform> getChainrJoltTransformations(ClassLoader classLoader, Object specJson) throws Exception {
if (!(specJson instanceof List)) {
throw new SpecException("JOLT Chainr expects a JSON array of objects - Malformed spec.");
} else {
List operations = (List) specJson;
if (operations.isEmpty()) {
throw new SpecException("JOLT Chainr passed an empty JSON array.");
} else {
ArrayList<JoltTransform> entries = new ArrayList<JoltTransform>(operations.size());
for (Object chainrEntryObj : operations) {
if (!(chainrEntryObj instanceof Map)) {
throw new SpecException("JOLT ChainrEntry expects a JSON map - Malformed spec");
} else {
Map chainrEntryMap = (Map) chainrEntryObj;
String opString = (String) chainrEntryMap.get("operation");
String operationClassName;
if (opString == null) {
throw new SpecException("JOLT Chainr \'operation\' must implement Transform or ContextualTransform");
} else {
if (ChainrEntry.STOCK_TRANSFORMS.containsKey(opString)) {
operationClassName = ChainrEntry.STOCK_TRANSFORMS.get(opString);
} else {
operationClassName = opString;
}
entries.add(getCustomTransform(classLoader, operationClassName, chainrEntryMap.get("spec")));
}
}
}
return entries;
}
}
}
Aggregations