return ApiResponseSerializer.toSerializedString(response, responseType);
}
@Override
public AsyncJobResponse createAsyncJobResponse(AsyncJob job) {
AsyncJobResponse jobResponse = new AsyncJobResponse();
jobResponse.setAccountId(job.getAccountId());
jobResponse.setUserId(job.getUserId());
jobResponse.setCmd(job.getCmd());
jobResponse.setCreated(job.getCreated());
jobResponse.setJobId(job.getId());
jobResponse.setJobStatus(job.getStatus());
jobResponse.setJobProcStatus(job.getProcessStatus());
if (job.getInstanceType() != null && job.getInstanceId() != null) {
jobResponse.setJobInstanceType(job.getInstanceType().toString());
jobResponse.setJobInstanceId(job.getInstanceId());
}
jobResponse.setJobResultCode(job.getResultCode());
boolean savedValue = SerializationContext.current().getUuidTranslation();
SerializationContext.current().setUuidTranslation(false);
Object resultObject = ApiSerializerHelper.fromSerializedString(job.getResult());
jobResponse.setJobResult((ResponseObject) resultObject);
SerializationContext.current().setUuidTranslation(savedValue);
if (resultObject != null) {
Class<?> clz = resultObject.getClass();
if (clz.isPrimitive() || clz.getSuperclass() == Number.class || clz == String.class || clz == Date.class) {
jobResponse.setJobResultType("text");
} else {
jobResponse.setJobResultType("object");
}
}
jobResponse.setObjectName("asyncjobs");
return jobResponse;
}