• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java TenantContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.killbill.billing.util.callcontext.TenantContext的典型用法代码示例。如果您正苦于以下问题:Java TenantContext类的具体用法?Java TenantContext怎么用?Java TenantContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TenantContext类属于org.killbill.billing.util.callcontext包,在下文中一共展示了TenantContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: sendEmailForUpComingInvoice

import org.killbill.billing.util.callcontext.TenantContext; //导入依赖的package包/类
private void sendEmailForUpComingInvoice(final Account account, final ExtBusEvent killbillEvent, final TenantContext context) throws IOException, InvoiceApiException, EmailException, TenantApiException, EmailNotificationException {

        Preconditions.checkArgument(killbillEvent.getEventType() == ExtBusEventType.INVOICE_NOTIFICATION, String.format("Unexpected event %s", killbillEvent.getEventType()));

        final String dryRunTimePropValue = configProperties.getString(INVOICE_DRY_RUN_TIME_PROPERTY);
        Preconditions.checkArgument(dryRunTimePropValue != null, String.format("Cannot find property %s", INVOICE_DRY_RUN_TIME_PROPERTY));

        final TimeSpan span = new TimeSpan(dryRunTimePropValue);

        final DateTime now = clock.getClock().getUTCNow();
        final DateTime targetDateTime = now.plus(span.getMillis());

        final PluginCallContext callContext = new PluginCallContext(EmailNotificationActivator.PLUGIN_NAME, now, context.getTenantId());
        final Invoice invoice = osgiKillbillAPI.getInvoiceUserApi().triggerInvoiceGeneration(account.getId(), new LocalDate(targetDateTime, account.getTimeZone()), NULL_DRY_RUN_ARGUMENTS, callContext);
        if (invoice != null) {
            final EmailContent emailContent = templateRenderer.generateEmailForUpComingInvoice(account, invoice, context);
            sendEmail(account, emailContent, context);
        }
    }
 
开发者ID:killbill,项目名称:killbill-email-notifications-plugin,代码行数:20,代码来源:EmailNotificationListener.java


示例2: defaultAccountCustomField

import org.killbill.billing.util.callcontext.TenantContext; //导入依赖的package包/类
@Test(groups = "fast")
public void defaultAccountCustomField() {
    // given
    Account account = EasyTaxTestUtils.createAccount("NZ",
            DateTimeZone.forID("Pacific/Auckland"));
    CustomFieldUserApi fieldApi = Mockito.mock(CustomFieldUserApi.class);
    when(killbillApi.getCustomFieldUserApi()).thenReturn(fieldApi);
    ArgumentCaptor<TenantContext> contextCaptor = ArgumentCaptor.forClass(TenantContext.class);
    CustomField customField = createCustomField(
            AccountCustomFieldTaxZoneResolver.TAX_ZONE_CUSTOM_FIIELD, TEST_TAX_ZONE);
    when(fieldApi.getCustomFieldsForObject(eq(account.getId()), eq(ObjectType.ACCOUNT),
            contextCaptor.capture())).thenReturn(Collections.singletonList(customField));

    // when
    AccountCustomFieldTaxZoneResolver resolver = createResolver(new Properties());
    String taxZone = resolver.taxZoneForInvoice(tenantId, account, null,
            Collections.emptyList());

    // then
    assertEquals(contextCaptor.getValue().getTenantId(), tenantId, "TenantContext tenant ID");
    assertEquals(taxZone, TEST_TAX_ZONE, "Tax zone resolved from account custom field");
}
 
开发者ID:SolarNetwork,项目名称:killbill-easytax-plugin,代码行数:23,代码来源:AccountCustomFieldTaxZoneResolverTests.java


示例3: defaultFallbackToAccountCountry

