// // To track default cn for all ips
CallerConfiguration cn = null; // To create a
//configurationbean object
boolean isIPRangeFound = false;
boolean isExactlyOneFound = false;
ExactlyOne cp = null;
List cL = ((All) tp).getAssertions();
if (cL != null) {
for (Iterator ci =
cL.iterator(); ci.hasNext();) {
Object ca = ci.next();
if (ca instanceof XmlPrimtiveAssertion) {
XmlPrimtiveAssertion id = (XmlPrimtiveAssertion) ca;
OMElement el = id.getValue();
String t = el.getAttributeValue(
ThrottleConstants.THROTTLE_TYPE_ATTRIBUTE_QNAME);
if (t == null) {
handleException("Type of Throtle " +
"in the policy cannot be null");
}
if (t.equals("IP")) {
// create a ip based throttle context and configuration
tc = th.getThrottleConfiguration
(ThrottleConstants.IP_BASED_THROTTLE_KEY);
if (tc == null) {
tc =
ThrottleConfigurationFactory.
createThrottleConfiguration(
ThrottleConstants.IP_BASE);
th.addThrottleContext(
ThrottleConstants.IP_BASED_THROTTLE_KEY,
ThrottleContextFactory.createThrottleContext(
ThrottleConstants.IP_BASE, tc));
th.addThrottleConfiguration(
ThrottleConstants.IP_BASED_THROTTLE_KEY, tc);
}
//create a callercontext for ip based throttle
cn = CallerConfigurationFactory.
createCallerConfiguration(
ThrottleConstants.IP_BASE);
} else if (t.equals("DOMAIN")) {
// create a domain based throttle context and configuration
tc = th.getThrottleConfiguration(
ThrottleConstants.DOMAIN_BASED_THROTTLE_KEY);
if (tc == null) {
tc =
ThrottleConfigurationFactory.
createThrottleConfiguration(
ThrottleConstants.DOMAIN_BASE);
th.addThrottleContext(
ThrottleConstants.DOMAIN_BASED_THROTTLE_KEY,
ThrottleContextFactory.createThrottleContext(
ThrottleConstants.DOMAIN_BASE, tc));
th.addThrottleConfiguration(
ThrottleConstants.DOMAIN_BASED_THROTTLE_KEY, tc);
}
//create a callercontext for domain based throttl
cn =
CallerConfigurationFactory.
createCallerConfiguration(
ThrottleConstants.DOMAIN_BASE);
} else {
handleException("Unsupported throttle type : " + t);
}
if (cn != null) {
// Name of the policy assertion
String n = el.getLocalName();
// Value of the policy assertion
String v = el.getText();
// If Value and Name are null,
// then it is a invalid policy config
if (n == null || v == null) {
handleException("Either Value or" +
" Name of the policy cannot be null");
} else if (n.equals(ThrottleConstants.ID_PARAMETER_NAME)) {
if (!v.equals("")) {
isIPRangeFound = true;
cn.setID(v);
} else {
handleException("Value of ID cannot find " +
"- invalid configuration");
}
} else {
handleException("Undefined pocilcy property for" +
" throttle - Expect ID ");
}
}
} else if (ca instanceof ExactlyOne) {
cp = (ExactlyOne) ca;
}
}
}
if (cn != null) {
if (cp != null) {
List cal = cp.getPolicyComponents();
boolean haveSelectOneFromExactlyOne = false;
for (Iterator ci = cal.iterator(); ci.hasNext()
&& !haveSelectOneFromExactlyOne;) {
Object co = ci.next();
if (co instanceof All) {