congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
AuditLevel
Code IndexAdd Tabnine to your IDE (free)

How to use
AuditLevel
in
com.ning.billing.util.api

Best Java code snippets using com.ning.billing.util.api.AuditLevel (Showing top 20 results out of 315)

origin: com.ning.billing/killbill-jaxrs

public boolean withAudit() {
  return !AuditLevel.NONE.equals(level);
}
origin: com.ning.billing/killbill-jaxrs

  @Override
  public int hashCode() {
    return level != null ? level.hashCode() : 0;
  }
}
origin: com.ning.billing/killbill-jaxrs

@PUT
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("/{accountId:" + UUID_PATTERN + "}")
public Response updateAccount(final AccountJson json,
               @PathParam("accountId") final String accountId,
               @HeaderParam(HDR_CREATED_BY) final String createdBy,
               @HeaderParam(HDR_REASON) final String reason,
               @HeaderParam(HDR_COMMENT) final String comment,
               @javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException {
  final AccountData data = json.toAccountData();
  final UUID uuid = UUID.fromString(accountId);
  accountUserApi.updateAccount(uuid, data, context.createContext(createdBy, reason, comment, request));
  return getAccount(accountId, false, false, new AuditMode(AuditLevel.NONE.toString()), request);
}
origin: com.ning.billing/killbill-util

  @Test(groups = "fast")
  public void testForObject() throws Exception {
    for (final ObjectType objectType : ObjectType.values()) {
      for (final UUID objectId : objectIds) {
        for (final AuditLevel level : AuditLevel.values()) {
          if (AuditLevel.NONE.equals(level)) {
            Assert.assertEquals(auditUserApi.getAuditLogs(objectId, objectType, level, callContext).size(), 0);
          } else if (AuditLevel.MINIMAL.equals(level)) {
            Assert.assertEquals(auditUserApi.getAuditLogs(objectId, objectType, level, callContext), ImmutableList.<AuditLog>of(auditLogs.get(0)));
          } else {
            Assert.assertEquals(auditUserApi.getAuditLogs(objectId, objectType, level, callContext), auditLogs);
          }
        }
      }
    }
  }
}
origin: com.ning.billing/killbill-util

@Test(groups = "slow")
public void testRetrieveAuditsDirectly() throws Exception {
  addTag();
  // Verify we get an audit entry for the tag_history table
  final Handle handle = dbi.open();
  final String tagHistoryString = (String) handle.select("select id from tag_history limit 1").get(0).get("id");
  handle.close();
  for (final AuditLevel level : AuditLevel.values()) {
    final List<AuditLog> auditLogs = auditDao.getAuditLogsForId(TableName.TAG_HISTORY, UUID.fromString(tagHistoryString), level, internalCallContext);
    verifyAuditLogsForTag(auditLogs, level);
  }
}
origin: com.ning.billing/killbill-jaxrs

public AuditMode(final String auditModeString) {
  this.level = AuditLevel.valueOf(auditModeString.toUpperCase());
}
origin: com.ning.billing/killbill-util

@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);
  }
}
origin: com.ning.billing/killbill-util

  private List<AuditLog> filterAuditLogs(final AuditLevel auditLevel, final List<AuditLog> auditLogs) {
    // TODO Do the filtering in the query
    if (AuditLevel.FULL.equals(auditLevel)) {
      return auditLogs;
    } else if (AuditLevel.MINIMAL.equals(auditLevel) && !auditLogs.isEmpty()) {
      if (ChangeType.INSERT.equals(auditLogs.get(0).getChangeType())) {
        return ImmutableList.<AuditLog>of(auditLogs.get(0));
      } else {
        // We may be coming here via the history code path - only a single mapped history record id
        // will be for the initial INSERT
        return ImmutableList.<AuditLog>of();
      }
    } else if (AuditLevel.NONE.equals(auditLevel)) {
      return ImmutableList.<AuditLog>of();
    } else {
      return auditLogs;
    }
  }
}
origin: com.ning.billing/killbill-jaxrs