import org.killbill.billing.util.callcontext.TenantContext; //导入依赖的package包/类
@Test(groups = "fast")
public void defaultFallbackToAccountCountry() {
    // given
    Account account = EasyTaxTestUtils.createAccount("NZ",
            DateTimeZone.forID("Pacific/Auckland"));
    CustomFieldUserApi fieldApi = Mockito.mock(CustomFieldUserApi.class);
    when(killbillApi.getCustomFieldUserApi()).thenReturn(fieldApi);
    ArgumentCaptor<TenantContext> contextCaptor = ArgumentCaptor.forClass(TenantContext.class);
    when(fieldApi.getCustomFieldsForObject(eq(account.getId()), eq(ObjectType.ACCOUNT),
            contextCaptor.capture())).thenReturn(Collections.emptyList());

    // when
    AccountCustomFieldTaxZoneResolver resolver = createResolver(new Properties());
    String taxZone = resolver.taxZoneForInvoice(tenantId, account, null,
            Collections.emptyList());

    // then
    assertEquals(contextCaptor.getValue().getTenantId(), tenantId, "TenantContext tenant ID");
    assertEquals(taxZone, account.getCountry(),
            "Fallback to account country when no custom field present");
}
 
开发者ID:SolarNetwork,项目名称:killbill-easytax-plugin,代码行数:22,代码来源:AccountCustomFieldTaxZoneResolverTests.java


示例4: givenPermissions

import org.killbill.billing.util.callcontext.TenantContext; //导入依赖的package包/类
private void givenPermissions(String username, String password, Set<Permission> permissions) {
    String credentials = username + ":" + password;
    try {
        String authHeaderValue = "Basic "
                + Base64.getEncoder().encodeToString(credentials.getBytes("UTF-8"));
        given(req.getHeader("Authorization")).willReturn(authHeaderValue);
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e);
    }
    given(securityApi.isSubjectAuthenticated()).willReturn(true);
    given(securityApi
            .getCurrentUserPermissions(Matchers.argThat(new ArgumentMatcher<TenantContext>() {

                @Override
                public boolean matches(Object arg) {
                    return (arg instanceof TenantContext
                            && tenantId.equals(((TenantContext) arg).getTenantId()));
                }

            }))).willReturn(permissions);
}
 
开发者ID:SolarNetwork,项目名称:killbill-easytax-plugin,代码行数:22,代码来源:EasyTaxServletTests.java


示例5: getTranslationMap

import org.killbill.billing.util.callcontext.TenantContext; //导入依赖的package包/类
private Map<String, String> getTranslationMap(final String accountLocale, final ResourceBundleFactory.ResourceBundleType bundleType, final TenantContext context) throws TenantApiException, EmailNotificationException {
    final ResourceBundle translationBundle = accountLocale != null ?
            bundleFactory.createBundle(LocaleUtils.toLocale(accountLocale), bundleType, context) : null;

    if (translationBundle == null){
        throw new EmailNotificationException(TRANSLATION_INVALID, accountLocale);
    }

    final Map<String, String> text = new HashMap<String, String>();
    Enumeration<String> keys = translationBundle.getKeys();
    while (keys.hasMoreElements()) {
        final String key = keys.nextElement();
        text.put(key, translationBundle.getString(key));
    }
    return text;
}
 
开发者ID:killbill,项目名称:killbill-email-notifications-plugin,代码行数:17,代码来源:TemplateRenderer.java


示例6: getTemplateText

import org.killbill.billing.util.callcontext.TenantContext; //导入依赖的package包/类
private String getTemplateText(final Locale locale, final TemplateType templateType, final TenantContext context) throws TenantApiException {

        final String defaultTemplateName = DEFAULT_TEMPLATE_PATH_PREFIX + templateType.getDefaultTemplateName();
        if (context.getTenantId() == null) {
            return getDefaultTemplate(defaultTemplateName);
        }

        // TODO Caching strategy
        final String templateTenantKey = LocaleUtils.localeString(locale, templateType.getTemplateKey());
        final List<String> result = tenantApi.getTenantValuesForKey(templateTenantKey, context);
        if (result.size() == 1) {

            return result.get(0);
        }
        return getDefaultTemplate(defaultTemplateName);

    }
 
