コード例 #1
0
  protected Collection<Payment> getPaymentsWithPluginInfoByAccountId(
      final UUID accountId, final TenantContext context) throws AnalyticsRefreshException {
    PaymentApiException error;

    final PaymentApi paymentApi = getPaymentUserApi();
    try {
      return paymentApi.getAccountPayments(accountId, true, PLUGIN_PROPERTIES, context);
    } catch (PaymentApiException e) {
      error = e;
      if (e.getCode() == ErrorCode.PAYMENT_NO_SUCH_PAYMENT_PLUGIN.getCode()) {
        logService.log(
            LogService.LOG_WARNING,
            e.getMessage() + ". Analytics tables will be missing plugin specific information");

        try {
          return paymentApi.getAccountPayments(accountId, false, PLUGIN_PROPERTIES, context);
        } catch (PaymentApiException e1) {
          error = e1;
        }
      }
    }

    logService.log(
        LogService.LOG_WARNING, "Error retrieving payments for account id " + accountId, error);
    throw new AnalyticsRefreshException(error);
  }
コード例 #2
0
  protected List<PaymentMethod> getPaymentMethodsForAccount(
      final UUID accountId, final TenantContext context) throws AnalyticsRefreshException {
    PaymentApiException error;

    final PaymentApi paymentApi = getPaymentUserApi();
    try {
      // Try to get all payment methods, with plugin information
      // TODO this will not return deleted payment methods
      return paymentApi.getAccountPaymentMethods(accountId, true, PLUGIN_PROPERTIES, context);
    } catch (PaymentApiException e) {
      error = e;
      if (e.getCode() == ErrorCode.PAYMENT_NO_SUCH_PAYMENT_PLUGIN.getCode()) {
        logService.log(
            LogService.LOG_WARNING,
            e.getMessage() + ". Analytics tables will be missing plugin specific information");

        try {
          return paymentApi.getAccountPaymentMethods(accountId, false, PLUGIN_PROPERTIES, context);
        } catch (PaymentApiException e1) {
          error = e1;
        }
      }
    }

    logService.log(
        LogService.LOG_WARNING,
        "Error retrieving payment methods for account id " + accountId,
        error);
    throw new AnalyticsRefreshException(error);
  }
コード例 #3
0
  protected Account getAccount(final UUID accountId, final TenantContext context)
      throws AnalyticsRefreshException {
    final AccountUserApi accountUserApi = getAccountUserApi();

    try {
      return accountUserApi.getAccountById(accountId, context);
    } catch (AccountApiException e) {
      logService.log(LogService.LOG_WARNING, "Error retrieving account for id " + accountId, e);
      throw new AnalyticsRefreshException(e);
    }
  }
コード例 #4
0
 public void rebuildAnalyticsForAccount(final UUID accountId, final CallContext context)
     throws AnalyticsRefreshException {
   final BusinessContextFactory businessContextFactory =
       new BusinessContextFactory(
           accountId,
           context,
           currencyConversionDao,
           logService,
           osgiKillbillAPI,
           osgiConfigPropertiesService,
           clock);
   logService.log(
       LogService.LOG_INFO,
       "Starting Analytics refresh for account " + businessContextFactory.getAccountId());
   // TODO Should we take the account lock?
   allBusinessObjectsDao.update(businessContextFactory);
   logService.log(
       LogService.LOG_INFO,
       "Finished Analytics refresh for account " + businessContextFactory.getAccountId());
 }
コード例 #5
0
  protected AuditLog getTagCreationAuditLog(
      final UUID tagId, final AccountAuditLogs accountAuditLogs) throws AnalyticsRefreshException {
    final List<AuditLog> auditLogsForTag = accountAuditLogs.getAuditLogsForTag(tagId);
    for (final AuditLog auditLog : auditLogsForTag) {
      if (auditLog.getChangeType().equals(ChangeType.INSERT)) {
        return auditLog;
      }
    }

    logService.log(LogService.LOG_WARNING, "Unable to find Tag creation audit log for id " + tagId);
    return null;
  }
コード例 #6
0
  protected List<SubscriptionBundle> getSubscriptionBundlesForAccount(
      final UUID accountId, final TenantContext context) throws AnalyticsRefreshException {
    final SubscriptionApi subscriptionApi = getSubscriptionApi();

    try {
      return subscriptionApi.getSubscriptionBundlesForAccountId(accountId, context);
    } catch (SubscriptionApiException e) {
      logService.log(
          LogService.LOG_WARNING, "Error retrieving bundles for account id " + accountId, e);
      throw new AnalyticsRefreshException(e);
    }
  }
