}
if ((stickyPolicies != null) && (stickyPolicies.length > 0) && (stickyPolicies[0] != null)) {
long timeout = 2;// netscaler default 2 min
String cookieName = null;
StickinessPolicyTO stickinessPolicy = stickyPolicies[0];
// get the session persistence parameters
List<Pair<String, String>> paramsList = stickinessPolicy.getParams();
for (Pair<String, String> param : paramsList) {
if ("holdtime".equalsIgnoreCase(param.first())) {
timeout = Long.parseLong(param.second());
} else if ("name".equalsIgnoreCase(param.first())) {
cookieName = param.second();
}
}
// configure virtual server based on the persistence method
if (StickinessMethodType.LBCookieBased.getName().equalsIgnoreCase(stickinessPolicy.getMethodName())) {
vserver.set_persistencetype("COOKIEINSERT");
} else if (StickinessMethodType.SourceBased.getName().equalsIgnoreCase(stickinessPolicy.getMethodName())) {
vserver.set_persistencetype("SOURCEIP");
} else if (StickinessMethodType.AppCookieBased.getName().equalsIgnoreCase(stickinessPolicy.getMethodName())) {
vserver.set_persistencetype("RULE");
vserver.set_rule("HTTP.REQ.HEADER(\"COOKIE\").VALUE(0).typecast_nvlist_t('=',';').value(\"" + cookieName + "\")");
vserver.set_resrule("HTTP.RES.HEADER(\"SET-COOKIE\").VALUE(0).typecast_nvlist_t('=',';').value(\"" + cookieName + "\")");
} else {
throw new ExecutionException("Got invalid session persistence method: " + stickinessPolicy.getMethodName() + " in the load balancing rule");
}
// set session persistence timeout
vserver.set_timeout(timeout);
} else {