开发者ID:killbill,项目名称:killbill-email-notifications-plugin,代码行数:18,代码来源:TemplateRenderer.java


示例7: getTenantBundleForType

import org.killbill.billing.util.callcontext.TenantContext; //导入依赖的package包/类
private String getTenantBundleForType(final Locale locale, final ResourceBundleType type, final TenantContext tenantContext) throws TenantApiException {
    String tenantKey;
    switch (type) {
        case CATALOG_TRANSLATION:
            tenantKey = LocaleUtils.localeString(locale, TenantKV.TenantKey.CATALOG_TRANSLATION_.name());
            break;
        case TEMPLATE_TRANSLATION:
            tenantKey = LocaleUtils.localeString(locale, type.getTranslationKey());
            break;
        default:
            return null;
    }
    if (tenantKey !=  null) {
        final List<String> result = tenantApi.getTenantValuesForKey(tenantKey, tenantContext);
        if (result.size() == 1) {
            return result.get(0);
        }
    }
    return null;
}
 
开发者ID:killbill,项目名称:killbill-email-notifications-plugin,代码行数:21,代码来源:ResourceBundleFactory.java


示例8: testPaymentRefund

import org.killbill.billing.util.callcontext.TenantContext; //导入依赖的package包/类
@Test(groups = "fast")
public void testPaymentRefund() throws Exception {
    final AccountData account = createAccount();
    final PaymentTransaction paymentTransaction = createPaymentTransaction(new BigDecimal("937.070000000"), Currency.USD);

    final TenantContext tenantContext = createTenantContext();
    final EmailContent email = renderer.generateEmailForPaymentRefund(account, paymentTransaction, tenantContext);

    final String expectedBody = "*** Your payment has been refunded ***\n" +
            "\n" +
            "We have processed a refund in the amount of $937.07.\n" +
            "\n" +
            "This refund will appear on your next credit card statement in approximately 3-5 business days.\n" +
            "\n" +
            "If you have any questions about your account, please reply to this email or contact MERCHANT_NAME Support at: (888) 555-1234";

    // System.err.println(email.getBody());
    Assert.assertEquals(email.getSubject(), "MERCHANT_NAME: Refund Receipt");
    Assert.assertEquals(email.getBody(), expectedBody);
}
 
开发者ID:killbill,项目名称:killbill-email-notifications-plugin,代码行数:21,代码来源:TestTemplateRenderer.java


示例9: testSubscriptionCancellationEffective

import org.killbill.billing.util.callcontext.TenantContext; //导入依赖的package包/类
@Test(groups = "fast")
public void testSubscriptionCancellationEffective() throws Exception {

    final AccountData account = createAccount();
    final Subscription cancelledSubscription = createFutureCancelledSubscription(new LocalDate("2015-04-06"), "myPlanName");

    final TenantContext tenantContext = createTenantContext();
    final EmailContent email = renderer.generateEmailForSubscriptionCancellationEffective(account, cancelledSubscription, tenantContext);

    final String expectedBody = "Your Personal subscription to MERCHANT_NAME was canceled earlier and has now ended. Your access to MERCHANT_NAME on your iPad will end shortly.\n" +
            "\n" +
            "We're sorry to see you go.  To reactivate your MERCHANT_NAME service, contact the Support Team at (888) 555-1234.\n" +
            "\n" +
            "If you have any questions about your account, please reply to this email or contact MERCHANT_NAME Support at: (888) 555-1234";

    //System.err.println(email.getBody());
    Assert.assertEquals(email.getSubject(), "MERCHANT_NAME: Subscription Ended");
    Assert.assertEquals(email.getBody(), expectedBody);
}
 
开发者ID:killbill,项目名称:killbill-email-notifications-plugin,代码行数:20,代码来源:TestTemplateRenderer.java


示例10: withThreePagesOfSearchResults