@GET
@Path("/" + PAGINATION)
@Produces(APPLICATION_JSON)
public Response getAccounts(@QueryParam(QUERY_SEARCH_OFFSET) @DefaultValue("0") final Long offset,
              @QueryParam(QUERY_SEARCH_LIMIT) @DefaultValue("100") final Long limit,
              @QueryParam(QUERY_ACCOUNT_WITH_BALANCE) @DefaultValue("false") final Boolean accountWithBalance,
              @QueryParam(QUERY_ACCOUNT_WITH_BALANCE_AND_CBA) @DefaultValue("false") final Boolean accountWithBalanceAndCBA,
              @QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode,
              @javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException {
  final TenantContext tenantContext = context.createContext(request);
  final Pagination<Account> accounts = accountUserApi.getAccounts(offset, limit, tenantContext);
  final URI nextPageUri = uriBuilder.nextPage(AccountResource.class, "getAccounts", accounts.getNextOffset(), limit, ImmutableMap.<String, String>of(QUERY_ACCOUNT_WITH_BALANCE, accountWithBalance.toString(),
                                                                            QUERY_ACCOUNT_WITH_BALANCE_AND_CBA, accountWithBalanceAndCBA.toString(),
                                                                            QUERY_AUDIT, auditMode.getLevel().toString()));
  return buildStreamingPaginationResponse(accounts,
                      new Function<Account, AccountJson>() {
                        @Override
                        public AccountJson apply(final Account account) {
                          final AccountAuditLogs accountAuditLogs = auditUserApi.getAccountAuditLogs(account.getId(), auditMode.getLevel(), tenantContext);
                          return getAccount(account, accountWithBalance, accountWithBalanceAndCBA, accountAuditLogs, tenantContext);
                        }
                      },
                      nextPageUri);
}
origin: com.ning.billing/killbill-util

@Override
public List<AuditLog> getAuditLogs(final UUID objectId, final ObjectType objectType, final AuditLevel auditLevel, final TenantContext context) {
  // Optimization - bail early
  if (AuditLevel.NONE.equals(auditLevel)) {
    return ImmutableList.<AuditLog>of();
  }
  final TableName tableName = getTableNameFromObjectType(objectType);
  if (tableName == null) {
    return ImmutableList.<AuditLog>of();
  }
  return auditDao.getAuditLogsForId(tableName, objectId, auditLevel, internalCallContextFactory.createInternalTenantContext(context));
}
origin: com.ning.billing/killbill-jaxrs

@GET
@Path("/" + PAGINATION)
@Produces(APPLICATION_JSON)
public Response getInvoices(@QueryParam(QUERY_SEARCH_OFFSET) @DefaultValue("0") final Long offset,
              @QueryParam(QUERY_SEARCH_LIMIT) @DefaultValue("100") final Long limit,
              @QueryParam(QUERY_INVOICE_WITH_ITEMS) @DefaultValue("false") final Boolean withItems,
              @QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode,
              @javax.ws.rs.core.Context final HttpServletRequest request) throws InvoiceApiException {
  final TenantContext tenantContext = context.createContext(request);
  final Pagination<Invoice> invoices = invoiceApi.getInvoices(offset, limit, tenantContext);
  final URI nextPageUri = uriBuilder.nextPage(InvoiceResource.class, "getInvoices", invoices.getNextOffset(), limit, ImmutableMap.<String, String>of(QUERY_INVOICE_WITH_ITEMS, withItems.toString(),
                                                                            QUERY_AUDIT, auditMode.getLevel().toString()));
  final AtomicReference<Map<UUID, AccountAuditLogs>> accountsAuditLogs = new AtomicReference<Map<UUID, AccountAuditLogs>>(new HashMap<UUID, AccountAuditLogs>());
  return buildStreamingPaginationResponse(invoices,
                      new Function<Invoice, InvoiceJson>() {
                        @Override
                        public InvoiceJson apply(final Invoice invoice) {
                          // Cache audit logs per account
                          if (accountsAuditLogs.get().get(invoice.getAccountId()) == null) {
                            accountsAuditLogs.get().put(invoice.getAccountId(), auditUserApi.getAccountAuditLogs(invoice.getAccountId(), auditMode.getLevel(), tenantContext));
                          }
                          return new InvoiceJson(invoice, withItems, accountsAuditLogs.get().get(invoice.getAccountId()));
                        }
                      },
                      nextPageUri);
}
origin: com.ning.billing/killbill-util

@Override
public AccountAuditLogs getAccountAuditLogs(final UUID accountId, final AuditLevel auditLevel, final TenantContext tenantContext) {
  // Optimization - bail early
  if (AuditLevel.NONE.equals(auditLevel)) {
    return new DefaultAccountAuditLogs(accountId);
  }
  return auditDao.getAuditLogsForAccountRecordId(auditLevel, internalCallContextFactory.createInternalTenantContext(accountId, tenantContext));
}
origin: com.ning.billing/killbill-jaxrs

@GET
@Path("/" + PAGINATION)
@Produces(APPLICATION_JSON)
public Response getBundles(@QueryParam(QUERY_SEARCH_OFFSET) @DefaultValue("0") final Long offset,
              @QueryParam(QUERY_SEARCH_LIMIT) @DefaultValue("100") final Long limit,
              @QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode,
              @javax.ws.rs.core.Context final HttpServletRequest request) throws SubscriptionApiException {
  final TenantContext tenantContext = context.createContext(request);
  final Pagination<SubscriptionBundle> bundles = subscriptionApi.getSubscriptionBundles(offset, limit, tenantContext);
  final URI nextPageUri = uriBuilder.nextPage(BundleResource.class, "getBundles", bundles.getNextOffset(), limit, ImmutableMap.<String, String>of(QUERY_AUDIT, auditMode.getLevel().toString()));
  final AtomicReference<Map<UUID, AccountAuditLogs>> accountsAuditLogs = new AtomicReference<Map<UUID, AccountAuditLogs>>(new HashMap<UUID, AccountAuditLogs>());
  return buildStreamingPaginationResponse(bundles,
                      new Function<SubscriptionBundle, BundleJson>() {
                        @Override
                        public BundleJson apply(final SubscriptionBundle bundle) {
                          // Cache audit logs per account
                          if (accountsAuditLogs.get().get(bundle.getAccountId()) == null) {
                            accountsAuditLogs.get().put(bundle.getAccountId(), auditUserApi.getAccountAuditLogs(bundle.getAccountId(), auditMode.getLevel(), tenantContext));
                          }
                          return new BundleJson(bundle, accountsAuditLogs.get().get(bundle.getAccountId()));
                        }
                      },
                      nextPageUri);
}
origin: com.ning.billing/killbill-util

  @Override
  public List<AuditLog> getAuditLogsForId(final TableName tableName, final UUID objectId, final AuditLevel auditLevel, final InternalTenantContext context) {
    final Map<UUID, List<AuditLog>> auditLogsForTableName = auditLogsForTables.get(tableName);
    if (auditLogsForTableName == null) {
      return ImmutableList.<AuditLog>of();
    }

    final List<AuditLog> auditLogsForObjectId = auditLogsForTableName.get(objectId);
    final List<AuditLog> allAuditLogs = Objects.firstNonNull(auditLogsForObjectId, ImmutableList.<AuditLog>of());
    if (AuditLevel.FULL.equals(auditLevel)) {
      return allAuditLogs;
    } else if (AuditLevel.MINIMAL.equals(auditLevel) && allAuditLogs.size() > 0) {
      return ImmutableList.<AuditLog>of(allAuditLogs.get(0));
    } else if (AuditLevel.NONE.equals(auditLevel)) {
      return ImmutableList.<AuditLog>of();
    } else {
      return allAuditLogs;
    }
  }
}
origin: com.ning.billing/killbill-jaxrs

