Search in sources :

Example 1 with AuditLogQueryResult

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);
}
Also used : JSONAuditLogMarshaller(com.emc.storageos.api.service.impl.resource.utils.JSONAuditLogMarshaller) XMLAuditLogMarshaller(com.emc.storageos.api.service.impl.resource.utils.XMLAuditLogMarshaller) JSONAuditLogMarshaller(com.emc.storageos.api.service.impl.resource.utils.JSONAuditLogMarshaller) TimeSeriesMetadata(com.emc.storageos.db.client.TimeSeriesMetadata) XMLAuditLogMarshaller(com.emc.storageos.api.service.impl.resource.utils.XMLAuditLogMarshaller) DateTime(org.joda.time.DateTime) AuditLogQueryResult(com.emc.storageos.api.service.impl.resource.utils.AuditLogQueryResult)

Aggregations

AuditLogQueryResult (com.emc.storageos.api.service.impl.resource.utils.AuditLogQueryResult)1 JSONAuditLogMarshaller (com.emc.storageos.api.service.impl.resource.utils.JSONAuditLogMarshaller)1 XMLAuditLogMarshaller (com.emc.storageos.api.service.impl.resource.utils.XMLAuditLogMarshaller)1 TimeSeriesMetadata (com.emc.storageos.db.client.TimeSeriesMetadata)1 DateTime (org.joda.time.DateTime)1