import org.killbill.billing.util.callcontext.TenantContext; //导入依赖的package包/类
private void withThreePagesOfSearchResults(TenantContext tenantContext) {
    when(customFieldApi.searchCustomFields(anyString(), eq(0L), eq(PAGE_SIZE), eq(tenantContext)))//
            .thenReturn(pageStart);
    when(customFieldApi.searchCustomFields(anyString(), eq(PAGE_SIZE), eq(PAGE_SIZE), eq(tenantContext)))//
            .thenReturn(pageMiddle);
    when(customFieldApi.searchCustomFields(anyString(), eq(2 * PAGE_SIZE), eq(PAGE_SIZE), eq(tenantContext)))//
            .thenReturn(pageEnd);

    when(pageStart.getNextOffset()).thenReturn(PAGE_SIZE);
    when(pageMiddle.getNextOffset()).thenReturn(2 * PAGE_SIZE);
    when(pageEnd.getNextOffset()).thenReturn(null);

    CustomFieldBuilder builder = new CustomFieldBuilder().withObjectType(ACCOUNT).withFieldName("toto");
    when(pageStart.iterator()).thenReturn(forArray(//
            copy(builder).withFieldValue("page0-invoice").withObjectType(INVOICE).build(),//
            copy(builder).withFieldValue("page0-account").build()));
    when(pageMiddle.iterator()).thenReturn(forArray(//
            copy(builder).withFieldValue("page1-toto").build(),//
            copy(builder).withFieldValue("page1-plop").withFieldName("plop").build()));
    when(pageEnd.iterator()).thenReturn(forArray(//
            copy(builder).withFieldValue("page2").build()));
}
 
开发者ID:bgandon,项目名称:killbill-simple-tax-plugin,代码行数:23,代码来源:TestCustomFieldService.java


示例11: getPaymentInfo

import org.killbill.billing.util.callcontext.TenantContext; //导入依赖的package包/类
@Override
public List<PaymentTransactionInfoPlugin> getPaymentInfo(final UUID kbAccountId, final UUID kbPaymentId, final Iterable<PluginProperty> properties, final TenantContext context) throws PaymentPluginApiException {
    final List<PaymentTransactionInfoPlugin> transactions = super.getPaymentInfo(kbAccountId, kbPaymentId, properties, context);
    if (transactions.isEmpty()) {
        // We don't know about this payment (maybe it was aborted in a control plugin)
        return transactions;
    }

    final ExpiredPaymentPolicy expiredPaymentPolicy = expiredPaymentPolicy(context);
    if (expiredPaymentPolicy.isExpired(transactions)) {
        cancelExpiredPayment(expiredPaymentPolicy.latestTransaction(transactions), context);
        // reload payment
        return super.getPaymentInfo(kbAccountId, kbPaymentId, properties, context);
    }
    return transactions;
}
 
开发者ID:killbill,项目名称:killbill-adyen-plugin,代码行数:17,代码来源:AdyenPaymentPluginApi.java


示例12: cancelExpiredPayment

import org.killbill.billing.util.callcontext.TenantContext; //导入依赖的package包/类
private void cancelExpiredPayment(PaymentTransactionInfoPlugin expiredTransaction, final TenantContext context) {
    final List<PluginProperty> updatedStatusProperties = PluginProperties.buildPluginProperties(
            ImmutableMap.builder()
                        .put(PROPERTY_FROM_HPP_TRANSACTION_STATUS,
                             PaymentPluginStatus.CANCELED.toString())
                        .put("message",
                             "Payment Expired - Cancelled by Janitor")
                        .build());

    try {
        dao.updateResponse(expiredTransaction.getKbTransactionPaymentId(),
                           PluginProperties.merge(expiredTransaction.getProperties(), updatedStatusProperties),
                           context.getTenantId());
    } catch (final SQLException e) {
        logService.log(LogService.LOG_ERROR, "Unable to update canceled payment", e);
    }
}
 