@GET
@Path("/" + PAGINATION)
@Produces(APPLICATION_JSON)
public Response getCustomFields(@QueryParam(QUERY_SEARCH_OFFSET) @DefaultValue("0") final Long offset,
                @QueryParam(QUERY_SEARCH_LIMIT) @DefaultValue("100") final Long limit,
                @QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode,
                @javax.ws.rs.core.Context final HttpServletRequest request) throws CustomFieldApiException {
  final TenantContext tenantContext = context.createContext(request);
  final Pagination<CustomField> customFields = customFieldUserApi.getCustomFields(offset, limit, tenantContext);
  final URI nextPageUri = uriBuilder.nextPage(CustomFieldResource.class, "getCustomFields", customFields.getNextOffset(), limit, ImmutableMap.<String, String>of(QUERY_AUDIT, auditMode.getLevel().toString()));
  return buildStreamingPaginationResponse(customFields,
                      new Function<CustomField, CustomFieldJson>() {
                        @Override
                        public CustomFieldJson apply(final CustomField customField) {
                          // TODO Really slow - we should instead try to figure out the account id
                          final List<AuditLog> auditLogs = auditUserApi.getAuditLogs(customField.getId(), ObjectType.CUSTOM_FIELD, auditMode.getLevel(), tenantContext);
                          return new CustomFieldJson(customField, auditLogs);
                        }
                      },
                      nextPageUri);
}
origin: com.ning.billing/killbill-jaxrs

  @Override
  public RefundJson apply(final Refund refund) {
    UUID kbAccountId = null;
    if (!AuditLevel.NONE.equals(auditMode.getLevel()) && paymentIdAccountIdMappings.get(refund.getPaymentId()) == null) {
      try {
        kbAccountId = paymentApi.getPayment(refund.getPaymentId(), false, tenantContext).getAccountId();
        paymentIdAccountIdMappings.put(refund.getPaymentId(), kbAccountId);
      } catch (final PaymentApiException e) {
        log.warn("Unable to retrieve payment for id " + refund.getPaymentId());
      }
    }
    // Cache audit logs per account
    if (accountsAuditLogs.get().get(kbAccountId) == null) {
      accountsAuditLogs.get().put(kbAccountId, auditUserApi.getAccountAuditLogs(kbAccountId, auditMode.getLevel(), tenantContext));
    }
    final List<AuditLog> auditLogs = accountsAuditLogs.get().get(kbAccountId) == null ? null : accountsAuditLogs.get().get(kbAccountId).getAuditLogsForRefund(refund.getId());
    return new RefundJson(refund, null, auditLogs);
  }
},
origin: com.ning.billing/killbill-jaxrs

