private static final Log log = LogFactory.getLog(KnowledgeBaseManager.class);
public static ThrottlingDataContext feedKnowledgeBase(int tenantId, Task task,
List<Object> knowledgeBase) throws ThrottlingException {
// initialize the throttling context
ThrottlingDataContext throttlingDataContext = new ThrottlingDataContext(tenantId);
// prepare data from data providers
try {
task.prepareData(throttlingDataContext);
} catch (ThrottlingException e) {
String msg = "Error in preparing throttling data for tenant: " + tenantId + ".";
log.error(msg, e);
throw new ThrottlingException(msg, e);
}
// add data entries with object types separately
for (ThrottlingDataEntry dataEntry : throttlingDataContext.getData()) {
if (dataEntry.getValueType() == 4) {
Object object = dataEntry.getObjectValue();
if (object != null) {
knowledgeBase.add(object);
}
}
}
// load the access validation data
try {
ValidationInfoManager.loadValidationDetails(throttlingDataContext);
} catch (ThrottlingException e) {
String msg = "Error in loading validation details. tenant id: " + tenantId + ".";
log.error(msg, e);
throw new ThrottlingException(msg, e);
}
// add metering data context
knowledgeBase.add(throttlingDataContext);
// add access validation information
knowledgeBase.add(throttlingDataContext.getAccessValidation());
return throttlingDataContext;
}