开发者ID:killbill,项目名称:killbill-adyen-plugin,代码行数:18,代码来源:AdyenPaymentPluginApi.java


示例13: getPaymentTransactionInfoPluginForHPP

import org.killbill.billing.util.callcontext.TenantContext; //导入依赖的package包/类
private PaymentTransactionInfoPlugin getPaymentTransactionInfoPluginForHPP(final TransactionType transactionType, final UUID kbAccountId, final UUID kbPaymentId, final UUID kbTransactionId, final BigDecimal amount, final Currency currency, final Iterable<PluginProperty> properties, final TenantContext context) throws PaymentPluginApiException {
    final AdyenPaymentServiceProviderHostedPaymentPagePort hostedPaymentPagePort = adyenHppConfigurationHandler.getConfigurable(context.getTenantId());
    final Map<String, String> requestParameterMap = Maps.transformValues(PluginProperties.toStringMap(properties), new Function<String, String>() {
        @Override
        public String apply(final String input) {
            // Adyen will encode parameters like merchantSig
            return decode(input);
        }
    });
    final HppCompletedResult hppCompletedResult = hostedPaymentPagePort.parseAndVerifyRequestIntegrity(requestParameterMap);
    final PurchaseResult purchaseResult = new PurchaseResult(hppCompletedResult);

    final DateTime utcNow = clock.getUTCNow();
    try {
        final AdyenResponsesRecord adyenResponsesRecord = dao.addResponse(kbAccountId, kbPaymentId, kbTransactionId, transactionType, amount, currency, purchaseResult, utcNow, context.getTenantId());
        return buildPaymentTransactionInfoPlugin(adyenResponsesRecord);
    } catch (final SQLException e) {
        throw new PaymentPluginApiException("HPP payment came through, but we encountered a database error", e);
    }
}
 
开发者ID:killbill,项目名称:killbill-adyen-plugin,代码行数:21,代码来源:AdyenPaymentPluginApi.java


示例14: buildPaymentData

import org.killbill.billing.util.callcontext.TenantContext; //导入依赖的package包/类
private PaymentData buildPaymentData(final String merchantAccount, final String countryCode, final AccountData account, final UUID kbPaymentId, final UUID kbTransactionId, final AdyenPaymentMethodsRecord paymentMethodsRecord, final BigDecimal amount, final Currency currency, final Iterable<PluginProperty> properties, final TenantContext context) throws PaymentPluginApiException {
    final Payment payment;
    try {
        payment = killbillAPI.getPaymentApi().getPayment(kbPaymentId, false, false, properties, context);
    } catch (final PaymentApiException e) {
        throw new PaymentPluginApiException(String.format("Unable to retrieve kbPaymentId='%s'", kbPaymentId), e);
    }

    final PaymentTransaction paymentTransaction = Iterables.<PaymentTransaction>find(payment.getTransactions(),
                                                                                     new Predicate<PaymentTransaction>() {
                                                                                         @Override
                                                                                         public boolean apply(final PaymentTransaction input) {
                                                                                             return kbTransactionId.equals(input.getId());
                                                                                         }
                                                                                     });

    final PaymentInfo paymentInfo = buildPaymentInfo(merchantAccount, countryCode, account, paymentMethodsRecord, properties, context);

    return new PaymentData<PaymentInfo>(amount, currency, paymentTransaction.getExternalKey(), paymentInfo);
}
 
开发者ID:killbill,项目名称:killbill-adyen-plugin,代码行数:21,代码来源:AdyenPaymentPluginApi.java


示例15: getInvoicesForAccount

