@Override public StaticCatalog getCurrentCatalog(final String catalogName, final TenantContext tenantContext) throws CatalogApiException { final InternalTenantContext internalTenantContext; if (tenantContext.getAccountId() != null) { internalTenantContext = internalCallContextFactory.createInternalTenantContext(tenantContext.getAccountId(), tenantContext); } else { internalTenantContext = createInternalTenantContext(tenantContext); } return catalogService.getFullCatalog(true, true, internalTenantContext); }
@Override public List<AuditLogWithHistory> getEmailAuditLogsWithHistoryForId(final UUID accountEmailId, final AuditLevel auditLevel, final TenantContext tenantContext) throws AccountApiException { return accountDao.getEmailAuditLogsWithHistoryForId(accountEmailId, auditLevel, internalCallContextFactory.createInternalTenantContext(tenantContext.getAccountId(), tenantContext)); } }
@Override public VersionedCatalog<? extends StaticCatalog> getCatalog(final String catalogName, @Nullable final DateTime catalogDateVersion, final TenantContext tenantContext) throws CatalogApiException { final InternalTenantContext internalTenantContext; if (tenantContext.getAccountId() != null) { internalTenantContext = internalCallContextFactory.createInternalTenantContext(tenantContext.getAccountId(), tenantContext); } else { internalTenantContext = createInternalTenantContext(tenantContext); } final DefaultVersionedCatalog fullCatalog = catalogService.getFullCatalog(true, true, internalTenantContext); if (catalogDateVersion == null) { return fullCatalog; } else { final DefaultVersionedCatalog filteredCatalog = new DefaultVersionedCatalog(clock); for (final StandaloneCatalog v : fullCatalog.getVersions()) { if (v.getEffectiveDate().compareTo(catalogDateVersion.toDate()) >= 0) { filteredCatalog.add(v); break; } } return filteredCatalog; } }
private SubscriptionBaseBundle getBundleWithSanity(final SubscriptionBaseWithAddOnsSpecifier subscriptionBaseWithAddOnsSpecifier, final Catalog catalog, final TenantContext callContext, final InternalCallContext context) throws SubscriptionBaseApiException, CatalogApiException { SubscriptionBaseBundle bundle = null; if (subscriptionBaseWithAddOnsSpecifier.getBundleId() != null) { bundle = dao.getSubscriptionBundleFromId(subscriptionBaseWithAddOnsSpecifier.getBundleId(), context); if (bundle == null || (subscriptionBaseWithAddOnsSpecifier.getBundleExternalKey() != null && !subscriptionBaseWithAddOnsSpecifier.getBundleExternalKey().equals(bundle.getExternalKey()))) { throw new SubscriptionBaseApiException(ErrorCode.SUB_CREATE_INVALID_ENTITLEMENT_SPECIFIER); } } else if (subscriptionBaseWithAddOnsSpecifier.getBundleExternalKey() != null) { final SubscriptionBaseBundle tmp = getActiveBundleForKey(subscriptionBaseWithAddOnsSpecifier.getBundleExternalKey(), catalog, context); if (tmp != null && !tmp.getAccountId().equals(callContext.getAccountId())) { throw new SubscriptionBaseApiException(ErrorCode.SUB_CREATE_ACTIVE_BUNDLE_KEY_EXISTS, subscriptionBaseWithAddOnsSpecifier.getBundleExternalKey()); } else { bundle = tmp; } } return bundle; }
@Override public UUID getAccountId() { return delegate.getAccountId(); }
@Override public UUID getAccountId() { return delegate.getAccountId(); }
@Override public StaticCatalog getCurrentCatalog(final String catalogName, final TenantContext tenantContext) throws CatalogApiException { final InternalTenantContext internalTenantContext; if (tenantContext.getAccountId() != null) { internalTenantContext = internalCallContextFactory.createInternalTenantContext(tenantContext.getAccountId(), tenantContext); } else { internalTenantContext = createInternalTenantContext(tenantContext); } return catalogService.getFullCatalog(true, true, internalTenantContext); }
@Override public List<AuditLogWithHistory> getEmailAuditLogsWithHistoryForId(final UUID accountEmailId, final AuditLevel auditLevel, final TenantContext tenantContext) throws AccountApiException { return accountDao.getEmailAuditLogsWithHistoryForId(accountEmailId, auditLevel, internalCallContextFactory.createInternalTenantContext(tenantContext.getAccountId(), tenantContext)); } }
@Override public InvoicePayment getInvoicePaymentByCookieId(final String cookieId, final TenantContext context) { final InvoicePaymentModelDao invoicePaymentModelDao = dao.getInvoicePaymentByCookieId(cookieId, internalCallContextFactory.createInternalTenantContext(context.getAccountId(), ObjectType.ACCOUNT, context)); return invoicePaymentModelDao == null ? null : new DefaultInvoicePayment(invoicePaymentModelDao); } }
@Override public VersionedCatalog<? extends StaticCatalog> getCatalog(final String catalogName, @Nullable final DateTime catalogDateVersion, final TenantContext tenantContext) throws CatalogApiException { final InternalTenantContext internalTenantContext; if (tenantContext.getAccountId() != null) { internalTenantContext = internalCallContextFactory.createInternalTenantContext(tenantContext.getAccountId(), tenantContext); } else { internalTenantContext = createInternalTenantContext(tenantContext); } final DefaultVersionedCatalog fullCatalog = catalogService.getFullCatalog(true, true, internalTenantContext); if (catalogDateVersion == null) { return fullCatalog; } else { final DefaultVersionedCatalog filteredCatalog = new DefaultVersionedCatalog(clock); for (final StandaloneCatalog v : fullCatalog.getVersions()) { if (v.getEffectiveDate().compareTo(catalogDateVersion.toDate()) >= 0) { filteredCatalog.add(v); break; } } return filteredCatalog; } }
private SubscriptionBaseBundle getBundleWithSanity(final SubscriptionBaseWithAddOnsSpecifier subscriptionBaseWithAddOnsSpecifier, final Catalog catalog, final TenantContext callContext, final InternalCallContext context) throws SubscriptionBaseApiException, CatalogApiException { SubscriptionBaseBundle bundle = null; if (subscriptionBaseWithAddOnsSpecifier.getBundleId() != null) { bundle = dao.getSubscriptionBundleFromId(subscriptionBaseWithAddOnsSpecifier.getBundleId(), context); if (bundle == null || (subscriptionBaseWithAddOnsSpecifier.getBundleExternalKey() != null && !subscriptionBaseWithAddOnsSpecifier.getBundleExternalKey().equals(bundle.getExternalKey()))) { throw new SubscriptionBaseApiException(ErrorCode.SUB_CREATE_INVALID_ENTITLEMENT_SPECIFIER); } } else if (subscriptionBaseWithAddOnsSpecifier.getBundleExternalKey() != null) { final SubscriptionBaseBundle tmp = getActiveBundleForKey(subscriptionBaseWithAddOnsSpecifier.getBundleExternalKey(), catalog, context); if (tmp != null && !tmp.getAccountId().equals(callContext.getAccountId())) { throw new SubscriptionBaseApiException(ErrorCode.SUB_CREATE_ACTIVE_BUNDLE_KEY_EXISTS, subscriptionBaseWithAddOnsSpecifier.getBundleExternalKey()); } else { bundle = tmp; } } return bundle; }