}
public JSONObject addPrintService(HttpSession session, JSONObject json) {
try {
BarcodableSchema barcodableSchema = printManager.getBarcodableSchema(json.getString("schema"));
MisoPrintService printService = new DefaultPrintService();
if ("Custom".equals(json.getString("serviceFor"))) {
printService = new CustomPrintService();
}
printService.setName(json.getString("serviceName"));
PrintContext pc = printManager.getPrintContext(json.getString("contextName"));
JSONObject contextFields = JSONObject.fromObject(json.getString("contextFields"));
PrintServiceUtils.mapJSONToContextFields(contextFields, pc);
printService.setPrintContext(pc);
printService.setBarcodableSchema(barcodableSchema);
printService.setEnabled(true);
if ("Custom".equals(json.getString("serviceFor"))) {
printService.setPrintServiceFor(JSONObject.class);
}
else {
printService.setPrintServiceFor(Class.forName(json.getString("serviceFor")).asSubclass(Barcodable.class));
}
printManager.storePrintService(printService);
return JSONUtils.JSONObjectResponse("html", "OK");
}
catch (ClassNotFoundException e) {