use of org.killbill.billing.util.audit.AccountAuditLogs in project killbill by killbill.
the class AccountResource method getBlockingStates.
/*
* ************************* BLOCKING STATE *****************************
*/
@TimedResource
@GET
@Path("/{accountId:" + UUID_PATTERN + "}/" + BLOCK)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve blocking states for account", response = BlockingStateJson.class, responseContainer = "List")
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid account id supplied") })
public Response getBlockingStates(@PathParam(ID_PARAM_NAME) final String id, @QueryParam(QUERY_BLOCKING_STATE_TYPES) final List<BlockingStateType> typeFilter, @QueryParam(QUERY_BLOCKING_STATE_SVCS) final List<String> svcsFilter, @QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode, @javax.ws.rs.core.Context final HttpServletRequest request) throws EntitlementApiException {
final TenantContext tenantContext = this.context.createContext(request);
final UUID accountId = UUID.fromString(id);
final Iterable<BlockingState> blockingStates = subscriptionApi.getBlockingStates(accountId, typeFilter, svcsFilter, OrderingType.ASCENDING, SubscriptionApi.ALL_EVENTS, tenantContext);
final AccountAuditLogs accountAuditLogs = auditUserApi.getAccountAuditLogs(accountId, auditMode.getLevel(), tenantContext);
final List<BlockingStateJson> result = ImmutableList.copyOf(Iterables.transform(blockingStates, new Function<BlockingState, BlockingStateJson>() {
@Override
public BlockingStateJson apply(final BlockingState input) {
return new BlockingStateJson(input, accountAuditLogs);
}
}));
return Response.status(Status.OK).entity(result).build();
}
use of org.killbill.billing.util.audit.AccountAuditLogs in project killbill by killbill.
the class BundleResource method getBundleByKey.
@TimedResource
@GET
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve a bundle by external key", response = BundleJson.class)
@ApiResponses(value = { @ApiResponse(code = 404, message = "Bundle not found") })
public Response getBundleByKey(@QueryParam(QUERY_EXTERNAL_KEY) final String externalKey, @QueryParam(QUERY_INCLUDED_DELETED) @DefaultValue("false") final Boolean includedDeleted, @QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode, @javax.ws.rs.core.Context final HttpServletRequest request) throws SubscriptionApiException, AccountApiException, CatalogApiException {
final TenantContext tenantContext = this.context.createContext(request);
final List<SubscriptionBundle> bundles;
if (includedDeleted) {
bundles = subscriptionApi.getSubscriptionBundlesForExternalKey(externalKey, tenantContext);
} else {
final SubscriptionBundle activeBundle = subscriptionApi.getActiveSubscriptionBundleForExternalKey(externalKey, tenantContext);
bundles = ImmutableList.of(activeBundle);
}
final List<BundleJson> result = new ArrayList<BundleJson>(bundles.size());
for (final SubscriptionBundle bundle : bundles) {
final Account account = accountUserApi.getAccountById(bundle.getAccountId(), tenantContext);
final AccountAuditLogs accountAuditLogs = auditUserApi.getAccountAuditLogs(bundle.getAccountId(), auditMode.getLevel(), tenantContext);
final BundleJson json = new BundleJson(bundle, account.getCurrency(), accountAuditLogs);
result.add(json);
}
return Response.status(Status.OK).entity(result).build();
}
use of org.killbill.billing.util.audit.AccountAuditLogs 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);
}
}
Aggregations