import org.killbill.billing.util.callcontext.TenantContext; //导入依赖的package包/类
public Collection<BusinessInvoice> getInvoicesForAccount(final UUID accountId, final TenantContext context) {
    final Long accountRecordId = getAccountRecordId(accountId, context);
    final Long tenantRecordId = getTenantRecordId(context);

    final List<BusinessInvoiceItemBaseModelDao> businessInvoiceItemModelDaos = new ArrayList<BusinessInvoiceItemBaseModelDao>();
    businessInvoiceItemModelDaos.addAll(sqlDao.getInvoiceAdjustmentsByAccountRecordId(accountRecordId, tenantRecordId, context));
    businessInvoiceItemModelDaos.addAll(sqlDao.getInvoiceItemsByAccountRecordId(accountRecordId, tenantRecordId, context));
    businessInvoiceItemModelDaos.addAll(sqlDao.getInvoiceItemAdjustmentsByAccountRecordId(accountRecordId, tenantRecordId, context));
    businessInvoiceItemModelDaos.addAll(sqlDao.getInvoiceItemCreditsByAccountRecordId(accountRecordId, tenantRecordId, context));

    final Map<UUID, List<BusinessInvoiceItemBaseModelDao>> itemsPerInvoice = new LinkedHashMap<UUID, List<BusinessInvoiceItemBaseModelDao>>();
    for (final BusinessInvoiceItemBaseModelDao businessInvoiceModelDao : businessInvoiceItemModelDaos) {
        if (itemsPerInvoice.get(businessInvoiceModelDao.getInvoiceId()) == null) {
            itemsPerInvoice.put(businessInvoiceModelDao.getInvoiceId(), new LinkedList<BusinessInvoiceItemBaseModelDao>());
        }
        itemsPerInvoice.get(businessInvoiceModelDao.getInvoiceId()).add(businessInvoiceModelDao);
    }

    final List<BusinessInvoiceModelDao> businessInvoiceModelDaos = sqlDao.getInvoicesByAccountRecordId(accountRecordId, tenantRecordId, context);
    return Lists.transform(businessInvoiceModelDaos, new Function<BusinessInvoiceModelDao, BusinessInvoice>() {
        @Override
        public BusinessInvoice apply(final BusinessInvoiceModelDao input) {
            return new BusinessInvoice(input, MoreObjects.firstNonNull(itemsPerInvoice.get(input.getInvoiceId()), ImmutableList.<BusinessInvoiceItemBaseModelDao>of()));
        }
    });
}
 
开发者ID:killbill,项目名称:killbill-analytics-plugin,代码行数:27,代码来源:AnalyticsDao.java


示例16: getFieldsForAccount

import org.killbill.billing.util.callcontext.TenantContext; //导入依赖的package包/类
public Collection<BusinessField> getFieldsForAccount(final UUID accountId, final TenantContext context) {
    final Long accountRecordId = getAccountRecordId(accountId, context);
    final Long tenantRecordId = getTenantRecordId(context);

    final List<BusinessFieldModelDao> businessFieldModelDaos = new LinkedList<BusinessFieldModelDao>();
    businessFieldModelDaos.addAll(sqlDao.getAccountFieldsByAccountRecordId(accountRecordId, tenantRecordId, context));
    businessFieldModelDaos.addAll(sqlDao.getBundleFieldsByAccountRecordId(accountRecordId, tenantRecordId, context));
    businessFieldModelDaos.addAll(sqlDao.getInvoiceFieldsByAccountRecordId(accountRecordId, tenantRecordId, context));
    businessFieldModelDaos.addAll(sqlDao.getInvoicePaymentFieldsByAccountRecordId(accountRecordId, tenantRecordId, context));
    businessFieldModelDaos.addAll(sqlDao.getPaymentFieldsByAccountRecordId(accountRecordId, tenantRecordId, context));
    businessFieldModelDaos.addAll(sqlDao.getPaymentMethodFieldsByAccountRecordId(accountRecordId, tenantRecordId, context));
    businessFieldModelDaos.addAll(sqlDao.getTransactionFieldsByAccountRecordId(accountRecordId, tenantRecordId, context));

    return Lists.transform(businessFieldModelDaos, new Function<BusinessFieldModelDao, BusinessField>() {
        @Override
        public BusinessField apply(final BusinessFieldModelDao input) {
            return BusinessField.create(input);
        }
    });
}
 
