public void fillLimitsById(Integer contextId, Limit limit) {
if (limit == null)
throw new IllegalArgumentException("Limit must not be null");
ContextWrapper ctx = cachingTableContext.get(contextId);
if (ctx == null)
throw new IllegalArgumentException("There is no limit available with that ID");
if (ctx.getApiContext() != null) {
// It's an API Context
limit.setQuotaPerDay(null);
limit.setQuotaPerWeek(null);
limit.setQuotaPerMonth(null);
limit.setRateLimitPerMinute(new Counter(ctx.getApiContext().getMaxRateLimitTPMWarning(), ctx.getApiContext().getMaxRateLimitTPMThreshold()));
limit.setRateLimitPerSecond(new Counter(ctx.getApiContext().getMaxRateLimitTPSWarning(), ctx.getApiContext().getMaxRateLimitTPSThreshold()));
}
if (ctx.getPolicyContext() != null) {
// It's a Policy Context
limit.setQuotaPerDay(ctx.getPolicyContext().getQuotaPerDay());
limit.setQuotaPerWeek(ctx.getPolicyContext().getQuotaPerWeek());
limit.setQuotaPerMonth(ctx.getPolicyContext().getQuotaPerMonth());
limit.setRateLimitPerMinute(ctx.getPolicyContext().getRateLimitPerMinute());
limit.setRateLimitPerSecond(ctx.getPolicyContext().getRateLimitPerSecond());
limit.setCreatedDate(ctx.getPolicyContext().getCreatedDate());
}
}