use of org.xwiki.rest.model.jaxb.JobLog in project xwiki-platform by xwiki.
the class ModelFactory method toRestJobLog.
public JobLog toRestJobLog(Collection<LogEvent> logs, URI self) {
JobLog log = this.objectFactory.createJobLog();
// Serialize log
for (LogEvent logEvent : logs) {
// TODO: add support for log arguments
// TODO: add support for log Marker
org.xwiki.rest.model.jaxb.LogEvent event = this.objectFactory.createLogEvent();
event.setLevel(logEvent.getLevel().name());
Calendar calendarDate = Calendar.getInstance();
calendarDate.setTimeInMillis(logEvent.getTimeStamp());
event.setDate(calendarDate);
event.setFormattedMessage(logEvent.getFormattedMessage());
log.getLogEvents().add(event);
}
// Set link
if (self != null) {
Link link = this.objectFactory.createLink();
link.setHref(self.toString());
link.setRel(Relations.SELF);
log.getLinks().add(link);
}
return log;
}