use of com.emc.storageos.api.service.impl.resource.utils.AuditLogQueryResult in project coprhd-controller by CoprHD.
the class DbAuditLogRetriever method getBulkAuditLogs.
@Override
public void getBulkAuditLogs(AuditLogRequest auditLogRequest, MediaType type, Writer writer) throws MarshallingExcetion {
if (dbClient == null) {
throw APIException.internalServerErrors.auditLogNoDb();
}
AuditLogMarshaller marshaller = null;
if (type.equals(MediaType.APPLICATION_XML_TYPE)) {
marshaller = new XMLAuditLogMarshaller();
log.debug("Parser type: {}", type.toString());
} else if (type.equals(MediaType.APPLICATION_JSON_TYPE)) {
marshaller = new JSONAuditLogMarshaller();
log.debug("Parser type: {}", type.toString());
} else if (type.equals(MediaType.TEXT_PLAIN_TYPE)) {
marshaller = new TextAuditLogMarshaller();
log.debug("parser type: {}", type.toString());
} else {
log.warn("unsupported type: {}, use XML", type.toString());
marshaller = new XMLAuditLogMarshaller();
}
marshaller.setLang(auditLogRequest.getLanguage());
DateTime start = auditLogRequest.getStartTime();
DateTime end = auditLogRequest.getEndTime();
TimeSeriesMetadata.TimeBucket bucket = TimeSeriesMetadata.TimeBucket.HOUR;
if (start.plusSeconds(59).isEqual(end.toInstant())) {
bucket = TimeSeriesMetadata.TimeBucket.MINUTE;
}
AuditLogQueryResult result = new AuditLogQueryResult(marshaller, writer, auditLogRequest);
marshaller.header(writer);
log.info("Query time bucket {} to {}", start, end);
for (; !start.isAfter(end.toInstant()); start = start.plusHours(1)) {
dbClient.queryTimeSeries(AuditLogTimeSeries.class, start, bucket, result, getThreadPool());
}
result.outputCount();
marshaller.tailer(writer);
}
Aggregations