开发者ID:killbill,项目名称:killbill-analytics-plugin,代码行数:21,代码来源:AnalyticsDao.java


示例17: getPaymentsWithPluginInfoByAccountId

import org.killbill.billing.util.callcontext.TenantContext; //导入依赖的package包/类
protected Collection<Payment> getPaymentsWithPluginInfoByAccountId(final UUID accountId, final TenantContext context) throws AnalyticsRefreshException {
    PaymentApiException error;

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

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

    logger.warn("Error retrieving payments for account id " + accountId, error);
    throw new AnalyticsRefreshException(error);
}
 
开发者ID:killbill,项目名称:killbill-analytics-plugin,代码行数:23,代码来源:BusinessFactoryBase.java


示例18: getPaymentMethodsForAccount

import org.killbill.billing.util.callcontext.TenantContext; //导入依赖的package包/类
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()) {
            logger.warn(e.getMessage() + ". Analytics tables will be missing plugin specific information");

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

    logger.warn("Error retrieving payment methods for account id " + accountId, error);
    throw new AnalyticsRefreshException(error);
}
 
开发者ID:killbill,项目名称:killbill-analytics-plugin,代码行数:25,代码来源:BusinessFactoryBase.java


示例19: doGet

import org.killbill.billing.util.callcontext.TenantContext; //导入依赖的package包/类
@Override
protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
    final TenantContext context = createCallContext(req, resp);

    final String reportName = (String) req.getAttribute(REPORT_NAME_ATTRIBUTE);
    if (reportName != null) {
        final ReportConfigurationJson reportConfigurationJson;
        try {
            reportConfigurationJson = reportsUserApi.getReportConfiguration(reportName, context);
        } catch (SQLException e) {
            resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getLocalizedMessage());
            return;
        }

        if (reportConfigurationJson == null) {
            resp.sendError(404, reportName + "");
        }
        resp.getOutputStream().write(jsonMapper.writeValueAsBytes(reportConfigurationJson));
        resp.setContentType("application/json");
    } else {
        doHandleReports(req, resp, context);
    }
}
 
开发者ID:killbill,项目名称:killbill-analytics-plugin,代码行数:24,代码来源:ReportsServlet.java


示例20: checkPermission

import org.killbill.billing.util.callcontext.TenantContext; //导入依赖的package包/类
private int checkPermission(Tenant tenant, Set<Permission> required, HttpServletRequest req) {
    if (required.isEmpty()) {
        return 0;
    }
    String authHeader = req.getHeader("Authorization");
    if (authHeader == null) {
        return 401;
    }

    final String[] authHeaderComponents = authHeader.split(" ");
    if (authHeaderComponents.length < 2) {
        return 403;
    }

    try {
        final String credentials = new String(
                Base64.getDecoder().decode(authHeaderComponents[1]), "UTF-8").trim();
        final String[] credentialComponents = credentials.split(":", 2);
        if (credentialComponents.length < 2) {
            return 403;
        }

        securityApi.login(credentialComponents[0], credentialComponents[1]);
        TenantContext context = new EasyTaxTenantContext(tenant.getId(), null);
        Set<Permission> granted = securityApi.getCurrentUserPermissions(context);
        if (granted == null) {
            return 403;
        }
        if (granted.containsAll(required)) {
            return 0;
        }
    } catch (Exception e) {
        // ignore and deny
        log.info("Permission check failed for Authorization header {}: {}", authHeader,
                e.getMessage());
    }
    return 403;
}
 
开发者ID:SolarNetwork,项目名称:killbill-easytax-plugin,代码行数:39,代码来源:EasyTaxServlet.java



注:本文中的org.killbill.billing.util.callcontext.TenantContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EncryptedAssertion类代码示例发布时间:2022-05-22
下一篇:
Java IIndividual类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap