in wilma-application/modules/wilma-stub-configuration-parser/src/main/java/com/epam/wilma/stubconfig/json/parser/ResponseDescriptorJsonParser.java [106:132]
private Template getTemplate(final String templateName, final JSONObject root) {
String name;
String type = null;
String resourceString = null;
boolean found = false;
if (root.has("templates")) {
JSONArray templateArray = root.getJSONArray("templates");
for (int i = 0; templateArray.length() > i; i++) {
JSONObject template = templateArray.getJSONObject(i);
name = template.getString("name");
if (name.contentEquals(templateName)) {
type = template.getString("type");
resourceString = template.getString("resource");
found = true;
break;
}
}
} else {
throw new DescriptorCannotBeParsedException("There is no Template defined.");
}
if (!found) {
throw new DescriptorCannotBeParsedException("Cannot find template with name: '" + templateName + "'.");
}
TemplateType templateType = getTemplateType(type);
byte[] resource = initializeResource(templateType, resourceString);
return new Template(templateName, templateType, resource);
}