Search in sources :

Example 1 with JobLog

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;
}
Also used : LogEvent(org.xwiki.logging.event.LogEvent) JobLog(org.xwiki.rest.model.jaxb.JobLog) Calendar(java.util.Calendar) Link(org.xwiki.rest.model.jaxb.Link)

Aggregations

Calendar (java.util.Calendar)1 LogEvent (org.xwiki.logging.event.LogEvent)1 JobLog (org.xwiki.rest.model.jaxb.JobLog)1 Link (org.xwiki.rest.model.jaxb.Link)1