コード例 #7
0
 protected Plan getPlanFromInvoiceItem(final InvoiceItem invoiceItem, final TenantContext context)
     throws AnalyticsRefreshException {
   try {
     final Catalog catalog = getCatalog(context);
     return catalog.findPlan(
         invoiceItem.getPlanName(), invoiceItem.getStartDate().toDateTimeAtStartOfDay());
   } catch (CatalogApiException e) {
     logService.log(
         LogService.LOG_INFO,
         "Unable to retrieve plan for invoice item " + invoiceItem.getId(),
         e);
     return null;
   }
 }
コード例 #8
0
  protected AuditLog getInvoicePaymentCreationAuditLog(
      final UUID invoicePaymentId, final AccountAuditLogs accountAuditLogs)
      throws AnalyticsRefreshException {
    final List<AuditLog> auditLogsForInvoicePayment =
        accountAuditLogs.getAuditLogsForInvoicePayment(invoicePaymentId);
    for (final AuditLog auditLog : auditLogsForInvoicePayment) {
      if (auditLog.getChangeType().equals(ChangeType.INSERT)) {
        return auditLog;
      }
    }

    logService.log(
        LogService.LOG_WARNING,
        "Unable to find Invoice payment creation audit log for id " + invoicePaymentId);
    return null;
  }
コード例 #9
0
  protected AuditLog getBlockingStateCreationAuditLog(
      final UUID blockingStateId, final AccountAuditLogs accountAuditLogs)
      throws AnalyticsRefreshException {
    final List<AuditLog> auditLogsForBlockingState =
        accountAuditLogs.getAuditLogsForBlockingState(blockingStateId);
    for (final AuditLog auditLog : auditLogsForBlockingState) {
      if (auditLog.getChangeType().equals(ChangeType.INSERT)) {
        return auditLog;
      }
    }

    logService.log(
        LogService.LOG_WARNING,
        "Unable to find Blocking state creation audit log for id " + blockingStateId);
    return null;
  }
コード例 #10
0
  protected AuditLog getSubscriptionEventCreationAuditLog(
      final UUID subscriptionEventId,
      final ObjectType objectType,
      final AccountAuditLogs accountAuditLogs)
      throws AnalyticsRefreshException {
    final List<AuditLog> auditLogsForSubscriptionEvent =
        accountAuditLogs.getAuditLogs(objectType).getAuditLogs(subscriptionEventId);
    for (final AuditLog auditLog : auditLogsForSubscriptionEvent) {
      if (auditLog.getChangeType().equals(ChangeType.INSERT)) {
        return auditLog;
      }
    }

    logService.log(
        LogService.LOG_WARNING,
        "Unable to find Subscription event creation audit log for id " + subscriptionEventId);
    return null;
  }
コード例 #11
0
 protected PlanPhase getPlanPhaseFromInvoiceItem(
     final InvoiceItem invoiceItem,
     final LocalDate subscriptionStartDate,
     final TenantContext context)
     throws AnalyticsRefreshException {
   try {
     final Catalog catalog = getCatalog(context);
     // TODO - Inaccurate timing
     return catalog.findPhase(
         invoiceItem.getPhaseName(),
         invoiceItem.getStartDate().toDateTimeAtStartOfDay(),
         subscriptionStartDate.toDateTimeAtStartOfDay());
   } catch (CatalogApiException e) {
     logService.log(
         LogService.LOG_INFO,
         "Unable to retrieve phase for invoice item " + invoiceItem.getId(),
         e);
     return null;
   }
 }
コード例 #12
0
  protected SubscriptionBundle getLatestSubscriptionBundleForExternalKey(
      final String bundleExternalKey, final TenantContext context)
      throws AnalyticsRefreshException {
    final SubscriptionApi subscriptionApi = getSubscriptionApi();

    try {
      final List<SubscriptionBundle> bundles =
          subscriptionApi.getSubscriptionBundlesForExternalKey(bundleExternalKey, context);
      if (bundles.size() == 0) {
        throw new AnalyticsRefreshException(
            "Unable to retrieve latest bundle for bundle external key " + bundleExternalKey);
      }
      return bundles.get(bundles.size() - 1);
    } catch (SubscriptionApiException e) {
      logService.log(
          LogService.LOG_WARNING,
          "Error retrieving bundles for bundle external key " + bundleExternalKey,
          e);
      throw new AnalyticsRefreshException(e);
    }
  }