try
{
XcapUri xcapUri = _xcapResources.get(0);
XcapResource xcapResource = _xcapService.getResource(xcapUri, false, null, null);
Ruleset ruleset = RulesetDocument.Factory.parse(xcapResource.getSelectedResource().getDom()).getRuleset();
SubHandling best = null;
String domain = null;
if (subscriberUri.indexOf('@') != -1)
domain = subscriberUri.substring(subscriberUri.indexOf('@') + 1);
for (int i = 0; i < ruleset.getRuleArray().length; i++)
{
RuleType rule = ruleset.getRuleArray(i);
if (match(rule.getConditions(), subscriberUri, domain))
{
SubHandling subHandling = getSubHandling(rule.getActions());
if (best == null || subHandling.getValue() > best.getValue())
best = subHandling;
}
}
if (best == null)
{
for (int i = 0; i < ruleset.getRuleArray().length; i++)
{
RuleType rule = ruleset.getRuleArray(i);
if (matchOma(rule.getConditions(), subscriberUri))
{
SubHandling subHandling = getSubHandling(rule.getActions());
if (best == null || subHandling.getValue() > best.getValue())
best = subHandling;
}
}
}
if (best == null)
{
for (int i = 0; i < ruleset.getRuleArray().length; i++)
{
RuleType rule = ruleset.getRuleArray(i);
if (matchOmaOtherIdentity(rule.getConditions()))
{
SubHandling subHandling = getSubHandling(rule.getActions());
if (best == null || subHandling.getValue() > best.getValue())
best = subHandling;
}
}
}
__log.debug("Got policy " + best + " for subscriber {} and resource {}", subscriberUri, _resourceUri);