Search in sources :

Example 1 with CookieScopeImpl

use of org.webpieces.router.impl.ctx.CookieScopeImpl in project webpieces by deanhiller.

the class CookieTranslator method addScopeToCookieIfExist.

public void addScopeToCookieIfExist(List<RouterCookie> cookies, CookieScope cookie1) {
    if (!(cookie1 instanceof CookieScopeImpl))
        throw new IllegalArgumentException("Cookie is not the right data type=" + cookie1.getClass() + " needs to be of type " + CookieScopeImpl.class);
    CookieScopeImpl data = (CookieScopeImpl) cookie1;
    if (data.isNeedCreateSetCookie()) {
        log.debug(() -> "translating cookie=" + cookie1.getName() + " to send to browser");
        RouterCookie cookie = translateScopeToCookie(data);
        cookies.add(cookie);
    } else if (data.isNeedCreateDeleteCookie()) {
        log.debug(() -> "creating delete cookie for " + cookie1.getName() + " to send to browser");
        RouterCookie cookie = createDeleteCookie(data.getName());
        cookies.add(cookie);
    } else {
        log.debug(() -> "not sending any cookie to browser for cookie=" + cookie1.getName());
    }
}
Also used : CookieScopeImpl(org.webpieces.router.impl.ctx.CookieScopeImpl) RouterCookie(org.webpieces.ctx.api.RouterCookie)

Aggregations

RouterCookie (org.webpieces.ctx.api.RouterCookie)1 CookieScopeImpl (org.webpieces.router.impl.ctx.CookieScopeImpl)1