@GET
@Path("/" + SEARCH + "/{searchKey:" + ANYTHING_PATTERN + "}")
@Produces(APPLICATION_JSON)
public Response searchInvoices(@PathParam("searchKey") final String searchKey,
                @QueryParam(QUERY_SEARCH_OFFSET) @DefaultValue("0") final Long offset,
                @QueryParam(QUERY_SEARCH_LIMIT) @DefaultValue("100") final Long limit,
                @QueryParam(QUERY_INVOICE_WITH_ITEMS) @DefaultValue("false") final Boolean withItems,
                @QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode,
                @javax.ws.rs.core.Context final HttpServletRequest request) throws SubscriptionApiException {
  final TenantContext tenantContext = context.createContext(request);
  final Pagination<Invoice> invoices = invoiceApi.searchInvoices(searchKey, offset, limit, tenantContext);
  final URI nextPageUri = uriBuilder.nextPage(InvoiceResource.class, "searchInvoices", invoices.getNextOffset(), limit, ImmutableMap.<String, String>of("searchKey", searchKey,
                                                                             QUERY_INVOICE_WITH_ITEMS, withItems.toString(),
                                                                             QUERY_AUDIT, auditMode.getLevel().toString()));
  final AtomicReference<Map<UUID, AccountAuditLogs>> accountsAuditLogs = new AtomicReference<Map<UUID, AccountAuditLogs>>(new HashMap<UUID, AccountAuditLogs>());
  return buildStreamingPaginationResponse(invoices,
                      new Function<Invoice, InvoiceJson>() {
                        @Override
                        public InvoiceJson apply(final Invoice invoice) {
                          // Cache audit logs per account
                          if (accountsAuditLogs.get().get(invoice.getAccountId()) == null) {
                            accountsAuditLogs.get().put(invoice.getAccountId(), auditUserApi.getAccountAuditLogs(invoice.getAccountId(), auditMode.getLevel(), tenantContext));
                          }
                          return new InvoiceJson(invoice, withItems, accountsAuditLogs.get().get(invoice.getAccountId()));
                        }
                      },
                      nextPageUri);
}
origin: com.ning.billing/killbill-jaxrs

  @Override
  public RefundJson apply(final Refund refund) {
    UUID kbAccountId = null;
    if (!AuditLevel.NONE.equals(auditMode.getLevel()) && paymentIdAccountIdMappings.get(refund.getPaymentId()) == null) {
      try {
        kbAccountId = paymentApi.getPayment(refund.getPaymentId(), false, tenantContext).getAccountId();
        paymentIdAccountIdMappings.put(refund.getPaymentId(), kbAccountId);
      } catch (final PaymentApiException e) {
        log.warn("Unable to retrieve payment for id " + refund.getPaymentId());
      }
    }
    // Cache audit logs per account
    if (accountsAuditLogs.get().get(kbAccountId) == null) {
      accountsAuditLogs.get().put(kbAccountId, auditUserApi.getAccountAuditLogs(kbAccountId, auditMode.getLevel(), tenantContext));
    }
    final List<AuditLog> auditLogs = accountsAuditLogs.get().get(kbAccountId) == null ? null : accountsAuditLogs.get().get(kbAccountId).getAuditLogsForRefund(refund.getId());
    return new RefundJson(refund, null, auditLogs);
  }
},
origin: com.ning.billing/killbill-jaxrs

