if (json.has("task")) {
json = json.getJSONObject("task");
}
ImportTask task = new ImportTask();
if (json.has("id")) {
task.setId(json.getInt("id"));
}
if (json.has("updateMode")) {
task.setUpdateMode(UpdateMode.valueOf(json.getString("updateMode").toUpperCase()));
} else {
// if it hasn't been specified by the request, set this to null
// or else it's possible to overwrite an existing setting
task.setUpdateMode(null);
}
JSONObject data = null;
if (json.has("data")) {
data = json.getJSONObject("data");
}
else if (json.has("source")) { // backward compatible check for source
data = json.getJSONObject("source");
}
if (data != null) {
// we only support updating the charset
if (data.has("charset")) {
if (task.getData() == null) {
task.setData(new ImportData.TransferObject());
}
task.getData().setCharsetEncoding(data.getString("charset"));
}
}
if (json.has("target")) {
task.setStore(fromJSON(json.getJSONObject("target"), StoreInfo.class));
}
LayerInfo layer = null;
if (json.has("layer")) {
layer = layer(json.getJSONObject("layer"));
} else {
layer = importer.getCatalog().getFactory().createLayer();
}
task.setLayer(layer);
if (json.has("transformChain")) {
task.setTransform(transformChain(json.getJSONObject("transformChain")));
}
return task;
}