if (!(extensibleConfiguration instanceof RuleSetDescription)) {
throw new LoggedRuntimeException("Invalid rule configuration," +
"expect RuleSetDescription.", log);
}
RuleSetDescription description = (RuleSetDescription) extensibleConfiguration;
QName parentQName = ruleSet.getQName();
QNameFactory qNameFactory = QNameFactory.getInstance();
QName sourceQName = qNameFactory.createQName(CommonsConstants.ELE_SOURCE,
parentQName);
OMElement sourceElement = ruleSet.getFirstChildWithName(sourceQName);
if (sourceElement == null) {
throw new LoggedRuntimeException("Invalid configuration. " +
"The rule set source cannot be found.", log);
}
String ruleKey = sourceElement.getAttributeValue(CommonsConstants.ATT_KEY_Q);
if (ruleKey != null && !"".equals(ruleKey)) {
description.setKey(ruleKey.trim());
} else {
OMElement inLinedSource = sourceElement.getFirstElement();
if (inLinedSource == null) {
String inLinedText = sourceElement.getText();
if (inLinedText == null || "".equals(inLinedText.trim())) {
throw new LoggedRuntimeException("The rule set source cannot be found " +
"from either in-lined or key. It is required.", log);
} else {
description.setRuleSource(inLinedText.trim());
}
} else {
description.setRuleSource(inLinedSource);
}
}
}