Search in sources :

Example 31 with AccountAuditLogs

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();
}
Also used : Function(com.google.common.base.Function) TenantContext(org.killbill.billing.util.callcontext.TenantContext) BlockingState(org.killbill.billing.entitlement.api.BlockingState) UUID(java.util.UUID) AccountAuditLogs(org.killbill.billing.util.audit.AccountAuditLogs) BlockingStateJson(org.killbill.billing.jaxrs.json.BlockingStateJson) Path(javax.ws.rs.Path) TimedResource(org.killbill.commons.metrics.TimedResource) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 32 with AccountAuditLogs

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();
}
Also used : Account(org.killbill.billing.account.api.Account) SubscriptionBundle(org.killbill.billing.entitlement.api.SubscriptionBundle) ArrayList(java.util.ArrayList) TenantContext(org.killbill.billing.util.callcontext.TenantContext) AccountAuditLogs(org.killbill.billing.util.audit.AccountAuditLogs) BundleJson(org.killbill.billing.jaxrs.json.BundleJson) TimedResource(org.killbill.commons.metrics.TimedResource) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 33 with AccountAuditLogs

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);
    }
}
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

AccountAuditLogs (org.killbill.billing.util.audit.AccountAuditLogs)33 ApiOperation (io.swagger.annotations.ApiOperation)31 ApiResponses (io.swagger.annotations.ApiResponses)31 GET (javax.ws.rs.GET)31 Produces (javax.ws.rs.Produces)31 TenantContext (org.killbill.billing.util.callcontext.TenantContext)31 TimedResource (org.killbill.commons.metrics.TimedResource)31 Path (javax.ws.rs.Path)27 UUID (java.util.UUID)19 Account (org.killbill.billing.account.api.Account)16 PluginProperty (org.killbill.billing.payment.api.PluginProperty)13 URI (java.net.URI)10 Payment (org.killbill.billing.payment.api.Payment)9 ImmutableMap (com.google.common.collect.ImmutableMap)8 HashMap (java.util.HashMap)8 Map (java.util.Map)8 AtomicReference (java.util.concurrent.atomic.AtomicReference)8 SubscriptionBundle (org.killbill.billing.entitlement.api.SubscriptionBundle)6 Invoice (org.killbill.billing.invoice.api.Invoice)6 PaymentJson (org.killbill.billing.jaxrs.json.PaymentJson)6