public DefaultCallContext(final UUID accountId, final UUID tenantId, final String userName, final CallOrigin callOrigin, final UserType userType, final String reasonCode, final String comment, final UUID userToken, final Clock clock) { super(accountId, tenantId, userName, callOrigin, userType, reasonCode, comment, userToken); this.createdDate = clock.getUTCNow(); this.updateDate = createdDate; }
public DefaultCallContext(final UUID accountId, final UUID tenantId, final String userName, final CallOrigin callOrigin, final UserType userType, final UUID userToken, final Clock clock) { super(accountId, tenantId, userName, callOrigin, userType, userToken); this.createdDate = clock.getUTCNow(); this.updateDate = createdDate; }
@Override public List<SubscriptionBaseEvent> getPendingEventsForSubscription(final UUID subscriptionId, final InternalTenantContext context) { final Date now = clock.getUTCNow().toDate(); return transactionalSqlDao.execute(true, new EntitySqlDaoTransactionWrapper<List<SubscriptionBaseEvent>>() { @Override public List<SubscriptionBaseEvent> inTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory) throws Exception { final List<SubscriptionEventModelDao> eventModels = entitySqlDaoWrapperFactory.become(SubscriptionEventSqlDao.class).getFutureActiveEventForSubscription(subscriptionId.toString(), now, context); return toSubscriptionBaseEvents(eventModels); } }); }
private boolean shouldSkip(final SubscriptionBaseTransition input) { if (visibility == Visibility.FROM_DISK_ONLY && ! ((SubscriptionBaseTransitionData) input).isFromDisk()) { return true; } if ((timeLimit == TimeLimit.FUTURE_ONLY && !input.getEffectiveTransitionTime().isAfter(clock.getUTCNow())) || ((timeLimit == TimeLimit.PAST_OR_PRESENT_ONLY && input.getEffectiveTransitionTime().isAfter(clock.getUTCNow())))) { return true; } return false; }
@Override public Void inTransaction(final Handle handle, final TransactionStatus status) throws Exception { final NodeInfoSqlDao sqlDao = handle.attach(NodeInfoSqlDao.class); final Date updateDate = clock.getUTCNow().toDate(); sqlDao.updateNodeInfo(nodeName, nodeInfo, updateDate); return null; } });
@Override public PriceList findCurrentPricelist(final String name) throws CatalogApiException { return versionForDate(clock.getUTCNow()).findCurrentPriceList(name); }
@Override public PlanChangeResult planChange(final PlanPhaseSpecifier from, final PlanSpecifier to) throws CatalogApiException { return versionForDate(clock.getUTCNow()).planChange(from, to); }
@Override public BillingActionPolicy planCancelPolicy(final PlanPhaseSpecifier planPhase) throws CatalogApiException { return versionForDate(clock.getUTCNow()).planCancelPolicy(planPhase); }
@Override public BillingAlignment billingAlignment(final PlanPhaseSpecifier planPhase) throws CatalogApiException { return versionForDate(clock.getUTCNow()).billingAlignment(planPhase); }
@Override public PlanAlignmentCreate planCreateAlignment(final PlanSpecifier specifier) throws CatalogApiException { return versionForDate(clock.getUTCNow()).planCreateAlignment(specifier); }
@Override public PlanPhase findCurrentPhase(final String name) throws CatalogApiException { return versionForDate(clock.getUTCNow()).findCurrentPhase(name); }
@Override public Collection<Product> getCurrentProducts() throws CatalogApiException { return versionForDate(clock.getUTCNow()).getCurrentProducts(); }
@Override public Unit[] getCurrentUnits() throws CatalogApiException { return versionForDate(clock.getUTCNow()).getCurrentUnits(); }
@Override public Plan createOrFindCurrentPlan(final PlanSpecifier spec, final PlanPhasePriceOverridesWithCallContext overrides) throws CatalogApiException { return versionForDate(clock.getUTCNow()).createOrFindCurrentPlan(spec, overrides); }
@Override public Date getEffectiveDate() throws CatalogApiException { return versionForDate(clock.getUTCNow()).getEffectiveDate(); }
@Override public Void inTransaction(final Handle handle, final TransactionStatus status) throws Exception { final DateTime updatedDate = clock.getUTCNow(); final UsersSqlDao usersSqlDao = handle.attach(UsersSqlDao.class); final UserModelDao userModelDao = usersSqlDao.getByUsername(username); if (userModelDao == null) { throw new SecurityApiException(ErrorCode.SECURITY_INVALID_USER, username); } usersSqlDao.invalidate(username, updatedDate.toDate(), updatedBy); return null; } });
@Override public Void inTransaction(final Handle handle, final TransactionStatus status) throws Exception { final DateTime updatedDate = clock.getUTCNow(); final UsersSqlDao usersSqlDao = handle.attach(UsersSqlDao.class); final UserModelDao userModelDao = usersSqlDao.getByUsername(username); if (userModelDao == null) { throw new SecurityApiException(ErrorCode.SECURITY_INVALID_USER, username); } usersSqlDao.updatePassword(username, hashedPasswordBase64, salt.toBase64(), updatedDate.toDate(), updatedBy); return null; } });
@Override public void triggerNodeCommand(final NodeCommand nodeCommand, final boolean localNodeOnly) { final String event; try { event = mapper.serializeNodeCommand(nodeCommand.getNodeCommandMetadata()); broadcastApi.broadcast(KILLBILL_SERVICES.BROADCAST_SERVICE.getServiceName(), nodeCommand.getNodeCommandType(), event, clock.getUTCNow(), "unset", localNodeOnly); } catch (JsonProcessingException e) { throw new RuntimeException(e); } }
@Override public Long withHandle(final Handle handle) throws Exception { return (Long) handle.select("select count(distinct record_id) count from bus_events").get(0).get("count") + (Long) handle.select("select count(distinct record_id) count from notifications where effective_date < ?", clock.getUTCNow().toDate()).get(0).get("count") + (Long) handle.select("select count(distinct record_id) count from notifications where processing_state = 'IN_PROCESSING'").get(0).get("count"); } }
public static void refreshCallContext(final UUID accountId, final Clock clock, final InternalCallContextFactory internalCallContextFactory, final MutableCallContext callContext, final MutableInternalCallContext internalCallContext) { final InternalTenantContext tmp = internalCallContextFactory.createInternalTenantContext(accountId, callContext); internalCallContext.setAccountRecordId(tmp.getAccountRecordId()); internalCallContext.setFixedOffsetTimeZone(tmp.getFixedOffsetTimeZone()); internalCallContext.setReferenceTime(tmp.getReferenceLocalTime()); internalCallContext.setCreatedDate(clock.getUTCNow()); internalCallContext.setUpdatedDate(clock.getUTCNow()); callContext.setDelegate(accountId, internalCallContext); }