List of usage examples for com.google.gwt.user.client Cookies removeCookie
public static void removeCookie(String name)
From source file:com.bedatadriven.rebar.appcache.client.Html5AppCache.java
License:Apache License
@Override public void ensureCached(final AsyncCallback<Void> callback) { Cookies.removeCookie(DISABLE_COOKIE_NAME); if (callbackIfCached(callback)) return;//from w ww . jav a 2s. com // otherwise we need to wait until the download is complete. // unfortunately there doesn't seem to be a way to determine whether we're busy // downloading for the first time, or a new version new Timer() { @Override public void run() { if (callbackIfCached(callback)) { this.cancel(); } } }.scheduleRepeating(1000); }
From source file:com.bedatadriven.rebar.appcache.client.Html5AppCache.java
License:Apache License
@Override public void ensureUpToDate(final AsyncCallback<Void> callback) { LOGGER.fine("ensureUpToDate starting..."); Cookies.removeCookie(DISABLE_COOKIE_NAME); // an error retrieving the cache does not neccessarily // alter the status if it is just a network problem. // but we want to make sure that we have an answer so we // have to trap the errors ourselves sinkErrorEvent(this); final ErrorListener errors = new ErrorListener(); LOGGER.fine("Status: " + statusDebugString()); if (getAppCacheStatus() == IDLE || getAppCacheStatus() == UPDATE_READY) { try {//from www . j a va2s . c o m LOGGER.fine("Calling update()"); update(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Html5AppCache: call to update() threw exception. Current state = " + getAppCacheStatus(), e); callback.onFailure(e); return; } } final long startTime = new Date().getTime(); new Timer() { @Override public void run() { LOGGER.fine("Status: " + statusDebugString()); switch (getAppCacheStatus()) { case IDLE: if (errors.haveOccurred()) { callback.onFailure(new AppCacheException(AppCacheErrorType.CONNECTION)); } else { callback.onSuccess(null); } this.cancel(); break; case UPDATE_READY: callback.onSuccess(null); this.cancel(); break; case UNCACHED: callback.onFailure(new AppCacheException(AppCacheErrorType.MISSING_MANIFEST)); this.cancel(); break; case OBSOLETE: callback.onFailure(new AppCacheException(AppCacheErrorType.OBSOLETE)); this.cancel(); break; default: case CHECKING: case DOWNLOADING: long runningTime = new Date().getTime() - startTime; if (runningTime > TIMEOUT_MILLISECONDS) { callback.onFailure(new AppCacheException(AppCacheErrorType.TIMEOUT)); this.cancel(); } } } }.scheduleRepeating(500); }
From source file:com.bedatadriven.rebar.appcache.client.Html5AppCache.java
License:Apache License
@Override public void removeCache(final AsyncCallback<Void> callback) { int status = 0; try {//from w ww . j a v a 2 s. c o m status = getAppCacheStatus(); if (status == UNCACHED || status == OBSOLETE) { callback.onSuccess(null); } else { Cookies.setCookie(DISABLE_COOKIE_NAME, DISABLE_COOKIE_VALUE); update(); new Timer() { @Override public void run() { switch (getAppCacheStatus()) { case IDLE: case UPDATE_READY: // connection problems preventing the app cache as being marked as obsolete callback.onFailure(new AppCacheException(AppCacheErrorType.CONNECTION)); this.cancel(); Cookies.removeCookie(DISABLE_COOKIE_NAME); break; case UNCACHED: case OBSOLETE: callback.onSuccess(null); this.cancel(); Cookies.removeCookie(DISABLE_COOKIE_NAME); break; } } }.scheduleRepeating(500); } } catch (Exception e) { callback.onFailure(new AppCacheException(e)); } }
From source file:com.calclab.emite.browser.AutoConfigBoot.java
License:Open Source License
/** * Try to resume the given session.//from ww w.ja v a2 s. c o m * * @return true if the cookie is present (and therefore the session is * resumed), false otherwise. True doesn't mean the sessions is * <b>succesfully</b> resumed. */ private final boolean resumeSession() { final String pause = Cookies.getCookie(PAUSE_COOKIE); if (pause == null) return false; logger.finer("Resume session: " + pause); Cookies.removeCookie(PAUSE_COOKIE); final Map<String, String> map = cookieSplitter.split(pause); final StreamSettings stream = new StreamSettings(); stream.rid = Integer.parseInt(map.get("rid")); stream.sid = map.get("sid"); stream.wait = map.get("wait"); stream.setInactivity(map.get("inactivity")); stream.setMaxPause(map.get("maxPause")); final XmppURI user = uri(map.get("user")); session.resume(user, stream); return true; }
From source file:com.calclab.emite.browser.AutoConfigBoot.java
License:Open Source License
private final void closeSession() { Cookies.removeCookie(PAUSE_COOKIE); session.logout(); }
From source file:com.calclab.emite.browser.client.PageAssist.java
License:Open Source License
public static void closeSession(final XmppSession session) { Cookies.removeCookie(PAUSE_COOKIE); session.logout(); }
From source file:com.calclab.emite.browser.client.PageAssist.java
License:Open Source License
/** * Try to resume the given session./* w w w.j a v a2s . c om*/ * * @param session * the session to be resumed * @return true if the cookie is present (and therefore the session is * resumed), false otherwise. True doesn't mean the sessions is * <b>succesfully</b> resumed. */ public static final boolean resumeSession(final XmppSession session) { final String pause = Cookies.getCookie(PAUSE_COOKIE); if (pause == null) return false; logger.finer("Resume session: " + pause); Cookies.removeCookie(PAUSE_COOKIE); final SerializableMap map = SerializableMap.restore(pause); final StreamSettings stream = new StreamSettings(); stream.rid = Integer.parseInt(map.get("rid")); stream.sid = map.get("sid"); stream.setWait(map.get("wait")); stream.setInactivity(map.get("inactivity")); stream.setMaxPause(map.get("maxPause")); final XmppURI user = uri(map.get("user")); session.resume(user, stream); return true; }
From source file:com.chinarewards.gwt.license.client.support.impl.CookieSessionManager.java
protected void tokenObtained(UserSession rep) { if (rep != null && rep.getToken() != null) { session.setToken(rep.getToken()); session.setLoginName(rep.getLoginName()); session.setCorporationId(rep.getCorporationId()); session.setUserRoles(rep.getUserRoles()); session.setDepartmentId(rep.getDepartmentId()); session.setStaffId(rep.getStaffId()); session.setLastLoginRole(rep.getLastLoginRole()); session.setCorporationName(rep.getCorporationName()); session.setPhoto(rep.getPhoto()); Date expires = new Date((new Date()).getTime() + COOKIE_TIMEOUT); Cookies.setCookie("token", rep.getToken(), expires); } else {// www .ja va 2 s . c om session.setToken(null); Cookies.removeCookie("token"); } }
From source file:com.chinarewards.gwt.license.client.support.impl.CookieSessionManager.java
protected void tokenObtaineds(LoginResponse rep) { if (rep != null && rep.getToken() != null) { session.setToken(rep.getToken()); session.setLoginName(rep.getLoginName()); session.setCorporationId(rep.getCorporationId()); session.setUserRoles(rep.getUserRoles()); session.setDepartmentId(rep.getDepartmentId()); session.setStaffId(rep.getStaffId()); session.setLastLoginRole(rep.getLastLoginRole()); session.setCorporationName(rep.getCorporationName()); session.setPhoto(rep.getPhoto()); Date expires = new Date((new Date()).getTime() + COOKIE_TIMEOUT); Cookies.setCookie("token", rep.getToken(), expires); } else {// w w w.ja va2 s . co m session.setToken(null); Cookies.removeCookie("token"); } }
From source file:com.chinarewards.gwt.license.client.support.impl.CookieSessionManager.java
protected void tokenObtainedToo(TokenValidResponse rep) { if (rep != null && rep.getToken() != null) { session.setToken(rep.getToken()); session.setLoginName(rep.getLoginName()); session.setCorporationId(rep.getCorporationId()); session.setUserRoles(rep.getUserRoles()); session.setDepartmentId(rep.getDepartmentId()); session.setStaffId(rep.getStaffId()); session.setLastLoginRole(rep.getLastLoginRole()); session.setCorporationName(rep.getCorporationName()); session.setPhoto(rep.getPhoto()); Date expires = new Date((new Date()).getTime() + COOKIE_TIMEOUT); Cookies.setCookie("token", rep.getToken(), expires); } else {/*from www. ja va 2s . c o m*/ session.setToken(null); Cookies.removeCookie("token"); } }