public F.Promise<Result> call(Http.Context ctx) throws Throwable { try { return delegate.call(ctx); } catch (Exception e) { e.printStackTrace(); StringBuilder sb = new StringBuilder(); sb.append("Error for request at " + ctx.request().uri() + "\n"); sb.append("Headers: \n"); Map<String, String[]> headers = ctx.request().headers(); for (String key : headers.keySet()) { sb.append(" " + key + " --> "); for (String val : headers.get(key)) { sb.append(val + "|||"); } sb.append("\n"); } sb.append("Cookies: \n"); for (Http.Cookie cookie : ctx.request().cookies()) { sb.append(" " + cookie.name() + " --> " + cookie.value() + "\n"); } Http.RequestBody body = ctx.request().body(); Map<String, String[]> body_vals = body.asFormUrlEncoded(); if (body_vals != null) { sb.append("Body (as form URL encoded): \n"); for (String key : body_vals.keySet()) { sb.append(" " + key + " --> "); for (String val : body_vals.get(key)) { sb.append(val + "|||"); } sb.append("\n"); } } Logger.error(sb.toString()); throw e; } }
/** * Start the workflow run asynchronously. * * @param name The name of the workflow * @return json response containing id */ @Security.Authenticated(Secured.class) public Result runWorkflow(String name) { FormDefinition form = formDefinitionForWorkflow(name); // Process file upload first if present in form data Http.MultipartFormData body = request().body().asMultipartFormData(); for (Object obj : body.getFiles()) { Http.MultipartFormData.FilePart filePart = (Http.MultipartFormData.FilePart) obj; UserUpload userUpload = uploadFile(filePart); BasicField fileInputField = form.getField(filePart.getKey()); fileInputField.setValue(userUpload); } // Set the form definition field values from the request data Map<String, String[]> data = body.asFormUrlEncoded(); for (String key : data.keySet()) { BasicField field = form.getField(key); field.setValue(data.get(key)); } // Transfer form field data to workflow settings map Map<String, Object> settings = new HashMap<>(); for (BasicField field : form.fields) { settings.put(field.name, field.value()); } settings.putAll(settingsFromConfig(form)); // Update the workflow model object and persist to the db Workflow workflow = Workflow.find.where().eq("name", form.name).findUnique(); if (workflow == null) { workflow = new Workflow(); } workflow.name = form.name; workflow.title = form.title; workflow.yamlFile = form.yamlFile; workflow.save(); // Run the workflow ObjectNode response = runYamlWorkflow(form.yamlFile, workflow, settings); return redirect(routes.Application.index()); }