@GET
@Path("/" + SEARCH + "/{searchKey:" + ANYTHING_PATTERN + "}")
@Produces(APPLICATION_JSON)
public Response searchAccounts(@PathParam("searchKey") final String searchKey,
                @QueryParam(QUERY_SEARCH_OFFSET) @DefaultValue("0") final Long offset,
                @QueryParam(QUERY_SEARCH_LIMIT) @DefaultValue("100") final Long limit,
                @QueryParam(QUERY_ACCOUNT_WITH_BALANCE) @DefaultValue("false") final Boolean accountWithBalance,
                @QueryParam(QUERY_ACCOUNT_WITH_BALANCE_AND_CBA) @DefaultValue("false") final Boolean accountWithBalanceAndCBA,
                @QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode,
                @javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException {
  final TenantContext tenantContext = context.createContext(request);
  final Pagination<Account> accounts = accountUserApi.searchAccounts(searchKey, offset, limit, tenantContext);
  final URI nextPageUri = uriBuilder.nextPage(AccountResource.class, "searchAccounts", accounts.getNextOffset(), limit, ImmutableMap.<String, String>of("searchKey", searchKey,
                                                                             QUERY_ACCOUNT_WITH_BALANCE, accountWithBalance.toString(),
                                                                             QUERY_ACCOUNT_WITH_BALANCE_AND_CBA, accountWithBalanceAndCBA.toString(),
                                                                             QUERY_AUDIT, auditMode.getLevel().toString()));
  return buildStreamingPaginationResponse(accounts,
                      new Function<Account, AccountJson>() {
                        @Override
                        public AccountJson apply(final Account account) {
                          final AccountAuditLogs accountAuditLogs = auditUserApi.getAccountAuditLogs(account.getId(), auditMode.getLevel(), tenantContext);
                          return getAccount(account, accountWithBalance, accountWithBalanceAndCBA, accountAuditLogs, tenantContext);
                        }
                      },
                      nextPageUri);
}
origin: com.ning.billing/killbill-util

@Override
public AccountAuditLogsForObjectType getAccountAuditLogs(final UUID accountId, final ObjectType objectType, final AuditLevel auditLevel, final TenantContext tenantContext) {
  // Optimization - bail early
  if (AuditLevel.NONE.equals(auditLevel)) {
    return new DefaultAccountAuditLogsForObjectType(auditLevel);
  }
  final TableName tableName = getTableNameFromObjectType(objectType);
  if (tableName == null) {
    return new DefaultAccountAuditLogsForObjectType(auditLevel);
  }
  return auditDao.getAuditLogsForAccountRecordId(tableName, auditLevel, internalCallContextFactory.createInternalTenantContext(accountId, tenantContext));
}
com.ning.billing.util.apiAuditLevel

Most used methods

  • equals
  • hashCode
  • toString
  • valueOf
  • values

Popular in Java

  • Updating database using SQL prepared statement
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • startActivity (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now