Map objectModel,
String src,
Parameters parameters)
throws Exception {
Response res = ObjectModelHelper.getResponse(objectModel);
/*
* check response validity
*/
if (res == null) {
if (getLogger().isDebugEnabled()) {
getLogger().debug("COOKIECREATOR: no response object");
}
return null;
}
String cookieName = null;
String
cookieValue = null;
String
cookieComment = null;
String
cookieDomain = null;
String
cookiePath = null;
try {
cookieName = parameters.getParameter("name");
} catch (Exception e) {
if (getLogger().isDebugEnabled()) {
getLogger().debug("COOKIECREATOR: cannot retrieve cookie name attribute");
}
return null;
}
cookieValue = parameters.getParameter("value", "");
Cookie cookie = res.createCookie(cookieName, cookieValue);
try {
if ((cookieComment = parameters.getParameter("comment")) != null) {
cookie.setComment(cookieComment);
}
} catch (ParameterException ignore) {
}
try {
if ((cookieDomain = parameters.getParameter("domain")) != null) {
cookie.setDomain(cookieDomain);
}
} catch (ParameterException ignore) {
}
try {
if ((cookiePath = parameters.getParameter("path")) != null) {
cookie.setPath(cookiePath);
}
} catch (ParameterException ignore) {
}
cookie.setSecure(parameters.getParameterAsBoolean("secure", false));
cookie.setMaxAge(parameters.getParameterAsInteger("maxage", 0));
cookie.setVersion(parameters.getParameterAsInteger("version", 0));
res.addCookie(cookie);
if (getLogger().isDebugEnabled()) {
if (cookie.getMaxAge() == 0) {
getLogger().debug("COOKIECREATOR: '" + cookieName
+ "' cookie has been removed");