use of com.tremolosecurity.provisioning.workflow.ApprovalData in project OpenUnison by TremoloSecurity.
the class ExecuteWorkflow method doPost.
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
Gson gson = new Gson();
String wfcall = req.getParameter("wfcall");
if (wfcall == null) {
logger.error("Could not get workflow call");
resp.setStatus(500);
ProvisioningError pe = new ProvisioningError();
ProvisioningResult pres = new ProvisioningResult();
pres.setSuccess(false);
pres.setError(pe);
pe.setError("Could not get workflow call");
gson = new Gson();
resp.getOutputStream().print(gson.toJson(pres));
return;
}
String line;
StringBuffer json = new StringBuffer();
BufferedReader in = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(wfcall.getBytes("UTF-8"))));
while ((line = in.readLine()) != null) {
json.append(line).append('\n');
}
WFCall wfCall = gson.fromJson(json.toString(), WFCall.class);
if (wfCall == null) {
logger.error("Could not get workflow call");
resp.setStatus(500);
ProvisioningError pe = new ProvisioningError();
pe.setError("Could not get workflow call");
ProvisioningResult pres = new ProvisioningResult();
pres.setSuccess(false);
pres.setError(pe);
gson = new Gson();
resp.getOutputStream().print(gson.toJson(pres));
return;
}
List<ApprovalData> autoApprovals = null;
try {
// TremoloContext.getContext().getConfigManager("proxy").getProvisioningEngine().getWorkFlow(wfCall.getName()).executeWorkflow(wfCall);
com.tremolosecurity.provisioning.workflow.ExecuteWorkflow exec = new com.tremolosecurity.provisioning.workflow.ExecuteWorkflow();
exec.execute(wfCall, GlobalEntries.getGlobalEntries().getConfigManager());
ProvisioningResult res = new ProvisioningResult();
res.setSuccess(true);
resp.getOutputStream().print(gson.toJson(res));
} catch (Throwable t) {
logger.error("Error executing workflow", t);
resp.setStatus(500);
ProvisioningError pe = new ProvisioningError();
pe.setError("Error executing workflow");
ProvisioningResult pres = new ProvisioningResult();
pres.setSuccess(false);
pres.setError(pe);
gson = new Gson();
resp.getOutputStream().print(gson.toJson(pres));
}
}
Aggregations