Package er.persistentsessionstorage.model

Examples of er.persistentsessionstorage.model.ERSessionInfo


  private static final Logger log = Logger.getLogger(ERPersistentSessionStore.class);

  @Override
  public WOSession removeSessionWithID(String s) {
    EOEditingContext ec = ERXEC.newEditingContext();
    ERSessionInfo info = ERSessionInfo.clazz.objectMatchingKeyAndValue(ec, ERSessionInfo.SESSION_ID_KEY, s);
    if(info != null) {
      WOSession session = info.session();
      info.delete();
      ec.saveChanges();
      return session;
    }
    return null;
  }
View Full Code Here


  }

  @Override
  public WOSession restoreSessionWithID(String s, WORequest request) {
    EOEditingContext ec = ERXEC.newEditingContext();
    ERSessionInfo info = ERSessionInfo.clazz.objectMatchingKeyAndValue(ec, ERSessionInfo.SESSION_ID_KEY, s);
    return info == null || info.expirationDate().getTime() < System.currentTimeMillis()?null:info.session();
  }
View Full Code Here

  @Override
  public void saveSessionForContext(WOContext context) {
    WOSession session = context.session();
    EOEditingContext ec = ERXEC.newEditingContext();
    ERSessionInfo info = ERSessionInfo.clazz.objectMatchingKeyAndValue(ec, ERSessionInfo.SESSION_ID_KEY, session.sessionID());
    if(info == null) {
      info = ERSessionInfo.clazz.createAndInsertObject(ec);
      info.setSessionID(session.sessionID());
    }
    NSTimestamp expires = new NSTimestamp(System.currentTimeMillis() + session.timeOutMillis());
    info.setExpirationDate(expires);
    try {
      /*
       * An error here can later hang the instance when the session is restored.
       * If the session fails to archive, delete it.
       */
      info.archiveDataFromSession(session);
    } catch (Exception e) {
      log.error("Error archiving session! Deleting session.");
      ERXApplication app = ERXApplication.erxApplication();
      NSMutableDictionary extraInfo = app.extraInformationForExceptionInContext(e, context);
      app.reportException(e, context, extraInfo);
      /*
       * If the session info is new, just don't save it.
       * Otherwise, we need to delete the session.
       */
      if(!info.isNewObject()) {
        removeSessionWithID(session.sessionID());
      }
      return;
    }
    ec.saveChanges();
View Full Code Here

TOP

Related Classes of er.persistentsessionstorage.model.ERSessionInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.