@Override @PortalTransactional public IPortalCookie addOrUpdatePortletCookie(IPortalCookie portalCookie, Cookie cookie) { final Set<IPortletCookie> portletCookies = portalCookie.getPortletCookies();
/** * Convert the {@link IPortalCookie} into a servlet {@link Cookie}. * * @param portalCookie * @return */ protected Cookie convertToCookie(IPortalCookie portalCookie, boolean secure) { final Cookie cookie = new Cookie(this.cookieName, portalCookie.getValue()); // Set the cookie's fields cookie.setComment(this.comment); cookie.setMaxAge(this.maxAge); cookie.setSecure(secure); cookie.setHttpOnly(true); if (this.domain != null) { cookie.setDomain(this.domain); } cookie.setPath(this.path); return cookie; }
@Override @PortalTransactional public IPortalCookie updatePortalCookieExpiration(IPortalCookie portalCookie, int maxAge) { // Calculate expiration date and update the portal cookie final DateTime expiration = DateTime.now().plusSeconds(maxAge); portalCookie.setExpires(expiration); this.getEntityManager().persist(portalCookie); return portalCookie; }
final DateTime expires = portalCookie.getExpires(); if (DateTime.now() .minusMillis(this.maxAgeUpdateInterval)
/** * Locate the existing {@link IPortalCookie} with the request, or create a new one. * * @param request * @return the {@link IPortalCookie} - never null */ protected IPortalCookie getOrCreatePortalCookie(HttpServletRequest request) { IPortalCookie result = null; // first check in request final Cookie cookie = this.getCookieFromRequest(this.cookieName, request); if (cookie != null) { // found a potential cookie, call off to the dao final String value = cookie.getValue(); result = this.portletCookieDao.getPortalCookie(value); } // still null? check in the session if (result == null) { result = locatePortalCookieInSession(request.getSession()); } // if by this point we still haven't found the portal cookie, create one if (result == null) { result = this.portletCookieDao.createPortalCookie(this.maxAge); // store the portal cookie value value in the session HttpSession session = request.getSession(); synchronized (WebUtils.getSessionMutex(session)) { session.setAttribute(SESSION_ATTRIBUTE__PORTAL_COOKIE_ID, result.getValue()); } } return result; }
for (IPortletCookie portletCookie : portalCookie.getPortletCookies()) { if (portletCookie.getExpires().isAfterNow()) { portletCookies.add(portletCookie);