use of com.tremolosecurity.config.xml.ProvisionMappingsType in project OpenUnison by TremoloSecurity.
the class ParseWorkflow method createMappingTask.
private void createMappingTask(JSONObject node, String path, List<WorkflowTaskType> parent, ParsedWorkflow pw) {
MappingType task = new MappingType();
OptionType[] options = new OptionType[] { new OptionType("strict", false, OptionType.OptionValueType.BOOLEAN) };
for (OptionType ot : options) {
setAttribute(node, ot, task, MappingType.class, pw, path);
if (pw.getError() != null) {
return;
}
}
task.setMap(new ProvisionMappingsType());
Object o = node.get("map");
node.remove("map");
if (o == null) {
pw.setError("map required and must be an array");
pw.setErrorPath(path);
return;
}
if (!(o instanceof JSONArray)) {
pw.setError("map must be an array");
pw.setErrorPath(path);
return;
}
int ii = 0;
JSONArray map = (JSONArray) o;
for (Object oo : map) {
if (!(oo instanceof JSONObject)) {
pw.setError("All map entries must be objects");
pw.setErrorPath(path + ".map[" + ii + "]");
ii++;
return;
}
JSONObject mapNode = (JSONObject) oo;
options = new OptionType[] { new OptionType("targetAttributeName", true, OptionType.OptionValueType.STRING), new OptionType("sourceType", true, OptionType.OptionValueType.STRING), new OptionType("targetAttributeSource", true, OptionType.OptionValueType.STRING) };
ProvisionMappingType pmt = new ProvisionMappingType();
for (OptionType ot : options) {
setAttribute(mapNode, ot, pmt, ProvisionMappingType.class, pw, path);
if (pw.getError() != null) {
return;
}
}
if (!mapNode.isEmpty()) {
pw.setError("Extra JSON keys : " + mapNode.toString());
pw.setErrorPath(path + ".map[" + ii + "]");
return;
}
task.getMap().getMapping().add(pmt);
}
loadSubTasks(node, path, pw, task);
if (pw.getError() != null) {
return;
}
if (!node.isEmpty()) {
pw.setError("Extra JSON keys : " + node.toString());
pw.setErrorPath(path);
return;
}
parent.add(task);
}
Aggregations