use of com.evolveum.midpoint.xml.ns._public.model.scripting_3.ExecuteScriptOutputType in project midpoint by Evolveum.
the class ModelRestService method executeScript.
@POST
@Path("/rpc/executeScript")
// @Produces({"text/html", "application/xml"})
@Consumes({ "application/xml" })
public Response executeScript(@Convertor(ExecuteScriptConvertor.class) ExecuteScriptType command, @QueryParam("asynchronous") Boolean asynchronous, @Context UriInfo uriInfo, @Context MessageContext mc) {
Task task = RestServiceUtil.initRequest(mc);
OperationResult result = task.getResult().createSubresult(OPERATION_EXECUTE_SCRIPT);
Response response;
try {
if (Boolean.TRUE.equals(asynchronous)) {
scriptingService.evaluateExpression(command, task, result);
URI resourceUri = uriInfo.getAbsolutePathBuilder().path(task.getOid()).build(task.getOid());
response = RestServiceUtil.createResponse(Response.Status.CREATED, resourceUri, result);
} else {
ScriptExecutionResult executionResult = scriptingService.evaluateExpression(command, task, result);
ExecuteScriptResponseType responseData = new ExecuteScriptResponseType().result(result.createOperationResultType()).output(new ExecuteScriptOutputType().consoleOutput(executionResult.getConsoleOutput()).dataOutput(ModelWebService.prepareXmlData(executionResult.getDataOutput(), command.getOptions())));
response = RestServiceUtil.createResponse(Response.Status.OK, responseData, result);
}
} catch (Exception ex) {
response = RestServiceUtil.handleException(result, ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't execute script.", ex);
}
result.computeStatus();
finishRequest(task);
return response;
}
Aggregations