protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
String profile = request.getParameter("profile");
String usr = request.getParameter("usr");
String pwd = request.getParameter("pwd");
TaskDefinitionService taskService = createTaskService(request, usr, pwd);
FormDefinitionService formService = createFormService(request, usr, pwd);
FormRepresentationEncoder encoder = FormEncodingFactory.getEncoder();
JsonObject json = new JsonObject();
json.addProperty("embedded", profile);
try {
if ( profile != null && "designer".equals(profile)) {
String userTask = request.getParameter("userTask");
String processName = request.getParameter("processName");
String bpmn2Process = IOUtils.toString(request.getReader());
TaskRef task = taskService.getBPMN2Task(bpmn2Process, processName, userTask);
if (task != null) {
//get associated form if it exists
FormRepresentation form = formService.getAssociatedForm(task.getPackageName(), task);
if (form != null) {
json.addProperty("formjson", encoder.encode(form));
}
json.add("task", toJsonObject(task));
json.addProperty("packageName", task.getPackageName());