Search in sources :

Example 1 with AccountAuditLogsForObjectType

use of org.killbill.billing.util.audit.AccountAuditLogsForObjectType in project killbill by killbill.

the class JaxRsResourceBase method createTagResponse.

protected Response createTagResponse(final UUID accountId, final List<Tag> tags, final AuditMode auditMode, final TenantContext context) throws TagDefinitionApiException {
    final AccountAuditLogsForObjectType tagsAuditLogs = auditUserApi.getAccountAuditLogs(accountId, ObjectType.TAG, auditMode.getLevel(), context);
    final Map<UUID, TagDefinition> tagDefinitionsCache = new HashMap<UUID, TagDefinition>();
    final Collection<TagJson> result = new LinkedList<TagJson>();
    for (final Tag tag : tags) {
        if (tagDefinitionsCache.get(tag.getTagDefinitionId()) == null) {
            tagDefinitionsCache.put(tag.getTagDefinitionId(), tagUserApi.getTagDefinition(tag.getTagDefinitionId(), context));
        }
        final TagDefinition tagDefinition = tagDefinitionsCache.get(tag.getTagDefinitionId());
        final List<AuditLog> auditLogs = tagsAuditLogs.getAuditLogs(tag.getId());
        result.add(new TagJson(tag, tagDefinition, auditLogs));
    }
    return Response.status(Response.Status.OK).entity(result).build();
}
Also used : TagDefinition(org.killbill.billing.util.tag.TagDefinition) TagJson(org.killbill.billing.jaxrs.json.TagJson) HashMap(java.util.HashMap) AccountAuditLogsForObjectType(org.killbill.billing.util.audit.AccountAuditLogsForObjectType) Tag(org.killbill.billing.util.tag.Tag) UUID(java.util.UUID) LinkedList(java.util.LinkedList) AuditLog(org.killbill.billing.util.audit.AuditLog)

Example 2 with AccountAuditLogsForObjectType

use of org.killbill.billing.util.audit.AccountAuditLogsForObjectType in project killbill by killbill.

the class TestDefaultAuditDao method testRetrieveAuditsViaHistory.

@Test(groups = "slow")
public void testRetrieveAuditsViaHistory() throws Exception {
    addTag();
    for (final AuditLevel level : AuditLevel.values()) {
        final List<AuditLog> auditLogs = auditDao.getAuditLogsForId(TableName.TAG, tag.getId(), level, internalCallContext);
        verifyAuditLogsForTag(auditLogs, level);
        final AccountAuditLogs accountAuditLogs = auditDao.getAuditLogsForAccountRecordId(level, internalCallContext);
        verifyAuditLogsForTag(accountAuditLogs.getAuditLogs(ObjectType.TAG).getAuditLogs(tag.getId()), level);
        final AccountAuditLogsForObjectType accountAuditLogsForObjectType = auditDao.getAuditLogsForAccountRecordId(TableName.TAG, level, internalCallContext);
        verifyAuditLogsForTag(accountAuditLogsForObjectType.getAuditLogs(tag.getId()), level);
    }
}
Also used : AuditLevel(org.killbill.billing.util.api.AuditLevel) AccountAuditLogsForObjectType(org.killbill.billing.util.audit.AccountAuditLogsForObjectType) AccountAuditLogs(org.killbill.billing.util.audit.AccountAuditLogs) AuditLog(org.killbill.billing.util.audit.AuditLog) Test(org.testng.annotations.Test)

Aggregations

AccountAuditLogsForObjectType (org.killbill.billing.util.audit.AccountAuditLogsForObjectType)2 AuditLog (org.killbill.billing.util.audit.AuditLog)2 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 UUID (java.util.UUID)1 TagJson (org.killbill.billing.jaxrs.json.TagJson)1 AuditLevel (org.killbill.billing.util.api.AuditLevel)1 AccountAuditLogs (org.killbill.billing.util.audit.AccountAuditLogs)1 Tag (org.killbill.billing.util.tag.Tag)1 TagDefinition (org.killbill.billing.util.tag.TagDefinition)1 Test (org.testng.annotations.Test)1